14 |
14 |
from pylons.i18n import lazy_ugettext as l_
|
15 |
15 |
from sqlalchemy import asc
|
16 |
16 |
from sqlalchemy.sql import func
|
17 |
|
from repoze.what.predicates import Any, not_anonymous
|
|
17 |
from repoze.what.predicates import Any, All, in_group, \
|
|
18 |
has_permission, not_anonymous
|
18 |
19 |
from formencode import validators, schema
|
19 |
20 |
|
20 |
21 |
from vigilo.models.session import DBSession
|
21 |
22 |
from vigilo.models.tables import Event, EventHistory, CorrEvent, Host, \
|
22 |
|
SupItem, SupItemGroup, LowLevelService
|
|
23 |
SupItem, SupItemGroup, LowLevelService, \
|
|
24 |
StateName
|
23 |
25 |
from vigilo.models.functions import sql_escape_like
|
24 |
26 |
from vigilo.models.tables.secondary_tables import EVENTSAGGREGATE_TABLE
|
25 |
27 |
|
... | ... | |
68 |
70 |
validators=DefaultSchema(),
|
69 |
71 |
error_handler = process_form_errors)
|
70 |
72 |
@expose('events_table.html')
|
71 |
|
@require(Any(not_anonymous(), msg=l_("You need to be authenticated")))
|
|
73 |
@require(
|
|
74 |
All(
|
|
75 |
not_anonymous(msg=l_("You need to be authenticated")),
|
|
76 |
Any(in_group('managers'),
|
|
77 |
has_permission('vigiboard-read'),
|
|
78 |
msg=l_("You don't have read access to VigiBoard"))
|
|
79 |
))
|
72 |
80 |
def default(self, page, supitemgroup, host, service,
|
73 |
81 |
output, trouble_ticket, from_date, to_date):
|
74 |
82 |
"""
|
... | ... | |
215 |
223 |
validators=MaskedEventsSchema(),
|
216 |
224 |
error_handler = process_form_errors)
|
217 |
225 |
@expose('raw_events_table.html')
|
218 |
|
@require(Any(not_anonymous(), msg=l_("You need to be authenticated")))
|
|
226 |
@require(
|
|
227 |
All(
|
|
228 |
not_anonymous(msg=l_("You need to be authenticated")),
|
|
229 |
Any(in_group('managers'),
|
|
230 |
has_permission('vigiboard-read'),
|
|
231 |
msg=l_("You don't have read access to VigiBoard"))
|
|
232 |
))
|
219 |
233 |
def masked_events(self, idcorrevent, page):
|
220 |
234 |
"""
|
221 |
235 |
Affichage de la liste des événements bruts masqués dans un
|
... | ... | |
321 |
335 |
validators=EventSchema(),
|
322 |
336 |
error_handler = process_form_errors)
|
323 |
337 |
@expose('history_table.html')
|
324 |
|
@require(Any(not_anonymous(), msg=l_("You need to be authenticated")))
|
|
338 |
@require(
|
|
339 |
All(
|
|
340 |
not_anonymous(msg=l_("You need to be authenticated")),
|
|
341 |
Any(in_group('managers'),
|
|
342 |
has_permission('vigiboard-read'),
|
|
343 |
msg=l_("You don't have read access to VigiBoard"))
|
|
344 |
))
|
325 |
345 |
def event(self, idevent, page):
|
326 |
346 |
"""
|
327 |
347 |
Affichage de l'historique d'un événement brut.
|
... | ... | |
410 |
430 |
validators=ItemSchema(),
|
411 |
431 |
error_handler = process_form_errors)
|
412 |
432 |
@expose('events_table.html')
|
413 |
|
@require(Any(not_anonymous(), msg=l_("You need to be authenticated")))
|
|
433 |
@require(
|
|
434 |
All(
|
|
435 |
not_anonymous(msg=l_("You need to be authenticated")),
|
|
436 |
Any(in_group('managers'),
|
|
437 |
has_permission('vigiboard-read'),
|
|
438 |
msg=l_("You don't have read access to VigiBoard"))
|
|
439 |
))
|
414 |
440 |
def item(self, page, host, service):
|
415 |
441 |
"""
|
416 |
442 |
Affichage de l'historique de l'ensemble des événements corrélés
|
... | ... | |
487 |
513 |
id = validators.Regex(r'^[0-9]+(,[0-9]+)*,?$')
|
488 |
514 |
last_modification = validators.Number(not_empty=True)
|
489 |
515 |
trouble_ticket = validators.String(if_missing='')
|
490 |
|
ack = validators.OneOf([
|
491 |
|
u'NoChange',
|
492 |
|
u'None',
|
493 |
|
u'Acknowledged',
|
494 |
|
u'AAClosed'
|
495 |
|
], not_empty=True)
|
|
516 |
ack = validators.OneOf(
|
|
517 |
[unicode(s[0]) for s in edit_event_status_options],
|
|
518 |
not_empty=True)
|
496 |
519 |
|
497 |
520 |
@validate(
|
498 |
521 |
validators=UpdateSchema(),
|
499 |
522 |
error_handler = process_form_errors)
|
500 |
|
@require(Any(not_anonymous(), msg=l_("You need to be authenticated")))
|
|
523 |
@require(
|
|
524 |
All(
|
|
525 |
not_anonymous(msg=l_("You need to be authenticated")),
|
|
526 |
Any(in_group('managers'),
|
|
527 |
has_permission('vigiboard-write'),
|
|
528 |
msg=l_("You don't have write access to VigiBoard"))
|
|
529 |
))
|
501 |
530 |
@expose()
|
502 |
531 |
def update(self, id, last_modification, trouble_ticket, ack):
|
503 |
532 |
"""
|
... | ... | |
557 |
586 |
# Modification des événements et création d'un historique
|
558 |
587 |
# pour chacun d'eux.
|
559 |
588 |
for req in events.req:
|
560 |
|
if isinstance(req, CorrEvent):
|
561 |
|
event = req
|
562 |
|
else:
|
563 |
|
event = req[0]
|
|
589 |
event = req
|
564 |
590 |
|
565 |
591 |
if trouble_ticket and trouble_ticket != event.trouble_ticket:
|
566 |
592 |
history = EventHistory(
|
... | ... | |
576 |
602 |
DBSession.add(history)
|
577 |
603 |
event.trouble_ticket = trouble_ticket
|
578 |
604 |
|
579 |
|
if ack != 'NoChange':
|
|
605 |
# Changement du statut d'acquittement.
|
|
606 |
if ack != u'NoChange':
|
|
607 |
# Pour forcer l'acquittement d'un événement,
|
|
608 |
# il faut en plus avoir la permission
|
|
609 |
# "vigiboard-admin".
|
|
610 |
if ack == u'Forced':
|
|
611 |
condition = Any(
|
|
612 |
in_group('managers'),
|
|
613 |
has_permission('vigiboard-admin'),
|
|
614 |
msg=l_("You don't have administrative access "
|
|
615 |
"to VigiBoard"))
|
|
616 |
try:
|
|
617 |
condition.check_authorization(request.environ)
|
|
618 |
except NotAuthorizedError, e:
|
|
619 |
reason = unicode(e)
|
|
620 |
flash(reason, 'error')
|
|
621 |
raise redirect(request.environ.get('HTTP_REFERER', '/'))
|
|
622 |
else:
|
|
623 |
ack = u'AAClosed'
|
|
624 |
# On met systématiquement l'état à "OK", même s'il
|
|
625 |
# s'agit d'un hôte. Techniquement, c'est incorrect,
|
|
626 |
# mais comme on fait ça pour masquer l'événement...
|
|
627 |
event.cause.current_state = \
|
|
628 |
StateName.statename_to_value(u'OK')
|
|
629 |
|
580 |
630 |
history = EventHistory(
|
581 |
631 |
type_action="Acknowledgement change state",
|
582 |
632 |
idevent=event.idcause,
|
583 |
|
value=unicode(ack),
|
|
633 |
value=ack,
|
584 |
634 |
text="Changed acknowledgement status "
|
585 |
635 |
"from '%s' to '%s'" % (
|
586 |
636 |
event.status, ack
|
... | ... | |
608 |
658 |
validators=GetPluginValueSchema(),
|
609 |
659 |
error_handler = handle_validation_errors_json)
|
610 |
660 |
@expose('json')
|
611 |
|
@require(Any(not_anonymous(), msg=l_("You need to be authenticated")))
|
|
661 |
@require(
|
|
662 |
All(
|
|
663 |
not_anonymous(msg=l_("You need to be authenticated")),
|
|
664 |
Any(in_group('managers'),
|
|
665 |
has_permission('vigiboard-read'),
|
|
666 |
msg=l_("You don't have read access to VigiBoard"))
|
|
667 |
))
|
612 |
668 |
def get_plugin_value(self, idcorrevent, plugin_name, *arg, **krgv):
|
613 |
669 |
"""
|
614 |
670 |
Permet de récupérer la valeur d'un plugin associée à un CorrEvent
|
... | ... | |
702 |
758 |
"""
|
703 |
759 |
Renvoie une liste d'instances de plugins pour VigiBoard.
|
704 |
760 |
|
705 |
|
@return: Liste de tuples contenant le nom du plugin et l'instance associé.
|
|
761 |
@return: Liste de tuples contenant le nom du plugin
|
|
762 |
et l'instance associée.
|
706 |
763 |
@rtype: C{list} of C{tuple}
|
707 |
764 |
"""
|
708 |
765 |
plugins = config.get('vigiboard_plugins', [])
|