summaryrefslogtreecommitdiffstats
path: root/ipalib
diff options
context:
space:
mode:
authorTomas Babej <tbabej@redhat.com>2013-05-09 14:47:29 +0200
committerMartin Kosek <mkosek@redhat.com>2013-06-05 12:50:29 +0200
commite87c21ade2fada3786a0bf7d135238fd4e0dde2c (patch)
tree6719f11b0f8e0029087b66a99ec8e7e5b4b1c186 /ipalib
parent89ffaf411d4cfbf7cc7861439b8cde7ea8ba3ff7 (diff)
downloadfreeipa-e87c21ade2fada3786a0bf7d135238fd4e0dde2c.tar.gz
freeipa-e87c21ade2fada3786a0bf7d135238fd4e0dde2c.tar.xz
freeipa-e87c21ade2fada3786a0bf7d135238fd4e0dde2c.zip
Incorporate interactive prompts in idrange-add
In idrange-add command, ensure that RID base is prompted for in the interactive mode if domain SID or domain name was specified. If domain name nor SID was specified, make sure rid base is prompted for if secondary rid base was specified and vice versa. https://fedorahosted.org/freeipa/ticket/3602
Diffstat (limited to 'ipalib')
-rw-r--r--ipalib/plugins/idrange.py41
1 files changed, 38 insertions, 3 deletions
diff --git a/ipalib/plugins/idrange.py b/ipalib/plugins/idrange.py
index 22383ba9b..73628795a 100644
--- a/ipalib/plugins/idrange.py
+++ b/ipalib/plugins/idrange.py
@@ -359,6 +359,41 @@ class idrange_add(LDAPCreate):
msg_summary = _('Added ID range "%(value)s"')
+ def interactive_prompt_callback(self, kw):
+ """
+ Ensure that rid-base is prompted for when dom-sid is specified.
+
+ Also ensure that secondary-rid-base is prompted for when rid-base is
+ specified and vice versa, in case that dom-sid was not specified.
+ """
+
+ # dom-sid can be specified using dom-sid or dom-name options
+
+ # it can be also set using --setattr or --addattr, in these cases
+ # we will not prompt, but raise an ValidationError later
+
+ dom_sid_set = any(dom_id in kw for dom_id in
+ ('ipanttrusteddomainname', 'ipanttrusteddomainsid'))
+
+ rid_base_set = 'ipabaserid' in kw
+ secondary_rid_base_set = 'ipasecondarybaserid' in kw
+
+ # Prompt for RID base if domain SID / name was given
+ if dom_sid_set and not rid_base_set:
+ value = self.prompt_param(self.params['ipabaserid'])
+ kw.update(dict(ipabaserid=value))
+
+ if not dom_sid_set:
+ # Prompt for secondary RID base if RID base was given
+ if rid_base_set and not secondary_rid_base_set:
+ value = self.prompt_param(self.params['ipasecondarybaserid'])
+ kw.update(dict(ipasecondarybaserid=value))
+
+ # Symetrically, prompt for RID base if secondary RID base was given
+ if not rid_base_set and secondary_rid_base_set:
+ value = self.prompt_param(self.params['ipabaserid'])
+ kw.update(dict(ipabaserid=value))
+
def pre_callback(self, ldap, dn, entry_attrs, attrs_list, *keys, **options):
assert isinstance(dn, DN)
@@ -412,9 +447,9 @@ class idrange_add(LDAPCreate):
entry_attrs['ipabaserid'],
entry_attrs['ipasecondarybaserid'],
entry_attrs['ipaidrangesize']):
- raise errors.ValidationError(name='ID Range setup',
- error=_("Primary RID range and secondary RID range"
- " cannot overlap"))
+ raise errors.ValidationError(name='ID Range setup',
+ error=_("Primary RID range and secondary RID range"
+ " cannot overlap"))
entry_attrs['objectclass'].append('ipadomainidrange')