Revision 075487bf
Mise à jour du contrôleur RPC pour mieux prendre en compte les permissions sur les données.
Ajout du support des permissions au proxy Nagios.
Utilisation du proxy Nagios dans les résultats de la recherche (template searchhost.html).
Mise à jour des données de test pour tester les permissions :
- l'utilisateur "editor" voit le groupe "Serveurs" car il a accès au groupe "Serveurs Linux" (et uniquement celui-là)
- dans "Serveurs Linux", il voit l'hôte "localhost" car il a accès à son service "SSH" (et uniquement celui-là)
- il peut accéder à la page Nagios de "localhost" et voir tous les services configurés dessus
- il peut accéder à la page Nagios du service "SSH" sur "localhost"
- s'il tente d'accéder aux pages des autres services de "localhost", une erreur 403 lui est retournée
- s'il tente d'accéder à un hôte non-supervisé ou qu'une autre erreur est rencontrée, il obtient une erreur 404
git-svn-id: https://vigilo-dev.si.c-s.fr/svn@2750 b22e2e97-25c9-44ff-b637-2e5ceca36478
vigigraph/controllers/rpc.py | ||
---|---|---|
76 | 76 |
return dict(items=[]) |
77 | 77 |
supitemgroups = user.supitemgroups() |
78 | 78 |
|
79 |
groups_with_parents = DBSession.query( |
|
80 |
GroupHierarchy.idparent, |
|
81 |
).distinct( |
|
82 |
).filter(GroupHierarchy.idchild.in_(supitemgroups) |
|
83 |
).all() |
|
84 |
groups_with_parents = [g.idparent for g in groups_with_parents] |
|
85 |
|
|
79 | 86 |
children = DBSession.query( |
80 | 87 |
SupItemGroup |
81 | 88 |
).distinct( |
... | ... | |
85 | 92 |
|
86 | 93 |
topgroups = DBSession.query( |
87 | 94 |
SupItemGroup, |
88 |
).filter(SupItemGroup.idgroup.in_(supitemgroups)
|
|
95 |
).filter(SupItemGroup.idgroup.in_(groups_with_parents)
|
|
89 | 96 |
).except_(children).order_by(SupItemGroup.name).all() |
90 | 97 |
topgroups = [(sig.name, str(sig.idgroup)) for sig in topgroups] |
91 | 98 |
return dict(items=topgroups) |
... | ... | |
124 | 131 |
SupItemGroup.name.asc(), |
125 | 132 |
).all() |
126 | 133 |
hostgroups = [(hg.name, str(hg.idgroup)) for hg in hostgroups] |
134 |
hostgroups.insert(0, (_('No subgroup'), str(maingroupid))) |
|
127 | 135 |
return dict(items=hostgroups) |
128 | 136 |
|
129 | 137 |
@expose('json') |
... | ... | |
143 | 151 |
return dict(items=[]) |
144 | 152 |
supitemgroups = user.supitemgroups() |
145 | 153 |
|
154 |
groups_with_parents = DBSession.query( |
|
155 |
GroupHierarchy.idparent, |
|
156 |
).distinct( |
|
157 |
).filter(GroupHierarchy.idchild.in_(supitemgroups) |
|
158 |
).all() |
|
159 |
groups_with_parents = [g.idparent for g in groups_with_parents] |
|
160 |
|
|
146 | 161 |
hosts = DBSession.query( |
147 | 162 |
Host.name, |
148 | 163 |
Host.idhost, |
164 |
).distinct( |
|
165 |
).outerjoin( |
|
166 |
(LowLevelService, LowLevelService.idhost == Host.idhost), |
|
149 | 167 |
).join( |
150 |
(SUPITEM_GROUP_TABLE, SUPITEM_GROUP_TABLE.c.idsupitem == \ |
|
151 |
Host.idhost), |
|
168 |
(SUPITEM_GROUP_TABLE, or_( |
|
169 |
SUPITEM_GROUP_TABLE.c.idsupitem == Host.idhost, |
|
170 |
SUPITEM_GROUP_TABLE.c.idsupitem == |
|
171 |
LowLevelService.idservice, |
|
172 |
)), |
|
152 | 173 |
).filter(SUPITEM_GROUP_TABLE.c.idgroup == othergroupid |
153 |
).filter(SUPITEM_GROUP_TABLE.c.idgroup.in_(supitemgroups)
|
|
174 |
).filter(SUPITEM_GROUP_TABLE.c.idgroup.in_(groups_with_parents)
|
|
154 | 175 |
).order_by( |
155 | 176 |
Host.name.asc(), |
156 | 177 |
).all() |
... | ... | |
576 | 597 |
return result |
577 | 598 |
|
578 | 599 |
@expose() |
579 |
def supPage(self, host): |
|
580 |
proxy = nagiosproxy.NagiosProxy() |
|
581 |
values = { |
|
582 |
'host' : host, |
|
583 |
'style' : 'detail', |
|
584 |
'supNav' : 1, |
|
585 |
} |
|
586 |
|
|
587 |
try: |
|
588 |
res = proxy.retrieve(host, 'cgi-bin/status.cgi', values) |
|
589 |
except urllib2.URLError: |
|
590 |
LOGGER.exception(_("Can't get Nagios data on host \"%s\"") % host) |
|
591 |
error_url = '../error/nagios_host_error?host=%s' % host |
|
592 |
redirect(error_url) |
|
593 |
except nagiosproxy.NoNagiosServerConfigured: |
|
594 |
txt = _("No server has been configured to monitor \"%s\"") % host |
|
595 |
LOGGER.error(txt) |
|
596 |
error_url = '../error/nagios_host_error?host=%s' % host |
|
597 |
redirect(error_url) |
|
598 |
return res.read() |
|
599 |
|
|
600 |
@expose() |
|
601 |
def servicePage(self, host, service): |
|
602 |
""" |
|
603 |
Affichage page supervision Nagios pour un hote |
|
604 |
(appel fonction get_extinfo via proxy Nagios) |
|
605 |
|
|
606 |
@param host : hôte |
|
607 |
@type host : C{str} |
|
608 |
@param service : service |
|
609 |
@type service : C{str} |
|
610 |
|
|
611 |
@return: page de supervision Nagios |
|
612 |
@rtype: page |
|
613 |
""" |
|
614 |
proxy = nagiosproxy.NagiosProxy() |
|
615 |
values = { |
|
616 |
'host' : host, |
|
617 |
'service': service, |
|
618 |
'type' : 2, |
|
619 |
'supNav' : 1, |
|
620 |
} |
|
621 |
|
|
622 |
try: |
|
623 |
res = proxy.retrieve(host, 'cgi-bin/extinfo.cgi', values) |
|
624 |
except urllib2.URLError: |
|
625 |
txt = _("Can't get Nagios data on host \"%(host)s\" " |
|
626 |
"and service \"%(service)s\"") % { |
|
627 |
'host': host, |
|
628 |
'service': service, |
|
629 |
} |
|
630 |
LOGGER.error(txt) |
|
631 |
error_url = '../error/nagios_host_service_error' \ |
|
632 |
'?host=%s&service=%s' % (host, service) |
|
633 |
redirect(error_url) |
|
634 |
except nagiosproxy.NoNagiosServerConfigured: |
|
635 |
txt = _("No server has been configured to monitor \"%s\"") % host |
|
636 |
LOGGER.error(txt) |
|
637 |
error_url = '../error/nagios_host_error?host=%s' % host |
|
638 |
redirect(error_url) |
|
639 |
return res.read() |
|
640 |
|
|
641 |
@expose() |
|
642 | 600 |
def metroPage(self, host): |
643 | 601 |
""" |
644 | 602 |
Affichage page metrologie pour un hote |
Also available in: Unified diff