From 03967f62e9787b27d7f91684ec76c688529ff5bd Mon Sep 17 00:00:00 2001 From: Pavel Zuna Date: Wed, 17 Feb 2010 15:46:43 +0100 Subject: Auto-generate --all and --raw for commands, that return entries. --- ipalib/plugins/baseldap.py | 68 +++------------------------------------------- ipalib/plugins/dns.py | 33 ---------------------- 2 files changed, 4 insertions(+), 97 deletions(-) (limited to 'ipalib/plugins') diff --git a/ipalib/plugins/baseldap.py b/ipalib/plugins/baseldap.py index 964f8e5d9..9aa002a67 100644 --- a/ipalib/plugins/baseldap.py +++ b/ipalib/plugins/baseldap.py @@ -135,16 +135,6 @@ class LDAPCreate(crud.Create): """ takes_options = ( - Flag('raw', - cli_name='raw', - doc='print entries as they are stored in LDAP', - exclude='webui', - ), - Flag('all', - cli_name='all', - doc='retrieve all attributes', - exclude='webui', - ), Str('addattr*', validate_add_attribute, cli_name='addattr', doc='Add an attribute/value pair. Format is attr=value', @@ -242,18 +232,6 @@ class LDAPRetrieve(LDAPQuery): """ Retrieve an LDAP entry. """ - - takes_options = ( - Flag('raw', - cli_name='raw', - doc='print entries as they are stored in LDAP', - ), - Flag('all', - cli_name='all', - doc='retrieve all attributes', - ), - ) - has_output = output.standard_entry def execute(self, *keys, **options): @@ -295,16 +273,6 @@ class LDAPUpdate(LDAPQuery, crud.Update): """ takes_options = ( - Flag('raw', - cli_name='raw', - doc='print entries as they are stored in LDAP', - exclude='webui', - ), - Flag('all', - cli_name='all', - doc='retrieve all attributes', - exclude='webui', - ), Str('addattr*', validate_add_attribute, cli_name='addattr', doc='Add an attribute/value pair. Format is attr=value', @@ -457,14 +425,6 @@ class LDAPModMember(LDAPQuery): member_param_doc = 'comma-separated list of %s' member_count_out = ('%i member processed.', '%i members processed.') - takes_options = ( - Flag('raw', - cli_name='raw', - doc='print entries as they are stored in LDAP', - exclude='webui', - ), - ) - def get_options(self): for option in super(LDAPModMember, self).get_options(): yield option @@ -645,17 +605,6 @@ class LDAPSearch(crud.Search): """ Retrieve all LDAP entries matching the given criteria. """ - takes_options = ( - Flag('raw', - cli_name='raw', - doc='print entries as they are stored in LDAP', - ), - Flag('all', - cli_name='all', - doc='retrieve all attributes', - ), - ) - def get_args(self): for key in self.obj.get_ancestor_primary_keys(): yield key @@ -664,13 +613,6 @@ class LDAPSearch(crud.Search): def get_options(self): for option in super(LDAPSearch, self).get_options(): yield option - if self.obj.uuid_attribute: - yield Str('%s?' % self.obj.uuid_attribute, - cli_name='uuid', - doc='unique identifier', - attribute=True, - query=True, - ) def execute(self, *args, **options): ldap = self.obj.backend @@ -716,13 +658,11 @@ class LDAPSearch(crud.Search): self.post_callback(self, ldap, entries, truncated, *args, **options) if not options.get('raw', False): - for i in xrange(len(entries)): - dn = self.obj.get_primary_key_from_dn(entries[i][0]) - self.obj.convert_attribute_members( - entries[i][1], *args, **options - ) - entries[i] = (dn, entries[i][1]) + for e in entries: + self.obj.convert_attribute_members(e[1], *args, **options) + for e in entries: + e[1]['dn'] = e[0] entries = tuple(e for (dn, e) in entries) return dict( diff --git a/ipalib/plugins/dns.py b/ipalib/plugins/dns.py index 49d073e8c..397eb0b72 100644 --- a/ipalib/plugins/dns.py +++ b/ipalib/plugins/dns.py @@ -110,7 +110,6 @@ def _get_record_dn(ldap, zone, idnsname): class dns(Object): """DNS zone/SOA record object.""" - label = _('DNS') takes_params = ( @@ -176,7 +175,6 @@ class dns_add(crud.Create): """ Create new DNS zone/SOA record. """ - def execute(self, *args, **options): ldap = self.Backend.ldap2 idnsname = args[0] @@ -228,7 +226,6 @@ class dns_del(crud.Delete): """ Delete existing DNS zone/SOA record. """ - def execute(self, *args, **options): ldap = self.api.Backend.ldap2 idnsname = args[0] @@ -264,7 +261,6 @@ class dns_mod(crud.Update): """ Modify DNS zone/SOA record. """ - def execute(self, *args, **options): ldap = self.api.Backend.ldap2 idnsname = args[0] @@ -306,13 +302,6 @@ class dns_find(crud.Search): """ Search for DNS zones/SOA records. """ - - takes_options = ( - Flag('all', - doc='retrieve all attributes', - ), - ) - def execute(self, term, **options): ldap = self.api.Backend.ldap2 @@ -365,13 +354,6 @@ class dns_show(crud.Retrieve): """ Display DNS zone/SOA record. """ - - takes_options = ( - Flag('all', - doc='retrieve all attributes', - ), - ) - def execute(self, idnsname, **options): ldap = self.api.Backend.ldap2 @@ -404,7 +386,6 @@ class dns_enable(Command): """ Activate DNS zone. """ - takes_args = ( Str('zone', cli_name='zone', @@ -440,7 +421,6 @@ class dns_disable(Command): """ Deactivate DNS zone. """ - takes_args = ( Str('zone', cli_name='zone', @@ -476,7 +456,6 @@ class dns_add_rr(Command): """ Add new DNS resource record. """ - takes_args = ( Str('zone', cli_name='zone', @@ -593,7 +572,6 @@ class dns_del_rr(Command): """ Delete DNS resource record. """ - takes_args = ( Str('zone', cli_name='zone', @@ -681,7 +659,6 @@ class dns_find_rr(Command): """ Search for DNS resource records. """ - takes_args = ( Str('zone', cli_name='zone', @@ -709,9 +686,6 @@ class dns_find_rr(Command): cli_name='data', doc='type-specific data', ), - Flag('all', - doc='retrieve all attributes', - ), ) has_output = output.standard_list_of_entries @@ -811,7 +785,6 @@ class dns_show_rr(Command): """ Show existing DNS resource records. """ - takes_args = ( Str('zone', cli_name='zone', @@ -825,12 +798,6 @@ class dns_show_rr(Command): ), ) - takes_options = ( - Flag('all', - doc='retrieve all attributes', - ), - ) - has_output = output.standard_entry def execute(self, zone, idnsname, **options): -- cgit