Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

vigiboard / vigiboard / config / app_cfg.py @ a77de887

History | View | Annotate | Download (3.9 KB)

1
# -*- coding: utf-8 -*-
2
# vim: set fileencoding=utf-8 sw=4 ts=4 et :
3
################################################################################
4
#
5
# Copyright (C) 2007-2009 CS-SI
6
#
7
# This program is free software; you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License version 2 as
9
# published by the Free Software Foundation.
10
#
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
# GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License
17
# along with this program; if not, write to the Free Software
18
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19
################################################################################
20

    
21
"""
22
Global configuration file for TG2-specific settings in vigiboard.
23

24
This file complements development/deployment.ini.
25

26
Please note that **all the argument values are strings**. If you want to
27
convert them into boolean, for example, you should use the
28
:func:`paste.deploy.converters.asbool` function, as in::
29

30
    from paste.deploy.converters import asbool
31
    setting = asbool(global_conf.get('the_setting'))
32

33
"""
34

    
35
from vigilo.turbogears import VigiloAppConfig
36

    
37
import vigiboard
38
from vigiboard.lib import app_globals, helpers
39

    
40
class VigiboardConfig(VigiloAppConfig):
41
    def setup_sqlalchemy(self):
42
        super(VigiboardConfig, self).setup_sqlalchemy()
43

    
44
        # On est obligés d'attendre que la base de données
45
        # soit configurée pour charger les plugins.
46
        from pkg_resources import working_set
47
        from vigiboard.controllers.plugins import VigiboardRequestPlugin
48
        from tg import config
49

    
50
        plugins = []
51
        for plugin_name in config['vigiboard_plugins']:
52
            try:
53
                ep = working_set.iter_entry_points(
54
                        "vigiboard.columns", plugin_name).next()
55
            except StopIteration:
56
                pass
57

    
58
            if ep.name in dict(plugins):
59
                continue
60

    
61
            try:
62
                plugin_class = ep.load(require=True)
63
                if issubclass(plugin_class, VigiboardRequestPlugin):
64
                    plugins.append((unicode(ep.name), plugin_class()))
65
            except:
66
                # @TODO: lever une erreur ?
67
                pass
68
        config['columns_plugins'] = plugins
69

    
70
base_config = VigiboardConfig('vigiboard')
71
base_config.package = vigiboard
72

    
73
##################################
74
# Settings specific to Vigiboard #
75
##################################
76

    
77
# Configuration des liens
78
# Les elements suivants peuvent etre utilises dans la chaine de formatage :
79
# - %(idcorrevent)d : identifiant de l'aggregat (alerte correlee)
80
# - %(host)s : le nom de l'hote concerne par l'alerte
81
# - %(service)s : le nom du service concerne par l'alerte
82
# - %(message) : le message transmis par Nagios dans l'alerte
83
#
84
# Permet de satisfaire l'exigence VIGILO_EXIG_VIGILO_BAC_0130.
85
base_config['vigiboard_links.eventdetails'] = (
86
    (
87
        u'Détail de l\'hôte dans Nagios',
88
        '/nagios/%(host)s/cgi-bin/status.cgi?host=%(host)s'
89
    ), (
90
        u'Détail de la métrologie',
91
        'http://vigilo.example.com/vigigraph/rpc/fullHostPage?host=%(host)s'
92
    ), (
93
        u'Détail de la sécurité',
94
        'http://security.example.com/?host=%(host)s'
95
    ), (
96
        'Inventaire',
97
        'http://cmdb.example.com/?host=%(host)s'
98
    ), (
99
        'Documentation',
100
        'http://doc.example.com/?q=%(message)s'
101
    ),
102
)
103

    
104
# URL des tickets, possibilités:
105
# - %(idcorrevent)d
106
# - %(host)s
107
# - %(service)s
108
# - %(tt)s
109
base_config['vigiboard_links.tt'] = 'http://bugs.example.com/?ticket=%(tt)s'
110

    
111
# Plugins to use
112
base_config['vigiboard_plugins'] = (
113
    'details',
114
    'date',
115
    'priority',
116
    'occurrences',
117
    'hostname',
118
    'servicename',
119
    'output',
120
    'hls',
121
    'status',
122
)