mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
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>
This commit is contained in:
committed by
Petr Vobornik
parent
3bea441808
commit
1d60825138
4
API.txt
4
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)
|
||||
|
||||
4
VERSION
4
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
|
||||
|
||||
@@ -565,18 +565,32 @@ class user_del(baseuser_del):
|
||||
msg_summary = _('Deleted user "%(value)s"')
|
||||
|
||||
takes_options = baseuser_del.takes_options + (
|
||||
Flag('preserve?',
|
||||
doc=_('Delete a user, keeping the entry available for future use'),
|
||||
cli_name='preserve',
|
||||
default=False,
|
||||
Bool('preserve?',
|
||||
exclude='cli',
|
||||
),
|
||||
Flag('permanently?',
|
||||
Flag('preserve?',
|
||||
include='cli',
|
||||
doc=_('Delete a user, keeping the entry available for future use'),
|
||||
),
|
||||
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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user