Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

vigiboard / vigiboard / model / vigiboard_bdd / eventhistory.py @ 20367931

History | View | Annotate | Download (2.43 KB)

1
# -*- coding: utf-8 -*-
2
# vim:set expandtab tabstop=4 shiftwidth=4: 
3
"""Modèle pour la table EventHistory"""
4

    
5
from sqlalchemy.orm import mapper, relation
6
from sqlalchemy import ForeignKey, Table, Column, Index
7
from sqlalchemy.types import Integer, String, Text, DateTime
8

    
9
from vigiboard.model import metadata
10

    
11
from sqlalchemy.databases.mysql import MSEnum
12

    
13
from vigiboard.config.vigiboard_config import vigiboard_config
14

    
15
from datetime import datetime
16

    
17
# Generation par SQLAutoCode
18

    
19
event_history =  Table(vigiboard_config['vigiboard_bdd.basename'] + 'event_history', metadata,
20
        Column(u'idhistory', Integer(),primary_key=True, nullable=False,autoincrement=True),
21
        Column(u'type_action', MSEnum('Nagios update state','Acknowlegement change state','New occurence','User comment','Ticket change','Oncall','Forced state'), primary_key=False, nullable=False),
22
        Column(u'idevent', Integer(), ForeignKey(vigiboard_config['vigiboard_bdd.basename'] +'events.idevent'),index=True,primary_key=False, nullable=False),
23
        Column(u'value', String(length=255, convert_unicode=True, assert_unicode=None), primary_key=False),
24
        Column(u'text', Text(length=None, convert_unicode=True, assert_unicode=None), primary_key=False),
25
        Column(u'timestamp', DateTime(timezone=False), default=datetime.now(),primary_key=False),
26
        Column(u'username', String(length=255, convert_unicode=True, assert_unicode=None), primary_key=False),
27
        mysql_engine='InnoDB',
28
        mysql_charset='utf8'
29
    )
30

    
31
# Classe a mapper
32

    
33
class EventHistory(object):
34
    """
35
    Classe liée avec la table associée
36
    """
37
    def __init__(self,type_action,idevent,value='',text='',username=''):
38
        
39
        """
40
        Fonction d'initialisation, permet de faire un INSERT en une fonction
41

42
        @param type_action: Le type d'action effectué, peut être 'Nagios update state',
43
                            'Acknowlegement change state', 'New occurence', 'User comment', 'Ticket change',
44
                            'Oncall' ou 'Forced state'
45
        @param idevent: Identifiant de l'évènement
46
        @param value: Nouvelle sévérité
47
        @param text: Commentaire sur l'action effectuée
48
        @param username: Nom d'utilisateur de la personne effectuant l'action
49
        """
50

    
51
        self.type_action = type_action
52
        self.idevent = idevent 
53
        self.value = value
54
        self.text = text
55
        self.username = username
56

    
57
mapper(EventHistory,event_history)