Revision bfe25999
Déplacement de la priorité des LLS vers les HLS.
Prise en compte des changements dans le chargement des classes (lazy=True au lieu de lazy='dynamic').
Mise à jour des données de test.
git-svn-id: https://vigilo-dev.si.c-s.fr/svn@1476 b22e2e97-25c9-44ff-b637-2e5ceca36478
vigiboard/controllers/vigiboard_plugin/shn.py | ||
---|---|---|
4 | 4 |
Plugin SHN : High level service |
5 | 5 |
""" |
6 | 6 |
|
7 |
from vigiboard.controllers.vigiboard_plugin import \ |
|
8 |
VigiboardRequestPlugin |
|
9 |
from vigiboard.model import DBSession, CorrEvent |
|
10 | 7 |
from pylons.i18n import gettext as _ |
11 | 8 |
from tg import url |
9 |
from sqlalchemy.sql import functions |
|
10 |
|
|
11 |
from vigiboard.controllers.vigiboard_plugin import \ |
|
12 |
VigiboardRequestPlugin |
|
13 |
from vigiboard.model import DBSession, ServiceHighLevel, \ |
|
14 |
CorrEvent, Event, \ |
|
15 |
ImpactedHLS, ImpactedPath |
|
16 |
from vigilo.models.supitem import SupItem |
|
17 |
from vigilo.models.secondary_tables import EVENTSAGGREGATE_TABLE |
|
12 | 18 |
|
13 | 19 |
class PluginSHN(VigiboardRequestPlugin): |
14 | 20 |
|
... | ... | |
27 | 33 |
|
28 | 34 |
def show(self, aggregate): |
29 | 35 |
"""Fonction d'affichage""" |
36 |
supitem = DBSession.query(SupItem).join( |
|
37 |
(Event, Event.idsupitem == SupItem.idsupitem), |
|
38 |
(CorrEvent, CorrEvent.idcause == Event.idevent), |
|
39 |
).filter(CorrEvent.idcorrevent == aggregate.idcorrevent).first() |
|
40 |
|
|
41 |
if not supitem: |
|
42 |
count = 0 |
|
43 |
else: |
|
44 |
count = supitem.impacted_hls( |
|
45 |
ServiceHighLevel.idservice |
|
46 |
).count() |
|
47 |
|
|
30 | 48 |
dico = { |
31 | 49 |
'baseurl': url('/'), |
32 | 50 |
'idcorrevent': aggregate.idcorrevent, |
33 |
'impacted_hls': aggregate.high_level_services.count(),
|
|
51 |
'count': count,
|
|
34 | 52 |
} |
53 |
|
|
35 | 54 |
# XXX Il faudrait échapper l'URL contenue dans baseurl |
36 | 55 |
# pour éviter des attaques de type XSS. |
37 | 56 |
res = ('<a href="javascript:vigiboard_hls_dialog(this,' + \ |
38 | 57 |
'\'%(baseurl)s\',%(idcorrevent)d)" ' + \ |
39 |
'class="hls_link">%(impacted_hls)d</a>') % dico
|
|
58 |
'class="hls_link">%(count)d</a>') % dico
|
|
40 | 59 |
return res |
41 | 60 |
|
42 | 61 |
def context(self, context): |
... | ... | |
46 | 65 |
def controller(self, *argv, **krgv): |
47 | 66 |
"""Ajout de fonctionnalités au contrôleur""" |
48 | 67 |
idcorrevent = krgv['idcorrevent'] |
49 |
correvent = DBSession.query(CorrEvent) \ |
|
50 |
.filter(CorrEvent.idcorrevent == idcorrevent).one() |
|
51 |
services = correvent.high_level_services |
|
68 |
supitem = DBSession.query(SupItem).join( |
|
69 |
(Event, Event.idsupitem == SupItem.idsupitem), |
|
70 |
(CorrEvent, CorrEvent.idcause == Event.idevent), |
|
71 |
).filter(CorrEvent.idcorrevent == idcorrevent).first() |
|
72 |
|
|
73 |
if not supitem: |
|
74 |
# XXX On devrait afficher une erreur (avec tg.flash()). |
|
75 |
return [] |
|
76 |
|
|
77 |
services = supitem.impacted_hls( |
|
78 |
ServiceHighLevel.servicename |
|
79 |
).order_by( |
|
80 |
ServiceHighLevel.servicename.asc() |
|
81 |
).all() |
|
52 | 82 |
|
53 | 83 |
return dict(services=[service.servicename for service in services]) |
54 | 84 |
|
vigiboard/controllers/vigiboardrequest.py | ||
---|---|---|
358 | 358 |
# Une liste (une case par plugin) de ce que le plugin souhaite |
359 | 359 |
# afficher en fonction de l'événement |
360 | 360 |
|
361 |
cause = event.cause.first()
|
|
361 |
cause = event.cause |
|
362 | 362 |
|
363 | 363 |
events.append([ |
364 | 364 |
event, |
vigiboard/model/__init__.py | ||
---|---|---|
9 | 9 |
|
10 | 10 |
from vigilo.models import User, UserGroup, Permission |
11 | 11 |
from vigilo.models import Event, EventHistory, CorrEvent |
12 |
from vigilo.models import Version, StateName |
|
12 |
from vigilo.models import Version, StateName, Access
|
|
13 | 13 |
from vigilo.models import Host, HostGroup |
14 | 14 |
from vigilo.models import ServiceLowLevel, ServiceHighLevel, ServiceGroup |
15 |
from vigilo.models import Access
|
|
15 |
from vigilo.models import ImpactedHLS, ImpactedPath
|
|
16 | 16 |
|
vigiboard/tests/functional/test_vigiboardrequest.py | ||
---|---|---|
59 | 59 |
'hosttpl': u'/dev/null', |
60 | 60 |
'mainip': u'192.168.1.1', |
61 | 61 |
'snmpport': 42, |
62 |
'weight': 42, |
|
62 | 63 |
} |
63 | 64 |
|
64 | 65 |
managerhost = Host(name=u'managerhost', **host_template) |
... | ... | |
71 | 72 |
'command': u'halt', |
72 | 73 |
'op_dep': u'+', |
73 | 74 |
'priority': 1, |
75 |
'weight': 42, |
|
74 | 76 |
} |
75 | 77 |
|
76 | 78 |
service1 = ServiceLowLevel( |
Also available in: Unified diff