Revision 348eec2c
Fix broken references to models renamed in svn rev [674].
git grep wEl 'Events|GraphGroups|Groups|HostGroups|ServiceGroups' - \
{vigiboard,models,correlator,connector,glue,vigicore} \
|xargs sed -i -re 's:\<(Event|GraphGroup|Group|HostGroup|ServiceGroup)s\>:\1:g'
git-svn-id: https://vigilo-dev.si.c-s.fr/svn@695 b22e2e97-25c9-44ff-b637-2e5ceca36478
vigiboard/controllers/root.py | ||
---|---|---|
9 | 9 |
from pylons.controllers.util import abort |
10 | 10 |
from sqlalchemy import asc |
11 | 11 |
from vigiboard.model import DBSession |
12 |
from vigiboard.model import Events, EventHistory, Host, User, HostGroups
|
|
12 |
from vigiboard.model import Event, EventHistory, Host, User, HostGroup
|
|
13 | 13 |
from repoze.what.predicates import Any, not_anonymous |
14 | 14 |
from vigiboard.widgets.edit_event import edit_event_status_options |
15 | 15 |
from vigiboard.controllers.vigiboardrequest import VigiboardRequest |
... | ... | |
71 | 71 |
# Application des filtres si nécessaire |
72 | 72 |
if host : |
73 | 73 |
search['host'] = host |
74 |
events.add_filter(Events.hostname.like('%%%s%%' % host))
|
|
74 |
events.add_filter(Event.hostname.like('%%%s%%' % host)) |
|
75 | 75 |
if service : |
76 | 76 |
search['service'] = service |
77 |
events.add_filter(Events.servicename.like('%%%s%%' % service))
|
|
77 |
events.add_filter(Event.servicename.like('%%%s%%' % service)) |
|
78 | 78 |
if output : |
79 | 79 |
search['output'] = output |
80 |
events.add_filter(Events.output.like('%%%s%%' % output))
|
|
80 |
events.add_filter(Event.output.like('%%%s%%' % output)) |
|
81 | 81 |
if trouble_ticket : |
82 | 82 |
search['tt'] = trouble_ticket |
83 |
events.add_filter(Events.trouble_ticket.like(
|
|
83 |
events.add_filter(Event.trouble_ticket.like( |
|
84 | 84 |
'%%%s%%' % trouble_ticket)) |
85 | 85 |
|
86 | 86 |
# Calcul des éléments à afficher et du nombre de pages possibles |
... | ... | |
130 | 130 |
).get('repoze.who.userid') |
131 | 131 |
user = User.by_user_name(username) |
132 | 132 |
|
133 |
events = DBSession.query(Events.severity, Events.idevent,
|
|
134 |
Events.hostname, Events.servicename
|
|
135 |
).join(( HostGroups , Events.hostname == HostGroups.hostname )
|
|
136 |
).filter(HostGroups.groupname.in_(user.groups)
|
|
137 |
).filter(Events.idevent == idevent)[0]
|
|
133 |
events = DBSession.query(Event.severity, Event.idevent,
|
|
134 |
Event.hostname, Event.servicename
|
|
135 |
).join(( HostGroup , Event.hostname == HostGroup.hostname )
|
|
136 |
).filter(HostGroup.groupname.in_(user.groups) |
|
137 |
).filter(Event.idevent == idevent)[0] |
|
138 | 138 |
initial_state = DBSession.query(EventHistory |
139 | 139 |
).filter(EventHistory.idevent == idevent |
140 | 140 |
).order_by(asc(EventHistory.timestamp) |
... | ... | |
182 | 182 |
""" |
183 | 183 |
|
184 | 184 |
events = VigiboardRequest() |
185 |
events.add_filter(Events.idevent == idevent)
|
|
185 |
events.add_filter(Event.idevent == idevent) |
|
186 | 186 |
|
187 | 187 |
# Vérification que l'évènement existe |
188 | 188 |
if events.num_rows() != 1 : |
... | ... | |
223 | 223 |
""" |
224 | 224 |
|
225 | 225 |
events = VigiboardRequest() |
226 |
events.add_filter(Events.hostname == host,
|
|
227 |
Events.servicename == service)
|
|
226 |
events.add_filter(Event.hostname == host, |
|
227 |
Event.servicename == service) |
|
228 | 228 |
del events.filter[2] |
229 | 229 |
|
230 | 230 |
# Vérification qu'il y a au moins 1 évènement qui correspond |
... | ... | |
275 | 275 |
ids = ids[:-1] |
276 | 276 |
|
277 | 277 |
events = VigiboardRequest() |
278 |
events.add_filter(Events.idevent.in_(ids))
|
|
278 |
events.add_filter(Event.idevent.in_(ids)) |
|
279 | 279 |
|
280 | 280 |
# Vérification que au moins un des identifiants existe et est éditable |
281 | 281 |
if events.num_rows() <= 0 : |
... | ... | |
289 | 289 |
).get('repoze.who.userid') |
290 | 290 |
|
291 | 291 |
for req in events.req : |
292 |
if isinstance(req, Events):
|
|
292 |
if isinstance(req, Event): |
|
293 | 293 |
event = req |
294 | 294 |
else: |
295 | 295 |
event = req[0] |
vigiboard/controllers/vigiboard_plugin/shn.py | ||
---|---|---|
6 | 6 |
|
7 | 7 |
from vigiboard.controllers.vigiboard_plugin import \ |
8 | 8 |
VigiboardRequestPlugin |
9 |
from vigiboard.model import DBSession, ServiceHautNiveau, Events
|
|
9 |
from vigiboard.model import DBSession, ServiceHautNiveau, Event |
|
10 | 10 |
from sqlalchemy import sql |
11 | 11 |
from pylons.i18n import gettext as _ |
12 | 12 |
from tg import tmpl_context, url |
... | ... | |
22 | 22 |
def __init__(self): |
23 | 23 |
super(PluginSHN, self).__init__( |
24 | 24 |
table = [ServiceHautNiveau.servicename_dep, |
25 |
sql.func.count(Events.idevent)],
|
|
25 |
sql.func.count(Event.idevent)], |
|
26 | 26 |
outerjoin = [(ServiceHautNiveau, |
27 |
ServiceHautNiveau.servicename_dep == Events.servicename)],
|
|
28 |
groupby = [(Events),(ServiceHautNiveau.servicename_dep)],
|
|
27 |
ServiceHautNiveau.servicename_dep == Event.servicename)], |
|
28 |
groupby = [(Event),(ServiceHautNiveau.servicename_dep)], |
|
29 | 29 |
name = _(u'Impacted HLS'), |
30 | 30 |
style = {'title': _(u'Impacted High-Level Services'), |
31 | 31 |
'style': 'text-align:center'}, |
... | ... | |
59 | 59 |
def controller(self, *argv, **krgv): |
60 | 60 |
"""Ajout de fonctionnalités au contrôleur""" |
61 | 61 |
idevent = krgv['idevent'] |
62 |
service = DBSession.query(Events.servicename
|
|
63 |
).filter(Events.idevent == idevent).one().servicename
|
|
62 |
service = DBSession.query(Event.servicename |
|
63 |
).filter(Event.idevent == idevent).one().servicename |
|
64 | 64 |
|
65 | 65 |
shns = DBSession.query(ServiceHautNiveau.servicename |
66 | 66 |
).filter(ServiceHautNiveau.servicename_dep == service) |
vigiboard/controllers/vigiboard_plugin/tests.py | ||
---|---|---|
6 | 6 |
|
7 | 7 |
from vigiboard.controllers.vigiboard_plugin.shn import \ |
8 | 8 |
PluginSHN |
9 |
from vigiboard.model import EventHistory, Events
|
|
9 |
from vigiboard.model import EventHistory, Event |
|
10 | 10 |
|
11 | 11 |
class MonPlugin(PluginSHN): |
12 | 12 |
"""Plugin de test""" |
... | ... | |
15 | 15 |
PluginSHN.__init__( |
16 | 16 |
self, |
17 | 17 |
table = [EventHistory.idevent], |
18 |
join = [(EventHistory, EventHistory.idevent == Events.idevent)]
|
|
18 |
join = [(EventHistory, EventHistory.idevent == Event.idevent)] |
|
19 | 19 |
) |
20 | 20 |
|
21 | 21 |
def show(self, req): |
vigiboard/controllers/vigiboardrequest.py | ||
---|---|---|
2 | 2 |
# vim:set expandtab tabstop=4 shiftwidth=4: |
3 | 3 |
"""Gestion de la requête, des plugins et de l'affichage du Vigiboard""" |
4 | 4 |
|
5 |
from vigiboard.model import Events, Host, Service, \
|
|
6 |
HostGroups, ServiceGroups, EventHistory, User
|
|
5 |
from vigiboard.model import Event, Host, Service, \ |
|
6 |
HostGroup, ServiceGroup, EventHistory, User
|
|
7 | 7 |
from tg import tmpl_context, url, config, request |
8 | 8 |
from vigiboard.model import DBSession |
9 | 9 |
from sqlalchemy import not_ , and_ , asc , desc |
... | ... | |
41 | 41 |
self.class_ack = {'Acknowledged': 'Ack', 'None': '', 'AAClosed': 'Ack'} |
42 | 42 |
|
43 | 43 |
self.generaterq = False |
44 |
self.table = [Events]
|
|
45 |
self.join = [( Host, Events.hostname == Host.name ),
|
|
46 |
( Service, Events.servicename == Service.name ),
|
|
47 |
( HostGroups , Host.name == HostGroups.hostname ),
|
|
48 |
( ServiceGroups , Service.name == ServiceGroups.servicename )
|
|
44 |
self.table = [Event] |
|
45 |
self.join = [( Host, Event.hostname == Host.name ), |
|
46 |
( Service, Event.servicename == Service.name ), |
|
47 |
( HostGroup , Host.name == HostGroup.hostname ),
|
|
48 |
( ServiceGroup , Service.name == ServiceGroup.servicename )
|
|
49 | 49 |
] |
50 | 50 |
self.outerjoin = [] |
51 |
self.filter = [HostGroups.groupname.in_(self.user_groups),
|
|
52 |
ServiceGroups.groupname.in_(self.user_groups),
|
|
53 |
not_(and_(Events.active == False,
|
|
54 |
Events.status == 'AAClosed')),
|
|
55 |
Events.timestamp_active != None#,
|
|
56 |
#not_(Events.timestamp_active.like('0000-00-00 00:00:00'))
|
|
51 |
self.filter = [HostGroup.groupname.in_(self.user_groups), |
|
52 |
ServiceGroup.groupname.in_(self.user_groups), |
|
53 |
not_(and_(Event.active == False, |
|
54 |
Event.status == 'AAClosed')), |
|
55 |
Event.timestamp_active != None#, |
|
56 |
#not_(Event.timestamp_active.like('0000-00-00 00:00:00')) |
|
57 | 57 |
] |
58 |
self.orderby = [desc(Events.status),
|
|
59 |
desc(Events.active),
|
|
60 |
desc(Events.severity),
|
|
61 |
asc(Events.hostname),
|
|
62 |
desc(Events.timestamp)]
|
|
58 |
self.orderby = [desc(Event.status), |
|
59 |
desc(Event.active), |
|
60 |
desc(Event.severity), |
|
61 |
asc(Event.hostname), |
|
62 |
desc(Event.timestamp)] |
|
63 | 63 |
self.groupby = [] |
64 | 64 |
self.plugin = [] |
65 | 65 |
self.events = [] |
... | ... | |
298 | 298 |
# rq devient une liste plutôt que d'être directement la |
299 | 299 |
# table souhaité |
300 | 300 |
|
301 |
if isinstance(req, Events) :
|
|
301 |
if isinstance(req, Event) : |
|
302 | 302 |
event = req |
303 | 303 |
else : |
304 | 304 |
event = req[0] |
vigiboard/i18n/en_US/LC_MESSAGES/vigiboard.po | ||
---|---|---|
459 | 459 |
msgstr "" |
460 | 460 |
|
461 | 461 |
#: vigiboard/templates/vigiboard_event_table.html:12 |
462 |
msgid "Events table"
|
|
462 |
msgid "Event table" |
|
463 | 463 |
msgstr "" |
464 | 464 |
|
465 | 465 |
#: vigiboard/templates/vigiboard_event_table.html:17 |
vigiboard/i18n/fr_FR/LC_MESSAGES/vigiboard.po | ||
---|---|---|
459 | 459 |
msgstr "Arrêter" |
460 | 460 |
|
461 | 461 |
#: vigiboard/templates/vigiboard_event_table.html:12 |
462 |
msgid "Events table"
|
|
462 |
msgid "Event table" |
|
463 | 463 |
msgstr "Table des évènements" |
464 | 464 |
|
465 | 465 |
#: vigiboard/templates/vigiboard_event_table.html:17 |
vigiboard/i18n/vigiboard.pot | ||
---|---|---|
448 | 448 |
msgstr "" |
449 | 449 |
|
450 | 450 |
#: vigiboard/templates/vigiboard_event_table.html:12 |
451 |
msgid "Events table"
|
|
451 |
msgid "Event table" |
|
452 | 452 |
msgstr "" |
453 | 453 |
|
454 | 454 |
#: vigiboard/templates/vigiboard_event_table.html:17 |
vigiboard/templates/vigiboard_event_table.html | ||
---|---|---|
9 | 9 |
<?python from genshi import HTML ?> |
10 | 10 |
|
11 | 11 |
<py:if test="len(events) > 1"> |
12 |
<table class="vigitable" summary="Events table">
|
|
12 |
<table class="vigitable" summary="Event table"> |
|
13 | 13 |
|
14 | 14 |
<thead> |
15 | 15 |
<tr > |
vigiboard/tests/functional/test_userutils.py | ||
---|---|---|
5 | 5 |
""" |
6 | 6 |
from nose.tools import assert_true |
7 | 7 |
|
8 |
from vigiboard.model import DBSession, Groups, Permission
|
|
8 |
from vigiboard.model import DBSession, Group, Permission |
|
9 | 9 |
from vigiboard.tests import TestController |
10 | 10 |
from vigiboard.tests import teardown_db |
11 | 11 |
import tg |
... | ... | |
25 | 25 |
raise SkipTest |
26 | 26 |
# |
27 | 27 |
# On commence par peupler la base |
28 |
hostmanagers = Groups(name=u'hostmanagers', parent=None)
|
|
28 |
hostmanagers = Group(name=u'hostmanagers', parent=None) |
|
29 | 29 |
DBSession.add(hostmanagers) |
30 | 30 |
|
31 |
hosteditors = Groups(name=u'hosteditors', parent=hostmanagers)
|
|
31 |
hosteditors = Group(name=u'hosteditors', parent=hostmanagers) |
|
32 | 32 |
DBSession.add(hosteditors) |
33 | 33 |
|
34 | 34 |
manage_perm = Permission.by_permission_name(u'manage') |
vigiboard/tests/functional/test_vigiboardrequest.py | ||
---|---|---|
6 | 6 |
from nose.tools import assert_true |
7 | 7 |
|
8 | 8 |
from vigiboard.model import DBSession, \ |
9 |
Events, EventHistory, Permission, \
|
|
10 |
Groups, Host, HostGroups, Service, ServiceGroups
|
|
9 |
Event, EventHistory, Permission, \ |
|
10 |
Group, Host, HostGroup, Service, ServiceGroup
|
|
11 | 11 |
from vigiboard.tests import TestController |
12 | 12 |
from vigiboard.controllers.vigiboardrequest import VigiboardRequest |
13 | 13 |
from vigiboard.controllers.vigiboard_plugin.tests import MonPlugin |
... | ... | |
29 | 29 |
# On commence par peupler la base de donnée actuellement vide |
30 | 30 |
|
31 | 31 |
# les groups et leurs dépendances |
32 |
hostmanagers = Groups(name=u'hostmanagers')
|
|
33 |
hosteditors = Groups(name=u'hosteditors', parent=hostmanagers)
|
|
32 |
hostmanagers = Group(name=u'hostmanagers') |
|
33 |
hosteditors = Group(name=u'hosteditors', parent=hostmanagers) |
|
34 | 34 |
DBSession.add(hostmanagers) |
35 | 35 |
DBSession.add(hosteditors) |
36 | 36 |
|
... | ... | |
47 | 47 |
DBSession.add(Host(name = "monhostuser")) |
48 | 48 |
DBSession.add(Service(name = "monserviceuser")) |
49 | 49 |
DBSession.flush() |
50 |
event1 = Events(hostname = "monhost", servicename = "monservice")
|
|
51 |
event2 = Events(hostname = "monhostuser", servicename = "monservice")
|
|
52 |
event3 = Events(hostname = "monhost", servicename = "monserviceuser")
|
|
53 |
event4 = Events(hostname = "monhostuser",
|
|
50 |
event1 = Event(hostname = "monhost", servicename = "monservice") |
|
51 |
event2 = Event(hostname = "monhostuser", servicename = "monservice") |
|
52 |
event3 = Event(hostname = "monhost", servicename = "monserviceuser") |
|
53 |
event4 = Event(hostname = "monhostuser", |
|
54 | 54 |
servicename = "monserviceuser") |
55 | 55 |
|
56 | 56 |
# Les historiques |
... | ... | |
77 | 77 |
idevent = event4.idevent)) |
78 | 78 |
|
79 | 79 |
# Table de jointure entre les hôtes et services et les groups |
80 |
DBSession.add(HostGroups(hostname = "monhost",
|
|
80 |
DBSession.add(HostGroup(hostname = "monhost", |
|
81 | 81 |
groupname = "hostmanagers")) |
82 |
DBSession.add(HostGroups(hostname = "monhostuser",
|
|
82 |
DBSession.add(HostGroup(hostname = "monhostuser", |
|
83 | 83 |
groupname = "hosteditors")) |
84 |
DBSession.add(ServiceGroups(servicename = "monservice",
|
|
84 |
DBSession.add(ServiceGroup(servicename = "monservice", |
|
85 | 85 |
groupname = "hostmanagers")) |
86 |
DBSession.add(ServiceGroups(servicename = "monserviceuser",
|
|
86 |
DBSession.add(ServiceGroup(servicename = "monserviceuser", |
|
87 | 87 |
groupname = "hosteditors")) |
88 | 88 |
DBSession.flush() |
89 | 89 |
|
Also available in: Unified diff