diff options
author | Fraser Tweedale <ftweedal@redhat.com> | 2016-12-19 14:31:14 +1000 |
---|---|---|
committer | Jan Cholasta <jcholast@redhat.com> | 2017-01-11 15:26:20 +0100 |
commit | 09a65df6842411d42966111e50924df3de0b7031 (patch) | |
tree | f96b847e1a3aa7d5239d50f3438ec7d3f6f73a6a /ipaserver/plugins/certprofile.py | |
parent | f54df62abae4a15064bf297634558eb9be83ce33 (diff) | |
download | freeipa-09a65df6842411d42966111e50924df3de0b7031.tar.gz freeipa-09a65df6842411d42966111e50924df3de0b7031.tar.xz freeipa-09a65df6842411d42966111e50924df3de0b7031.zip |
Reuse self.api when executing ca_enabled_check
The ca_enabled_check function is a wrapper around
api.Command.ca_is_enabled. When using remote_api (e.g. during
installer), ca_enabled_check invokes the *global* api instead of the
remote_api.
Update ca_enabled_check to explicitly receive an api object from the
caller and invoke Command.ca_is_enabled through it.
Part of: https://fedorahosted.org/freeipa/ticket/2614
Reviewed-By: Jan Cholasta <jcholast@redhat.com>
Diffstat (limited to 'ipaserver/plugins/certprofile.py')
-rw-r--r-- | ipaserver/plugins/certprofile.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/ipaserver/plugins/certprofile.py b/ipaserver/plugins/certprofile.py index 2bd3311e3..4eab09f24 100644 --- a/ipaserver/plugins/certprofile.py +++ b/ipaserver/plugins/certprofile.py @@ -75,14 +75,14 @@ The following restrictions apply to profiles managed by FreeIPA: register = Registry() -def ca_enabled_check(): +def ca_enabled_check(_api): """Raise NotFound if CA is not enabled. This function is defined in multiple plugins to avoid circular imports (cert depends on certprofile, so we cannot import cert here). """ - if not api.Command.ca_is_enabled()['result']: + if not _api.Command.ca_is_enabled()['result']: raise errors.NotFound(reason=_('CA is not configured')) @@ -191,7 +191,7 @@ class certprofile_find(LDAPSearch): ) def execute(self, *args, **kwargs): - ca_enabled_check() + ca_enabled_check(self.api) return super(certprofile_find, self).execute(*args, **kwargs) @@ -206,7 +206,7 @@ class certprofile_show(LDAPRetrieve): ) def execute(self, *keys, **options): - ca_enabled_check() + ca_enabled_check(self.api) result = super(certprofile_show, self).execute(*keys, **options) if 'out' in options: @@ -233,7 +233,7 @@ class certprofile_import(LDAPCreate): PROFILE_ID_PATTERN = re.compile('^profileId=([a-zA-Z]\w*)', re.MULTILINE) def pre_callback(self, ldap, dn, entry, entry_attrs, *keys, **options): - ca_enabled_check() + ca_enabled_check(self.api) context.profile = options['file'] match = self.PROFILE_ID_PATTERN.search(options['file']) @@ -271,7 +271,7 @@ class certprofile_del(LDAPDelete): msg_summary = _('Deleted profile "%(value)s"') def pre_callback(self, ldap, dn, *keys, **options): - ca_enabled_check() + ca_enabled_check(self.api) if keys[0] in [p.profile_id for p in INCLUDED_PROFILES]: raise errors.ValidationError(name='profile_id', @@ -304,7 +304,7 @@ class certprofile_mod(LDAPUpdate): ) def pre_callback(self, ldap, dn, entry_attrs, attrs_list, *keys, **options): - ca_enabled_check() + ca_enabled_check(self.api) # Once a profile id is set it cannot be changed if 'cn' in entry_attrs: raise errors.ProtectedEntryError(label='certprofile', key=keys[0], |