Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

vigiboard / app_cfg.py @ b82c4c03

History | View | Annotate | Download (4.65 KB)

1 d3c47597 Francois POIROTTE
# -*- coding: utf-8 -*-
2 2e5394d8 Gabriel DE PERTHUIS
# vim: set fileencoding=utf-8 sw=4 ts=4 et :
3 a77de887 Francois POIROTTE
################################################################################
4
#
5 8d647d93 Francois POIROTTE
# Copyright (C) 2007-2015 CS-SI
6 a77de887 Francois POIROTTE
#
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 57f7cb3f Gabriel DE PERTHUIS
"""
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 2e753457 Francois POIROTTE

30 57f7cb3f Gabriel DE PERTHUIS
    from paste.deploy.converters import asbool
31
    setting = asbool(global_conf.get('the_setting'))
32 2e753457 Francois POIROTTE

33 57f7cb3f Gabriel DE PERTHUIS
"""
34
35 10848680 Francois POIROTTE
from vigilo.turbogears import VigiloAppConfig
36 d3c47597 Francois POIROTTE
37 57f7cb3f Gabriel DE PERTHUIS
import vigiboard
38 8b2edebe Aurelien BOMPARD
from vigiboard.lib import app_globals, helpers # pylint: disable-msg=W0611
39
# W0611: Unused import: imports nécessaires pour le fonctionnement
40
41 57f7cb3f Gabriel DE PERTHUIS
42 cf3c2494 Vincent QUEMENER
import logging
43
LOGGER = logging.getLogger(__name__)
44
45 65383903 Francois POIROTTE
class VigiboardConfig(VigiloAppConfig):
46
    def setup_sqlalchemy(self):
47
        super(VigiboardConfig, self).setup_sqlalchemy()
48
49
        # On est obligés d'attendre que la base de données
50
        # soit configurée pour charger les plugins.
51
        from pkg_resources import working_set
52
        from vigiboard.controllers.plugins import VigiboardRequestPlugin
53
        from tg import config
54
55
        plugins = []
56
        for plugin_name in config['vigiboard_plugins']:
57
            try:
58
                ep = working_set.iter_entry_points(
59
                        "vigiboard.columns", plugin_name).next()
60
            except StopIteration:
61
                pass
62
63
            if ep.name in dict(plugins):
64
                continue
65
66
            try:
67
                plugin_class = ep.load(require=True)
68
                if issubclass(plugin_class, VigiboardRequestPlugin):
69
                    plugins.append((unicode(ep.name), plugin_class()))
70 8b2edebe Aurelien BOMPARD
            except Exception: # pylint: disable-msg=W0703
71
                # W0703: Catch "Exception"
72 27140946 Francois POIROTTE
                LOGGER.exception(u'Unable to import plugin %s', plugin_name)
73 cf3c2494 Vincent QUEMENER
74 65383903 Francois POIROTTE
        config['columns_plugins'] = plugins
75
76 2bb1dbfc Francois POIROTTE
base_config = VigiboardConfig('VigiBoard')
77 57f7cb3f Gabriel DE PERTHUIS
base_config.package = vigiboard
78 a2fa6a5b Francois POIROTTE
base_config.mimetype_lookup = {
79
    '.csv': 'text/csv',
80
}
81 57f7cb3f Gabriel DE PERTHUIS
82 0f56fff9 Francois POIROTTE
##################################
83
# Settings specific to Vigiboard #
84
##################################
85
86 228aad1c Francois POIROTTE
# Configuration des liens
87 a2a22ade Francois POIROTTE
# Les elements suivants peuvent etre utilises dans la chaine de formatage :
88 94f31908 Francois POIROTTE
# - %(idcorrevent)d : identifiant de l'aggregat (alerte correlee)
89
# - %(host)s : le nom de l'hote concerne par l'alerte
90
# - %(service)s : le nom du service concerne par l'alerte
91
# - %(message) : le message transmis par Nagios dans l'alerte
92 e48c54c4 Francois POIROTTE
#
93
# Permet de satisfaire l'exigence VIGILO_EXIG_VIGILO_BAC_0130.
94 65383903 Francois POIROTTE
base_config['vigiboard_links.eventdetails'] = (
95 147b6daa Francois POIROTTE
    {
96
        'label': u'Détail de l\'hôte dans Nagios',
97
        'uri': '/nagios/%(host)s/cgi-bin/status.cgi?host=%(host)s',
98
    },
99
    {
100
        'label': u'Détail de la métrologie',
101
        'uri': 'http://vigilo.example.com/vigilo/vigigraph/rpc/fullHostPage?host=%(host)s',
102
    },
103
    {
104
        'label': u'Détail de la sécurité',
105
        'uri': 'http://security.example.com/?host=%(host)s',
106
    },
107
    {
108
        'label': 'Inventaire',
109
        'uri': 'http://cmdb.example.com/?host=%(host)s',
110
    },
111
    {
112
        'label': 'Documentation',
113
        'uri': 'http://doc.example.com/?q=%(message)s',
114
    },
115 65383903 Francois POIROTTE
)
116 0f56fff9 Francois POIROTTE
117 228aad1c Francois POIROTTE
# URL des tickets, possibilités:
118 94f31908 Francois POIROTTE
# - %(idcorrevent)d
119 228aad1c Francois POIROTTE
# - %(host)s
120
# - %(service)s
121
# - %(tt)s
122 4c949ec9 Francois POIROTTE
base_config['vigiboard_links.tt'] = 'http://bugs.example.com/?ticket=%(tt)s'
123 228aad1c Francois POIROTTE
124 0f56fff9 Francois POIROTTE
# Plugins to use
125 65383903 Francois POIROTTE
base_config['vigiboard_plugins'] = (
126 f37d1e09 Francois POIROTTE
#    'id',
127 65383903 Francois POIROTTE
    'details',
128 ce8fee78 Francois POIROTTE
#    'state',
129 27140946 Francois POIROTTE
    'groups',
130 65383903 Francois POIROTTE
    'date',
131
    'priority',
132
    'occurrences',
133
    'hostname',
134
    'servicename',
135
    'output',
136 3e5985c8 Francois POIROTTE
#    'masked_events',
137 65383903 Francois POIROTTE
    'hls',
138
    'status',
139 f37d1e09 Francois POIROTTE
#    'test',
140 ecf084d9 Francois POIROTTE
    'map',
141 65383903 Francois POIROTTE
)
142 a2fa6a5b Francois POIROTTE
143
base_config['csv_columns'] = (
144
    'id',
145
    'state',
146
    'initial_state',
147
    'peak_state',
148
    'date',
149
    'duration',
150
    'priority',
151
    'occurrences',
152
    'hostname',
153
    'servicename',
154
    'output',
155
    'ack',
156
    'trouble_ticket_id',
157
    'trouble_ticket_link',
158
)