vigiboard / vigiboard / model / vigilo_bdd / hostgroups.py @ 57f7cb3f
History | View | Annotate | Download (1.09 KB)
1 |
# -*- coding: utf-8 -*-
|
---|---|
2 |
# vim:set expandtab tabstop=4 shiftwidth=4:
|
3 |
"""Modèle pour la table HostGroups"""
|
4 |
from __future__ import absolute_import |
5 |
|
6 |
from sqlalchemy.orm import mapper |
7 |
from sqlalchemy import Table, ForeignKey, Column |
8 |
from sqlalchemy.types import String |
9 |
|
10 |
from ..vigilo_bdd_config import bdd_basename, metadata |
11 |
|
12 |
# Generation par SQLAutoCode
|
13 |
|
14 |
hostgroups = Table(bdd_basename + 'hostgroups',
|
15 |
metadata, |
16 |
Column(u'hostname',
|
17 |
String(length=100, convert_unicode=True, assert_unicode=None), |
18 |
ForeignKey(bdd_basename + u'host.name'),
|
19 |
primary_key=True, nullable=False), |
20 |
Column(u'groupname',
|
21 |
String(length=100, convert_unicode=True, assert_unicode=None), |
22 |
ForeignKey(bdd_basename + u'groups.name'),
|
23 |
index=True ,primary_key=True, nullable=False), |
24 |
mysql_engine='InnoDB',
|
25 |
mysql_charset='utf8'
|
26 |
) |
27 |
|
28 |
# Classe a mapper
|
29 |
|
30 |
class HostGroups(object): |
31 |
|
32 |
"""
|
33 |
Classe liée avec la table associée
|
34 |
"""
|
35 |
|
36 |
def __init__(self, hostname, groupname): |
37 |
self.hostname = hostname
|
38 |
self.groupname = groupname
|
39 |
|
40 |
mapper(HostGroups, hostgroups) |
41 |
|
42 |
|