From ef391a11ec536d0efb1b59e8139735b27b67c67f Mon Sep 17 00:00:00 2001 From: Andrea Tartaglia Date: Mon, 12 Dec 2016 23:16:23 +0000 Subject: [PATCH] Removed dict.iteritems() in modules. (#18859) This is for py3 compatibility, addressed in #18506 --- .../modules/cloud/amazon/dynamodb_table.py | 14 +++++------ lib/ansible/modules/cloud/amazon/ec2_asg.py | 2 +- .../modules/cloud/amazon/ec2_asg_facts.py | 2 +- .../modules/cloud/amazon/ec2_elb_lb.py | 4 ++-- lib/ansible/modules/cloud/amazon/ec2_facts.py | 2 +- .../amazon/ec2_vpc_dhcp_options_facts.py | 2 +- .../modules/cloud/amazon/ec2_vpc_nacl.py | 4 ++-- .../modules/cloud/amazon/ec2_vpc_peer.py | 4 ++-- .../cloud/amazon/ec2_vpc_route_table.py | 2 +- .../modules/cloud/amazon/ec2_vpc_vgw.py | 2 +- .../cloud/amazon/ecs_taskdefinition.py | 4 ++-- .../modules/cloud/amazon/elasticache.py | 4 ++-- lib/ansible/modules/cloud/amazon/s3_bucket.py | 2 +- .../modules/cloud/cloudstack/cs_facts.py | 2 +- .../cloud/cloudstack/cs_portforward.py | 2 +- .../cloud/digital_ocean/digital_ocean.py | 2 +- lib/ansible/modules/cloud/docker/_docker.py | 20 ++++++++-------- .../modules/cloud/docker/docker_container.py | 24 +++++++++---------- .../modules/cloud/docker/docker_image.py | 2 +- .../modules/cloud/docker/docker_network.py | 4 ++-- lib/ansible/modules/cloud/lxd/lxd_profile.py | 2 +- lib/ansible/modules/cloud/misc/proxmox.py | 2 +- lib/ansible/modules/cloud/misc/proxmox_kvm.py | 8 +++---- .../modules/cloud/misc/xenserver_facts.py | 2 +- lib/ansible/modules/cloud/rackspace/rax.py | 2 +- .../cloud/rackspace/rax_cbs_attachments.py | 2 +- .../modules/cloud/rackspace/rax_cdb.py | 2 +- .../modules/cloud/rackspace/rax_cdb_user.py | 4 ++-- .../modules/cloud/rackspace/rax_clb.py | 2 +- .../modules/cloud/rackspace/rax_clb_ssl.py | 2 +- .../modules/cloud/rackspace/rax_mon_check.py | 2 +- .../modules/cloud/vmware/vmware_guest.py | 6 ++--- .../modules/cloud/vmware/vsphere_guest.py | 12 +++++----- lib/ansible/modules/clustering/consul.py | 2 +- lib/ansible/modules/clustering/consul_acl.py | 6 ++--- lib/ansible/modules/commands/expect.py | 2 +- .../database/postgresql/postgresql_ext.py | 2 +- .../database/postgresql/postgresql_lang.py | 2 +- .../database/postgresql/postgresql_schema.py | 2 +- .../modules/monitoring/logicmonitor.py | 4 ++-- .../modules/network/cumulus/cl_bond.py | 2 +- .../modules/network/cumulus/cl_bridge.py | 2 +- .../modules/network/cumulus/cl_interface.py | 2 +- .../network/dellos10/dellos10_facts.py | 2 +- .../modules/network/dellos6/dellos6_facts.py | 4 ++-- .../modules/network/dellos9/dellos9_facts.py | 6 ++--- lib/ansible/modules/network/eos/eos_eapi.py | 2 +- .../modules/network/f5/bigip_gtm_facts.py | 6 ++--- .../modules/network/nxos/nxos_aaa_server.py | 9 +++---- .../network/nxos/nxos_aaa_server_host.py | 6 ++--- lib/ansible/modules/network/nxos/nxos_acl.py | 18 +++++++------- lib/ansible/modules/network/nxos/nxos_bgp.py | 8 +++---- .../modules/network/nxos/nxos_bgp_af.py | 8 +++---- .../modules/network/nxos/nxos_bgp_neighbor.py | 6 ++--- .../network/nxos/nxos_bgp_neighbor_af.py | 6 ++--- .../modules/network/nxos/nxos_evpn_global.py | 2 +- .../modules/network/nxos/nxos_evpn_vni.py | 8 +++---- lib/ansible/modules/network/nxos/nxos_hsrp.py | 6 ++--- lib/ansible/modules/network/nxos/nxos_igmp.py | 6 ++--- .../network/nxos/nxos_igmp_interface.py | 10 ++++---- .../network/nxos/nxos_igmp_snooping.py | 10 ++++---- .../modules/network/nxos/nxos_interface.py | 4 ++-- .../network/nxos/nxos_interface_ospf.py | 8 +++---- .../modules/network/nxos/nxos_ip_interface.py | 2 +- lib/ansible/modules/network/nxos/nxos_mtu.py | 10 ++++---- lib/ansible/modules/network/nxos/nxos_ntp.py | 6 ++--- .../modules/network/nxos/nxos_ntp_auth.py | 6 ++--- .../modules/network/nxos/nxos_ntp_options.py | 8 +++---- .../modules/network/nxos/nxos_nxapi.py | 2 +- .../modules/network/nxos/nxos_ospf_vrf.py | 8 +++---- .../network/nxos/nxos_overlay_global.py | 4 ++-- lib/ansible/modules/network/nxos/nxos_pim.py | 4 ++-- .../network/nxos/nxos_pim_interface.py | 14 +++++------ .../network/nxos/nxos_pim_rp_address.py | 4 ++-- lib/ansible/modules/network/nxos/nxos_ping.py | 2 +- .../modules/network/nxos/nxos_portchannel.py | 6 ++--- .../network/nxos/nxos_snmp_community.py | 8 +++---- .../modules/network/nxos/nxos_snmp_host.py | 8 +++---- .../modules/network/nxos/nxos_snmp_user.py | 4 ++-- .../modules/network/nxos/nxos_static_route.py | 2 +- .../modules/network/nxos/nxos_switchport.py | 2 +- lib/ansible/modules/network/nxos/nxos_udld.py | 10 ++++---- .../network/nxos/nxos_udld_interface.py | 4 ++-- lib/ansible/modules/network/nxos/nxos_vlan.py | 6 ++--- lib/ansible/modules/network/nxos/nxos_vpc.py | 6 ++--- .../network/nxos/nxos_vpc_interface.py | 8 +++---- lib/ansible/modules/network/nxos/nxos_vrf.py | 6 ++--- .../modules/network/nxos/nxos_vrf_af.py | 6 ++--- lib/ansible/modules/network/nxos/nxos_vrrp.py | 4 ++-- .../modules/network/nxos/nxos_vtp_domain.py | 4 ++-- .../modules/network/nxos/nxos_vtp_password.py | 4 ++-- .../modules/network/nxos/nxos_vtp_version.py | 4 ++-- .../modules/network/nxos/nxos_vxlan_vtep.py | 6 ++--- .../network/nxos/nxos_vxlan_vtep_vni.py | 6 ++--- .../modules/network/sros/sros_rollback.py | 2 +- .../modules/packaging/language/composer.py | 2 +- lib/ansible/modules/system/osx_defaults.py | 2 +- lib/ansible/modules/system/ufw.py | 2 +- lib/ansible/modules/system/zfs.py | 6 ++--- 99 files changed, 251 insertions(+), 250 deletions(-) diff --git a/lib/ansible/modules/cloud/amazon/dynamodb_table.py b/lib/ansible/modules/cloud/amazon/dynamodb_table.py index 75e410d4b7..20c7bc2859 100644 --- a/lib/ansible/modules/cloud/amazon/dynamodb_table.py +++ b/lib/ansible/modules/cloud/amazon/dynamodb_table.py @@ -274,14 +274,14 @@ def update_dynamo_table(table, throughput=None, check_mode=False, global_indexes removed_indexes, added_indexes, index_throughput_changes = get_changed_global_indexes(table, global_indexes) if removed_indexes: if not check_mode: - for name, index in removed_indexes.iteritems(): + for name, index in removed_indexes.items(): global_indexes_changed = table.delete_global_secondary_index(name) or global_indexes_changed else: global_indexes_changed = True if added_indexes: if not check_mode: - for name, index in added_indexes.iteritems(): + for name, index in added_indexes.items(): global_indexes_changed = table.create_global_secondary_index(global_index=index) or global_indexes_changed else: global_indexes_changed = True @@ -328,18 +328,18 @@ def get_changed_global_indexes(table, global_indexes): set_index_info = dict((index.name, index.schema()) for index in global_indexes) set_index_objects = dict((index.name, index) for index in global_indexes) - removed_indexes = dict((name, index) for name, index in table_index_info.iteritems() if name not in set_index_info) - added_indexes = dict((name, set_index_objects[name]) for name, index in set_index_info.iteritems() if name not in table_index_info) + removed_indexes = dict((name, index) for name, index in table_index_info.items() if name not in set_index_info) + added_indexes = dict((name, set_index_objects[name]) for name, index in set_index_info.items() if name not in table_index_info) # todo: uncomment once boto has https://github.com/boto/boto/pull/3447 fixed - # index_throughput_changes = dict((name, index.throughput) for name, index in set_index_objects.iteritems() if name not in added_indexes and (index.throughput['read'] != str(table_index_objects[name].throughput['read']) or index.throughput['write'] != str(table_index_objects[name].throughput['write']))) + # index_throughput_changes = dict((name, index.throughput) for name, index in set_index_objects.items() if name not in added_indexes and (index.throughput['read'] != str(table_index_objects[name].throughput['read']) or index.throughput['write'] != str(table_index_objects[name].throughput['write']))) # todo: remove once boto has https://github.com/boto/boto/pull/3447 fixed - index_throughput_changes = dict((name, index.throughput) for name, index in set_index_objects.iteritems() if name not in added_indexes) + index_throughput_changes = dict((name, index.throughput) for name, index in set_index_objects.items() if name not in added_indexes) return removed_indexes, added_indexes, index_throughput_changes def validate_index(index, module): - for key, val in index.iteritems(): + for key, val in index.items(): if key not in INDEX_OPTIONS: module.fail_json(msg='%s is not a valid option for an index' % key) for required_option in INDEX_REQUIRED_OPTIONS: diff --git a/lib/ansible/modules/cloud/amazon/ec2_asg.py b/lib/ansible/modules/cloud/amazon/ec2_asg.py index be7c634d74..d1020c5cfd 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_asg.py +++ b/lib/ansible/modules/cloud/amazon/ec2_asg.py @@ -458,7 +458,7 @@ def create_autoscaling_group(connection, module): asg_tags = [] for tag in set_tags: - for k,v in tag.iteritems(): + for k,v in tag.items(): if k !='propagate_at_launch': asg_tags.append(Tag(key=k, value=v, diff --git a/lib/ansible/modules/cloud/amazon/ec2_asg_facts.py b/lib/ansible/modules/cloud/amazon/ec2_asg_facts.py index 3cd6e67860..b52c884663 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_asg_facts.py +++ b/lib/ansible/modules/cloud/amazon/ec2_asg_facts.py @@ -206,7 +206,7 @@ except ImportError: HAS_BOTO3 = False def match_asg_tags(tags_to_match, asg): - for key, value in tags_to_match.iteritems(): + for key, value in tags_to_match.items(): for tag in asg['Tags']: if key == tag['Key'] and value == tag['Value']: break diff --git a/lib/ansible/modules/cloud/amazon/ec2_elb_lb.py b/lib/ansible/modules/cloud/amazon/ec2_elb_lb.py index ca87a1cb3a..9e162c6b0e 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_elb_lb.py +++ b/lib/ansible/modules/cloud/amazon/ec2_elb_lb.py @@ -911,7 +911,7 @@ class ElbManager(object): if not self.elb.health_check: self.elb.health_check = HealthCheck() - for attr, desired_value in health_check_config.iteritems(): + for attr, desired_value in health_check_config.items(): if getattr(self.elb.health_check, attr) != desired_value: setattr(self.elb.health_check, attr, desired_value) update_health_check = True @@ -950,7 +950,7 @@ class ElbManager(object): } update_access_logs_config = False - for attr, desired_value in access_logs_config.iteritems(): + for attr, desired_value in access_logs_config.items(): if getattr(attributes.access_log, attr) != desired_value: setattr(attributes.access_log, attr, desired_value) update_access_logs_config = True diff --git a/lib/ansible/modules/cloud/amazon/ec2_facts.py b/lib/ansible/modules/cloud/amazon/ec2_facts.py index 498cf9c2df..73d56f1412 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_facts.py +++ b/lib/ansible/modules/cloud/amazon/ec2_facts.py @@ -97,7 +97,7 @@ class Ec2Metadata(object): def _mangle_fields(self, fields, uri, filter_patterns=['public-keys-0']): new_fields = {} - for key, value in fields.iteritems(): + for key, value in fields.items(): split_fields = key[len(uri):].split('/') if len(split_fields) > 1 and split_fields[1]: new_key = "-".join(split_fields) diff --git a/lib/ansible/modules/cloud/amazon/ec2_vpc_dhcp_options_facts.py b/lib/ansible/modules/cloud/amazon/ec2_vpc_dhcp_options_facts.py index 063f525ea0..123e6e98ec 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_vpc_dhcp_options_facts.py +++ b/lib/ansible/modules/cloud/amazon/ec2_vpc_dhcp_options_facts.py @@ -106,7 +106,7 @@ def list_dhcp_options(client, module): if module.params.get('filters'): params['Filters'] = [] - for key, value in module.params.get('filters').iteritems(): + for key, value in module.params.get('filters').items(): temp_dict = dict() temp_dict['Name'] = key if isinstance(value, basestring): diff --git a/lib/ansible/modules/cloud/amazon/ec2_vpc_nacl.py b/lib/ansible/modules/cloud/amazon/ec2_vpc_nacl.py index 1758e288c6..4e32cb1e8f 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_vpc_nacl.py +++ b/lib/ansible/modules/cloud/amazon/ec2_vpc_nacl.py @@ -161,7 +161,7 @@ def icmp_present(entry): def load_tags(module): tags = [] if module.params.get('tags'): - for name, value in module.params.get('tags').iteritems(): + for name, value in module.params.get('tags').items(): tags.append({'Key': name, 'Value': str(value)}) tags.append({'Key': "Name", 'Value': module.params.get('name')}) else: @@ -239,7 +239,7 @@ def tags_changed(nacl_id, client, module): if nacl['NetworkAcls']: nacl_values = [t.values() for t in nacl['NetworkAcls'][0]['Tags']] nacl_tags = [item for sublist in nacl_values for item in sublist] - tag_values = [[key, str(value)] for key, value in tags.iteritems()] + tag_values = [[key, str(value)] for key, value in tags.items()] tags = [item for sublist in tag_values for item in sublist] if sorted(nacl_tags) == sorted(tags): changed = False diff --git a/lib/ansible/modules/cloud/amazon/ec2_vpc_peer.py b/lib/ansible/modules/cloud/amazon/ec2_vpc_peer.py index e55da2605f..71398f1045 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_vpc_peer.py +++ b/lib/ansible/modules/cloud/amazon/ec2_vpc_peer.py @@ -210,7 +210,7 @@ def tags_changed(pcx_id, client, module): if pcx['VpcPeeringConnections']: pcx_values = [t.values() for t in pcx['VpcPeeringConnections'][0]['Tags']] pcx_tags = [item for sublist in pcx_values for item in sublist] - tag_values = [[key, str(value)] for key, value in tags.iteritems()] + tag_values = [[key, str(value)] for key, value in tags.items()] tags = [item for sublist in tag_values for item in sublist] if sorted(pcx_tags) == sorted(tags): changed = False @@ -305,7 +305,7 @@ def accept_reject_delete(state, client, module): def load_tags(module): tags = [] if module.params.get('tags'): - for name, value in module.params.get('tags').iteritems(): + for name, value in module.params.get('tags').items(): tags.append({'Key': name, 'Value': str(value)}) return tags diff --git a/lib/ansible/modules/cloud/amazon/ec2_vpc_route_table.py b/lib/ansible/modules/cloud/amazon/ec2_vpc_route_table.py index 1529d92353..f839b703d1 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_vpc_route_table.py +++ b/lib/ansible/modules/cloud/amazon/ec2_vpc_route_table.py @@ -233,7 +233,7 @@ def get_resource_tags(vpc_conn, resource_id): def tags_match(match_tags, candidate_tags): return all((k in candidate_tags and candidate_tags[k] == v - for k, v in match_tags.iteritems())) + for k, v in match_tags.items())) def ensure_tags(vpc_conn, resource_id, tags, add_only, check_mode): diff --git a/lib/ansible/modules/cloud/amazon/ec2_vpc_vgw.py b/lib/ansible/modules/cloud/amazon/ec2_vpc_vgw.py index 40eb386156..b52e512984 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_vpc_vgw.py +++ b/lib/ansible/modules/cloud/amazon/ec2_vpc_vgw.py @@ -276,7 +276,7 @@ def load_tags(module): tags = [] if module.params.get('tags'): - for name, value in module.params.get('tags').iteritems(): + for name, value in module.params.get('tags').items(): tags.append({'Key': name, 'Value': str(value)}) tags.append({'Key': "Name", 'Value': module.params.get('name')}) else: diff --git a/lib/ansible/modules/cloud/amazon/ecs_taskdefinition.py b/lib/ansible/modules/cloud/amazon/ecs_taskdefinition.py index 85221a1043..6a24859ea7 100644 --- a/lib/ansible/modules/cloud/amazon/ecs_taskdefinition.py +++ b/lib/ansible/modules/cloud/amazon/ecs_taskdefinition.py @@ -244,7 +244,7 @@ def main(): def _right_has_values_of_left(left, right): # Make sure the values are equivalent for everything left has - for k, v in left.iteritems(): + for k, v in left.items(): if not ((not v and (k not in right or not right[k])) or (k in right and v == right[k])): # We don't care about list ordering because ECS can change things if isinstance(v, list) and k in right: @@ -261,7 +261,7 @@ def main(): return False # Make sure right doesn't have anything that left doesn't - for k, v in right.iteritems(): + for k, v in right.items(): if v and k not in left: return False diff --git a/lib/ansible/modules/cloud/amazon/elasticache.py b/lib/ansible/modules/cloud/amazon/elasticache.py index a9bfd0073e..24272549eb 100644 --- a/lib/ansible/modules/cloud/amazon/elasticache.py +++ b/lib/ansible/modules/cloud/amazon/elasticache.py @@ -385,7 +385,7 @@ class ElastiCacheManager(object): 'NumCacheNodes': self.num_nodes, 'EngineVersion': self.cache_engine_version } - for key, value in modifiable_data.iteritems(): + for key, value in modifiable_data.items(): if value is not None and self.data[key] != value: return True @@ -419,7 +419,7 @@ class ElastiCacheManager(object): # Only check for modifications if zone is specified if self.zone is not None: unmodifiable_data['zone'] = self.data['PreferredAvailabilityZone'] - for key, value in unmodifiable_data.iteritems(): + for key, value in unmodifiable_data.items(): if getattr(self, key) is not None and getattr(self, key) != value: return True return False diff --git a/lib/ansible/modules/cloud/amazon/s3_bucket.py b/lib/ansible/modules/cloud/amazon/s3_bucket.py index 970967e30b..37b3ffcc7e 100644 --- a/lib/ansible/modules/cloud/amazon/s3_bucket.py +++ b/lib/ansible/modules/cloud/amazon/s3_bucket.py @@ -141,7 +141,7 @@ def create_tags_container(tags): tag_set = TagSet() tags_obj = Tags() - for key, val in tags.iteritems(): + for key, val in tags.items(): tag_set.add_tag(key, val) tags_obj.add_tag_set(tag_set) diff --git a/lib/ansible/modules/cloud/cloudstack/cs_facts.py b/lib/ansible/modules/cloud/cloudstack/cs_facts.py index 6f51127df6..c5bbb39f82 100644 --- a/lib/ansible/modules/cloud/cloudstack/cs_facts.py +++ b/lib/ansible/modules/cloud/cloudstack/cs_facts.py @@ -132,7 +132,7 @@ class CloudStackFacts(object): result = {} filter = module.params.get('filter') if not filter: - for key,path in self.fact_paths.iteritems(): + for key,path in self.fact_paths.items(): result[key] = self._fetch(CS_METADATA_BASE_URL + "/" + path) result['cloudstack_user_data'] = self._get_user_data_json() else: diff --git a/lib/ansible/modules/cloud/cloudstack/cs_portforward.py b/lib/ansible/modules/cloud/cloudstack/cs_portforward.py index 139fa7773d..1dc80bb264 100644 --- a/lib/ansible/modules/cloud/cloudstack/cs_portforward.py +++ b/lib/ansible/modules/cloud/cloudstack/cs_portforward.py @@ -334,7 +334,7 @@ class AnsibleCloudStackPortforwarding(AnsibleCloudStack): super(AnsibleCloudStackPortforwarding, self).get_result(portforwarding_rule) if portforwarding_rule: # Bad bad API does not always return int when it should. - for search_key, return_key in self.returns_to_int.iteritems(): + for search_key, return_key in self.returns_to_int.items(): if search_key in portforwarding_rule: self.result[return_key] = int(portforwarding_rule[search_key]) return self.result diff --git a/lib/ansible/modules/cloud/digital_ocean/digital_ocean.py b/lib/ansible/modules/cloud/digital_ocean/digital_ocean.py index 2cdcbd6420..5f9f836e78 100644 --- a/lib/ansible/modules/cloud/digital_ocean/digital_ocean.py +++ b/lib/ansible/modules/cloud/digital_ocean/digital_ocean.py @@ -231,7 +231,7 @@ class Droplet(JsonfyMixIn): def update_attr(self, attrs=None): if attrs: - for k, v in attrs.iteritems(): + for k, v in attrs.items(): setattr(self, k, v) else: json = self.manager.show_droplet(self.id) diff --git a/lib/ansible/modules/cloud/docker/_docker.py b/lib/ansible/modules/cloud/docker/_docker.py index 08adf3b907..714b306f3e 100644 --- a/lib/ansible/modules/cloud/docker/_docker.py +++ b/lib/ansible/modules/cloud/docker/_docker.py @@ -902,11 +902,11 @@ class DockerManager(object): self.ensure_capability('env_file') parsed_env_file = docker.utils.parse_env_file(env_file) - for name, value in parsed_env_file.iteritems(): + for name, value in parsed_env_file.items(): final_env[name] = str(value) if env: - for name, value in env.iteritems(): + for name, value in env.items(): final_env[name] = str(value) return final_env @@ -998,7 +998,7 @@ class DockerManager(object): self.ensure_capability('log_driver') log_config = docker.utils.LogConfig(type=docker.utils.LogConfig.types.JSON) if optionals['log_opt'] is not None: - for k, v in optionals['log_opt'].iteritems(): + for k, v in optionals['log_opt'].items(): log_config.set_config_value(k, v) log_config.type = optionals['log_driver'] params['log_config'] = log_config @@ -1073,7 +1073,7 @@ class DockerManager(object): ''' parts = [] - for k, v in self.counters.iteritems(): + for k, v in self.counters.items(): if v == 0: continue @@ -1100,7 +1100,7 @@ class DockerManager(object): def get_summary_counters_msg(self): msg = "" - for k, v in self.counters.iteritems(): + for k, v in self.counters.items(): msg = msg + "%s %d " % (k, v) return msg @@ -1109,7 +1109,7 @@ class DockerManager(object): self.counters[name] = self.counters[name] + 1 def has_changed(self): - for k, v in self.counters.iteritems(): + for k, v in self.counters.items(): if v > 0: return True @@ -1287,7 +1287,7 @@ class DockerManager(object): expected_env[name] = value if self.environment: - for name, value in self.environment.iteritems(): + for name, value in self.environment.items(): expected_env[name] = str(value) actual_env = {} @@ -1304,7 +1304,7 @@ class DockerManager(object): # LABELS expected_labels = {} - for name, value in self.module.params.get('labels').iteritems(): + for name, value in self.module.params.get('labels').items(): expected_labels[name] = str(value) if isinstance(container['Config']['Labels'], dict): @@ -1401,7 +1401,7 @@ class DockerManager(object): expected_bound_ports = {} if self.port_bindings: - for container_port, config in self.port_bindings.iteritems(): + for container_port, config in self.port_bindings.items(): if isinstance(container_port, int): container_port = "{0}/tcp".format(container_port) if len(config) == 1: @@ -1437,7 +1437,7 @@ class DockerManager(object): # LINKS expected_links = set() - for link, alias in (self.links or {}).iteritems(): + for link, alias in (self.links or {}).items(): expected_links.add("/{0}:{1}/{2}".format(link, container["Name"], alias)) actual_links = set(container['HostConfig']['Links'] or []) diff --git a/lib/ansible/modules/cloud/docker/docker_container.py b/lib/ansible/modules/cloud/docker/docker_container.py index f921ce4717..2acba8388a 100644 --- a/lib/ansible/modules/cloud/docker/docker_container.py +++ b/lib/ansible/modules/cloud/docker/docker_container.py @@ -815,7 +815,7 @@ class TaskParameters(DockerBaseClass): kernel_memory='kernel_memory' ) result = dict() - for key, value in update_parameters.iteritems(): + for key, value in update_parameters.items(): if getattr(self, value, None) is not None: result[key] = getattr(self, value) return result @@ -927,7 +927,7 @@ class TaskParameters(DockerBaseClass): pid_mode='pid_mode' ) params = dict() - for key, value in host_config_params.iteritems(): + for key, value in host_config_params.items(): if getattr(self, value, None) is not None: params[key] = getattr(self, value) @@ -1116,10 +1116,10 @@ class TaskParameters(DockerBaseClass): final_env = {} if self.env_file: parsed_env_file = utils.parse_env_file(self.env_file) - for name, value in parsed_env_file.iteritems(): + for name, value in parsed_env_file.items(): final_env[name] = str(value) if self.env: - for name, value in self.env.iteritems(): + for name, value in self.env.items(): final_env[name] = str(value) return final_env @@ -1258,7 +1258,7 @@ class Container(DockerBaseClass): ) differences = [] - for key, value in config_mapping.iteritems(): + for key, value in config_mapping.items(): self.log('check differences %s %s vs %s' % (key, getattr(self.parameters, key), str(value))) if getattr(self.parameters, key, None) is not None: if isinstance(getattr(self.parameters, key), list) and isinstance(value, list): @@ -1314,7 +1314,7 @@ class Container(DockerBaseClass): ''' if not isinstance(dict_a, dict) or not isinstance(dict_b, dict): return False - for key, value in dict_a.iteritems(): + for key, value in dict_a.items(): if isinstance(value, dict): match = self._compare_dicts(value, dict_b.get(key)) elif isinstance(value, list): @@ -1353,7 +1353,7 @@ class Container(DockerBaseClass): ) differences = [] - for key, value in config_mapping.iteritems(): + for key, value in config_mapping.items(): if getattr(self.parameters, key, None) and getattr(self.parameters, key) != value: # no match. record the differences item = dict() @@ -1402,7 +1402,7 @@ class Container(DockerBaseClass): diff = True if network.get('links') and connected_networks[network['name']].get('Links'): expected_links = [] - for link, alias in network['links'].iteritems(): + for link, alias in network['links'].items(): expected_links.append("%s:%s" % (link, alias)) for link in expected_links: if link not in connected_networks[network['name']].get('Links', []): @@ -1433,7 +1433,7 @@ class Container(DockerBaseClass): connected_networks = self.container['NetworkSettings'].get('Networks') if connected_networks: - for network, network_config in connected_networks.iteritems(): + for network, network_config in connected_networks.items(): keep = False if self.parameters.networks: for expected_network in self.parameters.networks: @@ -1485,7 +1485,7 @@ class Container(DockerBaseClass): if not self.parameters.published_ports: return None expected_bound_ports = {} - for container_port, config in self.parameters.published_ports.iteritems(): + for container_port, config in self.parameters.published_ports.items(): if isinstance(container_port, int): container_port = "%s/tcp" % container_port if len(config) == 1: @@ -1504,7 +1504,7 @@ class Container(DockerBaseClass): self.log('parameter links:') self.log(self.parameters.links, pretty_print=True) exp_links = [] - for link, alias in self.parameters.links.iteritems(): + for link, alias in self.parameters.links.items(): exp_links.append("/%s:%s/%s" % (link, ('/' + self.parameters.name), alias)) return exp_links @@ -1635,7 +1635,7 @@ class Container(DockerBaseClass): if getattr(self.parameters, param_name, None) is None: return None results = [] - for key, value in getattr(self.parameters, param_name).iteritems(): + for key, value in getattr(self.parameters, param_name).items(): results.append("%s%s%s" % (key, join_with, value)) return results diff --git a/lib/ansible/modules/cloud/docker/docker_image.py b/lib/ansible/modules/cloud/docker/docker_image.py index 0de16632e0..06ca796c2f 100644 --- a/lib/ansible/modules/cloud/docker/docker_image.py +++ b/lib/ansible/modules/cloud/docker/docker_image.py @@ -509,7 +509,7 @@ class ImageManager(DockerBaseClass): if self.container_limits: params['container_limits'] = self.container_limits if self.buildargs: - for key, value in self.buildargs.iteritems(): + for key, value in self.buildargs.items(): if not isinstance(value, basestring): self.buildargs[key] = str(value) params['buildargs'] = self.buildargs diff --git a/lib/ansible/modules/cloud/docker/docker_network.py b/lib/ansible/modules/cloud/docker/docker_network.py index 24ce4dc6a4..3c7f46bfc0 100644 --- a/lib/ansible/modules/cloud/docker/docker_network.py +++ b/lib/ansible/modules/cloud/docker/docker_network.py @@ -242,7 +242,7 @@ class DockerNetworkManager(object): different = True differences.append('driver_options') else: - for key, value in self.parameters.driver_options.iteritems(): + for key, value in self.parameters.driver_options.items(): if not net['Options'].get(key) or value != net['Options'][key]: different = True differences.append('driver_options.%s' % key) @@ -255,7 +255,7 @@ class DockerNetworkManager(object): different = True differences.append('ipam_options') else: - for key, value in self.parameters.ipam_options.iteritems(): + for key, value in self.parameters.ipam_options.items(): camelkey = None for net_key in net['IPAM']['Config'][0]: if key == net_key.lower(): diff --git a/lib/ansible/modules/cloud/lxd/lxd_profile.py b/lib/ansible/modules/cloud/lxd/lxd_profile.py index 546d0c09ea..d32834732f 100644 --- a/lib/ansible/modules/cloud/lxd/lxd_profile.py +++ b/lib/ansible/modules/cloud/lxd/lxd_profile.py @@ -284,7 +284,7 @@ class LXDProfileManagement(object): def _apply_profile_configs(self): config = self.old_profile_json.copy() - for k, v in self.config.iteritems(): + for k, v in self.config.items(): config[k] = v self.client.do('PUT', '/1.0/profiles/{}'.format(self.name), config) self.actions.append('apply_profile_configs') diff --git a/lib/ansible/modules/cloud/misc/proxmox.py b/lib/ansible/modules/cloud/misc/proxmox.py index c404519d49..b492c96dac 100644 --- a/lib/ansible/modules/cloud/misc/proxmox.py +++ b/lib/ansible/modules/cloud/misc/proxmox.py @@ -328,7 +328,7 @@ def node_check(proxmox, node): def create_instance(module, proxmox, vmid, node, disk, storage, cpus, memory, swap, timeout, **kwargs): proxmox_node = proxmox.nodes(node) - kwargs = dict((k,v) for k, v in kwargs.iteritems() if v is not None) + kwargs = dict((k,v) for k, v in kwargs.items() if v is not None) if VZ_TYPE =='lxc': kwargs['cpulimit']=cpus kwargs['rootfs']=disk diff --git a/lib/ansible/modules/cloud/misc/proxmox_kvm.py b/lib/ansible/modules/cloud/misc/proxmox_kvm.py index e77f266b42..790ab6c2d8 100644 --- a/lib/ansible/modules/cloud/misc/proxmox_kvm.py +++ b/lib/ansible/modules/cloud/misc/proxmox_kvm.py @@ -689,7 +689,7 @@ def get_vminfo(module, proxmox, node, vmid, **kwargs): module.fail_json(msg='Getting information for VM with vmid = %s failed with exception: %s' % (vmid, e)) # Sanitize kwargs. Remove not defined args and ensure True and False converted to int. - kwargs = dict((k,v) for k, v in kwargs.iteritems() if v is not None) + kwargs = dict((k,v) for k, v in kwargs.items() if v is not None) # Convert all dict in kwargs to elements. For hostpci[n], ide[n], net[n], numa[n], parallel[n], sata[n], scsi[n], serial[n], virtio[n] for k in kwargs.keys(): @@ -698,7 +698,7 @@ def get_vminfo(module, proxmox, node, vmid, **kwargs): del kwargs[k] # Split information by type - for k, v in kwargs.iteritems(): + for k, v in kwargs.items(): if re.match(r'net[0-9]', k) is not None: interface = k k = vm[k] @@ -723,8 +723,8 @@ def create_vm(module, proxmox, vmid, node, name, memory, cpu, cores, sockets, ti proxmox_node = proxmox.nodes(node) # Sanitize kwargs. Remove not defined args and ensure True and False converted to int. - kwargs = dict((k,v) for k, v in kwargs.iteritems() if v is not None) - kwargs.update(dict([k, int(v)] for k, v in kwargs.iteritems() if isinstance(v, bool))) + kwargs = dict((k,v) for k, v in kwargs.items() if v is not None) + kwargs.update(dict([k, int(v)] for k, v in kwargs.items() if isinstance(v, bool))) # The features work only on PVE 4 if PVE_MAJOR_VERSION < 4: diff --git a/lib/ansible/modules/cloud/misc/xenserver_facts.py b/lib/ansible/modules/cloud/misc/xenserver_facts.py index afb559444c..08a31e19ee 100644 --- a/lib/ansible/modules/cloud/misc/xenserver_facts.py +++ b/lib/ansible/modules/cloud/misc/xenserver_facts.py @@ -129,7 +129,7 @@ def change_keys(recs, key='uuid', filter_func=None): """ new_recs = {} - for ref, rec in recs.iteritems(): + for ref, rec in recs.items(): if filter_func is not None and not filter_func(rec): continue diff --git a/lib/ansible/modules/cloud/rackspace/rax.py b/lib/ansible/modules/cloud/rackspace/rax.py index e9a1fd4876..cd4e142ee7 100644 --- a/lib/ansible/modules/cloud/rackspace/rax.py +++ b/lib/ansible/modules/cloud/rackspace/rax.py @@ -484,7 +484,7 @@ def cloudservers(module, state=None, name=None, flavor=None, image=None, if not boot_from_volume and not boot_volume and not image: module.fail_json(msg='image is required for the "rax" module') - for arg, value in dict(name=name, flavor=flavor).iteritems(): + for arg, value in dict(name=name, flavor=flavor).items(): if not value: module.fail_json(msg='%s is required for the "rax" module' % arg) diff --git a/lib/ansible/modules/cloud/rackspace/rax_cbs_attachments.py b/lib/ansible/modules/cloud/rackspace/rax_cbs_attachments.py index 0c8032b35e..c21f5231e4 100644 --- a/lib/ansible/modules/cloud/rackspace/rax_cbs_attachments.py +++ b/lib/ansible/modules/cloud/rackspace/rax_cbs_attachments.py @@ -129,7 +129,7 @@ def cloud_block_storage_attachments(module, state, volume, server, device, volume.get() - for key, value in vars(volume).iteritems(): + for key, value in vars(volume).items(): if (isinstance(value, NON_CALLABLES) and not key.startswith('_')): instance[key] = value diff --git a/lib/ansible/modules/cloud/rackspace/rax_cdb.py b/lib/ansible/modules/cloud/rackspace/rax_cdb.py index 4706457ae6..ee8d73f7fb 100644 --- a/lib/ansible/modules/cloud/rackspace/rax_cdb.py +++ b/lib/ansible/modules/cloud/rackspace/rax_cdb.py @@ -114,7 +114,7 @@ def save_instance(module, name, flavor, volume, cdb_type, cdb_version, wait, for arg, value in dict(name=name, flavor=flavor, volume=volume, type=cdb_type, version=cdb_version - ).iteritems(): + ).items(): if not value: module.fail_json(msg='%s is required for the "rax_cdb"' ' module' % arg) diff --git a/lib/ansible/modules/cloud/rackspace/rax_cdb_user.py b/lib/ansible/modules/cloud/rackspace/rax_cdb_user.py index 7fa1bc5048..401874c176 100644 --- a/lib/ansible/modules/cloud/rackspace/rax_cdb_user.py +++ b/lib/ansible/modules/cloud/rackspace/rax_cdb_user.py @@ -93,7 +93,7 @@ def find_user(instance, name): def save_user(module, cdb_id, name, password, databases, host): - for arg, value in dict(cdb_id=cdb_id, name=name).iteritems(): + for arg, value in dict(cdb_id=cdb_id, name=name).items(): if not value: module.fail_json(msg='%s is required for the "rax_cdb_user" ' 'module' % arg) @@ -148,7 +148,7 @@ def save_user(module, cdb_id, name, password, databases, host): def delete_user(module, cdb_id, name): - for arg, value in dict(cdb_id=cdb_id, name=name).iteritems(): + for arg, value in dict(cdb_id=cdb_id, name=name).items(): if not value: module.fail_json(msg='%s is required for the "rax_cdb_user"' ' module' % arg) diff --git a/lib/ansible/modules/cloud/rackspace/rax_clb.py b/lib/ansible/modules/cloud/rackspace/rax_clb.py index 9d4d75c229..c0d62c5ebd 100644 --- a/lib/ansible/modules/cloud/rackspace/rax_clb.py +++ b/lib/ansible/modules/cloud/rackspace/rax_clb.py @@ -200,7 +200,7 @@ def cloud_load_balancer(module, state, name, meta, algorithm, port, protocol, 'protocol': protocol, 'timeout': timeout } - for att, value in atts.iteritems(): + for att, value in atts.items(): current = getattr(balancer, att) if current != value: changed = True diff --git a/lib/ansible/modules/cloud/rackspace/rax_clb_ssl.py b/lib/ansible/modules/cloud/rackspace/rax_clb_ssl.py index 37c35b32de..43320dd3f5 100644 --- a/lib/ansible/modules/cloud/rackspace/rax_clb_ssl.py +++ b/lib/ansible/modules/cloud/rackspace/rax_clb_ssl.py @@ -143,7 +143,7 @@ def cloud_load_balancer_ssl(module, loadbalancer, state, enabled, private_key, needs_change = False if existing_ssl: - for ssl_attr, value in ssl_attrs.iteritems(): + for ssl_attr, value in ssl_attrs.items(): if ssl_attr == 'privatekey': # The private key is not included in get_ssl_termination's # output (as it shouldn't be). Also, if you're changing the diff --git a/lib/ansible/modules/cloud/rackspace/rax_mon_check.py b/lib/ansible/modules/cloud/rackspace/rax_mon_check.py index c8bcfcd569..5370bc25f9 100644 --- a/lib/ansible/modules/cloud/rackspace/rax_mon_check.py +++ b/lib/ansible/modules/cloud/rackspace/rax_mon_check.py @@ -191,7 +191,7 @@ def cloud_check(module, state, entity_id, label, check_type, # Only force a recreation of the check if one of the *specified* # keys is missing or has a different value. if details: - for (key, value) in details.iteritems(): + for (key, value) in details.items(): if key not in check.details: should_delete = should_create = True elif value != check.details[key]: diff --git a/lib/ansible/modules/cloud/vmware/vmware_guest.py b/lib/ansible/modules/cloud/vmware/vmware_guest.py index cf3e83b383..55b75eb30e 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_guest.py +++ b/lib/ansible/modules/cloud/vmware/vmware_guest.py @@ -594,7 +594,7 @@ class PyVmomiHelper(object): mac = device.macAddress ips = list(device.ipAddress) netDict[mac] = ips - for k,v in netDict.iteritems(): + for k,v in netDict.items(): for ipaddress in v: if ipaddress: if '::' in ipaddress: @@ -979,7 +979,7 @@ class PyVmomiHelper(object): timeout=10, headers=None) # save all of the transfer data - for k,v in info.iteritems(): + for k,v in info.items(): result[k] = v # exit early if xfer failed @@ -1045,7 +1045,7 @@ class PyVmomiHelper(object): result['msg'] = str(rsp.read()) # save all of the transfer data - for k,v in info.iteritems(): + for k,v in info.items(): result[k] = v return result diff --git a/lib/ansible/modules/cloud/vmware/vsphere_guest.py b/lib/ansible/modules/cloud/vmware/vsphere_guest.py index 5425db6f89..a309064fe4 100644 --- a/lib/ansible/modules/cloud/vmware/vsphere_guest.py +++ b/lib/ansible/modules/cloud/vmware/vsphere_guest.py @@ -863,7 +863,7 @@ def reconfigure_vm(vsphere_client, vm, module, esxi, resource_pool, cluster_name if vm_extra_config: spec = spec_singleton(spec, request, vm) extra_config = [] - for k,v in vm_extra_config.iteritems(): + for k,v in vm_extra_config.items(): ec = spec.new_extraConfig() ec.set_element_key(str(k)) ec.set_element_value(str(v)) @@ -1085,7 +1085,7 @@ def reconfigure_net(vsphere_client, vm, module, esxi, resource_pool, guest, vm_n module.fail_json(msg="Cannot find datacenter named: %s" % datacenter) dcprops = VIProperty(vsphere_client, dcmor) nfmor = dcprops.networkFolder._obj - for k,v in vm_nic.iteritems(): + for k,v in vm_nic.items(): nicNum = k[len(k) -1] if vm_nic[k]['network_type'] == 'dvs': portgroupKey = find_portgroup_key(module, s, nfmor, vm_nic[k]['network']) @@ -1116,7 +1116,7 @@ def reconfigure_net(vsphere_client, vm, module, esxi, resource_pool, guest, vm_n module.exit_json() if len(nics) > 0: - for nic, obj in nics.iteritems(): + for nic, obj in nics.items(): """ 1,2 and 3 are used to mark which action should be taken 1 = from a distributed switch to a distributed switch @@ -1145,7 +1145,7 @@ def reconfigure_net(vsphere_client, vm, module, esxi, resource_pool, guest, vm_n "nic_backing").pyclass() nic_backing.set_element_deviceName(vm_nic[nic]['network']) dev._obj.set_element_backing(nic_backing) - for nic, obj in nics.iteritems(): + for nic, obj in nics.items(): dev = obj[0] spec = request.new_spec() nic_change = spec.new_deviceChange() @@ -1178,7 +1178,7 @@ def _build_folder_tree(nodes, parent): def _find_path_in_tree(tree, path): - for name, o in tree.iteritems(): + for name, o in tree.items(): if name == path[0]: if len(path) == 1: return o @@ -1231,7 +1231,7 @@ def create_vm(vsphere_client, module, esxi, resource_pool, cluster_name, guest, # try the legacy behaviour of just matching the folder name, so 'lamp' alone matches 'production/customerA/lamp' if vmfmor is None: - for mor, name in vsphere_client._get_managed_objects(MORTypes.Folder).iteritems(): + for mor, name in vsphere_client._get_managed_objects(MORTypes.Folder).items(): if name == vm_extra_config['folder']: vmfmor = mor diff --git a/lib/ansible/modules/clustering/consul.py b/lib/ansible/modules/clustering/consul.py index f523b96ae4..4fb244fda9 100644 --- a/lib/ansible/modules/clustering/consul.py +++ b/lib/ansible/modules/clustering/consul.py @@ -352,7 +352,7 @@ def get_consul_api(module, token=None): def get_service_by_id_or_name(consul_api, service_id_or_name): ''' iterate the registered services and find one with the given id ''' - for name, service in consul_api.agent.services().iteritems(): + for name, service in consul_api.agent.services().items(): if service['ID'] == service_id_or_name or service['Service'] == service_id_or_name: return ConsulService(loaded=service) diff --git a/lib/ansible/modules/clustering/consul_acl.py b/lib/ansible/modules/clustering/consul_acl.py index 845c26f98f..2de400aba9 100644 --- a/lib/ansible/modules/clustering/consul_acl.py +++ b/lib/ansible/modules/clustering/consul_acl.py @@ -217,7 +217,7 @@ def load_rules_for_token(module, consul_api, token): if info and info['Rules']: rule_set = hcl.loads(to_ascii(info['Rules'])) for rule_type in rule_set: - for pattern, policy in rule_set[rule_type].iteritems(): + for pattern, policy in rule_set[rule_type].items(): rules.add_rule(rule_type, Rule(pattern, policy['policy'])) return rules except Exception as e: @@ -272,7 +272,7 @@ class Rules: rules = "" for rule_type in RULE_TYPES: - for pattern, rule in self.rules[rule_type].iteritems(): + for pattern, rule in self.rules[rule_type].items(): rules += template % (rule_type, pattern, rule.policy) return to_ascii(rules) @@ -288,7 +288,7 @@ class Rules: return False for rule_type in RULE_TYPES: - for name, other_rule in other.rules[rule_type].iteritems(): + for name, other_rule in other.rules[rule_type].items(): if not name in self.rules[rule_type]: return False rule = self.rules[rule_type][name] diff --git a/lib/ansible/modules/commands/expect.py b/lib/ansible/modules/commands/expect.py index 77dcdfdfa0..39b6a8ed33 100644 --- a/lib/ansible/modules/commands/expect.py +++ b/lib/ansible/modules/commands/expect.py @@ -146,7 +146,7 @@ def main(): echo = module.params['echo'] events = dict() - for key, value in responses.iteritems(): + for key, value in responses.items(): if isinstance(value, list): response = response_closure(module, key, value) else: diff --git a/lib/ansible/modules/database/postgresql/postgresql_ext.py b/lib/ansible/modules/database/postgresql/postgresql_ext.py index 09b2903dab..51576eb1dc 100644 --- a/lib/ansible/modules/database/postgresql/postgresql_ext.py +++ b/lib/ansible/modules/database/postgresql/postgresql_ext.py @@ -152,7 +152,7 @@ def main(): "login_password":"password", "port":"port" } - kw = dict( (params_map[k], v) for (k, v) in module.params.iteritems() + kw = dict( (params_map[k], v) for (k, v) in module.params.items() if k in params_map and v != '' ) try: db_connection = psycopg2.connect(database=db, **kw) diff --git a/lib/ansible/modules/database/postgresql/postgresql_lang.py b/lib/ansible/modules/database/postgresql/postgresql_lang.py index 1a868bf67a..91e5732fb3 100644 --- a/lib/ansible/modules/database/postgresql/postgresql_lang.py +++ b/lib/ansible/modules/database/postgresql/postgresql_lang.py @@ -237,7 +237,7 @@ def main(): "port":"port", "db":"database" } - kw = dict( (params_map[k], v) for (k, v) in module.params.iteritems() + kw = dict( (params_map[k], v) for (k, v) in module.params.items() if k in params_map and v != "" ) try: db_connection = psycopg2.connect(**kw) diff --git a/lib/ansible/modules/database/postgresql/postgresql_schema.py b/lib/ansible/modules/database/postgresql/postgresql_schema.py index 85ac875126..892690197c 100644 --- a/lib/ansible/modules/database/postgresql/postgresql_schema.py +++ b/lib/ansible/modules/database/postgresql/postgresql_schema.py @@ -210,7 +210,7 @@ def main(): "login_password":"password", "port":"port" } - kw = dict( (params_map[k], v) for (k, v) in module.params.iteritems() + kw = dict( (params_map[k], v) for (k, v) in module.params.items() if k in params_map and v != '' ) # If a login_unix_socket is specified, incorporate it here. diff --git a/lib/ansible/modules/monitoring/logicmonitor.py b/lib/ansible/modules/monitoring/logicmonitor.py index fc1157bbb6..e60f759668 100644 --- a/lib/ansible/modules/monitoring/logicmonitor.py +++ b/lib/ansible/modules/monitoring/logicmonitor.py @@ -1557,7 +1557,7 @@ class Host(LogicMonitor): if properties is not None and properties is not {}: self.module.debug("Properties hash exists") propnum = 0 - for key, value in properties.iteritems(): + for key, value in properties.items(): h["propName" + str(propnum)] = key h["propValue" + str(propnum)] = value propnum = propnum + 1 @@ -2049,7 +2049,7 @@ class Hostgroup(LogicMonitor): if properties != {}: self.module.debug("Properties hash exists") propnum = 0 - for key, value in properties.iteritems(): + for key, value in properties.items(): h["propName" + str(propnum)] = key h["propValue" + str(propnum)] = value propnum = propnum + 1 diff --git a/lib/ansible/modules/network/cumulus/cl_bond.py b/lib/ansible/modules/network/cumulus/cl_bond.py index 43952b4cb7..60b2666561 100644 --- a/lib/ansible/modules/network/cumulus/cl_bond.py +++ b/lib/ansible/modules/network/cumulus/cl_bond.py @@ -459,7 +459,7 @@ def main(): # checks all lists and removes it, so that functions expecting # an empty list, get this result. May upstream this fix into # the AnsibleModule code to have it check for this. - for k, _param in module.params.iteritems(): + for k, _param in module.params.items(): if isinstance(_param, list): module.params[k] = [x for x in _param if x] diff --git a/lib/ansible/modules/network/cumulus/cl_bridge.py b/lib/ansible/modules/network/cumulus/cl_bridge.py index e2805307c2..642b78db62 100644 --- a/lib/ansible/modules/network/cumulus/cl_bridge.py +++ b/lib/ansible/modules/network/cumulus/cl_bridge.py @@ -385,7 +385,7 @@ def main(): # checks all lists and removes it, so that functions expecting # an empty list, get this result. May upstream this fix into # the AnsibleModule code to have it check for this. - for k, _param in module.params.iteritems(): + for k, _param in module.params.items(): if isinstance(_param, list): module.params[k] = [x for x in _param if x] diff --git a/lib/ansible/modules/network/cumulus/cl_interface.py b/lib/ansible/modules/network/cumulus/cl_interface.py index 9ef22f880e..eb5304ed09 100644 --- a/lib/ansible/modules/network/cumulus/cl_interface.py +++ b/lib/ansible/modules/network/cumulus/cl_interface.py @@ -421,7 +421,7 @@ def main(): # checks all lists and removes it, so that functions expecting # an empty list, get this result. May upstream this fix into # the AnsibleModule code to have it check for this. - for k, _param in module.params.iteritems(): + for k, _param in module.params.items(): if isinstance(_param, list): module.params[k] = [x for x in _param if x] diff --git a/lib/ansible/modules/network/dellos10/dellos10_facts.py b/lib/ansible/modules/network/dellos10/dellos10_facts.py index e73785a0e1..679f4e1060 100644 --- a/lib/ansible/modules/network/dellos10/dellos10_facts.py +++ b/lib/ansible/modules/network/dellos10/dellos10_facts.py @@ -443,7 +443,7 @@ def main(): module.exit_json(out=module.from_json(runner.items)) ansible_facts = dict() - for key, value in facts.iteritems(): + for key, value in facts.items(): key = 'ansible_net_%s' % key ansible_facts[key] = value diff --git a/lib/ansible/modules/network/dellos6/dellos6_facts.py b/lib/ansible/modules/network/dellos6/dellos6_facts.py index bfb82fbc6f..3ab0b2a992 100644 --- a/lib/ansible/modules/network/dellos6/dellos6_facts.py +++ b/lib/ansible/modules/network/dellos6/dellos6_facts.py @@ -240,7 +240,7 @@ class Interfaces(FactsBase): def populate_interfaces(self, interfaces, desc, properties): facts = dict() - for key, value in interfaces.iteritems(): + for key, value in interfaces.items(): intf = dict() intf['description'] = self.parse_description(key,desc) intf['macaddress'] = self.parse_macaddress(value) @@ -433,7 +433,7 @@ def main(): module.exit_json(out=module.from_json(runner.items)) ansible_facts = dict() - for key, value in facts.iteritems(): + for key, value in facts.items(): key = 'ansible_net_%s' % key ansible_facts[key] = value diff --git a/lib/ansible/modules/network/dellos9/dellos9_facts.py b/lib/ansible/modules/network/dellos9/dellos9_facts.py index fe752ac373..e74d0eeb65 100644 --- a/lib/ansible/modules/network/dellos9/dellos9_facts.py +++ b/lib/ansible/modules/network/dellos9/dellos9_facts.py @@ -286,7 +286,7 @@ class Interfaces(FactsBase): def populate_interfaces(self, interfaces): facts = dict() - for key, value in interfaces.iteritems(): + for key, value in interfaces.items(): intf = dict() intf['description'] = self.parse_description(value) intf['macaddress'] = self.parse_macaddress(value) @@ -307,7 +307,7 @@ class Interfaces(FactsBase): return facts def populate_ipv6_interfaces(self, data): - for key, value in data.iteritems(): + for key, value in data.items(): self.facts['interfaces'][key]['ipv6'] = list() addresses = re.findall(r'\s+(.+), subnet', value, re.M) subnets = re.findall(r', subnet is (\S+)', value, re.M) @@ -556,7 +556,7 @@ def main(): module.exit_json(out=module.from_json(runner.items)) ansible_facts = dict() - for key, value in facts.iteritems(): + for key, value in facts.items(): key = 'ansible_net_%s' % key ansible_facts[key] = value diff --git a/lib/ansible/modules/network/eos/eos_eapi.py b/lib/ansible/modules/network/eos/eos_eapi.py index a5cfafabd6..ea51cdeed6 100644 --- a/lib/ansible/modules/network/eos/eos_eapi.py +++ b/lib/ansible/modules/network/eos/eos_eapi.py @@ -220,7 +220,7 @@ def get_instance(module): def started(module, instance, commands): commands.append('no shutdown') setters = set() - for key, value in module.argument_spec.iteritems(): + for key, value in module.argument_spec.items(): if module.params[key] is not None: setter = value.get('setter') or 'set_%s' % key if setter not in setters: diff --git a/lib/ansible/modules/network/f5/bigip_gtm_facts.py b/lib/ansible/modules/network/f5/bigip_gtm_facts.py index 9e3fc8b492..039fec5d58 100644 --- a/lib/ansible/modules/network/f5/bigip_gtm_facts.py +++ b/lib/ansible/modules/network/f5/bigip_gtm_facts.py @@ -227,7 +227,7 @@ class BigIpGtmFactsCommon(object): result = dict() for attribute in self.attributes_to_remove: parameters.pop(attribute, None) - for key, val in parameters.iteritems(): + for key, val in parameters.items(): result[key] = str(val) return result @@ -276,7 +276,7 @@ class BigIpGtmFactsPools(BigIpGtmFactsCommon): def get_facts_with_types(self): result = [] - for key, type in self.gtm_types.iteritems(): + for key, type in self.gtm_types.items(): facts = self.get_all_facts_by_type(key, type) if facts: result.append(facts) @@ -330,7 +330,7 @@ class BigIpGtmFactsWideIps(BigIpGtmFactsCommon): def get_facts_with_types(self): result = [] - for key, type in self.gtm_types.iteritems(): + for key, type in self.gtm_types.items(): facts = self.get_all_facts_by_type(key, type) if facts: result.append(facts) diff --git a/lib/ansible/modules/network/nxos/nxos_aaa_server.py b/lib/ansible/modules/network/nxos/nxos_aaa_server.py index 6b4f52ae4e..34f732993e 100644 --- a/lib/ansible/modules/network/nxos/nxos_aaa_server.py +++ b/lib/ansible/modules/network/nxos/nxos_aaa_server.py @@ -164,6 +164,7 @@ import re from ansible.module_utils.basic import get_exception from ansible.module_utils.netcfg import NetworkConfig, ConfigLine from ansible.module_utils.shell import ShellError +from ansible.module_utils.six import iteritems try: from ansible.module_utils.nxos import get_module @@ -508,7 +509,7 @@ def main(): server_timeout=server_timeout, directed_request=directed_request) changed = False - proposed = dict((k, v) for k, v in args.iteritems() if v is not None) + proposed = dict((k, v) for k, v in args.items() if v is not None) existing = get_aaa_server_info(server_type, module) end_state = existing @@ -531,15 +532,15 @@ def main(): module.fail_json( msg='server_timeout must be an integer between 1 and 60') - delta = dict(set(proposed.iteritems()).difference( - existing.iteritems())) + delta = dict(set(proposed.items()).difference( + existing.items())) if delta: command = config_aaa_server(delta, server_type) if command: commands.append(command) elif state == 'default': - for key, value in proposed.iteritems(): + for key, value in proposed.items(): if key != 'server_type' and value != 'default': module.fail_json( msg='Parameters must be set to "default"' diff --git a/lib/ansible/modules/network/nxos/nxos_aaa_server_host.py b/lib/ansible/modules/network/nxos/nxos_aaa_server_host.py index aef2af144f..fd023adf9c 100644 --- a/lib/ansible/modules/network/nxos/nxos_aaa_server_host.py +++ b/lib/ansible/modules/network/nxos/nxos_aaa_server_host.py @@ -513,7 +513,7 @@ def main(): auth_port=auth_port, acct_port=acct_port, tacacs_port=tacacs_port) - proposed = dict((k, v) for k, v in args.iteritems() if v is not None) + proposed = dict((k, v) for k, v in args.items() if v is not None) changed = False if encrypt_type and not key: @@ -543,7 +543,7 @@ def main(): msg='host_timeout must be an integer between 1 and 60') delta = dict( - set(proposed.iteritems()).difference(existing.iteritems())) + set(proposed.items()).difference(existing.items())) if delta: union = existing.copy() union.update(delta) @@ -553,7 +553,7 @@ def main(): elif state == 'absent': intersect = dict( - set(proposed.iteritems()).intersection(existing.iteritems())) + set(proposed.items()).intersection(existing.items())) if intersect.get('address') and intersect.get('server_type'): command = 'no {0}-server host {1}'.format( intersect.get('server_type'), intersect.get('address')) diff --git a/lib/ansible/modules/network/nxos/nxos_acl.py b/lib/ansible/modules/network/nxos/nxos_acl.py index 63762f9761..a27b8e43ec 100644 --- a/lib/ansible/modules/network/nxos/nxos_acl.py +++ b/lib/ansible/modules/network/nxos/nxos_acl.py @@ -525,13 +525,13 @@ def get_acl(module, acl_name, seq_number): options['time_range'] = each.get('timerange') options_no_null = {} - for key, value in options.iteritems(): + for key, value in options.items(): if value is not None: options_no_null[key] = value keep['options'] = options_no_null - for key, value in temp.iteritems(): + for key, value in temp.items(): if value: keep[key] = value # ensure options is always in the dict @@ -600,7 +600,7 @@ def config_acl_options(options): options.pop('time_range') command = '' - for option, value in options.iteritems(): + for option, value in options.items(): if option in ENABLE_ONLY: if value == 'enable': command += ' ' + option @@ -733,11 +733,11 @@ def main(): 'dest_port1', 'dest_port2', 'remark'] proposed_core = dict((param, value) for (param, value) in - module.params.iteritems() + module.params.items() if param in CORE and value is not None) proposed_options = dict((param, value) for (param, value) in - module.params.iteritems() + module.params.items() if param in OPTIONS_NAMES and value is not None) proposed = {} proposed.update(proposed_core) @@ -759,12 +759,12 @@ def main(): if not existing_core.get('remark'): delta_core = dict( - set(proposed_core.iteritems()).difference( - existing_core.iteritems()) + set(proposed_core.items()).difference( + existing_core.items()) ) delta_options = dict( - set(proposed_options.iteritems()).difference( - existing_options.iteritems()) + set(proposed_options.items()).difference( + existing_options.items()) ) if state == 'present': diff --git a/lib/ansible/modules/network/nxos/nxos_bgp.py b/lib/ansible/modules/network/nxos/nxos_bgp.py index a6306fe74c..a1d99ba102 100644 --- a/lib/ansible/modules/network/nxos/nxos_bgp.py +++ b/lib/ansible/modules/network/nxos/nxos_bgp.py @@ -755,7 +755,7 @@ def state_present(module, existing, proposed, candidate): proposed_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, proposed) existing_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, existing) - for key, value in proposed_commands.iteritems(): + for key, value in proposed_commands.items(): if value is True: commands.append(key) elif value is False: @@ -951,7 +951,7 @@ def main(): ] if module.params['vrf'] != 'default': - for param, inserted_value in module.params.iteritems(): + for param, inserted_value in module.params.items(): if param in GLOBAL_PARAMS and inserted_value: module.fail_json(msg='Global params can be modified only' ' under "default" VRF.', @@ -968,10 +968,10 @@ def main(): existing_asn=existing.get('asn')) end_state = existing - proposed_args = dict((k, v) for k, v in module.params.iteritems() + proposed_args = dict((k, v) for k, v in module.params.items() if v is not None and k in args) proposed = {} - for key, value in proposed_args.iteritems(): + for key, value in proposed_args.items(): if key != 'asn' and key != 'vrf': if str(value).lower() == 'default': value = PARAM_TO_DEFAULT_KEYMAP.get(key) diff --git a/lib/ansible/modules/network/nxos/nxos_bgp_af.py b/lib/ansible/modules/network/nxos/nxos_bgp_af.py index 3b804d51a3..11f1a9bfaf 100644 --- a/lib/ansible/modules/network/nxos/nxos_bgp_af.py +++ b/lib/ansible/modules/network/nxos/nxos_bgp_af.py @@ -736,7 +736,7 @@ def fix_proposed(module, proposed, existing): commands = list() command = '' fixed_proposed = {} - for key, value in proposed.iteritems(): + for key, value in proposed.items(): if key in DAMPENING_PARAMS: if value != 'default': command = 'dampening {0} {1} {2} {3}'.format( @@ -874,7 +874,7 @@ def state_present(module, existing, proposed, candidate): fixed_proposed, commands = fix_proposed(module, proposed, existing) proposed_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, fixed_proposed) existing_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, existing) - for key, value in proposed_commands.iteritems(): + for key, value in proposed_commands.items(): if key == 'address-family': addr_family_command = "address-family {0} {1}".format( module.params['afi'], module.params['safi']) @@ -1060,7 +1060,7 @@ def main(): existing_asn=existing.get('asn')) end_state = existing - proposed_args = dict((k, v) for k, v in module.params.iteritems() + proposed_args = dict((k, v) for k, v in module.params.items() if v is not None and k in args) if proposed_args.get('networks'): @@ -1071,7 +1071,7 @@ def main(): proposed_args['inject_map'] = 'default' proposed = {} - for key, value in proposed_args.iteritems(): + for key, value in proposed_args.items(): if key not in ['asn', 'vrf']: if str(value).lower() == 'default': value = PARAM_TO_DEFAULT_KEYMAP.get(key) diff --git a/lib/ansible/modules/network/nxos/nxos_bgp_neighbor.py b/lib/ansible/modules/network/nxos/nxos_bgp_neighbor.py index f0cc614581..f22fd6ccff 100644 --- a/lib/ansible/modules/network/nxos/nxos_bgp_neighbor.py +++ b/lib/ansible/modules/network/nxos/nxos_bgp_neighbor.py @@ -576,7 +576,7 @@ def state_present(module, existing, proposed, candidate): proposed_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, proposed) existing_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, existing) - for key, value in proposed_commands.iteritems(): + for key, value in proposed_commands.items(): if value is True: commands.append(key) @@ -725,11 +725,11 @@ def main(): existing_asn=existing.get('asn')) end_state = existing - proposed_args = dict((k, v) for k, v in module.params.iteritems() + proposed_args = dict((k, v) for k, v in module.params.items() if v is not None and k in args) proposed = {} - for key, value in proposed_args.iteritems(): + for key, value in proposed_args.items(): if key not in ['asn', 'vrf', 'neighbor', 'pwd_type']: if str(value).lower() == 'default': value = PARAM_TO_DEFAULT_KEYMAP.get(key) diff --git a/lib/ansible/modules/network/nxos/nxos_bgp_neighbor_af.py b/lib/ansible/modules/network/nxos/nxos_bgp_neighbor_af.py index e7d9ea6481..faca1b1532 100644 --- a/lib/ansible/modules/network/nxos/nxos_bgp_neighbor_af.py +++ b/lib/ansible/modules/network/nxos/nxos_bgp_neighbor_af.py @@ -895,7 +895,7 @@ def state_present(module, existing, proposed, candidate): 'route-map out', 'soft-reconfiguration inbound' ] - for key, value in proposed_commands.iteritems(): + for key, value in proposed_commands.items(): if key == 'send-community' and value == 'none': commands.append('{0}'.format(key)) @@ -1070,11 +1070,11 @@ def main(): module.params['advertise_map_non_exist'] = 'default' end_state = existing - proposed_args = dict((k, v) for k, v in module.params.iteritems() + proposed_args = dict((k, v) for k, v in module.params.items() if v is not None and k in args) proposed = {} - for key, value in proposed_args.iteritems(): + for key, value in proposed_args.items(): if key not in ['asn', 'vrf', 'neighbor']: if not isinstance(value, list): if str(value).lower() == 'true': diff --git a/lib/ansible/modules/network/nxos/nxos_evpn_global.py b/lib/ansible/modules/network/nxos/nxos_evpn_global.py index 375269e070..ed4a6a636c 100644 --- a/lib/ansible/modules/network/nxos/nxos_evpn_global.py +++ b/lib/ansible/modules/network/nxos/nxos_evpn_global.py @@ -269,7 +269,7 @@ def get_commands(module, existing, proposed, candidate): proposed_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, proposed) existing_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, existing) - for key, value in proposed_commands.iteritems(): + for key, value in proposed_commands.items(): if value is True: commands.append(key) elif value is False: diff --git a/lib/ansible/modules/network/nxos/nxos_evpn_vni.py b/lib/ansible/modules/network/nxos/nxos_evpn_vni.py index 5d20addd63..e70d933acd 100644 --- a/lib/ansible/modules/network/nxos/nxos_evpn_vni.py +++ b/lib/ansible/modules/network/nxos/nxos_evpn_vni.py @@ -330,7 +330,7 @@ def get_existing(module, args): else: existing[arg] = get_route_target_value(arg, config, module) - existing_fix = dict((k, v) for k, v in existing.iteritems() if v) + existing_fix = dict((k, v) for k, v in existing.items() if v) if existing_fix: existing['vni'] = module.params['vni'] else: @@ -358,7 +358,7 @@ def state_present(module, existing, proposed): proposed_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, proposed) existing_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, existing) - for key, value in proposed_commands.iteritems(): + for key, value in proposed_commands.items(): if key.startswith('route-target'): if value == ['default']: existing_value = existing_commands.get(key) @@ -434,11 +434,11 @@ def main(): existing = invoke('get_existing', module, args) end_state = existing - proposed_args = dict((k, v) for k, v in module.params.iteritems() + proposed_args = dict((k, v) for k, v in module.params.items() if v is not None and k in args) proposed = {} - for key, value in proposed_args.iteritems(): + for key, value in proposed_args.items(): if key != 'vni': if value == 'true': value = True diff --git a/lib/ansible/modules/network/nxos/nxos_hsrp.py b/lib/ansible/modules/network/nxos/nxos_hsrp.py index 9e9e7e3542..f1e069d144 100644 --- a/lib/ansible/modules/network/nxos/nxos_hsrp.py +++ b/lib/ansible/modules/network/nxos/nxos_hsrp.py @@ -512,7 +512,7 @@ def get_commands_config_hsrp(delta, interface, args): elif preempt == 'disabled': delta['preempt'] = 'no preempt' - for key, value in delta.iteritems(): + for key, value in delta.items(): command = config_args.get(key, 'DNE').format(**delta) if command and command != 'DNE': if key == 'group': @@ -664,7 +664,7 @@ def main(): preempt=preempt, vip=vip, auth_type=auth_type, auth_string=auth_string) - proposed = dict((k, v) for k, v in args.iteritems() if v is not None) + proposed = dict((k, v) for k, v in args.items() if v is not None) existing = get_hsrp_group(group, interface, module) @@ -685,7 +685,7 @@ def main(): commands = [] if state == 'present': delta = dict( - set(proposed.iteritems()).difference(existing.iteritems())) + set(proposed.items()).difference(existing.items())) if delta: command = get_commands_config_hsrp(delta, interface, args) commands.extend(command) diff --git a/lib/ansible/modules/network/nxos/nxos_igmp.py b/lib/ansible/modules/network/nxos/nxos_igmp.py index 3cd5a0dbd2..def225466a 100644 --- a/lib/ansible/modules/network/nxos/nxos_igmp.py +++ b/lib/ansible/modules/network/nxos/nxos_igmp.py @@ -301,11 +301,11 @@ def get_commands(module, existing, proposed, candidate): proposed_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, proposed) existing_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, existing) if module.params['state'] == 'default': - for key, value in proposed_commands.iteritems(): + for key, value in proposed_commands.items(): if existing_commands.get(key): commands.append('no {0}'.format(key)) else: - for key, value in proposed_commands.iteritems(): + for key, value in proposed_commands.items(): if value is True: commands.append(key) else: @@ -361,7 +361,7 @@ def main(): existing = invoke('get_existing', module, args) end_state = existing - proposed = dict((k, v) for k, v in module.params.iteritems() + proposed = dict((k, v) for k, v in module.params.items() if v is not None and k in args) proposed_args = proposed.copy() diff --git a/lib/ansible/modules/network/nxos/nxos_igmp_interface.py b/lib/ansible/modules/network/nxos/nxos_igmp_interface.py index d5e3226d34..e6e6107ead 100644 --- a/lib/ansible/modules/network/nxos/nxos_igmp_interface.py +++ b/lib/ansible/modules/network/nxos/nxos_igmp_interface.py @@ -624,7 +624,7 @@ def config_igmp_interface(delta, found_both, found_prefix): commands = [] command = None - for key, value in delta.iteritems(): + for key, value in delta.items(): if key == 'oif_source' or found_both or found_prefix: pass elif key == 'oif_prefix': @@ -669,7 +669,7 @@ def get_igmp_interface_defaults(): group_timeout=group_timeout, report_llg=report_llg, immediate_leave=immediate_leave) - default = dict((param, value) for (param, value) in args.iteritems() + default = dict((param, value) for (param, value) in args.items() if value is not None) return default @@ -678,7 +678,7 @@ def get_igmp_interface_defaults(): def config_default_igmp_interface(existing, delta, found_both, found_prefix): commands = [] proposed = get_igmp_interface_defaults() - delta = dict(set(proposed.iteritems()).difference(existing.iteritems())) + delta = dict(set(proposed.items()).difference(existing.items())) if delta: command = config_igmp_interface(delta, found_both, found_prefix) @@ -816,7 +816,7 @@ def main(): changed = False commands = [] - proposed = dict((k, v) for k, v in module.params.iteritems() + proposed = dict((k, v) for k, v in module.params.items() if v is not None and k in args) CANNOT_ABSENT = ['version', 'startup_query_interval', @@ -833,7 +833,7 @@ def main(): 'state=absent') # delta check for all params except oif_prefix and oif_source - delta = dict(set(proposed.iteritems()).difference(existing.iteritems())) + delta = dict(set(proposed.items()).difference(existing.items())) # now check to see there is a delta for prefix and source command option found_both = False diff --git a/lib/ansible/modules/network/nxos/nxos_igmp_snooping.py b/lib/ansible/modules/network/nxos/nxos_igmp_snooping.py index 7044adecd1..fbd6ab9c54 100644 --- a/lib/ansible/modules/network/nxos/nxos_igmp_snooping.py +++ b/lib/ansible/modules/network/nxos/nxos_igmp_snooping.py @@ -449,7 +449,7 @@ def config_igmp_snooping(delta, existing, default=False): commands = [] command = None - for key, value in delta.iteritems(): + for key, value in delta.items(): if value: if default and key == 'group_timeout': if existing.get(key): @@ -477,7 +477,7 @@ def get_igmp_snooping_defaults(): report_supp=report_supp, v3_report_supp=v3_report_supp, group_timeout=group_timeout) - default = dict((param, value) for (param, value) in args.iteritems() + default = dict((param, value) for (param, value) in args.items() if value is not None) return default @@ -506,7 +506,7 @@ def main(): report_supp=report_supp, v3_report_supp=v3_report_supp, group_timeout=group_timeout) - proposed = dict((param, value) for (param, value) in args.iteritems() + proposed = dict((param, value) for (param, value) in args.items() if value is not None) existing = get_igmp_snooping(module) @@ -516,7 +516,7 @@ def main(): commands = [] if state == 'present': delta = dict( - set(proposed.iteritems()).difference(existing.iteritems()) + set(proposed.items()).difference(existing.items()) ) if delta: command = config_igmp_snooping(delta, existing) @@ -525,7 +525,7 @@ def main(): elif state == 'default': proposed = get_igmp_snooping_defaults() delta = dict( - set(proposed.iteritems()).difference(existing.iteritems()) + set(proposed.items()).difference(existing.items()) ) if delta: command = config_igmp_snooping(delta, existing, default=True) diff --git a/lib/ansible/modules/network/nxos/nxos_interface.py b/lib/ansible/modules/network/nxos/nxos_interface.py index b65fb9d310..05dc3c155a 100644 --- a/lib/ansible/modules/network/nxos/nxos_interface.py +++ b/lib/ansible/modules/network/nxos/nxos_interface.py @@ -907,8 +907,8 @@ def main(): existing) commands.append(cmds) else: - delta = dict(set(proposed.iteritems()).difference( - existing.iteritems())) + delta = dict(set(proposed.items()).difference( + existing.items())) if delta: cmds = get_interface_config_commands(delta, normalized_interface, diff --git a/lib/ansible/modules/network/nxos/nxos_interface_ospf.py b/lib/ansible/modules/network/nxos/nxos_interface_ospf.py index 9f63bf57a0..c69e30e09b 100644 --- a/lib/ansible/modules/network/nxos/nxos_interface_ospf.py +++ b/lib/ansible/modules/network/nxos/nxos_interface_ospf.py @@ -507,7 +507,7 @@ def state_present(module, existing, proposed, candidate): proposed_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, proposed) existing_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, existing) - for key, value in proposed_commands.iteritems(): + for key, value in proposed_commands.items(): if value is True: commands.append(key) elif value is False: @@ -536,7 +536,7 @@ def state_absent(module, existing, proposed, candidate): parents = ['interface {0}'.format(module.params['interface'].capitalize())] existing_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, existing) - for key, value in existing_commands.iteritems(): + for key, value in existing_commands.items(): if value: if key.startswith('ip ospf message-digest-key'): if 'options' not in key: @@ -632,11 +632,11 @@ def main(): existing = invoke('get_existing', module, args) end_state = existing - proposed_args = dict((k, v) for k, v in module.params.iteritems() + proposed_args = dict((k, v) for k, v in module.params.items() if v is not None and k in args) proposed = {} - for key, value in proposed_args.iteritems(): + for key, value in proposed_args.items(): if key != 'interface': if str(value).lower() == 'true': value = True diff --git a/lib/ansible/modules/network/nxos/nxos_ip_interface.py b/lib/ansible/modules/network/nxos/nxos_ip_interface.py index b860ea20b6..7431be75ca 100644 --- a/lib/ansible/modules/network/nxos/nxos_ip_interface.py +++ b/lib/ansible/modules/network/nxos/nxos_ip_interface.py @@ -660,7 +660,7 @@ def main(): existing, address_list = get_ip_interface(interface, version, module) args = dict(addr=addr, mask=mask, interface=interface) - proposed = dict((k, v) for k, v in args.iteritems() if v is not None) + proposed = dict((k, v) for k, v in args.items() if v is not None) commands = [] changed = False end_state = existing diff --git a/lib/ansible/modules/network/nxos/nxos_mtu.py b/lib/ansible/modules/network/nxos/nxos_mtu.py index 48a92c2f94..392c4ffbad 100644 --- a/lib/ansible/modules/network/nxos/nxos_mtu.py +++ b/lib/ansible/modules/network/nxos/nxos_mtu.py @@ -411,7 +411,7 @@ def get_commands_config_mtu(delta, interface): } commands = [] - for param, value in delta.iteritems(): + for param, value in delta.items(): command = CONFIG_ARGS.get(param, 'DNE').format(**delta) if command and command != 'DNE': commands.append(command) @@ -428,7 +428,7 @@ def get_commands_remove_mtu(delta, interface): 'sysmtu': 'no system jumbomtu {sysmtu}', } commands = [] - for param, value in delta.iteritems(): + for param, value in delta.items(): command = CONFIG_ARGS.get(param, 'DNE').format(**delta) if command and command != 'DNE': commands.append(command) @@ -552,8 +552,8 @@ def main(): 'number between 576 and 9216') args = dict(mtu=mtu, sysmtu=sysmtu) - proposed = dict((k, v) for k, v in args.iteritems() if v is not None) - delta = dict(set(proposed.iteritems()).difference(existing.iteritems())) + proposed = dict((k, v) for k, v in args.items() if v is not None) + delta = dict(set(proposed.items()).difference(existing.items())) changed = False end_state = existing @@ -565,7 +565,7 @@ def main(): commands.append(command) elif state == 'absent': - common = set(proposed.iteritems()).intersection(existing.iteritems()) + common = set(proposed.items()).intersection(existing.items()) if common: command = get_commands_remove_mtu(dict(common), interface) commands.append(command) diff --git a/lib/ansible/modules/network/nxos/nxos_ntp.py b/lib/ansible/modules/network/nxos/nxos_ntp.py index 4c6e406e6b..c54919283b 100644 --- a/lib/ansible/modules/network/nxos/nxos_ntp.py +++ b/lib/ansible/modules/network/nxos/nxos_ntp.py @@ -439,7 +439,7 @@ def get_ntp_peer(module): args = dict(peer_type=peer_type, address=address, prefer=prefer, vrf_name=vrf_name, key_id=key_id) - ntp_peer = dict((k, v) for k, v in args.iteritems()) + ntp_peer = dict((k, v) for k, v in args.items()) ntp_peer_list.append(ntp_peer) except AttributeError: ntp_peer_list = [] @@ -573,7 +573,7 @@ def main(): prefer=prefer, vrf_name=vrf_name, source_type=source_type, source=source) - proposed = dict((k, v) for k, v in args.iteritems() if v is not None) + proposed = dict((k, v) for k, v in args.items() if v is not None) existing, peer_server_list = get_ntp_existing(address, peer_type, module) @@ -582,7 +582,7 @@ def main(): commands = [] if state == 'present': - delta = dict(set(proposed.iteritems()).difference(existing.iteritems())) + delta = dict(set(proposed.items()).difference(existing.items())) if delta: command = config_ntp(delta, existing) if command: diff --git a/lib/ansible/modules/network/nxos/nxos_ntp_auth.py b/lib/ansible/modules/network/nxos/nxos_ntp_auth.py index 25071d6b89..4d7be33e34 100644 --- a/lib/ansible/modules/network/nxos/nxos_ntp_auth.py +++ b/lib/ansible/modules/network/nxos/nxos_ntp_auth.py @@ -518,12 +518,12 @@ def main(): authentication=authentication) changed = False - proposed = dict((k, v) for k, v in args.iteritems() if v is not None) + proposed = dict((k, v) for k, v in args.items() if v is not None) existing = get_ntp_auth_info(key_id, module) end_state = existing - delta = dict(set(proposed.iteritems()).difference(existing.iteritems())) + delta = dict(set(proposed.items()).difference(existing.items())) commands = [] if state == 'present': @@ -553,7 +553,7 @@ def main(): clie = get_exception() module.fail_json(msg=str(clie) + ": " + cmds) end_state = get_ntp_auth_info(key_id, module) - delta = dict(set(end_state.iteritems()).difference(existing.iteritems())) + delta = dict(set(end_state.items()).difference(existing.items())) if delta or (len(existing) != len(end_state)): changed = True if 'configure' in cmds: diff --git a/lib/ansible/modules/network/nxos/nxos_ntp_options.py b/lib/ansible/modules/network/nxos/nxos_ntp_options.py index 010e67c886..9ef36d7522 100644 --- a/lib/ansible/modules/network/nxos/nxos_ntp_options.py +++ b/lib/ansible/modules/network/nxos/nxos_ntp_options.py @@ -468,13 +468,13 @@ def main(): args = dict(master=master, stratum=stratum, logging=logging) changed = False - proposed = dict((k, v) for k, v in args.iteritems() if v is not None) + proposed = dict((k, v) for k, v in args.items() if v is not None) if master is False: proposed['stratum'] = None stratum = None - delta = dict(set(proposed.iteritems()).difference(existing.iteritems())) + delta = dict(set(proposed.items()).difference(existing.items())) delta_stratum = delta.get('stratum') if delta_stratum: @@ -488,8 +488,8 @@ def main(): commands.append(command) elif state == 'absent': if existing: - isection = dict(set(proposed.iteritems()).intersection( - existing.iteritems())) + isection = dict(set(proposed.items()).intersection( + existing.items())) command = config_ntp_options(isection, flip=True) if command: commands.append(command) diff --git a/lib/ansible/modules/network/nxos/nxos_nxapi.py b/lib/ansible/modules/network/nxos/nxos_nxapi.py index 5317869f5a..9a3985a92f 100644 --- a/lib/ansible/modules/network/nxos/nxos_nxapi.py +++ b/lib/ansible/modules/network/nxos/nxos_nxapi.py @@ -177,7 +177,7 @@ def get_instance(module): def present(module, instance, commands): commands.append('feature nxapi') setters = set() - for key, value in module.argument_spec.iteritems(): + for key, value in module.argument_spec.items(): setter = value.get('setter') or 'set_%s' % key if setter not in setters: setters.add(setter) diff --git a/lib/ansible/modules/network/nxos/nxos_ospf_vrf.py b/lib/ansible/modules/network/nxos/nxos_ospf_vrf.py index 35e0d398f0..e2fb59043b 100644 --- a/lib/ansible/modules/network/nxos/nxos_ospf_vrf.py +++ b/lib/ansible/modules/network/nxos/nxos_ospf_vrf.py @@ -427,7 +427,7 @@ def state_present(module, existing, proposed, candidate): proposed_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, proposed) existing_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, existing) - for key, value in proposed_commands.iteritems(): + for key, value in proposed_commands.items(): if value is True: commands.append(key) @@ -481,7 +481,7 @@ def state_absent(module, existing, proposed, candidate): parents = ['router ospf {0}'.format(module.params['ospf'])] if module.params['vrf'] == 'default': existing_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, existing) - for key, value in existing_commands.iteritems(): + for key, value in existing_commands.items(): if value: if key == 'timers throttle lsa': command = 'no {0} {1} {2} {3}'.format( @@ -548,11 +548,11 @@ def main(): existing = invoke('get_existing', module, args) end_state = existing - proposed_args = dict((k, v) for k, v in module.params.iteritems() + proposed_args = dict((k, v) for k, v in module.params.items() if v is not None and k in args) proposed = {} - for key, value in proposed_args.iteritems(): + for key, value in proposed_args.items(): if key != 'interface': if str(value).lower() == 'true': value = True diff --git a/lib/ansible/modules/network/nxos/nxos_overlay_global.py b/lib/ansible/modules/network/nxos/nxos_overlay_global.py index 5b7d89c4b2..0bf78baeac 100644 --- a/lib/ansible/modules/network/nxos/nxos_overlay_global.py +++ b/lib/ansible/modules/network/nxos/nxos_overlay_global.py @@ -309,7 +309,7 @@ def get_commands(module, existing, proposed, candidate): proposed_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, proposed) existing_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, existing) - for key, value in proposed_commands.iteritems(): + for key, value in proposed_commands.items(): if value == 'default': existing_value = existing_commands.get(key) if existing_value: @@ -385,7 +385,7 @@ def main(): existing = invoke('get_existing', module, args) end_state = existing - proposed = dict((k, v) for k, v in module.params.iteritems() + proposed = dict((k, v) for k, v in module.params.items() if v is not None and k in args) result = {} diff --git a/lib/ansible/modules/network/nxos/nxos_pim.py b/lib/ansible/modules/network/nxos/nxos_pim.py index 659686ceaa..41571522a3 100644 --- a/lib/ansible/modules/network/nxos/nxos_pim.py +++ b/lib/ansible/modules/network/nxos/nxos_pim.py @@ -275,7 +275,7 @@ def get_commands(module, existing, proposed, candidate): proposed_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, proposed) existing_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, existing) - for key, value in proposed_commands.iteritems(): + for key, value in proposed_commands.items(): command = '{0} {1}'.format(key, value) commands.append(command) @@ -305,7 +305,7 @@ def main(): existing = invoke('get_existing', module, args) end_state = existing - proposed = dict((k, v) for k, v in module.params.iteritems() + proposed = dict((k, v) for k, v in module.params.items() if v is not None and k in args) result = {} diff --git a/lib/ansible/modules/network/nxos/nxos_pim_interface.py b/lib/ansible/modules/network/nxos/nxos_pim_interface.py index 119785d47e..60cabe5b41 100644 --- a/lib/ansible/modules/network/nxos/nxos_pim_interface.py +++ b/lib/ansible/modules/network/nxos/nxos_pim_interface.py @@ -661,7 +661,7 @@ def config_pim_interface(delta, existing, jp_bidir, isauth): if command: commands.append(command) - for k, v in delta.iteritems(): + for k, v in delta.items(): if k in ['dr_prio', 'hello_interval', 'hello_auth_key', 'border', 'sparse']: if v: @@ -726,7 +726,7 @@ def get_pim_interface_defaults(): hello_interval=hello_interval, hello_auth_key=hello_auth_key) - default = dict((param, value) for (param, value) in args.iteritems() + default = dict((param, value) for (param, value) in args.items() if value is not None) return default @@ -746,7 +746,7 @@ def default_pim_interface_policies(existing, jp_bidir): elif not jp_bidir: command = None - for k, v in existing.iteritems(): + for k, v in existing.items(): if k == 'jp_policy_in': if existing.get('jp_policy_in'): if existing.get('jp_type_in') == 'prefix': @@ -783,8 +783,8 @@ def config_pim_interface_defaults(existing, jp_bidir, isauth): # returns a dict defaults = get_pim_interface_defaults() - delta = dict(set(defaults.iteritems()).difference( - existing.iteritems())) + delta = dict(set(defaults.items()).difference( + existing.items())) if delta: # returns a list command = config_pim_interface(delta, existing, @@ -866,7 +866,7 @@ def main(): 'neighbor_type', 'neighbor_policy' ] - proposed = dict((k, v) for k, v in module.params.iteritems() + proposed = dict((k, v) for k, v in module.params.items() if v is not None and k in args) ''' @@ -879,7 +879,7 @@ def main(): if hello_interval: proposed['hello_interval'] = str(proposed['hello_interval'] * 1000) - delta = dict(set(proposed.iteritems()).difference(existing.iteritems())) + delta = dict(set(proposed.items()).difference(existing.items())) if state == 'present': if delta: diff --git a/lib/ansible/modules/network/nxos/nxos_pim_rp_address.py b/lib/ansible/modules/network/nxos/nxos_pim_rp_address.py index c53747e02d..8cd8d96575 100644 --- a/lib/ansible/modules/network/nxos/nxos_pim_rp_address.py +++ b/lib/ansible/modules/network/nxos/nxos_pim_rp_address.py @@ -375,11 +375,11 @@ def main(): existing = invoke('get_existing', module, args) end_state = existing - proposed_args = dict((k, v) for k, v in module.params.iteritems() + proposed_args = dict((k, v) for k, v in module.params.items() if v is not None and k in args) proposed = {} - for key, value in proposed_args.iteritems(): + for key, value in proposed_args.items(): if str(value).lower() == 'true': value = True elif str(value).lower() == 'false': diff --git a/lib/ansible/modules/network/nxos/nxos_ping.py b/lib/ansible/modules/network/nxos/nxos_ping.py index a698b98ba8..f5a53dfd8e 100644 --- a/lib/ansible/modules/network/nxos/nxos_ping.py +++ b/lib/ansible/modules/network/nxos/nxos_ping.py @@ -412,7 +412,7 @@ def main(): } ping_command = 'ping {0}'.format(destination) - for command, arg in OPTIONS.iteritems(): + for command, arg in OPTIONS.items(): if arg: ping_command += ' {0} {1}'.format(command, arg) diff --git a/lib/ansible/modules/network/nxos/nxos_portchannel.py b/lib/ansible/modules/network/nxos/nxos_portchannel.py index acb0a61b4c..6e0ebbef1b 100644 --- a/lib/ansible/modules/network/nxos/nxos_portchannel.py +++ b/lib/ansible/modules/network/nxos/nxos_portchannel.py @@ -475,7 +475,7 @@ def get_portchannel(module, netcfg=None): # Ensure each member have the same mode. modes = set() - for each, value in member_dictionary.iteritems(): + for each, value in member_dictionary.items(): modes.update([value['mode']]) if len(modes) == 1: portchannel['mode'] = value['mode'] @@ -597,7 +597,7 @@ def get_commands_if_mode_change(proposed, existing, group, mode, module): members_to_remove = set(existing_members).difference(proposed_members) members_with_mode_change = [] if members_dict: - for interface, values in members_dict.iteritems(): + for interface, values in members_dict.items(): if (interface in proposed_members and (interface not in members_to_remove)): if values['mode'] != mode: @@ -683,7 +683,7 @@ def main(): existing, interface_exist = invoke('get_existing', module, args) end_state = existing - proposed = dict((k, v) for k, v in module.params.iteritems() + proposed = dict((k, v) for k, v in module.params.items() if v is not None and k in args) result = {} diff --git a/lib/ansible/modules/network/nxos/nxos_snmp_community.py b/lib/ansible/modules/network/nxos/nxos_snmp_community.py index 93ed3f7be4..419a8ea9f7 100644 --- a/lib/ansible/modules/network/nxos/nxos_snmp_community.py +++ b/lib/ansible/modules/network/nxos/nxos_snmp_community.py @@ -405,7 +405,7 @@ def get_snmp_community(module, find_filter=None): return {} else: fix_find = {} - for (key, value) in find.iteritems(): + for (key, value) in find.items(): if isinstance(value, str): fix_find[key] = value.strip() else: @@ -419,7 +419,7 @@ def config_snmp_community(delta, community): 'acl': 'snmp-server community {0} use-acl {acl}' } commands = [] - for k, v in delta.iteritems(): + for k, v in delta.items(): cmd = CMDS.get(k).format(community, **delta) if cmd: commands.append(cmd) @@ -461,8 +461,8 @@ def main(): existing = get_snmp_community(module, community) args = dict(group=group, acl=acl) - proposed = dict((k, v) for k, v in args.iteritems() if v is not None) - delta = dict(set(proposed.iteritems()).difference(existing.iteritems())) + proposed = dict((k, v) for k, v in args.items() if v is not None) + delta = dict(set(proposed.items()).difference(existing.items())) changed = False end_state = existing diff --git a/lib/ansible/modules/network/nxos/nxos_snmp_host.py b/lib/ansible/modules/network/nxos/nxos_snmp_host.py index 366da22a91..53ae9f3c11 100644 --- a/lib/ansible/modules/network/nxos/nxos_snmp_host.py +++ b/lib/ansible/modules/network/nxos/nxos_snmp_host.py @@ -432,7 +432,7 @@ def get_snmp_host(host, module): if find: fix_find = {} - for (key, value) in find.iteritems(): + for (key, value) in find.items(): if isinstance(value, str): fix_find[key] = value.strip() else: @@ -507,7 +507,7 @@ def config_snmp_host(delta, proposed, existing, module): 'src_intf': 'snmp-server host {0} source-interface {src_intf}' } - for key, value in delta.iteritems(): + for key, value in delta.items(): if key in ['vrf_filter', 'vrf', 'udp', 'src_intf']: command = CMDS.get(key, None) if command: @@ -597,9 +597,9 @@ def main(): snmp_type=snmp_type ) - proposed = dict((k, v) for k, v in args.iteritems() if v is not None) + proposed = dict((k, v) for k, v in args.items() if v is not None) - delta = dict(set(proposed.iteritems()).difference(existing.iteritems())) + delta = dict(set(proposed.items()).difference(existing.items())) changed = False commands = [] diff --git a/lib/ansible/modules/network/nxos/nxos_snmp_user.py b/lib/ansible/modules/network/nxos/nxos_snmp_user.py index a06a015101..c0aa42a75c 100644 --- a/lib/ansible/modules/network/nxos/nxos_snmp_user.py +++ b/lib/ansible/modules/network/nxos/nxos_snmp_user.py @@ -506,7 +506,7 @@ def main(): args = dict(user=user, pwd=pwd, group=group, privacy=privacy, encrypt=encrypt, authentication=authentication) - proposed = dict((k, v) for k, v in args.iteritems() if v is not None) + proposed = dict((k, v) for k, v in args.items() if v is not None) if not existing: if encrypt: @@ -522,7 +522,7 @@ def main(): proposed['encrypt'] = 'aes-128' delta = dict( - set(proposed.iteritems()).difference(existing.iteritems())) + set(proposed.items()).difference(existing.items())) if delta.get('pwd'): delta['authentication'] = authentication diff --git a/lib/ansible/modules/network/nxos/nxos_static_route.py b/lib/ansible/modules/network/nxos/nxos_static_route.py index 2ff042d030..903e90b3c7 100644 --- a/lib/ansible/modules/network/nxos/nxos_static_route.py +++ b/lib/ansible/modules/network/nxos/nxos_static_route.py @@ -442,7 +442,7 @@ def main(): end_state = existing args = ['route_name', 'vrf', 'pref', 'tag', 'next_hop', 'prefix'] - proposed = dict((k, v) for k, v in module.params.iteritems() if v is not None and k in args) + proposed = dict((k, v) for k, v in module.params.items() if v is not None and k in args) if state == 'present' or (state == 'absent' and existing): candidate = CustomNetworkConfig(indent=3) diff --git a/lib/ansible/modules/network/nxos/nxos_switchport.py b/lib/ansible/modules/network/nxos/nxos_switchport.py index f0e06163ce..594775fab8 100644 --- a/lib/ansible/modules/network/nxos/nxos_switchport.py +++ b/lib/ansible/modules/network/nxos/nxos_switchport.py @@ -729,7 +729,7 @@ def main(): native_vlan=native_vlan, trunk_vlans=trunk_vlans, trunk_allowed_vlans=trunk_allowed_vlans) - proposed = dict((k, v) for k, v in args.iteritems() if v is not None) + proposed = dict((k, v) for k, v in args.items() if v is not None) interface = interface.lower() diff --git a/lib/ansible/modules/network/nxos/nxos_udld.py b/lib/ansible/modules/network/nxos/nxos_udld.py index 8318f4025b..958490e7a5 100644 --- a/lib/ansible/modules/network/nxos/nxos_udld.py +++ b/lib/ansible/modules/network/nxos/nxos_udld.py @@ -380,7 +380,7 @@ def get_commands_config_udld_global(delta, reset): 'msg_time': 'udld message-time {msg_time}' } commands = [] - for param, value in delta.iteritems(): + for param, value in delta.items(): if param == 'aggressive': if value == 'enabled': command = 'udld aggressive' @@ -404,7 +404,7 @@ def get_commands_remove_udld_global(delta): 'msg_time': 'no udld message-time {msg_time}', } commands = [] - for param, value in delta.iteritems(): + for param, value in delta.items(): command = config_args.get(param, 'DNE').format(**delta) if command and command != 'DNE': commands.append(command) @@ -460,12 +460,12 @@ def main(): 'between 7 and 90') args = dict(aggressive=aggressive, msg_time=msg_time, reset=reset) - proposed = dict((k, v) for k, v in args.iteritems() if v is not None) + proposed = dict((k, v) for k, v in args.items() if v is not None) existing = get_udld_global(module) end_state = existing - delta = set(proposed.iteritems()).difference(existing.iteritems()) + delta = set(proposed.items()).difference(existing.items()) changed = False commands = [] @@ -475,7 +475,7 @@ def main(): commands.append(command) elif state == 'absent': - common = set(proposed.iteritems()).intersection(existing.iteritems()) + common = set(proposed.items()).intersection(existing.items()) if common: command = get_commands_remove_udld_global(dict(common)) commands.append(command) diff --git a/lib/ansible/modules/network/nxos/nxos_udld_interface.py b/lib/ansible/modules/network/nxos/nxos_udld_interface.py index f73670c2b1..f106396b50 100644 --- a/lib/ansible/modules/network/nxos/nxos_udld_interface.py +++ b/lib/ansible/modules/network/nxos/nxos_udld_interface.py @@ -477,7 +477,7 @@ def main(): existing = get_udld_interface(module, interface) end_state = existing - delta = dict(set(proposed.iteritems()).difference(existing.iteritems())) + delta = dict(set(proposed.items()).difference(existing.items())) changed = False commands = [] @@ -487,7 +487,7 @@ def main(): module, existing) commands.append(command) elif state == 'absent': - common = set(proposed.iteritems()).intersection(existing.iteritems()) + common = set(proposed.items()).intersection(existing.items()) if common: command = get_commands_remove_udld_interface( dict(common), interface, module, existing diff --git a/lib/ansible/modules/network/nxos/nxos_vlan.py b/lib/ansible/modules/network/nxos/nxos_vlan.py index 67719262bd..886598cd5c 100644 --- a/lib/ansible/modules/network/nxos/nxos_vlan.py +++ b/lib/ansible/modules/network/nxos/nxos_vlan.py @@ -381,7 +381,7 @@ def get_vlan_config_commands(vlan, vid): commands = [] - for param, value in vlan.iteritems(): + for param, value in vlan.items(): if param == 'mapped_vni' and value == 'default': command = 'no vn-segment' else: @@ -589,7 +589,7 @@ def main(): args = dict(name=name, vlan_state=vlan_state, admin_state=admin_state, mapped_vni=mapped_vni) - proposed = dict((k, v) for k, v in args.iteritems() if v is not None) + proposed = dict((k, v) for k, v in args.items() if v is not None) proposed_vlans_list = numerical_sort(vlan_range_to_list( vlan_id or vlan_range)) @@ -620,7 +620,7 @@ def main(): proposed.get('mapped_vni') == 'default'): proposed.pop('mapped_vni') delta = dict(set( - proposed.iteritems()).difference(existing.iteritems())) + proposed.items()).difference(existing.items())) if delta or not existing: commands = get_vlan_config_commands(delta, vlan_id) diff --git a/lib/ansible/modules/network/nxos/nxos_vpc.py b/lib/ansible/modules/network/nxos/nxos_vpc.py index 42af1cb651..db78dd0a7f 100644 --- a/lib/ansible/modules/network/nxos/nxos_vpc.py +++ b/lib/ansible/modules/network/nxos/nxos_vpc.py @@ -542,7 +542,7 @@ def get_commands_to_config_vpc(module, vpc, domain, existing): 'auto_recovery': '{auto_recovery} auto-recovery', } - for param, value in vpc.iteritems(): + for param, value in vpc.items(): command = CONFIG_ARGS.get(param, 'DNE').format(**vpc) if command and command != 'DNE': commands.append(command.strip()) @@ -614,14 +614,14 @@ def main(): module.fail_json(msg='The VRF you are trying to use for the peer ' 'keepalive link is not on device yet. Add it' ' first, please.') - proposed = dict((k, v) for k, v in args.iteritems() if v is not None) + proposed = dict((k, v) for k, v in args.items() if v is not None) changed = False existing = get_vpc(module) end_state = existing commands = [] if state == 'present': - delta = set(proposed.iteritems()).difference(existing.iteritems()) + delta = set(proposed.items()).difference(existing.items()) if delta: command = get_commands_to_config_vpc(module, delta, domain, existing) commands.append(command) diff --git a/lib/ansible/modules/network/nxos/nxos_vpc_interface.py b/lib/ansible/modules/network/nxos/nxos_vpc_interface.py index 6f122f6f2d..85b944f178 100644 --- a/lib/ansible/modules/network/nxos/nxos_vpc_interface.py +++ b/lib/ansible/modules/network/nxos/nxos_vpc_interface.py @@ -446,7 +446,7 @@ def get_portchannel_vpc_config(module, portchannel): mapping = get_existing_portchannel_to_vpc_mappings(module) - for existing_vpc, port_channel in mapping.iteritems(): + for existing_vpc, port_channel in mapping.items(): port_ch = str(port_channel[2:]) if port_ch == portchannel: pc = port_ch @@ -511,7 +511,7 @@ def main(): "before trying to assign it here. ", existing_portchannel=mapping[vpc]) - for vpcid, existing_pc in mapping.iteritems(): + for vpcid, existing_pc in mapping.items(): if portchannel == existing_pc.strip('Po') and vpcid != vpc: module.fail_json(msg="This portchannel already has another" " VPC configured. Remove it first " @@ -538,13 +538,13 @@ def main(): config_value = 'peer-link' - proposed = dict((k, v) for k, v in args.iteritems() if v is not None) + proposed = dict((k, v) for k, v in args.items() if v is not None) existing = get_portchannel_vpc_config(module, portchannel) end_state = existing commands = [] if state == 'present': - delta = dict(set(proposed.iteritems()).difference(existing.iteritems())) + delta = dict(set(proposed.items()).difference(existing.items())) if delta: command = get_commands_to_config_vpc_interface( portchannel, diff --git a/lib/ansible/modules/network/nxos/nxos_vrf.py b/lib/ansible/modules/network/nxos/nxos_vrf.py index eb60306e08..03301fe252 100644 --- a/lib/ansible/modules/network/nxos/nxos_vrf.py +++ b/lib/ansible/modules/network/nxos/nxos_vrf.py @@ -367,7 +367,7 @@ def apply_key_map(key_map, table): def get_commands_to_config_vrf(delta, vrf): commands = [] - for param, value in delta.iteritems(): + for param, value in delta.items(): command = '' if param == 'description': command = 'description {0}'.format(value) @@ -479,7 +479,7 @@ def main(): end_state = existing changed = False - proposed = dict((k, v) for k, v in args.iteritems() if v is not None) + proposed = dict((k, v) for k, v in args.items() if v is not None) """Since 'admin_state' is either 'Up' or 'Down' from outputs, we use the following to make sure right letter case is used so that delta @@ -488,7 +488,7 @@ def main(): if existing['admin_state'].lower() == admin_state: proposed['admin_state'] = existing['admin_state'] - delta = dict(set(proposed.iteritems()).difference(existing.iteritems())) + delta = dict(set(proposed.items()).difference(existing.items())) changed = False end_state = existing commands = [] diff --git a/lib/ansible/modules/network/nxos/nxos_vrf_af.py b/lib/ansible/modules/network/nxos/nxos_vrf_af.py index 70ca67109e..1beca09ec8 100644 --- a/lib/ansible/modules/network/nxos/nxos_vrf_af.py +++ b/lib/ansible/modules/network/nxos/nxos_vrf_af.py @@ -335,7 +335,7 @@ def state_present(module, existing, proposed, candidate): proposed_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, proposed) existing_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, existing) - for key, value in proposed_commands.iteritems(): + for key, value in proposed_commands.items(): if value is True: commands.append(key) @@ -392,11 +392,11 @@ def main(): existing = invoke('get_existing', module, args) end_state = existing - proposed_args = dict((k, v) for k, v in module.params.iteritems() + proposed_args = dict((k, v) for k, v in module.params.items() if v is not None and k in args) proposed = {} - for key, value in proposed_args.iteritems(): + for key, value in proposed_args.items(): if key != 'interface': if str(value).lower() == 'default': value = PARAM_TO_DEFAULT_KEYMAP.get(key) diff --git a/lib/ansible/modules/network/nxos/nxos_vrrp.py b/lib/ansible/modules/network/nxos/nxos_vrrp.py index 58c04a8367..9a560bd794 100644 --- a/lib/ansible/modules/network/nxos/nxos_vrrp.py +++ b/lib/ansible/modules/network/nxos/nxos_vrrp.py @@ -622,7 +622,7 @@ def main(): vip=vip, authentication=authentication, admin_state=admin_state) - proposed = dict((k, v) for k, v in args.iteritems() if v is not None) + proposed = dict((k, v) for k, v in args.items() if v is not None) existing = get_existing_vrrp(interface, group, module, name) changed = False @@ -631,7 +631,7 @@ def main(): if state == 'present': delta = dict( - set(proposed.iteritems()).difference(existing.iteritems())) + set(proposed.items()).difference(existing.items())) if delta: command = get_commands_config_vrrp(delta, group) commands.append(command) diff --git a/lib/ansible/modules/network/nxos/nxos_vtp_domain.py b/lib/ansible/modules/network/nxos/nxos_vtp_domain.py index f96db115a6..61f28768b0 100644 --- a/lib/ansible/modules/network/nxos/nxos_vtp_domain.py +++ b/lib/ansible/modules/network/nxos/nxos_vtp_domain.py @@ -391,8 +391,8 @@ def main(): args = dict(domain=domain) changed = False - proposed = dict((k, v) for k, v in args.iteritems() if v is not None) - delta = dict(set(proposed.iteritems()).difference(existing.iteritems())) + proposed = dict((k, v) for k, v in args.items() if v is not None) + delta = dict(set(proposed.items()).difference(existing.items())) commands = [] if delta: diff --git a/lib/ansible/modules/network/nxos/nxos_vtp_password.py b/lib/ansible/modules/network/nxos/nxos_vtp_password.py index ce444381d0..69f9d6f852 100644 --- a/lib/ansible/modules/network/nxos/nxos_vtp_password.py +++ b/lib/ansible/modules/network/nxos/nxos_vtp_password.py @@ -424,8 +424,8 @@ def main(): args = dict(vtp_password=vtp_password) changed = False - proposed = dict((k, v) for k, v in args.iteritems() if v is not None) - delta = dict(set(proposed.iteritems()).difference(existing.iteritems())) + proposed = dict((k, v) for k, v in args.items() if v is not None) + delta = dict(set(proposed.items()).difference(existing.items())) commands = [] if state == 'absent': diff --git a/lib/ansible/modules/network/nxos/nxos_vtp_version.py b/lib/ansible/modules/network/nxos/nxos_vtp_version.py index bd10745ba8..5661f45084 100644 --- a/lib/ansible/modules/network/nxos/nxos_vtp_version.py +++ b/lib/ansible/modules/network/nxos/nxos_vtp_version.py @@ -386,8 +386,8 @@ def main(): args = dict(version=version) changed = False - proposed = dict((k, v) for k, v in args.iteritems() if v is not None) - delta = dict(set(proposed.iteritems()).difference(existing.iteritems())) + proposed = dict((k, v) for k, v in args.items() if v is not None) + delta = dict(set(proposed.items()).difference(existing.items())) commands = [] if delta: diff --git a/lib/ansible/modules/network/nxos/nxos_vxlan_vtep.py b/lib/ansible/modules/network/nxos/nxos_vxlan_vtep.py index 6d29597cd2..835c072f7c 100644 --- a/lib/ansible/modules/network/nxos/nxos_vxlan_vtep.py +++ b/lib/ansible/modules/network/nxos/nxos_vxlan_vtep.py @@ -409,7 +409,7 @@ def state_present(module, existing, proposed, candidate): commands = list() proposed_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, proposed) existing_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, existing) - for key, value in proposed_commands.iteritems(): + for key, value in proposed_commands.items(): if value is True: commands.append(key) @@ -475,11 +475,11 @@ def main(): existing = invoke('get_existing', module, args) end_state = existing - proposed_args = dict((k, v) for k, v in module.params.iteritems() + proposed_args = dict((k, v) for k, v in module.params.items() if v is not None and k in args) proposed = {} - for key, value in proposed_args.iteritems(): + for key, value in proposed_args.items(): if key != 'interface': if str(value).lower() == 'true': value = True diff --git a/lib/ansible/modules/network/nxos/nxos_vxlan_vtep_vni.py b/lib/ansible/modules/network/nxos/nxos_vxlan_vtep_vni.py index cf354d59c4..85a0139dbd 100644 --- a/lib/ansible/modules/network/nxos/nxos_vxlan_vtep_vni.py +++ b/lib/ansible/modules/network/nxos/nxos_vxlan_vtep_vni.py @@ -417,7 +417,7 @@ def state_present(module, existing, proposed, candidate): proposed_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, proposed) existing_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, existing) - for key, value in proposed_commands.iteritems(): + for key, value in proposed_commands.items(): if key == 'associate-vrf': command = 'member vni {0} {1}'.format(module.params['vni'], key) @@ -532,11 +532,11 @@ def main(): existing, interface_exist = invoke('get_existing', module, args) end_state = existing - proposed_args = dict((k, v) for k, v in module.params.iteritems() + proposed_args = dict((k, v) for k, v in module.params.items() if v is not None and k in args) proposed = {} - for key, value in proposed_args.iteritems(): + for key, value in proposed_args.items(): if key != 'interface': if str(value).lower() == 'default': value = PARAM_TO_DEFAULT_KEYMAP.get(key) diff --git a/lib/ansible/modules/network/sros/sros_rollback.py b/lib/ansible/modules/network/sros/sros_rollback.py index 85d7bdc506..77270126f4 100644 --- a/lib/ansible/modules/network/sros/sros_rollback.py +++ b/lib/ansible/modules/network/sros/sros_rollback.py @@ -125,7 +125,7 @@ def sanitize_config(lines): def present(module, commands): setters = set() - for key, value in module.argument_spec.iteritems(): + for key, value in module.argument_spec.items(): if module.params[key] is not None: setter = value.get('setter') or 'set_%s' % key if setter not in setters: diff --git a/lib/ansible/modules/packaging/language/composer.py b/lib/ansible/modules/packaging/language/composer.py index 172acb4ad1..dc0a62252b 100644 --- a/lib/ansible/modules/packaging/language/composer.py +++ b/lib/ansible/modules/packaging/language/composer.py @@ -215,7 +215,7 @@ def main(): 'ignore_platform_reqs': 'ignore-platform-reqs', } - for param, option in option_params.iteritems(): + for param, option in option_params.items(): if module.params.get(param) and option in available_options: option = "--%s" % option options.append(option) diff --git a/lib/ansible/modules/system/osx_defaults.py b/lib/ansible/modules/system/osx_defaults.py index 757cc811d9..20eff94893 100644 --- a/lib/ansible/modules/system/osx_defaults.py +++ b/lib/ansible/modules/system/osx_defaults.py @@ -137,7 +137,7 @@ class OSXDefaults(object): self.current_value = None # Just set all given parameters - for key, val in kwargs.iteritems(): + for key, val in kwargs.items(): setattr(self, key, val) # Try to find the defaults executable diff --git a/lib/ansible/modules/system/ufw.py b/lib/ansible/modules/system/ufw.py index 6d381785bc..4d5e3d0153 100644 --- a/lib/ansible/modules/system/ufw.py +++ b/lib/ansible/modules/system/ufw.py @@ -286,7 +286,7 @@ def main(): (_, pre_rules, _) = module.run_command("grep '^### tuple' /lib/ufw/user*.rules") # Execute commands - for (command, value) in commands.iteritems(): + for (command, value) in commands.items(): cmd = [[ufw_bin], [module.check_mode, '--dry-run']] if command == 'state': diff --git a/lib/ansible/modules/system/zfs.py b/lib/ansible/modules/system/zfs.py index d95971455e..5a4af03448 100644 --- a/lib/ansible/modules/system/zfs.py +++ b/lib/ansible/modules/system/zfs.py @@ -168,7 +168,7 @@ class Zfs(object): if volblocksize: cmd += ['-b', 'volblocksize'] if properties: - for prop, value in properties.iteritems(): + for prop, value in properties.items(): cmd += ['-o', '%s="%s"' % (prop, value)] if origin: cmd.append(origin) @@ -203,7 +203,7 @@ class Zfs(object): def set_properties_if_changed(self): current_properties = self.get_current_properties() - for prop, value in self.properties.iteritems(): + for prop, value in self.properties.items(): if current_properties.get(prop, None) != value: self.set_property(prop, value) @@ -242,7 +242,7 @@ def main(): # Get all valid zfs-properties properties = dict() - for prop, value in module.params.iteritems(): + for prop, value in module.params.items(): # All freestyle params are zfs properties if prop not in module.argument_spec: # Reverse the boolification of freestyle zfs properties