Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

vigiboard / dashboard / model / bdd_dashboard / eventhistory.py @ 805cc54a

History | View | Annotate | Download (1.61 KB)

1
# -*- coding: utf-8 -*-
2
"""Model For EventHistory Table"""
3

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

    
8
from dashboard.model import metadata
9

    
10
from sqlalchemy.databases.mysql import MSEnum
11

    
12
import datetime
13

    
14
# Generation par SQLAutoCode
15

    
16
event_history =  Table('event_history', metadata,
17
            Column(u'idhistory', Integer(), primary_key=True, nullable=False),
18
            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),
19
            Column(u'idevent', Integer(), primary_key=False, nullable=False),
20
            Column(u'value', String(length=255, convert_unicode=False, assert_unicode=None), primary_key=False),
21
            Column(u'text', Text(length=None, convert_unicode=False, assert_unicode=None), primary_key=False),
22
            Column(u'timestamp', DateTime(timezone=False), default=datetime.datetime.now(),primary_key=False),
23
            Column(u'username', String(length=255, convert_unicode=False, assert_unicode=None), primary_key=False),
24
                ForeignKeyConstraint([u'idevent'], [u'events.idevent'], name=u'actions_ibfk_1'),
25
    
26
    )
27
Index(u'idevent', event_history.c.idevent, unique=False)
28

    
29
# Classe a mapper
30

    
31
class EventHistory(object):
32
        def __init__(self,type_action,idevent,value,text,username):
33
                self.type_action = type_action
34
                self.idevent = idevent
35
                self.value = value
36
                self.text = text
37
                self.username = username
38

    
39
mapper(EventHistory,event_history)
40