vigiboard / vigiboard / websetup.py @ b82c4c03
History | View | Annotate | Download (2.58 KB)
1 |
# -*- coding: utf-8 -*-
|
---|---|
2 |
################################################################################
|
3 |
#
|
4 |
# Copyright (C) 2007-2015 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 |
import imp |
26 |
|
27 |
__all__ = ['setup_app', 'populate_db'] |
28 |
|
29 |
def _(msg): |
30 |
"""
|
31 |
Cette fonction n'est jamais exécutée.
|
32 |
Elle permet simplement de forcer la traduction de
|
33 |
chaînes provenant de vigilo-turbogears
|
34 |
"""
|
35 |
_('Vigilo has detected a breakdown on the following '
|
36 |
'collector(s): %(list)s')
|
37 |
|
38 |
def setup_app(command, conf, variables): |
39 |
"""Place any commands to setup vigiboard here"""
|
40 |
from vigilo.turbogears import populate_db as tg_pop_db |
41 |
|
42 |
# Charge le fichier "app_cfg.py" se trouvant aux côtés de "settings.ini".
|
43 |
mod_info = imp.find_module('app_cfg', [ conf.global_conf['here'] ]) |
44 |
app_cfg = imp.load_module('vigiboard.config.app_cfg', *mod_info)
|
45 |
|
46 |
# Initialisation de l'environnement d'exécution.
|
47 |
load_environment = app_cfg.base_config.make_load_environment() |
48 |
load_environment(conf.global_conf, conf.local_conf) |
49 |
tg_pop_db() |
50 |
|
51 |
def populate_db(bind): |
52 |
from vigilo.models.session import DBSession |
53 |
from vigilo.models import tables |
54 |
|
55 |
permissions = { |
56 |
'vigiboard-access':
|
57 |
'Gives access to VigiBoard',
|
58 |
|
59 |
'vigiboard-update':
|
60 |
'Allows users to update events',
|
61 |
|
62 |
'vigiboard-admin':
|
63 |
'Allows users to forcefully close open events',
|
64 |
|
65 |
'vigiboard-silence':
|
66 |
'Allows users to view and edit silence rules',
|
67 |
} |
68 |
|
69 |
for (permission_name, description) in permissions.iteritems(): |
70 |
if not tables.Permission.by_permission_name(unicode(permission_name)): |
71 |
DBSession.add(tables.Permission( |
72 |
permission_name=unicode(permission_name),
|
73 |
description=unicode(description),
|
74 |
)) |
75 |
DBSession.flush() |