Revision c49defb8
Corrections suite aux changements apportés dans le modèles.
Corrections des tests.
Ajout d'une image pour la flèche affichant les détails : cas où severity = NULL dans la base de données.
git-svn-id: https://vigilo-dev.si.c-s.fr/svn@804 b22e2e97-25c9-44ff-b637-2e5ceca36478
development.ini | ||
---|---|---|
35 | 35 |
; use SafeConfigParser which supports string interpolation escapes. |
36 | 36 |
; |
37 | 37 |
; URL des tickets, possibilités: |
38 |
; - %(idevent)d
|
|
38 |
; - %(idaggregate)s
|
|
39 | 39 |
; - %(host)s |
40 | 40 |
; - %(service)s |
41 | 41 |
; - %(tt)s |
42 |
vigiboard_links.tt = http://example4.com/%%(idaggregate)d/%%(tt)s
|
|
42 |
vigiboard_links.tt = http://example4.com/%%(idaggregate)s/%%(tt)s
|
|
43 | 43 |
|
44 | 44 |
; Default font size, must be a valid size as per the CSS 2.1 specification. |
45 | 45 |
; See http://www.w3.org/TR/CSS21/fonts.html#font-size-props |
vigiboard/config/app_cfg.py | ||
---|---|---|
88 | 88 |
# Links configuration |
89 | 89 |
# XXX Should be part of ini settings. |
90 | 90 |
base_config['vigiboard_links.eventdetails'] = { |
91 |
'nagios': ['Nagios host details', 'http://example1.com/%(idaggregate)d'],
|
|
92 |
'metrology': ['Metrology details', 'http://example2.com/%(idaggregate)d'],
|
|
93 |
'security': ['Security details', 'http://example3.com/%(idaggregate)d'],
|
|
94 |
'servicetype': ['Service Type', 'http://example4.com/%(idaggregate)d'],
|
|
91 |
'nagios': ['Nagios host details', 'http://example1.com/%(idaggregate)s'],
|
|
92 |
'metrology': ['Metrology details', 'http://example2.com/%(idaggregate)s'],
|
|
93 |
'security': ['Security details', 'http://example3.com/%(idaggregate)s'],
|
|
94 |
'servicetype': ['Service Type', 'http://example4.com/%(idaggregate)s'],
|
|
95 | 95 |
} |
96 | 96 |
|
97 | 97 |
# Plugins to use |
vigiboard/controllers/root.py | ||
---|---|---|
131 | 131 |
search = search, |
132 | 132 |
) |
133 | 133 |
|
134 |
@validate(validators={'idaggregate':validators.Int(not_empty=True)},
|
|
134 |
@validate(validators={'idaggregate':validators.String(not_empty=True)},
|
|
135 | 135 |
error_handler=process_form_errors) |
136 | 136 |
@expose('json') |
137 | 137 |
@require(Any(not_anonymous(), msg=_("You need to be authenticated"))) |
... | ... | |
179 | 179 |
_('None'), _('OK'), _('Suppressed'), _('Initial'), |
180 | 180 |
_('Maintenance'), _('Minor'), _('Major'), _('Critical') |
181 | 181 |
) |
182 |
if event.severity is None: |
|
183 |
current_state = _('Unknown') |
|
184 |
else: |
|
185 |
current_state = severity[event.severity] |
|
186 |
|
|
182 | 187 |
eventdetails = {} |
183 | 188 |
for edname, edlink in \ |
184 | 189 |
config['vigiboard_links.eventdetails'].iteritems(): |
... | ... | |
191 | 196 |
|
192 | 197 |
return dict( |
193 | 198 |
initial_state = severity[int(initial_state)], |
194 |
current_state = severity[event.severity],
|
|
199 |
current_state = current_state,
|
|
195 | 200 |
idaggregate = idaggregate, |
196 | 201 |
host = event.hostname, |
197 | 202 |
service = event.servicename, |
198 |
eventdetails = eventdetails |
|
203 |
eventdetails = eventdetails,
|
|
199 | 204 |
) |
200 | 205 |
|
201 |
@validate(validators={'idaggregate':validators.Int(not_empty=True)},
|
|
206 |
@validate(validators={'idaggregate':validators.String(not_empty=True)},
|
|
202 | 207 |
error_handler=process_form_errors) |
203 | 208 |
@expose('vigiboard.templates.vigiboard') |
204 | 209 |
@require(Any(not_anonymous(), msg=_("You need to be authenticated"))) |
... | ... | |
294 | 299 |
) |
295 | 300 |
|
296 | 301 |
@validate(validators={ |
297 |
"id":validators.Regex(r'^[0-9]+(,[0-9]*)*,?$'),
|
|
302 |
"id":validators.Regex(r'^[^,]+(,[^,]*)*,?$'),
|
|
298 | 303 |
# "trouble_ticket":validators.Regex(r'^[0-9]*$'), |
299 | 304 |
"status":validators.OneOf(['NoChange', 'None', 'Acknowledged', |
300 | 305 |
'AAClosed']) |
vigiboard/controllers/vigiboard_plugin/shn.py | ||
---|---|---|
31 | 31 |
dico = { |
32 | 32 |
'baseurl': url('/'), |
33 | 33 |
'idaggregate': aggregate.idaggregate, |
34 |
'impacted_hls': len(aggregate.highlevel),
|
|
34 |
'impacted_hls': len(aggregate.high_level_services),
|
|
35 | 35 |
} |
36 | 36 |
# XXX Il faudrait échapper l'URL contenue dans baseurl |
37 | 37 |
# pour éviter des attaques de type XSS. |
38 | 38 |
res = ('<a href="javascript:vigiboard_shndialog(' + \ |
39 |
'\'%(baseurl)s\',\'%(idaggregate)d\')" ' + \
|
|
39 |
'\'%(baseurl)s\',\'%(idaggregate)s\')" ' + \
|
|
40 | 40 |
'class="SHNLien">%(impacted_hls)d</a>') % dico |
41 | 41 |
return res |
42 | 42 |
|
vigiboard/controllers/vigiboardrequest.py | ||
---|---|---|
22 | 22 |
def __init__(self, user): |
23 | 23 |
|
24 | 24 |
""" |
25 |
Initialisation de toutes les variables nécessaires: Liste des groupes de
|
|
26 |
l'utilisateur, les classes à appliquer suivant la sévérité, les |
|
25 |
Initialisation de toutes les variables nécessaires: Liste des groupes |
|
26 |
de l'utilisateur, les classes à appliquer suivant la sévérité, les
|
|
27 | 27 |
différentes étapes de la génération de la requête et la liste des |
28 | 28 |
plugins appliqués. |
29 | 29 |
""" |
... | ... | |
106 | 106 |
self.req = DBSession |
107 | 107 |
self.context_fct = [] |
108 | 108 |
|
109 |
def get_bouton_severity(self, severity): |
|
110 |
if severity is None: |
|
111 |
return 'Unknown' |
|
112 |
return self.bouton_severity[severity] |
|
113 |
|
|
109 | 114 |
def add_plugin(self, *argv): |
110 | 115 |
|
111 | 116 |
""" |
... | ... | |
331 | 336 |
ids = [] |
332 | 337 |
for req in self.req[first_row : last_row]: |
333 | 338 |
# Si il y a plus d'un élément dans la liste des tables, |
334 |
# rq devient une liste plutôt que d'être directement la |
|
339 |
# req devient une liste plutôt que d'être directement la
|
|
335 | 340 |
# table souhaitée |
336 | 341 |
|
337 | 342 |
if isinstance(req, EventsAggregate): |
... | ... | |
354 | 359 |
events.append([ |
355 | 360 |
event, |
356 | 361 |
{'class': class_tr[i % 2]}, |
357 |
{'class' : self.bouton_severity[event.severity] + \
|
|
358 |
self.class_ack[event.status]},
|
|
359 |
{'class' : self.bouton_severity[event.severity] + \
|
|
360 |
self.class_ack[event.status]},
|
|
361 |
{'src' : '/images/%s2.png' % \
|
|
362 |
self.bouton_severity[event.severity].upper()},
|
|
362 |
{'class': self.get_bouton_severity(event.severity) + \
|
|
363 |
self.class_ack[event.status]}, |
|
364 |
{'class': self.get_bouton_severity(event.severity) + \
|
|
365 |
self.class_ack[event.status]}, |
|
366 |
{'src': '/images/%s2.png' % \ |
|
367 |
self.get_bouton_severity(event.severity).upper()},
|
|
363 | 368 |
self.format_events_img_status(event), |
364 | 369 |
[[j.__show__(event), j.style] for j in self.plugin] |
365 | 370 |
]) |
... | ... | |
368 | 373 |
events.append([ |
369 | 374 |
event, |
370 | 375 |
{'class': class_tr[i % 2]}, |
371 |
{'class' : self.bouton_severity[event.severity] + \
|
|
372 |
self.class_ack[event.status] },
|
|
373 |
{'class' : 'Cleared' + self.class_ack[event.status] },
|
|
374 |
{'src' : '/images/%s2.png' % \
|
|
375 |
self.bouton_severity[event.severity].upper()},
|
|
376 |
{'class': self.get_bouton_severity(event.severity) + \
|
|
377 |
self.class_ack[event.status] }, |
|
378 |
{'class': 'Cleared' + self.class_ack[event.status]},
|
|
379 |
{'src': '/images/%s2.png' % \ |
|
380 |
self.get_bouton_severity(event.severity).upper()},
|
|
376 | 381 |
self.format_events_img_status(event), |
377 | 382 |
[[j.__show__(event), j.style] for j in self.plugin] |
378 | 383 |
]) |
... | ... | |
428 | 433 |
hist.timestamp, |
429 | 434 |
hist.username, |
430 | 435 |
hist.type_action, |
431 |
self.severity[min(int(hist.value),7)], |
|
436 |
self.severity[min(int(hist.value), 7)],
|
|
432 | 437 |
hist.text, |
433 |
{'class': class_tr[i%2]},
|
|
434 |
{'class': self.class_severity[min(int(hist.value),7)]} |
|
438 |
{'class': class_tr[i % 2]},
|
|
439 |
{'class': self.class_severity[min(int(hist.value), 7)]}
|
|
435 | 440 |
]) |
436 | 441 |
|
437 | 442 |
else: |
... | ... | |
441 | 446 |
hist.type_action, |
442 | 447 |
self.severity[0], |
443 | 448 |
hist.text, |
444 |
{'class': class_tr[i%2]},
|
|
449 |
{'class': class_tr[i % 2]},
|
|
445 | 450 |
{'class': self.class_severity[0]} |
446 | 451 |
]) |
447 | 452 |
i += 1 |
vigiboard/tests/functional/test_vigiboardrequest.py | ||
---|---|---|
84 | 84 |
'message': u'foo', |
85 | 85 |
} |
86 | 86 |
|
87 |
event1 = Event(hostname=u'monhost', |
|
87 |
event1 = Event(idevent=u'event1', hostname=u'monhost',
|
|
88 | 88 |
servicename=u'monservice', **event_template) |
89 |
event2 = Event(hostname=u'monhostuser', |
|
89 |
event2 = Event(idevent=u'event2', hostname=u'monhostuser',
|
|
90 | 90 |
servicename=u'monservice', **event_template) |
91 |
event3 = Event(hostname=u'monhost', |
|
91 |
event3 = Event(idevent=u'event3', hostname=u'monhost',
|
|
92 | 92 |
servicename=u'monserviceuser', **event_template) |
93 |
event4 = Event(hostname=u'monhostuser', |
|
93 |
event4 = Event(idevent=u'event4', hostname=u'monhostuser',
|
|
94 | 94 |
servicename=u'monserviceuser', **event_template) |
95 | 95 |
|
96 | 96 |
DBSession.add(event1) |
... | ... | |
126 | 126 |
'status': u'None', |
127 | 127 |
} |
128 | 128 |
self.aggregate1 = EventsAggregate( |
129 |
idaggregate=u'foo', |
|
129 | 130 |
idcause=event1.idevent, **aggregate_template) |
130 | 131 |
self.aggregate2 = EventsAggregate( |
132 |
idaggregate=u'bar', |
|
131 | 133 |
idcause=event4.idevent, **aggregate_template) |
132 | 134 |
|
133 | 135 |
self.aggregate1.events.append(event1) |
Also available in: Unified diff