summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Heimes <cheimes@redhat.com>2015-07-23 17:48:56 +0200
committerMartin Basti <mbasti@redhat.com>2015-07-31 16:00:57 +0200
commitd80e90fa5c5ad41f5f29a02c11bca7c7da269938 (patch)
tree3548d5a289255c649edc46f8a2a901ad04dc4751
parent3b90044f309548a7d0c508622b2858c010ba352f (diff)
downloadfreeipa-d80e90fa5c5ad41f5f29a02c11bca7c7da269938.tar.gz
freeipa-d80e90fa5c5ad41f5f29a02c11bca7c7da269938.tar.xz
freeipa-d80e90fa5c5ad41f5f29a02c11bca7c7da269938.zip
certprofile-import: do not require profileId in profile data
certprofile-import no longer requires profileId in profile data. Instead the profile ID from the command line is taken and added to the profile data internally. If profileId is set in the profile, then it still has to match the CLI option. https://fedorahosted.org/freeipa/ticket/5090 Reviewed-By: Martin Basti <mbasti@redhat.com>
-rw-r--r--ipalib/plugins/certprofile.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/ipalib/plugins/certprofile.py b/ipalib/plugins/certprofile.py
index ae75d43d7..658fbca3b 100644
--- a/ipalib/plugins/certprofile.py
+++ b/ipalib/plugins/certprofile.py
@@ -11,6 +11,7 @@ from ipalib.plugins.virtual import VirtualCommand
from ipalib.plugins.baseldap import (
LDAPObject, LDAPSearch, LDAPCreate,
LDAPDelete, LDAPUpdate, LDAPRetrieve)
+from ipalib.request import context
from ipalib import ngettext
from ipalib.text import _
from ipapython.version import API_VERSION
@@ -230,11 +231,12 @@ class certprofile_import(LDAPCreate):
def pre_callback(self, ldap, dn, entry, entry_attrs, *keys, **options):
ca_enabled_check()
+ context.profile = options['file']
match = self.PROFILE_ID_PATTERN.search(options['file'])
if match is None:
- raise errors.ValidationError(name='file',
- error=_("Profile ID is not present in profile data"))
+ # no profileId found, use CLI value as profileId.
+ context.profile = u'profileId=%s\n%s' % (keys[0], context.profile)
elif keys[0] != match.group(1):
raise errors.ValidationError(name='file',
error=_("Profile ID '%(cli_value)s' does not match profile data '%(file_value)s'")
@@ -250,7 +252,7 @@ class certprofile_import(LDAPCreate):
"""
try:
with self.api.Backend.ra_certprofile as profile_api:
- profile_api.create_profile(options['file'])
+ profile_api.create_profile(context.profile)
profile_api.enable_profile(keys[0])
except:
# something went wrong ; delete entry