summaryrefslogtreecommitdiffstats
path: root/ipalib
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2010-12-14 11:06:26 +0100
committerRob Crittenden <rcritten@redhat.com>2010-12-20 11:27:46 -0500
commitffc6031ad76c2b28807e45a90b2906bf2e94b914 (patch)
treee5044bc605844b52ba5fdde6ec5ebf74b570f062 /ipalib
parentbf778a74a3f750af5a0ebc7f72a0db655d25ef66 (diff)
downloadfreeipa-ffc6031ad76c2b28807e45a90b2906bf2e94b914.tar.gz
freeipa-ffc6031ad76c2b28807e45a90b2906bf2e94b914.tar.xz
freeipa-ffc6031ad76c2b28807e45a90b2906bf2e94b914.zip
Allow RDN changes from CLI
https://fedorahosted.org/freeipa/ticket/397
Diffstat (limited to 'ipalib')
-rw-r--r--ipalib/parameters.py8
-rw-r--r--ipalib/plugins/baseldap.py14
2 files changed, 21 insertions, 1 deletions
diff --git a/ipalib/parameters.py b/ipalib/parameters.py
index f3b13bdb1..75772429a 100644
--- a/ipalib/parameters.py
+++ b/ipalib/parameters.py
@@ -579,9 +579,15 @@ class Param(ReadOnly):
"""
Return a new `Param` instance similar to this one.
"""
+ return self.clone_rename(self.name, **overrides)
+
+ def clone_rename(self, name, **overrides):
+ """
+ Return a new `Param` instance similar to this one, but named differently
+ """
kw = dict(self.__clonekw)
kw.update(overrides)
- return self.__class__(self.name, *self.rules, **kw)
+ return self.__class__(name, *self.rules, **kw)
def normalize(self, value):
"""
diff --git a/ipalib/plugins/baseldap.py b/ipalib/plugins/baseldap.py
index cf26a9517..46a98643e 100644
--- a/ipalib/plugins/baseldap.py
+++ b/ipalib/plugins/baseldap.py
@@ -708,6 +708,17 @@ class LDAPUpdate(LDAPQuery, crud.Update):
has_output_params = global_output_params
+ def _get_rename_option(self):
+ rdnparam = getattr(self.obj.params, self.obj.rdnattr)
+ return rdnparam.clone_rename('rename', cli_name='rename',
+ doc=_('Rename the %s object' % self.obj.object_name))
+
+ def get_options(self):
+ for option in super(LDAPUpdate, self).get_options():
+ yield option
+ if self.obj.rdnattr:
+ yield self._get_rename_option()
+
def execute(self, *keys, **options):
ldap = self.obj.backend
@@ -768,6 +779,9 @@ class LDAPUpdate(LDAPQuery, crud.Update):
rdnupdate = False
try:
+ if self.obj.rdnattr and 'rename' in options:
+ entry_attrs[self.obj.rdnattr] = options['rename']
+
if self.obj.rdnattr and self.obj.rdnattr in entry_attrs:
# RDN change
ldap.update_entry_rdn(dn, unicode('%s=%s' % (self.obj.rdnattr,