2007-02-12 22:39:14 +01:00
|
|
|
# -*- coding: UTF-8 -*-
|
|
|
|
#
|
|
|
|
# Copyright (C) 2007 by Jan Dittberner.
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful, but
|
|
|
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
# General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
|
|
|
# USA.
|
|
|
|
#
|
|
|
|
# Version: $Id$
|
|
|
|
|
|
|
|
from sqlalchemy import *
|
2007-02-13 19:18:09 +01:00
|
|
|
import ConfigParser, os
|
2007-02-12 22:39:14 +01:00
|
|
|
|
2007-02-13 19:18:09 +01:00
|
|
|
config = ConfigParser.ConfigParser()
|
2007-02-28 22:15:20 +01:00
|
|
|
config.readfp(open('gnuviechadmin/defaults.cfg'))
|
|
|
|
config.read(['gnuviechadmin/gva.cfg', os.path.expanduser('~/.gva.cfg')])
|
2007-02-13 19:18:09 +01:00
|
|
|
|
|
|
|
meta = BoundMetaData(config.get('database', 'uri'))
|
2007-02-12 22:39:14 +01:00
|
|
|
client_table = Table(
|
|
|
|
'client', meta,
|
|
|
|
Column('clientid', Integer, primary_key=True),
|
|
|
|
Column('title', String(10)),
|
|
|
|
Column('firstname', String(64), nullable=False),
|
|
|
|
Column('lastname', String(64), nullable=False),
|
|
|
|
Column('address1', String(64), nullable=False),
|
|
|
|
Column('address2', String(64)),
|
|
|
|
Column('zip', String(7), nullable=False),
|
|
|
|
Column('city', String(64), nullable=False),
|
|
|
|
Column('country', String(5), nullable=False),
|
|
|
|
Column('phone', String(32), nullable=False),
|
|
|
|
Column('mobile', String(32)),
|
|
|
|
Column('fax', String(32)),
|
2007-07-03 11:13:20 +02:00
|
|
|
Column('email', String(64), unique=True, nullable=False),
|
|
|
|
schema = config.get('database', 'schema')
|
|
|
|
)
|
2007-02-12 22:39:14 +01:00
|
|
|
client_table.create(checkfirst=True)
|
|
|
|
|
|
|
|
sysuser_table = Table(
|
|
|
|
'sysuser', meta,
|
|
|
|
Column('sysuserid', Integer, primary_key=True),
|
|
|
|
Column('username', String(12), nullable=False, unique=True),
|
|
|
|
Column('usertype', Integer, nullable=False, default=0, index=True),
|
|
|
|
Column('home', String(128)),
|
|
|
|
Column('shell', Boolean, nullable=False, default=False),
|
|
|
|
Column('clearpass', String(64)),
|
2007-07-02 11:14:47 +02:00
|
|
|
Column('md5pass', String(34)),
|
2007-02-12 22:39:14 +01:00
|
|
|
Column('clientid', Integer, ForeignKey("client.clientid"), nullable=False),
|
|
|
|
Column('sysuid', Integer, nullable=False, unique=True),
|
2007-07-03 11:13:20 +02:00
|
|
|
Column('lastchange', DateTime, default=func.now()),
|
|
|
|
schema = config.get('database', 'schema')
|
2007-02-12 22:39:14 +01:00
|
|
|
)
|
|
|
|
sysuser_table.create(checkfirst=True)
|
2007-07-02 11:14:47 +02:00
|
|
|
|
|
|
|
domain_table = Table(
|
|
|
|
'domain', meta,
|
|
|
|
Column('domainid', Integer, primary_key=True),
|
|
|
|
Column('name', String(255), nullable=False, unique=True),
|
|
|
|
Column('master', String(20)),
|
|
|
|
Column('last_check', Integer),
|
|
|
|
Column('type', String(6), nullable=False),
|
|
|
|
Column('notified_serial', Integer),
|
|
|
|
Column('sysuserid', Integer, ForeignKey("sysuser.sysuserid"),
|
2007-07-03 11:13:20 +02:00
|
|
|
nullable=False),
|
|
|
|
schema = config.get('database', 'schema')
|
|
|
|
)
|
2007-07-02 11:14:47 +02:00
|
|
|
domain_table.create(checkfirst=True)
|
|
|
|
|
|
|
|
record_table = Table(
|
|
|
|
'record', meta,
|
|
|
|
Column('recordid', Integer, primary_key=True),
|
|
|
|
Column('domainid', Integer, ForeignKey("domain.domainid"),
|
|
|
|
nullable=False),
|
|
|
|
Column('name', String(255)),
|
|
|
|
Column('type', String(6)),
|
|
|
|
Column('content', String(255)),
|
|
|
|
Column('ttl', Integer),
|
|
|
|
Column('prio', Integer),
|
2007-07-03 11:13:20 +02:00
|
|
|
Column('change_date', Integer),
|
|
|
|
schema = config.get('database', 'schema')
|
|
|
|
)
|
2007-07-02 11:14:47 +02:00
|
|
|
record_table.create(checkfirst=True)
|
|
|
|
|
|
|
|
supermaster_table = Table(
|
|
|
|
'supermaster', meta,
|
|
|
|
Column('ip', String(25), nullable=False),
|
|
|
|
Column('nameserver', String(255), nullable=False),
|
|
|
|
Column('account', Integer, ForeignKey("sysuser.sysuserid"),
|
2007-07-03 11:13:20 +02:00
|
|
|
nullable=False),
|
|
|
|
schema = config.get('database', 'schema')
|
|
|
|
)
|
2007-07-02 11:14:47 +02:00
|
|
|
supermaster_table.create(checkfirst=True)
|