diff options
author | Pavel Zuna <pzuna@redhat.com> | 2009-12-10 16:39:24 +0100 |
---|---|---|
committer | Rob Crittenden <rcritten@redhat.com> | 2010-01-11 13:28:05 -0500 |
commit | 74a538416999d84f7d3bd6cca4ab3655481ef848 (patch) | |
tree | e72e11e7092996946a439b6fd95cedf61e2fe2ba /ipalib | |
parent | b8016807ebb95b97f0a4631574be484371f4dcd0 (diff) | |
download | freeipa-74a538416999d84f7d3bd6cca4ab3655481ef848.tar.gz freeipa-74a538416999d84f7d3bd6cca4ab3655481ef848.tar.xz freeipa-74a538416999d84f7d3bd6cca4ab3655481ef848.zip |
Add --all to LDAPCreate and make LDAP commands always display default attributes.
Diffstat (limited to 'ipalib')
-rw-r--r-- | ipalib/plugins/baseldap.py | 32 | ||||
-rw-r--r-- | ipalib/plugins/group.py | 2 | ||||
-rw-r--r-- | ipalib/plugins/hbac.py | 2 | ||||
-rw-r--r-- | ipalib/plugins/host.py | 2 | ||||
-rw-r--r-- | ipalib/plugins/netgroup.py | 2 | ||||
-rw-r--r-- | ipalib/plugins/service.py | 2 | ||||
-rw-r--r-- | ipalib/plugins/user.py | 2 |
7 files changed, 30 insertions, 14 deletions
diff --git a/ipalib/plugins/baseldap.py b/ipalib/plugins/baseldap.py index 94b006257..98da3ed64 100644 --- a/ipalib/plugins/baseldap.py +++ b/ipalib/plugins/baseldap.py @@ -135,6 +135,10 @@ class LDAPCreate(crud.Create): doc='print entries as they are stored in LDAP', exclude='webui', ), + Flag('all', + cli_name='all', + doc='retrieve all attributes', + ), Str('addattr*', validate_add_attribute, cli_name='addattr', doc='Add an attribute/value pair. Format is attr=value', @@ -170,11 +174,18 @@ class LDAPCreate(crud.Create): if self.obj.uuid_attribute: entry_attrs[self.obj.uuid_attribute] = str(uuid.uuid1()) - dn = self.pre_callback(ldap, dn, entry_attrs, *keys, **options) + if options.get('all', False): + attrs_list = ['*'] + else: + attrs_list = list( + set(self.obj.default_attributes + entry_attrs.keys()) + ) + + dn = self.pre_callback(ldap, dn, entry_attrs, attrs_list, *keys, **options) ldap.add_entry(dn, entry_attrs) - (dn, entry_attrs) = ldap.get_entry(dn, entry_attrs.keys()) + (dn, entry_attrs) = ldap.get_entry(dn, attrs_list) dn = self.post_callback(ldap, dn, entry_attrs, *keys, **options) @@ -204,7 +215,7 @@ class LDAPCreate(crud.Create): else: textui.print_dashed('Created %s.' % self.obj.object_name) - def pre_callback(self, ldap, dn, entry_attrs, *keys, **options): + def pre_callback(self, ldap, dn, entry_attrs, attrs_list, *keys, **options): return dn def post_callback(self, ldap, dn, entry_attrs, *keys, **options): @@ -245,7 +256,7 @@ class LDAPRetrieve(LDAPQuery): dn = self.obj.get_dn(*keys, **options) - if options['all']: + if options.get('all', False): attrs_list = ['*'] else: attrs_list = list(self.obj.default_attributes) @@ -307,10 +318,12 @@ class LDAPUpdate(LDAPQuery, crud.Update): entry_attrs = self.args_options_2_entry(**options) - if options['all']: + if options.get('all', False): attrs_list = ['*'] else: - attrs_list = entry_attrs.keys() + attrs_list = list( + set(self.obj.default_attributes + entry_attrs.keys()) + ) dn = self.pre_callback(ldap, dn, entry_attrs, attrs_list, *keys, **options) @@ -666,10 +679,12 @@ class LDAPSearch(crud.Search): search_kw = self.args_options_2_entry(**options) - if options['all']: + if options.get('all', False): attrs_list = ['*'] else: - attrs_list = self.obj.default_attributes + search_kw.keys() + attrs_list = list( + set(self.obj.default_attributes + search_kw.keys()) + ) search_kw['objectclass'] = self.obj.object_class attr_filter = ldap.make_filter(search_kw, rules=ldap.MATCH_ALL) @@ -740,3 +755,4 @@ class LDAPSearch(crud.Search): def post_callback(self, ldap, entries, truncated, *args, **options): pass + diff --git a/ipalib/plugins/group.py b/ipalib/plugins/group.py index 322f3fa8b..cc949abfd 100644 --- a/ipalib/plugins/group.py +++ b/ipalib/plugins/group.py @@ -91,7 +91,7 @@ class group_add(LDAPCreate): ), ) - def pre_callback(self, ldap, dn, entry_attrs, *keys, **options): + def pre_callback(self, ldap, dn, entry_attrs, attrs_list, *keys, **options): if options['posix'] or 'gidnumber' in options: entry_attrs['objectclass'].append('posixgroup') return dn diff --git a/ipalib/plugins/hbac.py b/ipalib/plugins/hbac.py index 6dc13f6d5..ac944591e 100644 --- a/ipalib/plugins/hbac.py +++ b/ipalib/plugins/hbac.py @@ -124,7 +124,7 @@ class hbac_add(LDAPCreate): """ Create new HBAC rule. """ - def pre_callback(self, ldap, dn, entry_attrs, *keys, **options): + def pre_callback(self, ldap, dn, entry_attrs, attrs_list, *keys, **options): if not dn.startswith('cn='): msg = 'HBAC rule with name "%s" already exists' % keys[-1] raise errors.DuplicateEntry(message=msg) diff --git a/ipalib/plugins/host.py b/ipalib/plugins/host.py index 6c76f518e..15870b0a6 100644 --- a/ipalib/plugins/host.py +++ b/ipalib/plugins/host.py @@ -142,7 +142,7 @@ class host_add(LDAPCreate): msg_summary = _('Added host "%(value)s"') - def pre_callback(self, ldap, dn, entry_attrs, *keys, **options): + def pre_callback(self, ldap, dn, entry_attrs, attrs_list, *keys, **options): entry_attrs['cn'] = keys[-1] entry_attrs['serverhostname'] = keys[-1].split('.', 1)[0] # FIXME: do DNS lookup to ensure host exists diff --git a/ipalib/plugins/netgroup.py b/ipalib/plugins/netgroup.py index 5a3ad729e..66508b695 100644 --- a/ipalib/plugins/netgroup.py +++ b/ipalib/plugins/netgroup.py @@ -96,7 +96,7 @@ class netgroup_add(LDAPCreate): """ Create new netgroup. """ - def pre_callback(self, ldap, dn, entry_attrs, *keys, **options): + def pre_callback(self, ldap, dn, entry_attrs, attrs_list, *keys, **options): if not dn.startswith('cn='): msg = 'netgroup with name "%s" already exists' % keys[-1] raise errors.DuplicateEntry(message=msg) diff --git a/ipalib/plugins/service.py b/ipalib/plugins/service.py index 8c962f091..6ad992f3b 100644 --- a/ipalib/plugins/service.py +++ b/ipalib/plugins/service.py @@ -148,7 +148,7 @@ class service_add(LDAPCreate): doc='force principal name even if not in DNS', ), ) - def pre_callback(self, ldap, dn, entry_attrs, *keys, **options): + def pre_callback(self, ldap, dn, entry_attrs, attrs_list, *keys, **options): (service, hostname, realm) = split_principal(keys[-1]) if service.lower() == 'host' and not options['force']: raise errors.HostService() diff --git a/ipalib/plugins/user.py b/ipalib/plugins/user.py index 44b0f7d5e..97641a46c 100644 --- a/ipalib/plugins/user.py +++ b/ipalib/plugins/user.py @@ -135,7 +135,7 @@ class user_add(LDAPCreate): msg_summary = _('Added user "%(value)s"') - def pre_callback(self, ldap, dn, entry_attrs, *keys, **options): + def pre_callback(self, ldap, dn, entry_attrs, attrs_list, *keys, **options): config = ldap.get_ipa_config()[1] entry_attrs.setdefault('loginshell', config.get('ipadefaultloginshell')) # hack so we can request separate first and last name in CLI |