summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Cholasta <jcholast@redhat.com>2015-06-18 07:20:27 +0000
committerPetr Vobornik <pvoborni@redhat.com>2015-06-18 15:48:53 +0200
commit1d608251383e4842b89c941a76dbd13529558f42 (patch)
tree88920b39f410436ee3cf3082d0794cffbd720b08
parent3bea4418089dc97136040cfc58157a77aea8b0aa (diff)
downloadfreeipa-1d608251383e4842b89c941a76dbd13529558f42.tar.gz
freeipa-1d608251383e4842b89c941a76dbd13529558f42.tar.xz
freeipa-1d608251383e4842b89c941a76dbd13529558f42.zip
User life cycle: change user-del flags to be CLI-specific
Rename --permanently to --no-preserve. https://fedorahosted.org/freeipa/ticket/3813 Reviewed-By: Petr Vobornik <pvoborni@redhat.com>
-rw-r--r--API.txt4
-rw-r--r--VERSION4
-rw-r--r--ipalib/plugins/user.py32
3 files changed, 28 insertions, 12 deletions
diff --git a/API.txt b/API.txt
index c7f02b9e6..3bcb3bdd2 100644
--- a/API.txt
+++ b/API.txt
@@ -5155,8 +5155,8 @@ command: user_del
args: 1,4,3
arg: Str('uid', attribute=True, cli_name='login', maxlength=255, multivalue=True, pattern='^[a-zA-Z0-9_.][a-zA-Z0-9_.-]{0,252}[a-zA-Z0-9_.$-]?$', primary_key=True, query=True, required=True)
option: Flag('continue', autofill=True, cli_name='continue', default=False)
-option: Flag('permanently?', autofill=True, cli_name='permanently', default=False)
-option: Flag('preserve?', autofill=True, cli_name='preserve', default=False)
+option: Flag('no_preserve?', autofill=True, default=False, include='cli')
+option: Flag('preserve?', autofill=True, default=False, include='cli')
option: Str('version?', exclude='webui')
output: Output('result', <type 'dict'>, None)
output: Output('summary', (<type 'unicode'>, <type 'NoneType'>), None)
diff --git a/VERSION b/VERSION
index f38b49465..f8f398d58 100644
--- a/VERSION
+++ b/VERSION
@@ -90,5 +90,5 @@ IPA_DATA_VERSION=20100614120000
# #
########################################################
IPA_API_VERSION_MAJOR=2
-IPA_API_VERSION_MINOR=134
-# Last change: jcholast - User life cycle: provide preserved user virtual attribute
+IPA_API_VERSION_MINOR=135
+# Last change: jcholast - User life cycle: Make user-del flags CLI-specific
diff --git a/ipalib/plugins/user.py b/ipalib/plugins/user.py
index f4a8a2c3c..d2404e2ed 100644
--- a/ipalib/plugins/user.py
+++ b/ipalib/plugins/user.py
@@ -565,18 +565,32 @@ class user_del(baseuser_del):
msg_summary = _('Deleted user "%(value)s"')
takes_options = baseuser_del.takes_options + (
+ Bool('preserve?',
+ exclude='cli',
+ ),
Flag('preserve?',
+ include='cli',
doc=_('Delete a user, keeping the entry available for future use'),
- cli_name='preserve',
- default=False,
),
- Flag('permanently?',
+ Flag('no_preserve?',
+ include='cli',
doc=_('Delete a user'),
- cli_name='permanently',
- default=False,
),
)
+ def forward(self, *keys, **options):
+ if self.api.env.context == 'cli':
+ if options['no_preserve'] and options['preserve']:
+ raise errors.MutuallyExclusiveError(
+ reason=_("preserve and no-preserve cannot be both set"))
+ elif options['no_preserve']:
+ options['preserve'] = False
+ elif not options['preserve']:
+ del options['preserve']
+ del options['no_preserve']
+
+ return super(user_del, self).forward(*keys, **options)
+
def pre_callback(self, ldap, dn, *keys, **options):
assert isinstance(dn, DN)
@@ -606,13 +620,15 @@ class user_del(baseuser_del):
dn = self.obj.get_dn(*keys, **options)
- if options['permanently'] or dn.endswith(DN(self.obj.delete_container_dn, api.env.basedn)):
+ if (not options.get('preserve', True) or
+ dn.endswith(DN(self.obj.delete_container_dn,
+ self.api.env.basedn))):
# We are going to permanent delete or the user is already in the delete container.
# So we issue a true DEL on that entry
return super(user_del, self).execute(*keys, **options)
- # The user to delete is active and there is no 'permanently' option
- if options['preserve']:
+ # The user to delete is active and there is no 'no_preserve' option
+ if options.get('preserve', False):
ldap = self.obj.backend