Jan Dittberner
dea15a6c4f
git-svn-id: file:///home/www/usr01/svn/gnuviechadmin/trunk@242 a67ec6bc-e5d5-0310-a910-815c51eb3124
59 lines
1.6 KiB
Python
59 lines
1.6 KiB
Python
#!/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
|