diff options
author | Ana Krivokapic <akrivoka@redhat.com> | 2013-06-10 18:57:08 -0400 |
---|---|---|
committer | Petr Viktorin <pviktori@redhat.com> | 2013-06-24 14:30:06 +0200 |
commit | 91a5d3349be3a8c6044684405a4e66f4ed1dd543 (patch) | |
tree | c8d6ee3bbe7eaa81e25ab2b576f6db20345c3090 /ipalib/plugins/idrange.py | |
parent | 2775dec3bec3499c69de60d5bb581ffad7615cef (diff) | |
download | freeipa.git-91a5d3349be3a8c6044684405a4e66f4ed1dd543.tar.gz freeipa.git-91a5d3349be3a8c6044684405a4e66f4ed1dd543.tar.xz freeipa.git-91a5d3349be3a8c6044684405a4e66f4ed1dd543.zip |
Require rid-base and secondary-rid-base in idrange-add after ipa-adtrust-install
Add a new API command 'adtrust_is_enabled', which can be used to determine
whether ipa-adtrust-install has been run on the system. This new command is not
visible in IPA CLI.
Use this command in idrange_add to conditionally require rid-base and
secondary-rid-base options.
Add tests to cover the new functionality
https://fedorahosted.org/freeipa/ticket/3634
Diffstat (limited to 'ipalib/plugins/idrange.py')
-rw-r--r-- | ipalib/plugins/idrange.py | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/ipalib/plugins/idrange.py b/ipalib/plugins/idrange.py index 54b835e2..f258cbb1 100644 --- a/ipalib/plugins/idrange.py +++ b/ipalib/plugins/idrange.py @@ -356,7 +356,7 @@ class idrange_add(LDAPCreate): may be given for a new ID range for the local domain while - --rid-bas + --rid-base --dom-sid must be given to add a new range for a trusted AD domain. @@ -381,6 +381,9 @@ class idrange_add(LDAPCreate): 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. + + Also ensure that rid-base and secondary-rid-base is prompted for + if ipa-adtrust-install has been run on the system. """ # dom-sid can be specified using dom-sid or dom-name options @@ -410,6 +413,22 @@ class idrange_add(LDAPCreate): value = self.prompt_param(self.params['ipabaserid']) kw.update(dict(ipabaserid=value)) + # Prompt for rid-base and secondary-rid-base if ipa-adtrust-install + # has been run on the system + adtrust_is_enabled = api.Command['adtrust_is_enabled']()['result'] + + if adtrust_is_enabled: + rid_base = kw.get('ipabaserid', None) + secondary_rid_base = kw.get('ipasecondarybaserid', None) + + if rid_base is None: + value = self.prompt_param(self.params['ipabaserid']) + kw.update(dict(ipabaserid=value)) + + if secondary_rid_base is None: + value = self.prompt_param(self.params['ipasecondarybaserid']) + kw.update(dict(ipasecondarybaserid=value)) + def pre_callback(self, ldap, dn, entry_attrs, attrs_list, *keys, **options): assert isinstance(dn, DN) @@ -495,6 +514,20 @@ class idrange_add(LDAPCreate): error=_("Primary RID range and secondary RID range" " cannot overlap")) + # rid-base and secondary-rid-base must be set if + # ipa-adtrust-install has been run on the system + adtrust_is_enabled = api.Command['adtrust_is_enabled']()['result'] + + if adtrust_is_enabled and not ( + is_set('ipabaserid') and is_set('ipasecondarybaserid')): + raise errors.ValidationError( + name='ID Range setup', + error=_( + 'You must specify both rid-base and ' + 'secondary-rid-base options, because ' + 'ipa-adtrust-install has already been run.' + ) + ) return dn def post_callback(self, ldap, dn, entry_attrs, *keys, **options): |