diff options
Diffstat (limited to 'ipalib/plugins')
-rw-r--r-- | ipalib/plugins/aci.py | 2 | ||||
-rw-r--r-- | ipalib/plugins/baseldap.py | 50 | ||||
-rw-r--r-- | ipalib/plugins/batch.py | 2 | ||||
-rw-r--r-- | ipalib/plugins/config.py | 4 | ||||
-rw-r--r-- | ipalib/plugins/dns.py | 16 | ||||
-rw-r--r-- | ipalib/plugins/otptoken.py | 2 | ||||
-rw-r--r-- | ipalib/plugins/permission.py | 4 | ||||
-rw-r--r-- | ipalib/plugins/service.py | 5 | ||||
-rw-r--r-- | ipalib/plugins/stageuser.py | 6 |
9 files changed, 46 insertions, 45 deletions
diff --git a/ipalib/plugins/aci.py b/ipalib/plugins/aci.py index 0ff28b84e..cdc8f7092 100644 --- a/ipalib/plugins/aci.py +++ b/ipalib/plugins/aci.py @@ -223,7 +223,7 @@ def _make_aci(ldap, current, aciname, kw): if 'aciprefix' not in kw: raise errors.ValidationError(name='aciprefix', error=_('ACI prefix is required')) - if sum(valid.itervalues()) == 0: + if sum(valid.values()) == 0: raise errors.ValidationError(name='target', error=_('at least one of: type, filter, subtree, targetgroup, attrs or memberof are required')) if valid['filter'] + valid['memberof'] > 1: diff --git a/ipalib/plugins/baseldap.py b/ipalib/plugins/baseldap.py index a8525e81e..59d39c403 100644 --- a/ipalib/plugins/baseldap.py +++ b/ipalib/plugins/baseldap.py @@ -232,7 +232,7 @@ def entry_from_entry(entry, newentry): """ # Wipe out the current data - for e in entry.keys(): + for e in list(entry): del entry[e] # Re-populate it with new wentry @@ -242,7 +242,7 @@ def entry_from_entry(entry, newentry): def entry_to_dict(entry, **options): if options.get('raw', False): result = {} - for attr in entry.iterkeys(): + for attr in entry: if attr.lower() == 'attributelevelrights': value = entry[attr] elif entry.conn.get_attribute_type(attr) is str: @@ -256,7 +256,7 @@ def entry_to_dict(entry, **options): pass result[attr] = value else: - result = dict((k.lower(), v) for (k, v) in entry.iteritems()) + result = dict((k.lower(), v) for (k, v) in entry.items()) if options.get('all', False): result['dn'] = entry.dn return result @@ -793,10 +793,10 @@ class LDAPObject(Object): attrs = self.api.Backend.ldap2.schema.attribute_types(objectclasses) attrlist = [] # Go through the MUST first - for (oid, attr) in attrs[0].iteritems(): + for (oid, attr) in attrs[0].items(): attrlist.append(attr.names[0].lower()) # And now the MAY - for (oid, attr) in attrs[1].iteritems(): + for (oid, attr) in attrs[1].items(): attrlist.append(attr.names[0].lower()) json_dict['aciattrs'] = attrlist attrlist.sort() @@ -809,7 +809,7 @@ class LDAPObject(Object): # addattr can cause parameters to have more than one value even if not defined # as multivalue, make sure this isn't the case def _check_single_value_attrs(params, entry_attrs): - for (a, v) in entry_attrs.iteritems(): + for (a, v) in entry_attrs.items(): if isinstance(v, (list, tuple)) and len(v) > 1: if a in params and not params[a].multivalue: raise errors.OnlyOneValueAllowed(attr=a) @@ -817,7 +817,7 @@ def _check_single_value_attrs(params, entry_attrs): # setattr or --option='' can cause parameters to be empty that are otherwise # required, make sure we enforce that. def _check_empty_attrs(params, entry_attrs): - for (a, v) in entry_attrs.iteritems(): + for (a, v) in entry_attrs.items(): if v is None or (isinstance(v, six.string_types) and len(v) == 0): if a in params and params[a].required: raise errors.RequirementError(name=a) @@ -839,7 +839,7 @@ def _check_limit_object_class(attributes, attrs, allow_only): return limitattrs = deepcopy(attrs) # Go through the MUST first - for (oid, attr) in attributes[0].iteritems(): + for (oid, attr) in attributes[0].items(): if attr.names[0].lower() in limitattrs: if not allow_only: raise errors.ObjectclassViolation( @@ -847,7 +847,7 @@ def _check_limit_object_class(attributes, attrs, allow_only): attribute=attr.names[0].lower())) limitattrs.remove(attr.names[0].lower()) # And now the MAY - for (oid, attr) in attributes[1].iteritems(): + for (oid, attr) in attributes[1].items(): if attr.names[0].lower() in limitattrs: if not allow_only: raise errors.ObjectclassViolation( @@ -1015,9 +1015,9 @@ last, after all sets and adds."""), setdict = self._convert_2_dict(ldap, options.get('setattr', [])) deldict = self._convert_2_dict(ldap, options.get('delattr', [])) - setattrs = set(setdict.keys()) - addattrs = set(adddict.keys()) - delattrs = set(deldict.keys()) + setattrs = set(setdict) + addattrs = set(adddict) + delattrs = set(deldict) if dn is None: direct_add = addattrs @@ -1029,7 +1029,7 @@ last, after all sets and adds."""), direct_del = setattrs & delattrs needldapattrs = list((addattrs | delattrs) - setattrs) - for attr, val in setdict.iteritems(): + for attr, val in setdict.items(): entry_attrs[attr] = val for attr in direct_add: @@ -1063,7 +1063,7 @@ last, after all sets and adds."""), # Provide a nice error message when user tries to delete an # attribute that does not exist on the entry (and user is not # adding it) - names = set(n.lower() for n in old_entry.keys()) + names = set(n.lower() for n in old_entry) del_nonexisting = delattrs - (names | setattrs | addattrs) if del_nonexisting: raise errors.ValidationError(name=del_nonexisting.pop(), @@ -1229,8 +1229,8 @@ class LDAPCreate(BaseLDAPCommand, crud.Create): *keys, **options) _check_single_value_attrs(self.params, entry_attrs) - _check_limit_object_class(self.api.Backend.ldap2.schema.attribute_types(self.obj.limit_object_classes), entry_attrs.keys(), allow_only=True) - _check_limit_object_class(self.api.Backend.ldap2.schema.attribute_types(self.obj.disallow_object_classes), entry_attrs.keys(), allow_only=False) + _check_limit_object_class(self.api.Backend.ldap2.schema.attribute_types(self.obj.limit_object_classes), list(entry_attrs), allow_only=True) + _check_limit_object_class(self.api.Backend.ldap2.schema.attribute_types(self.obj.disallow_object_classes), list(entry_attrs), allow_only=False) try: self._exc_wrapper(keys, options, ldap.add_entry)(entry_attrs) @@ -1469,8 +1469,8 @@ class LDAPUpdate(LDAPQuery, crud.Update): self, ldap, entry_attrs.dn, entry_attrs, attrs_list, *keys, **options) - _check_limit_object_class(self.api.Backend.ldap2.schema.attribute_types(self.obj.limit_object_classes), entry_attrs.keys(), allow_only=True) - _check_limit_object_class(self.api.Backend.ldap2.schema.attribute_types(self.obj.disallow_object_classes), entry_attrs.keys(), allow_only=False) + _check_limit_object_class(self.api.Backend.ldap2.schema.attribute_types(self.obj.limit_object_classes), list(entry_attrs), allow_only=True) + _check_limit_object_class(self.api.Backend.ldap2.schema.attribute_types(self.obj.disallow_object_classes), list(entry_attrs), allow_only=False) rdnupdate = False try: @@ -1505,7 +1505,7 @@ class LDAPUpdate(LDAPQuery, crud.Update): # mean an error occurred, just that there were no other updates to # perform. update = self._exc_wrapper(keys, options, ldap.get_entry)( - entry_attrs.dn, entry_attrs.keys()) + entry_attrs.dn, list(entry_attrs)) update.update(entry_attrs) self._exc_wrapper(keys, options, ldap.update_entry)(update) @@ -1727,7 +1727,7 @@ class LDAPAddMember(LDAPModMember): assert isinstance(dn, DN) completed = 0 - for (attr, objs) in member_dns.iteritems(): + for (attr, objs) in member_dns.items(): for ldap_obj_name in objs: for m_dn in member_dns[attr][ldap_obj_name]: assert isinstance(m_dn, DN) @@ -1828,8 +1828,8 @@ class LDAPRemoveMember(LDAPModMember): assert isinstance(dn, DN) completed = 0 - for (attr, objs) in member_dns.iteritems(): - for ldap_obj_name, m_dns in objs.iteritems(): + for (attr, objs) in member_dns.items(): + for ldap_obj_name, m_dns in objs.items(): for m_dn in m_dns: assert isinstance(m_dn, DN) if not m_dn: @@ -2376,7 +2376,7 @@ class LDAPModAttribute(LDAPQuery): try: update = self._exc_wrapper(keys, options, ldap.get_entry)( - entry_attrs.dn, entry_attrs.keys()) + entry_attrs.dn, list(entry_attrs)) self._update_attrs(update, entry_attrs) self._exc_wrapper(keys, options, ldap.update_entry)(update) @@ -2425,7 +2425,7 @@ class LDAPAddAttribute(LDAPModAttribute): msg_summary = _('added attribute value to entry %(value)') def _update_attrs(self, update, entry_attrs): - for name, value in entry_attrs.iteritems(): + for name, value in entry_attrs.items(): old_value = set(update.get(name, [])) value_to_add = set(value) @@ -2442,7 +2442,7 @@ class LDAPRemoveAttribute(LDAPModAttribute): msg_summary = _('removed attribute values from entry %(value)') def _update_attrs(self, update, entry_attrs): - for name, value in entry_attrs.iteritems(): + for name, value in entry_attrs.items(): old_value = set(update.get(name, [])) value_to_remove = set(value) diff --git a/ipalib/plugins/batch.py b/ipalib/plugins/batch.py index 9b9ab6544..ddf24839d 100644 --- a/ipalib/plugins/batch.py +++ b/ipalib/plugins/batch.py @@ -97,7 +97,7 @@ class batch(Command): if name not in self.Command: raise errors.CommandError(name=name) a, kw = arg['params'] - newkw = dict((str(k), v) for k, v in kw.iteritems()) + newkw = dict((str(k), v) for k, v in kw.items()) params = api.Command[name].args_options_2_params(*a, **newkw) newkw.setdefault('version', options['version']) diff --git a/ipalib/plugins/config.py b/ipalib/plugins/config.py index 6267313d5..c8153c311 100644 --- a/ipalib/plugins/config.py +++ b/ipalib/plugins/config.py @@ -256,8 +256,8 @@ class config_mod(LDAPUpdate): if 'ipagroupsearchfields' in entry_attrs: kw['ipagroupsearchfields'] = 'ipagroupobjectclasses' if kw: - config = ldap.get_ipa_config(kw.values()) - for (k, v) in kw.iteritems(): + config = ldap.get_ipa_config(list(kw.values())) + for (k, v) in kw.items(): allowed_attrs = ldap.get_allowed_attributes(config[v]) fields = entry_attrs[k].split(',') for a in fields: diff --git a/ipalib/plugins/dns.py b/ipalib/plugins/dns.py index 10c4987af..6044d3823 100644 --- a/ipalib/plugins/dns.py +++ b/ipalib/plugins/dns.py @@ -1641,7 +1641,7 @@ def _create_idn_filter(cmd, ldap, *args, **options): search_kw = {} attr_extra_filters = [] - for attr, value in cmd.args_options_2_entry(**options).iteritems(): + for attr, value in cmd.args_options_2_entry(**options).items(): if not isinstance(value, list): value = [value] for i, v in enumerate(value): @@ -3245,11 +3245,11 @@ class dnsrecord(LDAPObject): """ rrattrs = {} if old_entry is not None: - old_rrattrs = dict((key, value) for key, value in old_entry.iteritems() + old_rrattrs = dict((key, value) for key, value in old_entry.items() if key in self.params and isinstance(self.params[key], DNSRecord)) rrattrs.update(old_rrattrs) - new_rrattrs = dict((key, value) for key, value in entry_attrs.iteritems() + new_rrattrs = dict((key, value) for key, value in entry_attrs.items() if key in self.params and isinstance(self.params[key], DNSRecord)) rrattrs.update(new_rrattrs) @@ -3267,7 +3267,7 @@ class dnsrecord(LDAPObject): '(RFC 2136, section 1.1.5)')) if any(rrvalue is not None and rrattr != 'cnamerecord' - for rrattr, rrvalue in rrattrs.iteritems()): + for rrattr, rrvalue in rrattrs.items()): raise errors.ValidationError(name='cnamerecord', error=_('CNAME record is not allowed to coexist ' 'with any other record (RFC 1034, section 3.6.2)')) @@ -3327,7 +3327,7 @@ class dnsrecord(LDAPObject): # all records were deleted => name should not exist in DNS return None - for attr, value in entry_attrs.iteritems(): + for attr, value in entry_attrs.items(): if not attr.endswith(record_attr_suf): continue @@ -3444,7 +3444,7 @@ class dnsrecord(LDAPObject): # name should not exist => ask for A record and check result ldap_rrsets = {dns.rdatatype.from_text('A'): None} - for rdtype, ldap_rrset in ldap_rrsets.iteritems(): + for rdtype, ldap_rrset in ldap_rrsets.items(): try: self.wait_for_modified_attr(ldap_rrset, rdtype, dns_name) @@ -3479,7 +3479,7 @@ class dnsrecord(LDAPObject): :param entries: Dict {(dns_domain, dns_name): entry_for_wait_for_modified_attrs} ''' - for entry_name, entry in entries.iteritems(): + for entry_name, entry in entries.items(): dns_domain = entry_name[0] dns_name = entry_name[1].derelativize(dns_domain) self.wait_for_modified_attrs(entry, dns_name, dns_domain) @@ -3691,7 +3691,7 @@ class dnsrecord_add(LDAPCreate): # already merged in pre_callback ldap = self.obj.backend entry_attrs = self.obj.get_record_entry_attrs(call_args[0]) - update = ldap.get_entry(entry_attrs.dn, entry_attrs.keys()) + update = ldap.get_entry(entry_attrs.dn, list(entry_attrs)) update.update(entry_attrs) ldap.update_entry(update, **call_kwargs) return diff --git a/ipalib/plugins/otptoken.py b/ipalib/plugins/otptoken.py index eb3e3f977..3c2cb9309 100644 --- a/ipalib/plugins/otptoken.py +++ b/ipalib/plugins/otptoken.py @@ -161,7 +161,7 @@ class otptoken(LDAPObject): doc=_('Type of the token'), default=u'totp', autofill=True, - values=tuple(TOKEN_TYPES.keys() + [x.upper() for x in TOKEN_TYPES]), + values=tuple(list(TOKEN_TYPES) + [x.upper() for x in TOKEN_TYPES]), flags=('virtual_attribute', 'no_update'), ), Str('description?', diff --git a/ipalib/plugins/permission.py b/ipalib/plugins/permission.py index 9544cd292..7a2e14c72 100644 --- a/ipalib/plugins/permission.py +++ b/ipalib/plugins/permission.py @@ -1148,7 +1148,7 @@ class permission_mod(baseldap.LDAPUpdate): # Since `entry` only contains the attributes we are currently changing, # it cannot be used directly to generate an ACI. # First we need to copy the original data into it. - for key, value in old_entry.iteritems(): + for key, value in old_entry.items(): if (key not in options and key != 'cn' and key not in self.obj.attribute_members): @@ -1355,7 +1355,7 @@ class permission_find(baseldap.LDAPSearch): for entry in entries: if options.get('pkey_only'): - for opt_name in entry.keys(): + for opt_name in list(entry): if opt_name != self.obj.primary_key.name: del entry[opt_name] else: diff --git a/ipalib/plugins/service.py b/ipalib/plugins/service.py index 6d0299164..d20f52876 100644 --- a/ipalib/plugins/service.py +++ b/ipalib/plugins/service.py @@ -22,6 +22,7 @@ import base64 import os + from ipalib import api, errors, util from ipalib import Str, Flag, Bytes, StrEnum, Bool from ipalib.plugable import Registry @@ -315,7 +316,7 @@ def check_required_principal(ldap, hostname, service): def update_krbticketflags(ldap, entry_attrs, attrs_list, options, existing): add = remove = 0 - for (name, value) in _ticket_flags_map.iteritems(): + for (name, value) in _ticket_flags_map.items(): if name not in options: continue if options[name]: @@ -356,7 +357,7 @@ def set_kerberos_attrs(entry_attrs, options): all_opt = options.get('all', False) - for (name, value) in _ticket_flags_map.iteritems(): + for (name, value) in _ticket_flags_map.items(): if name in options or all_opt: entry_attrs[name] = bool(ticket_flags & value) diff --git a/ipalib/plugins/stageuser.py b/ipalib/plugins/stageuser.py index f3788538a..2a232d1e3 100644 --- a/ipalib/plugins/stageuser.py +++ b/ipalib/plugins/stageuser.py @@ -639,7 +639,7 @@ class stageuser_activate(LDAPQuery): ) except errors.NotFound: self.obj.handle_not_found(*args) - entry_attrs = dict((k.lower(), v) for (k, v) in entry_attrs.iteritems()) + entry_attrs = dict((k.lower(), v) for (k, v) in entry_attrs.items()) # Check it does not exist an active entry with the same RDN active_dn = DN(staging_dn[0], api.env.container_user, api.env.basedn) @@ -660,7 +660,7 @@ class stageuser_activate(LDAPQuery): # Time to build the new entry result_entry = {'dn' : active_dn} new_entry_attrs = self.__dict_new_entry() - for (attr, values) in entry_attrs.iteritems(): + for (attr, values) in entry_attrs.items(): self.__merge_values(args, options, entry_attrs, new_entry_attrs, attr) result_entry[attr] = values @@ -670,7 +670,7 @@ class stageuser_activate(LDAPQuery): if result_entry['description'] == NO_UPG_MAGIC: del result_entry['description'] - for (k,v) in new_entry_attrs.iteritems(): + for (k, v) in new_entry_attrs.items(): self.log.debug("new entry: k=%r and v=%r)" % (k, v)) self._build_new_entry(ldap, staging_dn, entry_attrs, new_entry_attrs) |