summaryrefslogtreecommitdiffstats
path: root/pykolab/cli/cmd_add_domain.py
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2013-05-03 17:59:00 +0200
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2013-05-03 18:00:23 +0200
commitb1d4465c6eaf6848d67c1af4bcdfe158511ca244 (patch)
tree7e723c5b610b154c89765ec1f630169b6af0885b /pykolab/cli/cmd_add_domain.py
parent030c157841e2b8690938995f5ce6bd6c48a82ea5 (diff)
downloadpykolab-b1d4465c6eaf6848d67c1af4bcdfe158511ca244.tar.gz
Some initial domain operations for the command-line interface
Diffstat (limited to 'pykolab/cli/cmd_add_domain.py')
-rw-r--r--pykolab/cli/cmd_add_domain.py33
1 files changed, 7 insertions, 26 deletions
diff --git a/pykolab/cli/cmd_add_domain.py b/pykolab/cli/cmd_add_domain.py
index 16c3da8..92aab7c 100644
--- a/pykolab/cli/cmd_add_domain.py
+++ b/pykolab/cli/cmd_add_domain.py
@@ -35,16 +35,16 @@ def __init__():
def cli_options():
my_option_group = conf.add_cli_parser_option_group(_("CLI Options"))
my_option_group.add_option(
- '--alias-for',
- dest = "parent_domain",
- action = "store",
- default = None,
- help = _("Add domain as alias for DOMAIN"),
+ '--alias',
+ dest = "domains",
+ action = "append",
+ default = [],
+ help = _("Add alias domain."),
metavar = "DOMAIN",
)
def description():
- return _("Add a new domain or domain alias.")
+ return _("Add a new domain.")
def execute(*args, **kw):
from pykolab import wap_client
@@ -58,31 +58,12 @@ def execute(*args, **kw):
sys.exit(1)
wap_client.authenticate(username=username)
- domains = wap_client.domains_list()
dna = conf.get('ldap', 'domain_name_attribute')
- if not conf.parent_domain == None:
- parent_found = False
- if isinstance(domains['list'], dict):
- for _domain in domains['list'].keys():
- if parent_found:
- continue
-
- if isinstance(domains['list'][_domain][dna], basestring):
- if conf.parent_domain == domains['list'][_domain][dna]:
- parent_found = True
- elif isinstance(domains['list'][_domain], list):
- if conf.parent_domain in domains['list'][_domain][dna]:
- parent_found = True
-
- if not parent_found:
- log.error(_("Invalid parent domain"))
- sys.exit(1)
-
try:
domain = conf.cli_args.pop(0)
except IndexError, errmsg:
domain = utils.ask_question(_("Domain name"))
- wap_client.domain_add(domain, conf.parent_domain)
+ wap_client.domain_add(domain, conf.domains)