From: Cyril Roelandt Date: Tue, 16 Jun 2015 13:38:13 +0000 (+0000) Subject: Python3: do not change the size of a dict while iterating over it X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=4f46d2ae3a089f36512fae3bf49f155927095922;p=openstack-build%2Fneutron-build.git Python3: do not change the size of a dict while iterating over it This does not work in Python3, so we have to store the items first. Change-Id: I7d8641f980fe62d2900559433d5060a6281a97f8 Blueprint: neutron-python3 --- diff --git a/neutron/agent/linux/iptables_firewall.py b/neutron/agent/linux/iptables_firewall.py index 1cae8f642..f8431c7cb 100644 --- a/neutron/agent/linux/iptables_firewall.py +++ b/neutron/agent/linux/iptables_firewall.py @@ -657,7 +657,7 @@ class IptablesFirewallDriver(firewall.FirewallDriver): def _remove_unused_sg_members(self): """Remove sg_member entries where no IPv4 or IPv6 is associated.""" - for sg_id in self.sg_members.keys(): + for sg_id in list(self.sg_members.keys()): sg_has_members = (self.sg_members[sg_id][constants.IPv4] or self.sg_members[sg_id][constants.IPv6]) if not sg_has_members: diff --git a/neutron/api/extensions.py b/neutron/api/extensions.py index 905d8ce81..d4bd41404 100644 --- a/neutron/api/extensions.py +++ b/neutron/api/extensions.py @@ -460,7 +460,7 @@ class ExtensionManager(object): # is made in a whole iteration while exts_to_process: processed_ext_count = len(processed_exts) - for ext_name, ext in exts_to_process.items(): + for ext_name, ext in list(exts_to_process.items()): if not hasattr(ext, 'get_extended_resources'): del exts_to_process[ext_name] continue diff --git a/neutron/plugins/linuxbridge/agent/linuxbridge_neutron_agent.py b/neutron/plugins/linuxbridge/agent/linuxbridge_neutron_agent.py index aba3dee0b..ba9f36fc1 100644 --- a/neutron/plugins/linuxbridge/agent/linuxbridge_neutron_agent.py +++ b/neutron/plugins/linuxbridge/agent/linuxbridge_neutron_agent.py @@ -463,7 +463,7 @@ class LinuxBridgeManager(object): bridge_name) def remove_empty_bridges(self): - for network_id in self.network_map.keys(): + for network_id in list(self.network_map.keys()): bridge_name = self.get_bridge_name(network_id) if not self.get_tap_devices_count(bridge_name): self.delete_vlan_bridge(bridge_name) diff --git a/neutron/plugins/openvswitch/agent/ovs_neutron_agent.py b/neutron/plugins/openvswitch/agent/ovs_neutron_agent.py index 8e5a5c18c..1a279e948 100644 --- a/neutron/plugins/openvswitch/agent/ovs_neutron_agent.py +++ b/neutron/plugins/openvswitch/agent/ovs_neutron_agent.py @@ -1182,7 +1182,8 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin, break # If not, remove it else: - for remote_ip, ofport in self.tun_br_ofports[tunnel_type].items(): + items = list(self.tun_br_ofports[tunnel_type].items()) + for remote_ip, ofport in items: if ofport == tun_ofport: port_name = '%s-%s' % (tunnel_type, self.get_ip_in_hex(remote_ip))