- repository reorganization
git-svn-id: file:///home/www/usr01/svn/gnuviechadmin/trunk@242 a67ec6bc-e5d5-0310-a910-815c51eb3124
This commit is contained in:
parent
5c1a97e82d
commit
dea15a6c4f
29 changed files with 1053 additions and 0 deletions
4
test/manage.py
Normal file
4
test/manage.py
Normal file
|
@ -0,0 +1,4 @@
|
|||
#!/usr/bin/python
|
||||
from migrate.versioning.shell import main
|
||||
|
||||
main(url='postgres://jan:heyyou97@localhost:5432/jan',repository='ormaptest_repo')
|
32
test/ormaptest.py
Normal file
32
test/ormaptest.py
Normal file
|
@ -0,0 +1,32 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: UTF-8 -*-
|
||||
|
||||
from sqlalchemy import *
|
||||
|
||||
meta = BoundMetaData('postgres://jan:heyyou97@localhost:5432/jan')
|
||||
domains_table = Table('domains', meta, autoload=True)
|
||||
records_table = Table('records', meta, autoload=True)
|
||||
|
||||
class Domain(object):
|
||||
def __repr__(self):
|
||||
return "%s(%r,%r)" % (
|
||||
self.__class__.__name__, self.id, self.name)
|
||||
|
||||
class Record(object):
|
||||
def __repr__(self):
|
||||
return "%s(%r,%r,%r)" % (
|
||||
self.__class__.__name__, self.id, self.domain_id, self.domain)
|
||||
|
||||
recordmapper = mapper(Record, records_table)
|
||||
domainmapper = mapper(Domain, domains_table, properties = {
|
||||
'records': relation(Record, backref='domain')
|
||||
})
|
||||
|
||||
session = create_session()
|
||||
query = session.query(Domain)
|
||||
|
||||
domain = query.get_by(name='dittberner.info')
|
||||
if domain:
|
||||
print domain.records
|
||||
|
||||
session.flush()
|
4
test/ormaptest_repo/README
Normal file
4
test/ormaptest_repo/README
Normal file
|
@ -0,0 +1,4 @@
|
|||
This is a database migration repository.
|
||||
|
||||
More information at
|
||||
http://trac.erosson.com/migrate
|
0
test/ormaptest_repo/__init__.py
Normal file
0
test/ormaptest_repo/__init__.py
Normal file
4
test/ormaptest_repo/manage.py
Normal file
4
test/ormaptest_repo/manage.py
Normal file
|
@ -0,0 +1,4 @@
|
|||
#!/usr/bin/python
|
||||
from migrate.versioning.shell import main
|
||||
|
||||
main(repository='ormaptest_repo')
|
20
test/ormaptest_repo/migrate.cfg
Normal file
20
test/ormaptest_repo/migrate.cfg
Normal file
|
@ -0,0 +1,20 @@
|
|||
[db_settings]
|
||||
# Used to identify which repository this database is versioned under.
|
||||
# You can use the name of your project.
|
||||
repository_id=OR Mapping Test
|
||||
|
||||
# The name of the database table used to track the schema version.
|
||||
# This name shouldn't already be used by your project.
|
||||
# If this is changed once a database is under version control, you'll need to
|
||||
# change the table name in each database too.
|
||||
version_table=migrate_version
|
||||
|
||||
# When committing a change script, Migrate will attempt to generate the
|
||||
# sql for all supported databases; normally, if one of them fails - probably
|
||||
# because you don't have that database installed - it is ignored and the
|
||||
# commit continues, perhaps ending successfully.
|
||||
# Databases in this list MUST compile successfully during a commit, or the
|
||||
# entire commit will fail. List the databases your application will actually
|
||||
# be using to ensure your updates to that database work properly.
|
||||
# This must be a list; example: ['postgres','sqlite']
|
||||
required_dbs=[]
|
14
test/ormaptest_repo/versions/1/1.py
Normal file
14
test/ormaptest_repo/versions/1/1.py
Normal file
|
@ -0,0 +1,14 @@
|
|||
from sqlalchemy import *
|
||||
from migrate import *
|
||||
|
||||
meta = BoundMetaData(migrate_engine)
|
||||
account = Table('account', meta,
|
||||
Column('id', Integer, primary_key=True),
|
||||
Column('login', String(40)),
|
||||
Column('passwd', String(40)))
|
||||
|
||||
def upgrade():
|
||||
account.create()
|
||||
|
||||
def downgrade():
|
||||
account.drop()
|
11
test/ormaptest_repo/versions/2/2.py
Normal file
11
test/ormaptest_repo/versions/2/2.py
Normal file
|
@ -0,0 +1,11 @@
|
|||
from sqlalchemy import *
|
||||
from migrate import *
|
||||
|
||||
meta = BoundMetaData(migrate_engine)
|
||||
account = Table('account', meta)
|
||||
|
||||
def upgrade():
|
||||
account.drop()
|
||||
|
||||
def downgrade():
|
||||
account.create()
|
45
test/ormaptest_repo/versions/3/3.py
Normal file
45
test/ormaptest_repo/versions/3/3.py
Normal file
|
@ -0,0 +1,45 @@
|
|||
from sqlalchemy import *
|
||||
from migrate import *
|
||||
|
||||
meta = BoundMetaData(migrate_engine)
|
||||
supermasters = Table('supermasters', meta,
|
||||
Column('ip', String(25), nullable=False),
|
||||
Column('nameserver', String(255), nullable=False),
|
||||
Column('account', String(40)),
|
||||
)
|
||||
domains = Table('domains', meta,
|
||||
Column('id', Integer, primary_key=True),
|
||||
Column('name', String(255), nullable=False),
|
||||
Column('master', String(20)),
|
||||
Column('last_check', Integer),
|
||||
Column('type', String(6), nullable=False),
|
||||
Column('notified_serial', Integer),
|
||||
Column('account', String(40)),
|
||||
UniqueConstraint('name', name='name_index')
|
||||
)
|
||||
|
||||
records = Table('records', meta,
|
||||
Column('id', Integer, primary_key=True),
|
||||
Column('domain_id', Integer),
|
||||
Column('name', String(255)),
|
||||
Column('type', String(6)),
|
||||
Column('content', String(255)),
|
||||
Column('ttl', Integer),
|
||||
Column('prio', Integer),
|
||||
Column('change_date', Integer),
|
||||
ForeignKeyConstraint(['domain_id'], ['domains.id'],
|
||||
ondelete='CASCADE', name='domain_exists')
|
||||
)
|
||||
Index('domain_id', records.c.domain_id)
|
||||
Index('nametype_index', records.c.name, records.c.type)
|
||||
Index('rec_name_index', records.c.name)
|
||||
|
||||
def upgrade():
|
||||
supermasters.create()
|
||||
domains.create()
|
||||
records.create()
|
||||
|
||||
def downgrade():
|
||||
records.drop()
|
||||
domains.drop()
|
||||
supermasters.drop()
|
0
test/ormaptest_repo/versions/__init__.py
Normal file
0
test/ormaptest_repo/versions/__init__.py
Normal file
293
test/test.sql
Normal file
293
test/test.sql
Normal file
|
@ -0,0 +1,293 @@
|
|||
--
|
||||
-- Data for Name: domains; Type: TABLE DATA; Schema: public; Owner: postgres
|
||||
--
|
||||
|
||||
COPY domains (id, name, master, last_check, "type", notified_serial, account) FROM stdin;
|
||||
3 artist-michael.de \N \N MASTER 2005081501 \N
|
||||
4 blumendeko-wiebach.de \N \N MASTER 2005081701 \N
|
||||
5 cblicht.de \N \N MASTER 2006031901 \N
|
||||
6 centrum-warenhaus-dresden.de \N \N MASTER 2005090301 \N
|
||||
7 dancewarriors.de \N \N MASTER 2005081701 \N
|
||||
9 douth-hiphop.de \N \N MASTER 2005081701 \N
|
||||
10 efs-sohland.de \N \N MASTER 2005092001 \N
|
||||
11 ferien-am-stausee.de \N \N MASTER 2005081701 \N
|
||||
12 frank-schmidt-online.de \N \N MASTER 2006091901 \N
|
||||
13 freie-musikschule-sohland.de \N \N MASTER 2005081701 \N
|
||||
14 hondaracingclub.de \N \N MASTER 2005081701 \N
|
||||
15 jesusgemeindesohland.de \N \N MASTER 2006031901 \N
|
||||
16 jugendwoche2006.de \N \N MASTER 2006051701 \N
|
||||
17 katja-schumann.de \N \N MASTER 2006031901 \N
|
||||
18 ortodontia.de \N \N MASTER 2005101702 \N
|
||||
19 ostmodern.org \N \N MASTER 2006022001 \N
|
||||
20 peschel-maler.de \N \N MASTER 2006112800 \N
|
||||
21 purity-now.de \N \N MASTER 2006083001 \N
|
||||
22 regionalverkehr.net \N \N MASTER 2005121201 \N
|
||||
23 rundkino-dresden.de \N \N MASTER 2006112400 \N
|
||||
24 scheune-sohland.de \N \N MASTER 2006030102 \N
|
||||
25 spare-beatz.de \N \N MASTER 2005090501 \N
|
||||
26 tntlive.de \N \N MASTER 2006100401 \N
|
||||
27 wagner-sound.de \N \N MASTER 2005081701 \N
|
||||
28 winproject.de \N \N MASTER 2006100302 \N
|
||||
29 zahnspange-schubert.de \N \N MASTER 2005101702 \N
|
||||
1 jan-dittberner.de \N \N MASTER 2006031902 \N
|
||||
8 dittberner.info \N \N MASTER 0 \N
|
||||
2 gnuviech-server.de \N \N MASTER 2007010301 \N
|
||||
\.
|
||||
|
||||
|
||||
--
|
||||
-- Data for Name: records; Type: TABLE DATA; Schema: public; Owner: postgres
|
||||
--
|
||||
|
||||
COPY records (id, domain_id, name, "type", content, ttl, prio, change_date) FROM stdin;
|
||||
1 1 jan-dittberner.de SOA ns1.gnuviech-server.de hostmaster.gnuviech.info 2006031902 10000 7200 1209600 86400 86400 0 \N
|
||||
2 1 jan-dittberner.de NS ns1.gnuviech-server.de 86400 0 \N
|
||||
3 1 jan-dittberner.de NS ns10.schlundtech.de 86400 0 \N
|
||||
4 1 jan-dittberner.de A 81.169.155.87 86400 0 \N
|
||||
5 1 jan-dittberner.de MX gnuviech.info 86400 5 \N
|
||||
6 1 jan-dittberner.de TXT v=spf1 a mx 86400 0 \N
|
||||
7 1 *.jan-dittberner.de CNAME www.jan-dittberner.de 86400 0 \N
|
||||
8 1 www.jan-dittberner.de A 81.169.155.87 86400 0 \N
|
||||
10 2 gnuviech-server.de NS ns1.gnuviech-server.de 86400 0 \N
|
||||
11 2 gnuviech-server.de NS ns10.schlundtech.de 86400 0 \N
|
||||
12 2 gnuviech-server.de A 81.169.155.87 86400 0 \N
|
||||
13 2 gnuviech-server.de MX gnuviech.info 86400 5 \N
|
||||
14 2 gnuviech-server.de TXT v=spf1 a mx 86400 0 \N
|
||||
19 2 shell.gnuviech-server.de A 88.198.45.203 86400 0 \N
|
||||
15 2 ns1.gnuviech-server.de A 88.198.120.250 86400 0 \N
|
||||
21 3 artist-michael.de SOA ns1.gnuviech-server.de hostmaster.gnuviech.info 2005081501 86400 7200 1209600 86400 86400 0 \N
|
||||
22 3 artist-michael.de NS ns1.gnuviech-server.de 86400 0 \N
|
||||
23 3 artist-michael.de NS ns10.schlundtech.de 86400 0 \N
|
||||
24 3 artist-michael.de A 81.169.155.87 86400 0 \N
|
||||
25 3 artist-michael.de MX gnuviech.info 86400 5 \N
|
||||
26 3 artist-michael.de TXT v=spf1 a mx 86400 0 \N
|
||||
27 3 www.artist-michael.de A 81.169.155.87 86400 0 \N
|
||||
28 3 *.artist-michael.de CNAME www.artist-michael.de 86400 0 \N
|
||||
29 4 blumendeko-wiebach.de SOA ns1.gnuviech-server.de hostmaster.gnuviech.info 2005081701 86400 7200 1209600 86400 86400 0 \N
|
||||
30 4 blumendeko-wiebach.de NS ns1.gnuviech-server.de 86400 0 \N
|
||||
31 4 blumendeko-wiebach.de NS ns10.schlundtech.de 86400 0 \N
|
||||
32 4 blumendeko-wiebach.de A 81.169.155.87 86400 0 \N
|
||||
33 4 blumendeko-wiebach.de MX gnuviech.info 86400 5 \N
|
||||
34 4 blumendeko-wiebach.de TXT v=spf1 a mx 86400 0 \N
|
||||
35 4 www.blumendeko-wiebach.de A 81.169.155.87 86400 0 \N
|
||||
36 4 *.blumendeko-wiebach.de CNAME www.blumendeko-wiebach.de 86400 0 \N
|
||||
37 5 cblicht.de SOA ns1.gnuviech-server.de hostmaster.gnuviech.info 2006031901 86400 7200 1209600 86400 86400 0 \N
|
||||
38 5 cblicht.de NS ns1.gnuviech-server.de 86400 0 \N
|
||||
39 5 cblicht.de NS ns10.schlundtech.de 86400 0 \N
|
||||
40 5 cblicht.de A 81.169.155.87 86400 0 \N
|
||||
41 5 cblicht.de MX gnuviech.info 86400 5 \N
|
||||
42 5 cblicht.de TXT v=spf1 a mx 86400 0 \N
|
||||
43 5 www.cblicht.de A 81.169.155.87 86400 0 \N
|
||||
44 5 *.cblicht.de CNAME www.cblicht.de 86400 0 \N
|
||||
45 6 centrum-warenhaus-dresden.de SOA ns1.gnuviech-server.de hostmaster.gnuviech.info 2005090301 86400 7200 1209600 86400 86400 0 \N
|
||||
46 6 centrum-warenhaus-dresden.de NS ns1.gnuviech-server.de 86400 0 \N
|
||||
47 6 centrum-warenhaus-dresden.de NS ns10.schlundtech.de 86400 0 \N
|
||||
48 6 centrum-warenhaus-dresden.de A 81.169.155.87 86400 0 \N
|
||||
49 6 centrum-warenhaus-dresden.de MX gnuviech.info 86400 5 \N
|
||||
50 6 centrum-warenhaus-dresden.de TXT v=spf1 a mx 86400 0 \N
|
||||
51 6 www.centrum-warenhaus-dresden.de A 81.169.155.87 86400 0 \N
|
||||
52 6 *.centrum-warenhaus-dresden.de CNAME www.centrum-warenhaus-dresden.de 86400 0 \N
|
||||
53 7 dancewarriors.de SOA ns1.gnuviech-server.de hostmaster.gnuviech.info 2005081701 86400 7200 1209600 86400 86400 0 \N
|
||||
54 7 dancewarriors.de NS ns1.gnuviech-server.de 86400 0 \N
|
||||
55 7 dancewarriors.de NS ns10.schlundtech.de 86400 0 \N
|
||||
56 7 dancewarriors.de A 81.169.155.87 86400 0 \N
|
||||
57 7 dancewarriors.de MX gnuviech.info 86400 5 \N
|
||||
58 7 dancewarriors.de TXT v=spf1 a mx 86400 0 \N
|
||||
59 7 www.dancewarriors.de A 81.169.155.87 86400 0 \N
|
||||
60 7 *.dancewarriors.de CNAME www.dancewarriors.de 86400 0 \N
|
||||
70 9 douth-hiphop.de SOA ns1.gnuviech-server.de hostmaster.gnuviech.info 2005081701 86400 7200 1209600 86400 86400 0 \N
|
||||
71 9 douth-hiphop.de NS ns1.gnuviech-server.de 86400 0 \N
|
||||
72 9 douth-hiphop.de NS ns10.schlundtech.de 86400 0 \N
|
||||
73 9 douth-hiphop.de A 81.169.155.87 86400 0 \N
|
||||
74 9 douth-hiphop.de MX gnuviech.info 86400 5 \N
|
||||
75 9 douth-hiphop.de TXT v=spf1 a mx 86400 0 \N
|
||||
76 9 www.douth-hiphop.de A 81.169.155.87 86400 0 \N
|
||||
77 9 *.douth-hiphop.de CNAME www.douth-hiphop.de 86400 0 \N
|
||||
78 10 efs-sohland.de SOA ns1.gnuviech-server.de hostmaster.gnuviech.info 2005092001 86400 7200 1209600 86400 86400 0 \N
|
||||
79 10 efs-sohland.de NS ns1.gnuviech-server.de 86400 0 \N
|
||||
80 10 efs-sohland.de NS ns10.schlundtech.de 86400 0 \N
|
||||
81 10 efs-sohland.de A 81.169.155.87 86400 0 \N
|
||||
82 10 efs-sohland.de MX gnuviech.info 86400 5 \N
|
||||
83 10 efs-sohland.de TXT v=spf1 a mx 86400 0 \N
|
||||
84 10 www.efs-sohland.de A 81.169.155.87 86400 0 \N
|
||||
85 10 *.efs-sohland.de CNAME www.efs-sohland.de 86400 0 \N
|
||||
86 11 ferien-am-stausee.de SOA ns1.gnuviech-server.de hostmaster.gnuviech.info 2005081701 86400 7200 1209600 86400 86400 0 \N
|
||||
87 11 ferien-am-stausee.de NS ns1.gnuviech-server.de 86400 0 \N
|
||||
88 11 ferien-am-stausee.de NS ns10.schlundtech.de 86400 0 \N
|
||||
89 11 ferien-am-stausee.de A 81.169.155.87 86400 0 \N
|
||||
90 11 ferien-am-stausee.de MX gnuviech.info 86400 5 \N
|
||||
91 11 ferien-am-stausee.de TXT v=spf1 a mx 86400 0 \N
|
||||
92 11 www.ferien-am-stausee.de A 81.169.155.87 86400 0 \N
|
||||
93 11 *.ferien-am-stausee.de CNAME www.ferien-am-stausee.de 86400 0 \N
|
||||
94 12 frank-schmidt-online.de SOA ns1.gnuviech-server.de hostmaster.gnuviech.info 2006091901 86400 7200 1209600 86400 86400 0 \N
|
||||
95 12 frank-schmidt-online.de NS ns1.gnuviech-server.de 86400 0 \N
|
||||
96 12 frank-schmidt-online.de NS ns10.schlundtech.de 86400 0 \N
|
||||
97 12 frank-schmidt-online.de A 81.169.155.87 86400 0 \N
|
||||
98 12 frank-schmidt-online.de MX gnuviech.info 86400 5 \N
|
||||
99 12 frank-schmidt-online.de TXT v=spf1 a mx 86400 0 \N
|
||||
100 12 www.frank-schmidt-online.de A 81.169.155.87 86400 0 \N
|
||||
101 12 *.frank-schmidt-online.de CNAME www.frank-schmidt-online.de 86400 0 \N
|
||||
102 13 freie-musikschule-sohland.de SOA ns1.gnuviech-server.de hostmaster.gnuviech.info 2005081701 86400 7200 1209600 86400 86400 0 \N
|
||||
103 13 freie-musikschule-sohland.de NS ns1.gnuviech-server.de 86400 0 \N
|
||||
104 13 freie-musikschule-sohland.de NS ns10.schlundtech.de 86400 0 \N
|
||||
105 13 freie-musikschule-sohland.de A 81.169.155.87 86400 0 \N
|
||||
106 13 freie-musikschule-sohland.de MX gnuviech.info 86400 5 \N
|
||||
107 13 freie-musikschule-sohland.de TXT v=spf1 a mx 86400 0 \N
|
||||
108 13 www.freie-musikschule-sohland.de A 81.169.155.87 86400 0 \N
|
||||
109 13 *.freie-musikschule-sohland.de CNAME www.freie-musikschule-sohland.de 86400 0 \N
|
||||
110 14 hondaracingclub.de SOA ns1.gnuviech-server.de hostmaster.gnuviech.info 2005081701 86400 7200 1209600 86400 86400 0 \N
|
||||
111 14 hondaracingclub.de NS ns1.gnuviech-server.de 86400 0 \N
|
||||
112 14 hondaracingclub.de NS ns10.schlundtech.de 86400 0 \N
|
||||
113 14 hondaracingclub.de A 81.169.155.87 86400 0 \N
|
||||
114 14 hondaracingclub.de MX gnuviech.info 86400 5 \N
|
||||
115 14 hondaracingclub.de TXT v=spf1 a mx 86400 0 \N
|
||||
116 14 www.hondaracingclub.de A 81.169.155.87 86400 0 \N
|
||||
117 14 *.hondaracingclub.de CNAME www.hondaracingclub.de 86400 0 \N
|
||||
118 15 jesusgemeindesohland.de SOA ns1.gnuviech-server.de hostmaster.gnuviech.info 2006031901 86400 7200 1209600 86400 86400 0 \N
|
||||
119 15 jesusgemeindesohland.de NS ns1.gnuviech-server.de 86400 0 \N
|
||||
120 15 jesusgemeindesohland.de NS ns10.schlundtech.de 86400 0 \N
|
||||
121 15 jesusgemeindesohland.de A 81.169.155.87 86400 0 \N
|
||||
122 15 jesusgemeindesohland.de MX gnuviech.info 86400 5 \N
|
||||
123 15 jesusgemeindesohland.de TXT v=spf1 a mx 86400 0 \N
|
||||
124 15 www.jesusgemeindesohland.de A 81.169.155.87 86400 0 \N
|
||||
125 15 *.jesusgemeindesohland.de CNAME www.jesusgemeindesohland.de 86400 0 \N
|
||||
126 16 jugendwoche2006.de SOA ns1.gnuviech-server.de hostmaster.gnuviech.info 2006051701 86400 7200 1209600 86400 86400 0 \N
|
||||
127 16 jugendwoche2006.de NS ns1.gnuviech-server.de 86400 0 \N
|
||||
128 16 jugendwoche2006.de NS ns10.schlundtech.de 86400 0 \N
|
||||
129 16 jugendwoche2006.de A 81.169.155.87 86400 0 \N
|
||||
130 16 jugendwoche2006.de MX gnuviech.info 86400 5 \N
|
||||
131 16 jugendwoche2006.de TXT v=spf1 a mx 86400 0 \N
|
||||
132 16 www.jugendwoche2006.de A 81.169.155.87 86400 0 \N
|
||||
133 16 *.jugendwoche2006.de CNAME www.jugendwoche2006.de 86400 0 \N
|
||||
134 17 katja-schumann.de SOA ns1.gnuviech-server.de hostmaster.gnuviech.info 2006031901 86400 7200 1209600 86400 86400 0 \N
|
||||
135 17 katja-schumann.de NS ns1.gnuviech-server.de 86400 0 \N
|
||||
136 17 katja-schumann.de NS ns10.schlundtech.de 86400 0 \N
|
||||
137 17 katja-schumann.de A 81.169.155.87 86400 0 \N
|
||||
138 17 katja-schumann.de MX gnuviech.info 86400 5 \N
|
||||
139 17 katja-schumann.de TXT v=spf1 a mx 86400 0 \N
|
||||
140 17 www.katja-schumann.de A 81.169.155.87 86400 0 \N
|
||||
141 17 *.katja-schumann.de CNAME www.katja-schumann.de 86400 0 \N
|
||||
142 18 ortodontia.de SOA ns1.gnuviech-server.de hostmaster.gnuviech.info 2005101702 86400 7200 1209600 86400 86400 0 \N
|
||||
143 18 ortodontia.de NS ns1.gnuviech-server.de 86400 0 \N
|
||||
144 18 ortodontia.de NS ns10.schlundtech.de 86400 0 \N
|
||||
145 18 ortodontia.de A 81.169.155.87 86400 0 \N
|
||||
146 18 ortodontia.de MX gnuviech.info 86400 5 \N
|
||||
147 18 ortodontia.de TXT v=spf1 a mx 86400 0 \N
|
||||
148 18 www.ortodontia.de A 81.169.155.87 86400 0 \N
|
||||
149 18 *.ortodontia.de CNAME www.ortodontia.de 86400 0 \N
|
||||
150 19 ostmodern.org SOA ns1.gnuviech-server.de hostmaster.gnuviech.info 2006022001 86400 7200 1209600 86400 86400 0 \N
|
||||
151 19 ostmodern.org NS ns1.gnuviech-server.de 86400 0 \N
|
||||
152 19 ostmodern.org NS ns10.schlundtech.de 86400 0 \N
|
||||
153 19 ostmodern.org A 81.169.155.87 86400 0 \N
|
||||
154 19 ostmodern.org MX gnuviech.info 86400 5 \N
|
||||
155 19 ostmodern.org TXT v=spf1 a mx 86400 0 \N
|
||||
156 19 www.ostmodern.org A 81.169.155.87 86400 0 \N
|
||||
157 19 *.ostmodern.org CNAME www.ostmodern.org 86400 0 \N
|
||||
158 20 peschel-maler.de SOA ns1.gnuviech-server.de hostmaster.gnuviech.info 2006112800 86400 7200 1209600 86400 86400 0 \N
|
||||
159 20 peschel-maler.de NS ns1.gnuviech-server.de 86400 0 \N
|
||||
160 20 peschel-maler.de NS ns10.schlundtech.de 86400 0 \N
|
||||
161 20 peschel-maler.de A 81.169.155.87 86400 0 \N
|
||||
162 20 peschel-maler.de MX gnuviech.info 86400 5 \N
|
||||
163 20 peschel-maler.de TXT v=spf1 a mx 86400 0 \N
|
||||
164 20 www.peschel-maler.de A 81.169.155.87 86400 0 \N
|
||||
165 20 *.peschel-maler.de CNAME www.peschel-maler.de 86400 0 \N
|
||||
166 21 purity-now.de SOA ns1.gnuviech-server.de hostmaster.gnuviech.info 2006083001 86400 7200 1209600 86400 86400 0 \N
|
||||
167 21 purity-now.de NS ns1.gnuviech-server.de 86400 0 \N
|
||||
168 21 purity-now.de NS ns10.schlundtech.de 86400 0 \N
|
||||
169 21 purity-now.de A 81.169.155.87 86400 0 \N
|
||||
170 21 purity-now.de MX gnuviech.info 86400 5 \N
|
||||
171 21 purity-now.de TXT v=spf1 a mx 86400 0 \N
|
||||
172 21 www.purity-now.de A 81.169.155.87 86400 0 \N
|
||||
173 21 *.purity-now.de CNAME www.purity-now.de 86400 0 \N
|
||||
174 22 regionalverkehr.net SOA ns1.gnuviech-server.de hostmaster.gnuviech.info 2005121201 86400 7200 1209600 86400 86400 0 \N
|
||||
175 22 regionalverkehr.net NS ns1.gnuviech-server.de 86400 0 \N
|
||||
176 22 regionalverkehr.net NS ns10.schlundtech.de 86400 0 \N
|
||||
177 22 regionalverkehr.net A 81.169.155.87 86400 0 \N
|
||||
178 22 regionalverkehr.net MX gnuviech.info 86400 5 \N
|
||||
179 22 regionalverkehr.net TXT v=spf1 a mx 86400 0 \N
|
||||
180 22 www.regionalverkehr.net A 81.169.155.87 86400 0 \N
|
||||
181 22 *.regionalverkehr.net CNAME www.regionalverkehr.net 86400 0 \N
|
||||
182 23 rundkino-dresden.de SOA ns1.gnuviech-server.de hostmaster.gnuviech.info 2006112400 86400 7200 1209600 86400 86400 0 \N
|
||||
183 23 rundkino-dresden.de NS ns1.gnuviech-server.de 86400 0 \N
|
||||
184 23 rundkino-dresden.de NS ns10.schlundtech.de 86400 0 \N
|
||||
185 23 rundkino-dresden.de A 81.169.155.87 86400 0 \N
|
||||
186 23 rundkino-dresden.de MX gnuviech.info 86400 5 \N
|
||||
187 23 rundkino-dresden.de TXT v=spf1 a mx 86400 0 \N
|
||||
188 23 www.rundkino-dresden.de A 81.169.155.87 86400 0 \N
|
||||
189 23 *.rundkino-dresden.de CNAME www.rundkino-dresden.de 86400 0 \N
|
||||
190 24 scheune-sohland.de SOA ns1.gnuviech-server.de hostmaster.gnuviech.info 2006030102 86400 7200 1209600 86400 86400 0 \N
|
||||
191 24 scheune-sohland.de NS ns1.gnuviech-server.de 86400 0 \N
|
||||
192 24 scheune-sohland.de NS ns10.schlundtech.de 86400 0 \N
|
||||
193 24 scheune-sohland.de A 81.169.155.87 86400 0 \N
|
||||
194 24 scheune-sohland.de MX mail.gnuviech.info 86400 5 \N
|
||||
195 24 scheune-sohland.de TXT v=spf1 a mx 86400 0 \N
|
||||
196 24 www.scheune-sohland.de A 81.169.155.87 86400 0 \N
|
||||
197 24 *.scheune-sohland.de CNAME www.scheune-sohland.de 86400 0 \N
|
||||
198 25 spare-beatz.de SOA ns1.gnuviech-server.de hostmaster.gnuviech.info 2005090501 86400 7200 1209600 86400 86400 0 \N
|
||||
199 25 spare-beatz.de NS ns1.gnuviech-server.de 86400 0 \N
|
||||
200 25 spare-beatz.de NS ns10.schlundtech.de 86400 0 \N
|
||||
201 25 spare-beatz.de A 81.169.155.87 86400 0 \N
|
||||
202 25 spare-beatz.de MX gnuviech.info 86400 5 \N
|
||||
203 25 spare-beatz.de TXT v=spf1 a mx 86400 0 \N
|
||||
204 25 www.spare-beatz.de A 81.169.155.87 86400 0 \N
|
||||
205 25 *.spare-beatz.de CNAME www.spare-beatz.de 86400 0 \N
|
||||
206 26 tntlive.de SOA ns1.gnuviech-server.de hostmaster.gnuviech.info 2006100401 10000 7200 1209600 86400 86400 0 \N
|
||||
207 26 tntlive.de NS ns1.gnuviech-server.de 86400 0 \N
|
||||
208 26 tntlive.de NS ns10.schlundtech.de 86400 0 \N
|
||||
209 26 tntlive.de A 81.169.155.87 86400 0 \N
|
||||
210 26 tntlive.de MX gnuviech.info 86400 5 \N
|
||||
211 26 tntlive.de TXT v=spf1 a mx 86400 0 \N
|
||||
212 26 *.tntlive.de CNAME www.tntlive.de 86400 0 \N
|
||||
213 26 www.tntlive.de A 81.169.155.87 86400 0 \N
|
||||
214 27 wagner-sound.de SOA ns1.gnuviech-server.de hostmaster.gnuviech.info 2005081701 86400 7200 1209600 86400 86400 0 \N
|
||||
215 27 wagner-sound.de NS ns1.gnuviech-server.de 86400 0 \N
|
||||
216 27 wagner-sound.de NS ns10.schlundtech.de 86400 0 \N
|
||||
217 27 wagner-sound.de A 81.169.155.87 86400 0 \N
|
||||
218 27 wagner-sound.de MX gnuviech.info 86400 5 \N
|
||||
219 27 wagner-sound.de TXT v=spf1 a mx 86400 0 \N
|
||||
220 27 www.wagner-sound.de A 81.169.155.87 86400 0 \N
|
||||
221 27 *.wagner-sound.de CNAME www.wagner-sound.de 86400 0 \N
|
||||
222 28 winproject.de SOA ns1.gnuviech-server.de hostmaster.gnuviech.info 2006100302 10000 7200 1209600 86400 86400 0 \N
|
||||
223 28 winproject.de NS ns1.gnuviech-server.de 86400 0 \N
|
||||
224 28 winproject.de NS ns10.schlundtech.de 86400 0 \N
|
||||
225 28 winproject.de A 81.169.155.87 86400 0 \N
|
||||
226 28 winproject.de MX gnuviech.info 86400 5 \N
|
||||
227 28 winproject.de TXT v=spf1 a mx 86400 0 \N
|
||||
228 28 *.winproject.de CNAME www.winproject.de 86400 0 \N
|
||||
229 28 www.winproject.de A 81.169.155.87 86400 0 \N
|
||||
230 29 zahnspange-schubert.de SOA ns1.gnuviech-server.de hostmaster.gnuviech.info 2005101702 86400 7200 1209600 86400 86400 0 \N
|
||||
231 29 zahnspange-schubert.de NS ns1.gnuviech-server.de 86400 0 \N
|
||||
232 29 zahnspange-schubert.de NS ns10.schlundtech.de 86400 0 \N
|
||||
233 29 zahnspange-schubert.de A 81.169.155.87 86400 0 \N
|
||||
234 29 zahnspange-schubert.de MX gnuviech.info 86400 5 \N
|
||||
235 29 zahnspange-schubert.de TXT v=spf1 a mx 86400 0 \N
|
||||
236 29 www.zahnspange-schubert.de A 81.169.155.87 86400 0 \N
|
||||
237 29 *.zahnspange-schubert.de CNAME www.zahnspange-schubert.de 86400 0 \N
|
||||
61 8 dittberner.info SOA ns1.gnuviech-server.de hostmaster.gnuviech.info 0 10800 3600 604800 86400 86400 0 1166699628
|
||||
69 8 www.dittberner.info A 81.169.155.87 86400 0 1166699628
|
||||
67 8 *.dittberner.info CNAME www.dittberner.info 86400 0 1166699628
|
||||
66 8 dittberner.info TXT v=spf1 a mx -all 86400 0 1166699628
|
||||
65 8 dittberner.info MX gnuviech.info 86400 5 1166699628
|
||||
64 8 dittberner.info A 81.169.155.87 86400 0 1166699628
|
||||
63 8 dittberner.info NS ns10.schlundtech.de 86400 0 1166699628
|
||||
62 8 dittberner.info NS ns1.gnuviech-server.de 86400 0 1166699628
|
||||
17 2 hetzgnu.gnuviech-server.de A 88.198.120.250 86400 0 2006122203
|
||||
18 2 jabber.gnuviech-server.de A 88.198.120.250 86400 0 2006122203
|
||||
20 2 *.gnuviech-server.de CNAME gnuviech-server.de 86400 0 2007010301
|
||||
16 2 www.gnuviech-server.de A 88.198.120.250 86400 0 2007010301
|
||||
9 2 gnuviech-server.de SOA ns1.gnuviech-server.de hostmaster.gnuviech.info 2007010301 10000 7200 1209600 86400 86400 0 2007010301
|
||||
\.
|
||||
|
||||
|
||||
--
|
||||
-- Data for Name: supermasters; Type: TABLE DATA; Schema: public; Owner: postgres
|
||||
--
|
||||
|
||||
COPY supermasters (ip, nameserver, account) FROM stdin;
|
||||
\.
|
||||
|
||||
|
||||
--
|
||||
-- PostgreSQL database dump complete
|
||||
--
|
||||
|
74
testdb/addclient.py
Normal file
74
testdb/addclient.py
Normal file
|
@ -0,0 +1,74 @@
|
|||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright (c) 2007 Jan Dittberner
|
||||
# $Id$
|
||||
#
|
||||
import getopt, sys
|
||||
from gnuviechadmin.dblayer import *
|
||||
|
||||
def usage():
|
||||
print """Usage information:
|
||||
=====================
|
||||
%(process)s -h|--help
|
||||
- prints this help text
|
||||
|
||||
%(process)s --firstname=<firstname> --lastname=<lastname> \
|
||||
--address1=<address1> --town=<town> --zipcode=<zipcode> \
|
||||
[--address2=<address2>] [--country=<country>] [--state=<state>] \
|
||||
[--active=true|false] [--phone=<phone>] [--mobile=<mobile>]
|
||||
- adds a new client
|
||||
""" % {'process': sys.argv[0]}
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
(options, args) = getopt.getopt(sys.argv[1:], "h",
|
||||
['help',
|
||||
'firstname=', 'lastname=', 'address1=',
|
||||
'town=', 'zipcode=', 'address2=',
|
||||
'country=', 'state=', 'active=',
|
||||
'phone=', 'mobile='])
|
||||
except getopt.GetoptError:
|
||||
usage()
|
||||
sys.exit(1)
|
||||
|
||||
if (not options or
|
||||
dict(options).has_key('-h') or
|
||||
dict(options).has_key('--help') or
|
||||
not dict(options).has_key('--firstname') or
|
||||
not dict(options).has_key('--lastname') or
|
||||
not dict(options).has_key('--address1') or
|
||||
not dict(options).has_key('--town') or
|
||||
not dict(options).has_key('--zipcode') or
|
||||
not dict(options)['--firstname'].strip() or
|
||||
not dict(options)['--lastname'].strip() or
|
||||
not dict(options)['--address1'].strip() or
|
||||
not dict(options)['--town'].strip() or
|
||||
not dict(options)['--zipcode'].strip()):
|
||||
usage()
|
||||
sys.exit(1)
|
||||
|
||||
po = dict(options)
|
||||
for key in po.keys():
|
||||
po[key] = po[key].strip()
|
||||
client = Client()
|
||||
client.firstname = po['--firstname']
|
||||
client.lastname = po['--lastname']
|
||||
client.address1 = po['--address1']
|
||||
client.town = po['--town']
|
||||
client.zipcode = po['--zipcode']
|
||||
if po.has_key('--active'):
|
||||
client.active = (po['--active'] == 'true')
|
||||
else:
|
||||
client.active = True
|
||||
if po.has_key('--address2') and po['--address2']:
|
||||
client.address2 = po['--address2']
|
||||
if po.has_key('--country') and po['--country']:
|
||||
client.country = po['--country']
|
||||
if po.has_key('--state') and po['--state']:
|
||||
client.state = po['--state']
|
||||
if po.has_key('--phone') and po['--phone']:
|
||||
client.phone = po['--phone']
|
||||
if po.has_key('--mobile') and po['--mobile']:
|
||||
client.mobile = po['--mobile']
|
||||
session.save(client)
|
||||
session.flush()
|
59
testdb/adddomain.py
Normal file
59
testdb/adddomain.py
Normal file
|
@ -0,0 +1,59 @@
|
|||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright (c) 2007 Jan Dittberner
|
||||
# $Id$
|
||||
#
|
||||
import getopt, sys
|
||||
from gnuviechadmin.dblayer import *
|
||||
|
||||
def usage():
|
||||
print """Usage information:
|
||||
=====================
|
||||
%(process)s -h|--help
|
||||
- prints this help text
|
||||
|
||||
%(process)s --domain=<domain> --sysuser=<sysuser> --type=MASTER|SLAVE \
|
||||
[[--ns=<nameserver>] [--mx=<mxserver[,prio]>] [--a=<ipaddress>] ...]
|
||||
- adds a new domain
|
||||
""" % {'process': sys.argv[0]}
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
(options, args) = getopt.getopt(sys.argv[1:], "h",
|
||||
['help',
|
||||
'domain=', 'sysuser=',
|
||||
'type=', 'ns=', 'mx=', 'a='])
|
||||
except getopt.GetoptError:
|
||||
usage()
|
||||
sys.exit(1)
|
||||
|
||||
if (not options or
|
||||
dict(options).has_key('-h') or
|
||||
dict(options).has_key('--help') or
|
||||
not dict(options).has_key('--domain') or
|
||||
not dict(options).has_key('--sysuser') or
|
||||
not dict(options)['--sysuser'].strip() or
|
||||
not dict(options)['--domain'].strip()):
|
||||
usage()
|
||||
sys.exit(1)
|
||||
|
||||
po = {}
|
||||
for (key, value) in options:
|
||||
if po.has_key(key):
|
||||
po[key].append(value.strip())
|
||||
else:
|
||||
po[key] = [value.strip()]
|
||||
|
||||
# fetch the sysuser
|
||||
query = session.query(SysUser)
|
||||
sysuser = query.get_by(name = po['--sysuser'][0])
|
||||
if not sysuser:
|
||||
print "Invalid system user"
|
||||
allsysusers = query.get_by(name = '*')
|
||||
if allsysusers:
|
||||
print "Valid system users are:\n%s" % ("\n".join(allsysusers))
|
||||
else:
|
||||
print "No system users defined yet."
|
||||
sys.exit(1)
|
||||
|
||||
print sysuser.domains
|
45
testdb/addpopuser.py
Normal file
45
testdb/addpopuser.py
Normal file
|
@ -0,0 +1,45 @@
|
|||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright (c) 2007 Jan Dittberner
|
||||
# $Id$
|
||||
#
|
||||
import getopt, sys
|
||||
from gnuviechadmin.dblayer import *
|
||||
|
||||
def usage():
|
||||
print """Usage information:
|
||||
=====================
|
||||
%(process)s -h|--help
|
||||
- prints this help text
|
||||
|
||||
%(process)s --domain=<domain> [--password=<password>]
|
||||
- adds a new pop user for the given domain
|
||||
- if the optional password is ommitted a generated one is used
|
||||
- the password is checked using cracklib
|
||||
- if the password is too weak a generated one is used
|
||||
""" % {'process': sys.argv[0]}
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
(options, args) = getopt.getopt(sys.argv[1:], "h", ['help', 'password=', 'domain='])
|
||||
except getopt.GetoptError:
|
||||
usage()
|
||||
sys.exit(1)
|
||||
|
||||
if (not options or
|
||||
dict(options).has_key('-h') or
|
||||
dict(options).has_key('--help') or
|
||||
not dict(options).has_key('--domain') or
|
||||
not dict(options)['--domain'].strip()):
|
||||
usage()
|
||||
sys.exit(1)
|
||||
|
||||
# specify the domain
|
||||
query = session.query(Domain)
|
||||
domain = query.get_by(name = dict(options)['--domain'].strip())
|
||||
if not domain:
|
||||
print "Invalid Domain"
|
||||
print "valid domains are:\n%s" % ("\n".join(query.get()))
|
||||
sys.exit(1)
|
||||
|
||||
print domain.popaccounts
|
53
testdb/addsysuser.py
Normal file
53
testdb/addsysuser.py
Normal file
|
@ -0,0 +1,53 @@
|
|||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright (c) 2007 Jan Dittberner
|
||||
# $Id$
|
||||
#
|
||||
import getopt, sys
|
||||
from gnuviechadmin.dblayer import *
|
||||
|
||||
def usage():
|
||||
print """Usage information:
|
||||
=====================
|
||||
%(process)s -h|--help
|
||||
- prints this help text
|
||||
|
||||
%(process)s --type=admin|reseller|client --clientid=<clientid> \
|
||||
[--name=<name>] [--home=<home>] [--shell=<shell>] [--password] \
|
||||
[--sysuid=<uid>]
|
||||
- adds a new system user
|
||||
""" % {'process': sys.argv[0]}
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
(options, args) = getopt.getopt(sys.argv[1:], "h",
|
||||
['help',
|
||||
'type=', 'clientid=', 'name=', 'home=',
|
||||
'shell=', 'password=', 'sysuid='])
|
||||
except getopt.GetoptError:
|
||||
usage()
|
||||
sys.exit(1)
|
||||
|
||||
if (not options or
|
||||
dict(options).has_key('-h') or
|
||||
dict(options).has_key('--help') or
|
||||
not dict(options).has_key('--type') or
|
||||
not dict(options).has_key('--clientid') or
|
||||
not dict(options)['--type'].strip() or
|
||||
not dict(options)['--clientid'].strip() or
|
||||
not dict(options)['--type'].strip() in ('admin', 'reseller', 'client')):
|
||||
usage()
|
||||
sys.exit(1)
|
||||
|
||||
query = session.query(Client)
|
||||
client = query.get_by(clientid = dict(options)['--clientid'].strip())
|
||||
if not client:
|
||||
print "Invalid client"
|
||||
allclients = query.select()
|
||||
if allclients:
|
||||
print "Valid clients are:\n- %s" % "\n- ".join([str(client) for client in allclients])
|
||||
else:
|
||||
print "No clients defined yet."
|
||||
sys.exit(1)
|
||||
|
||||
print client.sysusers
|
4
testdb/dbschema/gnuviechadmin/README
Normal file
4
testdb/dbschema/gnuviechadmin/README
Normal file
|
@ -0,0 +1,4 @@
|
|||
This is a database migration repository.
|
||||
|
||||
More information at
|
||||
http://trac.erosson.com/migrate
|
0
testdb/dbschema/gnuviechadmin/__init__.py
Normal file
0
testdb/dbschema/gnuviechadmin/__init__.py
Normal file
4
testdb/dbschema/gnuviechadmin/manage.py
Normal file
4
testdb/dbschema/gnuviechadmin/manage.py
Normal file
|
@ -0,0 +1,4 @@
|
|||
#!/usr/bin/python
|
||||
from migrate.versioning.shell import main
|
||||
|
||||
main(repository='gnuviechadmin')
|
20
testdb/dbschema/gnuviechadmin/migrate.cfg
Normal file
20
testdb/dbschema/gnuviechadmin/migrate.cfg
Normal file
|
@ -0,0 +1,20 @@
|
|||
[db_settings]
|
||||
# Used to identify which repository this database is versioned under.
|
||||
# You can use the name of your project.
|
||||
repository_id=GNUViech Admin
|
||||
|
||||
# The name of the database table used to track the schema version.
|
||||
# This name shouldn't already be used by your project.
|
||||
# If this is changed once a database is under version control, you'll need to
|
||||
# change the table name in each database too.
|
||||
version_table=migrate_version
|
||||
|
||||
# When committing a change script, Migrate will attempt to generate the
|
||||
# sql for all supported databases; normally, if one of them fails - probably
|
||||
# because you don't have that database installed - it is ignored and the
|
||||
# commit continues, perhaps ending successfully.
|
||||
# Databases in this list MUST compile successfully during a commit, or the
|
||||
# entire commit will fail. List the databases your application will actually
|
||||
# be using to ensure your updates to that database work properly.
|
||||
# This must be a list; example: ['postgres','sqlite']
|
||||
required_dbs=[]
|
33
testdb/dbschema/gnuviechadmin/versions/1/1.py
Normal file
33
testdb/dbschema/gnuviechadmin/versions/1/1.py
Normal file
|
@ -0,0 +1,33 @@
|
|||
# setup tables for spamassassin
|
||||
from sqlalchemy import *
|
||||
from migrate import *
|
||||
|
||||
meta = BoundMetaData(migrate_engine)
|
||||
domains = Table('domains', meta, autoload = True)
|
||||
mailalias = Table(
|
||||
'mailalias', meta,
|
||||
Column('mailaliasid', Integer, primary_key = True),
|
||||
Column('domainid', Integer, ForeignKey('domains.id'), nullable = False),
|
||||
Column('email', String(255), nullable = False),
|
||||
Column('target', TEXT, nullable = False),
|
||||
UniqueConstraint('email', 'domainid'))
|
||||
|
||||
mailpassword = Table(
|
||||
'mailpassword', meta,
|
||||
Column('id', String(18), primary_key = True),
|
||||
Column('domainid', Integer, ForeignKey('domains.id'), nullable = False),
|
||||
Column('uid', Integer, nullable = False),
|
||||
Column('gid', Integer, nullable = False),
|
||||
Column('home', String(255), nullable = False),
|
||||
Column('cryptpass', String(34), nullable = False),
|
||||
Column('clearpass', String(64), nullable = False),
|
||||
Column('spamcheck', Boolean, default = False),
|
||||
Column('sajunkscore', Integer))
|
||||
|
||||
def upgrade():
|
||||
mailalias.create()
|
||||
mailpassword.create()
|
||||
|
||||
def downgrade():
|
||||
mailpassword.drop()
|
||||
mailalias.drop()
|
40
testdb/dbschema/gnuviechadmin/versions/2/2.py
Normal file
40
testdb/dbschema/gnuviechadmin/versions/2/2.py
Normal file
|
@ -0,0 +1,40 @@
|
|||
from sqlalchemy import *
|
||||
from migrate import *
|
||||
|
||||
meta = BoundMetaData(migrate_engine)
|
||||
client_table = Table(
|
||||
'client', meta,
|
||||
Column('clientid', Integer, primary_key = True),
|
||||
Column('firstname', String(40), nullable = False),
|
||||
Column('lastname', String(40), nullable = False),
|
||||
Column('address1', String(40), nullable = False),
|
||||
Column('address2', String(40)),
|
||||
Column('country', String(40)),
|
||||
Column('town', String(50), nullable = False),
|
||||
Column('zipcode', String(5), nullable = False),
|
||||
Column('state', String(40)),
|
||||
Column('active', Boolean, default = False, nullable = False),
|
||||
Column('phone', String(20)),
|
||||
Column('mobile', String(20)))
|
||||
|
||||
sysuser_table = Table(
|
||||
'sysuser', meta,
|
||||
Column('sysuserid', Integer, primary_key = True),
|
||||
Column('name', String(12), nullable = False),
|
||||
Column('type', Integer, default = 0, nullable = False),
|
||||
Column('home', String(128)),
|
||||
Column('shell', Boolean),
|
||||
Column('password', String(64)),
|
||||
Column('clientid', Integer, ForeignKey('client.clientid'),
|
||||
nullable = False),
|
||||
Column('toupdate', Boolean, default = False, nullable = False),
|
||||
Column('md5pass', String(34)),
|
||||
Column('sysuid', Integer))
|
||||
|
||||
def upgrade():
|
||||
client_table.create()
|
||||
sysuser_table.create()
|
||||
|
||||
def downgrade():
|
||||
sysuser_table.drop()
|
||||
client_table.drop()
|
17
testdb/dbschema/gnuviechadmin/versions/3/3.py
Normal file
17
testdb/dbschema/gnuviechadmin/versions/3/3.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
from sqlalchemy import *
|
||||
from migrate import *
|
||||
import migrate.changeset
|
||||
|
||||
meta = BoundMetaData(migrate_engine)
|
||||
sysuser = Table('sysuser', meta, autoload = True)
|
||||
domains = Table('domains', meta, autoload = True)
|
||||
sysuidrefcol = Column('sysuserid', Integer,
|
||||
ForeignKey('sysuser.sysuserid'),
|
||||
nullable = False)
|
||||
|
||||
def upgrade():
|
||||
sysuidrefcol.create(domains)
|
||||
|
||||
def downgrade():
|
||||
col = domains.c.sysuserid
|
||||
col.drop()
|
0
testdb/dbschema/gnuviechadmin/versions/__init__.py
Normal file
0
testdb/dbschema/gnuviechadmin/versions/__init__.py
Normal file
16
testdb/dbschema/initdb.sh
Executable file
16
testdb/dbschema/initdb.sh
Executable file
|
@ -0,0 +1,16 @@
|
|||
#!/bin/bash
|
||||
|
||||
dirname=$(pwd)
|
||||
dbname=testdb
|
||||
dbuser=jan
|
||||
dbpassword=heyyou97
|
||||
reponame=gnuviechadmin
|
||||
dburl=postgres://$dbuser:$dbpassword@localhost:5432/$dbname
|
||||
|
||||
sudo su - postgres -c "createdb -O $dbuser -E UTF-8 $dbname"
|
||||
sudo su - postgres -c "psql $dbname < $dirname/initdb.sql"
|
||||
|
||||
#migrate create $reponame "GNUViech Admin"
|
||||
migrate version_control $dburl $reponame
|
||||
migrate manage manage.py --repository=$reponame --url=$dburl
|
||||
python manage.py upgrade
|
188
testdb/dbschema/initdb.sql
Normal file
188
testdb/dbschema/initdb.sql
Normal file
|
@ -0,0 +1,188 @@
|
|||
-- initial schema setup for postgresql
|
||||
|
||||
-- spamassassin bayes storage
|
||||
|
||||
CREATE PROCEDURAL LANGUAGE plpgsql;
|
||||
|
||||
SET search_path = public, pg_catalog;
|
||||
|
||||
CREATE TABLE bayes_expire (
|
||||
id integer NOT NULL default '0',
|
||||
runtime integer NOT NULL default '0'
|
||||
) WITHOUT OIDS;
|
||||
|
||||
CREATE INDEX bayes_expire_idx1 ON bayes_expire (id);
|
||||
|
||||
CREATE TABLE bayes_global_vars (
|
||||
variable varchar(30) NOT NULL default '',
|
||||
value varchar(200) NOT NULL default '',
|
||||
PRIMARY KEY (variable)
|
||||
) WITHOUT OIDS;
|
||||
|
||||
INSERT INTO bayes_global_vars VALUES ('VERSION','3');
|
||||
|
||||
CREATE TABLE bayes_seen (
|
||||
id integer NOT NULL default '0',
|
||||
msgid varchar(200) NOT NULL default '',
|
||||
flag character(1) NOT NULL default '',
|
||||
PRIMARY KEY (id,msgid)
|
||||
) WITHOUT OIDS;
|
||||
|
||||
CREATE TABLE bayes_token (
|
||||
id integer NOT NULL default '0',
|
||||
token bytea NOT NULL default '',
|
||||
spam_count integer NOT NULL default '0',
|
||||
ham_count integer NOT NULL default '0',
|
||||
atime integer NOT NULL default '0',
|
||||
PRIMARY KEY (id,token)
|
||||
) WITHOUT OIDS;
|
||||
|
||||
CREATE INDEX bayes_token_idx1 ON bayes_token (token);
|
||||
|
||||
CREATE TABLE bayes_vars (
|
||||
id serial NOT NULL,
|
||||
username varchar(200) NOT NULL default '',
|
||||
spam_count integer NOT NULL default '0',
|
||||
ham_count integer NOT NULL default '0',
|
||||
token_count integer NOT NULL default '0',
|
||||
last_expire integer NOT NULL default '0',
|
||||
last_atime_delta integer NOT NULL default '0',
|
||||
last_expire_reduce integer NOT NULL default '0',
|
||||
oldest_token_age integer NOT NULL default '2147483647',
|
||||
newest_token_age integer NOT NULL default '0',
|
||||
PRIMARY KEY (id)
|
||||
) WITHOUT OIDS;
|
||||
|
||||
CREATE UNIQUE INDEX bayes_vars_idx1 ON bayes_vars (username);
|
||||
|
||||
CREATE OR REPLACE FUNCTION greatest_int (integer, integer)
|
||||
RETURNS INTEGER
|
||||
IMMUTABLE STRICT
|
||||
AS 'SELECT CASE WHEN $1 < $2 THEN $2 ELSE $1 END;'
|
||||
LANGUAGE SQL;
|
||||
|
||||
CREATE OR REPLACE FUNCTION least_int (integer, integer)
|
||||
RETURNS INTEGER
|
||||
IMMUTABLE STRICT
|
||||
AS 'SELECT CASE WHEN $1 < $2 THEN $1 ELSE $2 END;'
|
||||
LANGUAGE SQL;
|
||||
|
||||
CREATE OR REPLACE FUNCTION put_tokens(inuserid INTEGER,
|
||||
intokenary BYTEA[],
|
||||
inspam_count INTEGER,
|
||||
inham_count INTEGER,
|
||||
inatime INTEGER)
|
||||
RETURNS VOID AS '
|
||||
DECLARE
|
||||
_token BYTEA;
|
||||
new_tokens INTEGER := 0;
|
||||
BEGIN
|
||||
for i in array_lower(intokenary, 1) .. array_upper(intokenary, 1)
|
||||
LOOP
|
||||
_token := intokenary[i];
|
||||
UPDATE bayes_token
|
||||
SET spam_count = greatest_int(spam_count + inspam_count, 0),
|
||||
ham_count = greatest_int(ham_count + inham_count, 0),
|
||||
atime = greatest_int(atime, inatime)
|
||||
WHERE id = inuserid
|
||||
AND token = _token;
|
||||
IF NOT FOUND THEN
|
||||
-- we do not insert negative counts, just return true
|
||||
IF NOT (inspam_count < 0 OR inham_count < 0) THEN
|
||||
INSERT INTO bayes_token (id, token, spam_count, ham_count, atime)
|
||||
VALUES (inuserid, _token, inspam_count, inham_count, inatime);
|
||||
IF FOUND THEN
|
||||
new_tokens := new_tokens + 1;
|
||||
END IF;
|
||||
END IF;
|
||||
END IF;
|
||||
END LOOP;
|
||||
|
||||
IF new_tokens > 0 AND inatime > 0 THEN
|
||||
UPDATE bayes_vars
|
||||
SET token_count = token_count + new_tokens,
|
||||
newest_token_age = greatest_int(newest_token_age, inatime),
|
||||
oldest_token_age = least_int(oldest_token_age, inatime)
|
||||
WHERE id = inuserid;
|
||||
ELSEIF new_tokens > 0 AND NOT inatime > 0 THEN
|
||||
UPDATE bayes_vars
|
||||
SET token_count = token_count + new_tokens
|
||||
WHERE id = inuserid;
|
||||
ELSEIF NOT new_tokens > 0 AND inatime > 0 THEN
|
||||
UPDATE bayes_vars
|
||||
SET newest_token_age = greatest_int(newest_token_age, inatime),
|
||||
oldest_token_age = least_int(oldest_token_age, inatime)
|
||||
WHERE id = inuserid;
|
||||
END IF;
|
||||
RETURN;
|
||||
END;
|
||||
' LANGUAGE 'plpgsql';
|
||||
|
||||
-- tables for spamassassin auto-whitelists
|
||||
|
||||
CREATE TABLE awl (
|
||||
username varchar(100) NOT NULL default '',
|
||||
email varchar(200) NOT NULL default '',
|
||||
ip varchar(10) NOT NULL default '',
|
||||
count bigint default '0',
|
||||
totscore float default '0'
|
||||
);
|
||||
CREATE UNIQUE INDEX awl_pkey ON awl (username,email,ip);
|
||||
|
||||
-- tables for spamassassin user preferences
|
||||
|
||||
CREATE TABLE userpref (
|
||||
prefid bigserial NOT NULL unique primary key,
|
||||
username varchar(100) NOT NULL,
|
||||
preference varchar(30) NOT NULL,
|
||||
value varchar(100) NOT NULL
|
||||
);
|
||||
CREATE INDEX userpref_username_idx ON userpref(username);
|
||||
|
||||
-- tables for powerdns
|
||||
|
||||
CREATE TABLE domains (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name VARCHAR(255) NOT NULL UNIQUE,
|
||||
master VARCHAR(20) DEFAULT NULL,
|
||||
last_check INT DEFAULT NULL,
|
||||
type VARCHAR(6) NOT NULL,
|
||||
notified_serial INT DEFAULT NULL,
|
||||
account VARCHAR(40) DEFAULT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE records (
|
||||
id SERIAL PRIMARY KEY,
|
||||
domain_id INT DEFAULT NULL,
|
||||
name VARCHAR(255) DEFAULT NULL,
|
||||
type VARCHAR(6) DEFAULT NULL,
|
||||
content VARCHAR(255) DEFAULT NULL,
|
||||
ttl INT DEFAULT NULL,
|
||||
prio INT DEFAULT NULL,
|
||||
change_date INT DEFAULT NULL,
|
||||
CONSTRAINT domain_exists
|
||||
FOREIGN KEY(domain_id) REFERENCES domains(id)
|
||||
ON DELETE CASCADE
|
||||
);
|
||||
|
||||
CREATE INDEX rec_name_index ON records(name);
|
||||
CREATE INDEX nametype_index ON records(name, type);
|
||||
CREATE INDEX domain_id ON records(domain_id);
|
||||
|
||||
CREATE TABLE supermasters (
|
||||
ip VARCHAR(25) NOT NULL,
|
||||
nameserver VARCHAR(255) NOT NULL,
|
||||
account VARCHAR(40) DEFAULT NULL
|
||||
);
|
||||
|
||||
GRANT ALL ON supermasters TO jan;
|
||||
GRANT ALL ON domains TO jan;
|
||||
GRANT ALL ON domains_id_seq TO jan;
|
||||
GRANT ALL ON records TO jan;
|
||||
GRANT ALL ON records_id_seq TO jan;
|
||||
|
||||
-- GRANT SELECT ON supermasters TO pdns;
|
||||
-- GRANT ALL ON domains TO pdns;
|
||||
-- GRANT ALL ON domains_id_seq TO pdns;
|
||||
-- GRANT ALL ON records TO pdns;
|
||||
-- GRANT ALL ON records_id_seq TO pdns;
|
4
testdb/dbschema/manage.py
Normal file
4
testdb/dbschema/manage.py
Normal file
|
@ -0,0 +1,4 @@
|
|||
#!/usr/bin/python
|
||||
from migrate.versioning.shell import main
|
||||
|
||||
main(url='postgres://jan:heyyou97@localhost:5432/testdb',repository='gnuviechadmin')
|
0
testdb/gnuviechadmin/__init__.py
Normal file
0
testdb/gnuviechadmin/__init__.py
Normal file
23
testdb/gnuviechadmin/dblayer.py
Normal file
23
testdb/gnuviechadmin/dblayer.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
from sqlalchemy import *
|
||||
from entities import *
|
||||
|
||||
db = create_engine('postgres://jan:heyyou97@localhost:5432/testdb')
|
||||
|
||||
metadata = BoundMetaData(db)
|
||||
|
||||
domains_table = Table('domains', metadata, autoload = True)
|
||||
sysuser_table = Table('sysuser', metadata, autoload = True)
|
||||
mailpassword_table = Table('mailpassword', metadata, autoload = True)
|
||||
client_table = Table('client', metadata, autoload = True)
|
||||
|
||||
popaccountmapper = mapper(PopAccount, mailpassword_table)
|
||||
|
||||
domainmapper = mapper(Domain, domains_table)
|
||||
domainmapper.add_property('popaccounts', relation(PopAccount))
|
||||
|
||||
sysusermapper = mapper(SysUser, sysuser_table)
|
||||
|
||||
clientmapper = mapper(Client, client_table)
|
||||
clientmapper.add_property('sysusers', relation(SysUser))
|
||||
|
||||
session = create_session()
|
46
testdb/gnuviechadmin/entities.py
Normal file
46
testdb/gnuviechadmin/entities.py
Normal file
|
@ -0,0 +1,46 @@
|
|||
class Client(object):
|
||||
def __repr__(self):
|
||||
return "%s(clientid=%s,firstname=%s,lastname=%s)" % \
|
||||
(self.__class__.__name__,
|
||||
self.clientid,
|
||||
self.firstname,
|
||||
self.lastname)
|
||||
|
||||
class PopAccount(object):
|
||||
def __repr__(self):
|
||||
return "%s(%s,%d,%d,%d,%s,%s,%s)" % \
|
||||
(self.__class__.__name__,
|
||||
self.id,
|
||||
self.domainid,
|
||||
self.uid,
|
||||
self.gid,
|
||||
self.home,
|
||||
self.cryptpass,
|
||||
self.clearpass)
|
||||
|
||||
class SysUser(object):
|
||||
def __repr__(self):
|
||||
return "%s(%d,%s,%d,%s,%s,%s,%d,%d,%s,%d)" % \
|
||||
(self.__class__.__name__,
|
||||
self.sysuserid,
|
||||
self.name,
|
||||
self.type,
|
||||
self.home,
|
||||
self.shell,
|
||||
self.password,
|
||||
self.clientid,
|
||||
self.toupdate,
|
||||
self.md5pass,
|
||||
self.sysuid)
|
||||
|
||||
class Domain(object):
|
||||
def __repr__(self):
|
||||
return "%s(%d,%s,%s,%s,%s,%s,%s)" % \
|
||||
(self.__class__.__name__,
|
||||
self.id,
|
||||
self.name,
|
||||
self.master,
|
||||
self.last_check,
|
||||
self.type,
|
||||
self.notified_serial,
|
||||
self.account)
|
Loading…
Reference in a new issue