summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSumit Bose <sbose@redhat.com>2012-09-05 13:21:04 +0200
committerMartin Kosek <mkosek@redhat.com>2012-09-07 16:52:39 +0200
commit6e1635edb71d6638430291620fbbb07342447fa8 (patch)
tree8b538da5012b07fabd1648260b54801993fdf3af
parent9b7bdc4df8bb42e48795d45666e0f22acb603e1a (diff)
downloadfreeipa.git-6e1635edb71d6638430291620fbbb07342447fa8.tar.gz
freeipa.git-6e1635edb71d6638430291620fbbb07342447fa8.tar.xz
freeipa.git-6e1635edb71d6638430291620fbbb07342447fa8.zip
IDRange CLI: allow to work without arguments
Fixes https://fedorahosted.org/freeipa/ticket/2999
-rw-r--r--API.txt2
-rw-r--r--ipalib/plugins/idrange.py22
2 files changed, 17 insertions, 7 deletions
diff --git a/API.txt b/API.txt
index 1781de6c..6aee01ac 100644
--- a/API.txt
+++ b/API.txt
@@ -1888,7 +1888,7 @@ args: 1,11,3
arg: Str('cn', attribute=True, cli_name='name', multivalue=False, primary_key=True, required=True)
option: Int('ipabaseid', attribute=True, cli_name='base_id', multivalue=False, required=True)
option: Int('ipaidrangesize', attribute=True, cli_name='range_size', multivalue=False, required=True)
-option: Int('ipabaserid', attribute=True, cli_name='rid_base', multivalue=False, required=True)
+option: Int('ipabaserid', attribute=True, cli_name='rid_base', multivalue=False, required=False)
option: Int('ipasecondarybaserid', attribute=True, cli_name='secondary_rid_base', multivalue=False, required=False)
option: Str('ipanttrusteddomainsid', attribute=True, cli_name='dom_sid', multivalue=False, required=False)
option: Str('iparangetype', attribute=True, cli_name='iparangetype', multivalue=False, required=False)
diff --git a/ipalib/plugins/idrange.py b/ipalib/plugins/idrange.py
index 23c8e0c3..3231156b 100644
--- a/ipalib/plugins/idrange.py
+++ b/ipalib/plugins/idrange.py
@@ -63,7 +63,7 @@ class idrange(LDAPObject):
cli_name='range_size',
label=_("Number of IDs in the range"),
),
- Int('ipabaserid',
+ Int('ipabaserid?',
cli_name='rid_base',
label=_('First RID of the corresponding RID range'),
),
@@ -150,15 +150,25 @@ class idrange_add(LDAPCreate):
def pre_callback(self, ldap, dn, entry_attrs, attrs_list, *keys, **options):
assert isinstance(dn, DN)
- if ('ipanttrusteddomainsid' not in options and
- 'ipasecondarybaserid' not in options):
- raise errors.ValidationError(name=_('Range setup'),
- error=_('Ranges for local domain ' \
- 'must have a secondary RID base'))
if 'ipanttrusteddomainsid' in options:
+ if 'ipasecondarybaserid' in options:
+ raise errors.ValidationError(name=_('ID Range setup'),
+ error=_('Options dom_sid and secondary_rid_base cannot ' \
+ 'be used together'))
+
+ if 'ipabaserid' not in options:
+ raise errors.ValidationError(name=_('ID Range setup'),
+ error=_('Options dom_sid and rid_base must ' \
+ 'be used together'))
+
entry_attrs['objectclass'].append('ipatrustedaddomainrange')
else:
+ if (('ipasecondarybaserid' in options) != ('ipabaserid' in options)):
+ raise errors.ValidationError(name=_('ID Range setup'),
+ error=_('Options secondary_rid_base and rid_base must ' \
+ 'be used together'))
+
entry_attrs['objectclass'].append('ipadomainidrange')
return dn