vigiboard / vigiboard / websetup.py @ 703bd599
History | View | Annotate | Download (2.29 KB)
1 |
# -*- coding: utf-8 -*-
|
---|---|
2 |
################################################################################
|
3 |
#
|
4 |
# Copyright (C) 2007-2014 CS-SI
|
5 |
#
|
6 |
# This program is free software; you can redistribute it and/or modify
|
7 |
# it under the terms of the GNU General Public License version 2 as
|
8 |
# published by the Free Software Foundation.
|
9 |
#
|
10 |
# This program is distributed in the hope that it will be useful,
|
11 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
# GNU General Public License for more details.
|
14 |
#
|
15 |
# You should have received a copy of the GNU General Public License
|
16 |
# along with this program; if not, write to the Free Software
|
17 |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
18 |
################################################################################
|
19 |
|
20 |
"""Setup the vigiboard application"""
|
21 |
|
22 |
# pylint: disable-msg=W0613
|
23 |
# W0613: Unused arguments: on doit respecter l'API
|
24 |
|
25 |
__all__ = ['setup_app', 'populate_db'] |
26 |
|
27 |
def _(msg): |
28 |
"""
|
29 |
Cette fonction n'est jamais exécutée.
|
30 |
Elle permet simplement de forcer la traduction de
|
31 |
chaînes provenant de vigilo-turbogears
|
32 |
"""
|
33 |
_('Vigilo has detected a breakdown on the following '
|
34 |
'collector(s): %(list)s')
|
35 |
|
36 |
def setup_app(command, conf, variables): |
37 |
"""Place any commands to setup vigiboard here"""
|
38 |
from vigilo.turbogears import populate_db as tg_pop_db |
39 |
from vigiboard.config.environment import load_environment |
40 |
|
41 |
load_environment(conf.global_conf, conf.local_conf) |
42 |
tg_pop_db() |
43 |
|
44 |
def populate_db(bind): |
45 |
from vigilo.models.session import DBSession |
46 |
from vigilo.models import tables |
47 |
|
48 |
permissions = { |
49 |
'vigiboard-access':
|
50 |
'Gives access to VigiBoard',
|
51 |
|
52 |
'vigiboard-update':
|
53 |
'Allows users to update events',
|
54 |
|
55 |
'vigiboard-admin':
|
56 |
'Allows users to forcefully close open events',
|
57 |
|
58 |
'vigiboard-silence':
|
59 |
'Allows users to view and edit silence rules',
|
60 |
} |
61 |
|
62 |
for (permission_name, description) in permissions.iteritems(): |
63 |
if not tables.Permission.by_permission_name(unicode(permission_name)): |
64 |
DBSession.add(tables.Permission( |
65 |
permission_name=unicode(permission_name),
|
66 |
description=unicode(description),
|
67 |
)) |
68 |
DBSession.flush() |