summaryrefslogtreecommitdiffstats
path: root/ipalib/plugins
diff options
context:
space:
mode:
authorPetr Viktorin <pviktori@redhat.com>2012-06-21 08:20:26 -0400
committerMartin Kosek <mkosek@redhat.com>2013-02-21 16:26:09 +0100
commit7336a176b43989b9d459a2536af88f89e849213f (patch)
tree46c2ab141dc545e8f0c148871508fe7c952d22e5 /ipalib/plugins
parent246bc3f3eaccf2a84310df84dc85fe455c24ac65 (diff)
downloadfreeipa.git-7336a176b43989b9d459a2536af88f89e849213f.tar.gz
freeipa.git-7336a176b43989b9d459a2536af88f89e849213f.tar.xz
freeipa.git-7336a176b43989b9d459a2536af88f89e849213f.zip
Add the version option to all Commands
Several Commands were missing the 'version' option. Add it to those that were missing it. Do not remove the version option before calling commands. This means methods such as execute(), forward(), run() receive it. Several of these needed `**options` added to their signatures. Commands in the Cert plugin passed any unknown options to the underlying functions, these are changed to pass what's needed explicitly. Some commands in DNS and Batch plugins now pass version to commands they call. When the option is not given, fill it in automatically. (In a subsequent commit, a warning will be added in this case). Note that the public API did not change: all RPC calls already accepted a version option. There's no need for an API version bump (even though API.txt changes substantially). Design page: http://freeipa.org/page/V3/Messages Tickets: https://fedorahosted.org/freeipa/ticket/2732 https://fedorahosted.org/freeipa/ticket/3294
Diffstat (limited to 'ipalib/plugins')
-rw-r--r--ipalib/plugins/aci.py2
-rw-r--r--ipalib/plugins/automount.py2
-rw-r--r--ipalib/plugins/batch.py1
-rw-r--r--ipalib/plugins/cert.py12
-rw-r--r--ipalib/plugins/dns.py4
-rw-r--r--ipalib/plugins/hbacrule.py4
-rw-r--r--ipalib/plugins/internal.py2
-rw-r--r--ipalib/plugins/passwd.py2
-rw-r--r--ipalib/plugins/ping.py2
-rw-r--r--ipalib/plugins/selinuxusermap.py4
-rw-r--r--ipalib/plugins/sudorule.py4
11 files changed, 21 insertions, 18 deletions
diff --git a/ipalib/plugins/aci.py b/ipalib/plugins/aci.py
index 7c4e8a54..a97bb48b 100644
--- a/ipalib/plugins/aci.py
+++ b/ipalib/plugins/aci.py
@@ -566,7 +566,7 @@ class aci_del(crud.Delete):
takes_options = (_prefix_option,)
- def execute(self, aciname, aciprefix):
+ def execute(self, aciname, aciprefix, **options):
"""
Execute the aci-delete operation.
diff --git a/ipalib/plugins/automount.py b/ipalib/plugins/automount.py
index 19b60905..fcda0a10 100644
--- a/ipalib/plugins/automount.py
+++ b/ipalib/plugins/automount.py
@@ -889,7 +889,7 @@ class automountkey_del(LDAPDelete):
),
)
def get_options(self):
- for option in self.takes_options:
+ for option in super(automountkey_del, self).get_options():
if option.name == 'continue':
# TODO: hide for now - remove in future major release
yield option.clone(exclude='webui',
diff --git a/ipalib/plugins/batch.py b/ipalib/plugins/batch.py
index db9c08f1..5fd5943f 100644
--- a/ipalib/plugins/batch.py
+++ b/ipalib/plugins/batch.py
@@ -95,6 +95,7 @@ class batch(Command):
a, kw = arg['params']
newkw = dict((str(k), v) for k, v in kw.iteritems())
params = api.Command[name].args_options_2_params(*a, **newkw)
+ newkw.setdefault('version', options['version'])
result = api.Command[name](*a, **newkw)
self.info(
diff --git a/ipalib/plugins/cert.py b/ipalib/plugins/cert.py
index 51493c34..6b84c723 100644
--- a/ipalib/plugins/cert.py
+++ b/ipalib/plugins/cert.py
@@ -306,8 +306,7 @@ class cert_request(VirtualCommand):
ldap = self.api.Backend.ldap2
principal = kw.get('principal')
add = kw.get('add')
- del kw['principal']
- del kw['add']
+ request_type = kw.get('request_type')
service = None
"""
@@ -414,7 +413,8 @@ class cert_request(VirtualCommand):
api.Command['host_mod'](hostname, usercertificate=None)
# Request the certificate
- result = self.Backend.ra.request_certificate(csr, **kw)
+ result = self.Backend.ra.request_certificate(
+ csr, request_type=request_type)
cert = x509.load_certificate(result['certificate'])
result['issuer'] = unicode(cert.issuer)
result['valid_not_before'] = unicode(cert.valid_not_before_str)
@@ -596,10 +596,12 @@ class cert_revoke(VirtualCommand):
result = api.Command['cert_show'](unicode(serial_number))['result']
except errors.NotImplementedError:
pass
- if kw['revocation_reason'] == 7:
+ revocation_reason = kw['revocation_reason']
+ if revocation_reason == 7:
raise errors.CertificateOperationError(error=_('7 is not a valid revocation reason'))
return dict(
- result=self.Backend.ra.revoke_certificate(serial_number, **kw)
+ result=self.Backend.ra.revoke_certificate(
+ serial_number, revocation_reason=revocation_reason)
)
api.register(cert_revoke)
diff --git a/ipalib/plugins/dns.py b/ipalib/plugins/dns.py
index c329c100..61c2de32 100644
--- a/ipalib/plugins/dns.py
+++ b/ipalib/plugins/dns.py
@@ -2730,13 +2730,13 @@ class dnsrecord_del(LDAPUpdate):
error=_('Zone record \'%s\' cannot be deleted') \
% _dns_zone_record
)
- return self.obj.methods.delentry(*keys)
+ return self.obj.methods.delentry(*keys, version=options['version'])
result = super(dnsrecord_del, self).execute(*keys, **options)
if getattr(context, 'del_all', False) and not \
self.obj.is_pkey_zone_record(*keys):
- return self.obj.methods.delentry(*keys)
+ return self.obj.methods.delentry(*keys, version=options['version'])
return result
def post_callback(self, ldap, dn, entry_attrs, *keys, **options):
diff --git a/ipalib/plugins/hbacrule.py b/ipalib/plugins/hbacrule.py
index 0b1e8b83..8bc4c6df 100644
--- a/ipalib/plugins/hbacrule.py
+++ b/ipalib/plugins/hbacrule.py
@@ -303,7 +303,7 @@ class hbacrule_enable(LDAPQuery):
msg_summary = _('Enabled HBAC rule "%(value)s"')
has_output = output.standard_value
- def execute(self, cn):
+ def execute(self, cn, **options):
ldap = self.obj.backend
dn = self.obj.get_dn(cn)
@@ -330,7 +330,7 @@ class hbacrule_disable(LDAPQuery):
msg_summary = _('Disabled HBAC rule "%(value)s"')
has_output = output.standard_value
- def execute(self, cn):
+ def execute(self, cn, **options):
ldap = self.obj.backend
dn = self.obj.get_dn(cn)
diff --git a/ipalib/plugins/internal.py b/ipalib/plugins/internal.py
index cfb5d60f..e9fc9de4 100644
--- a/ipalib/plugins/internal.py
+++ b/ipalib/plugins/internal.py
@@ -682,7 +682,7 @@ class i18n_messages(Command):
has_output = (
Output('messages', dict, doc=_('Dict of I18N messages')),
)
- def execute(self):
+ def execute(self, **options):
return dict([("messages",json_serialize(self.messages))])
def output_for_cli(self, textui, result, *args, **options):
diff --git a/ipalib/plugins/passwd.py b/ipalib/plugins/passwd.py
index 68aa3ebb..280517cd 100644
--- a/ipalib/plugins/passwd.py
+++ b/ipalib/plugins/passwd.py
@@ -88,7 +88,7 @@ class passwd(Command):
has_output = output.standard_value
msg_summary = _('Changed password for "%(value)s"')
- def execute(self, principal, password, current_password):
+ def execute(self, principal, password, current_password, **options):
"""
Execute the passwd operation.
diff --git a/ipalib/plugins/ping.py b/ipalib/plugins/ping.py
index 0da07e0b..e9dc28fe 100644
--- a/ipalib/plugins/ping.py
+++ b/ipalib/plugins/ping.py
@@ -58,7 +58,7 @@ class ping(Command):
output.summary,
)
- def execute(self):
+ def execute(self, **options):
"""
A possible enhancement would be to take an argument and echo it
back but a fixed value works for now.
diff --git a/ipalib/plugins/selinuxusermap.py b/ipalib/plugins/selinuxusermap.py
index 32c55850..60eb053a 100644
--- a/ipalib/plugins/selinuxusermap.py
+++ b/ipalib/plugins/selinuxusermap.py
@@ -394,7 +394,7 @@ class selinuxusermap_enable(LDAPQuery):
msg_summary = _('Enabled SELinux User Map "%(value)s"')
has_output = output.standard_value
- def execute(self, cn):
+ def execute(self, cn, **options):
ldap = self.obj.backend
dn = self.obj.get_dn(cn)
@@ -421,7 +421,7 @@ class selinuxusermap_disable(LDAPQuery):
msg_summary = _('Disabled SELinux User Map "%(value)s"')
has_output = output.standard_value
- def execute(self, cn):
+ def execute(self, cn, **options):
ldap = self.obj.backend
dn = self.obj.get_dn(cn)
diff --git a/ipalib/plugins/sudorule.py b/ipalib/plugins/sudorule.py
index 11108099..878033f0 100644
--- a/ipalib/plugins/sudorule.py
+++ b/ipalib/plugins/sudorule.py
@@ -321,7 +321,7 @@ api.register(sudorule_show)
class sudorule_enable(LDAPQuery):
__doc__ = _('Enable a Sudo Rule.')
- def execute(self, cn):
+ def execute(self, cn, **options):
ldap = self.obj.backend
dn = self.obj.get_dn(cn)
@@ -345,7 +345,7 @@ api.register(sudorule_enable)
class sudorule_disable(LDAPQuery):
__doc__ = _('Disable a Sudo Rule.')
- def execute(self, cn):
+ def execute(self, cn, **options):
ldap = self.obj.backend
dn = self.obj.get_dn(cn)