]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Python 3: Wrap map() in a list call
authorfumihiko kakuma <kakuma@valinux.co.jp>
Thu, 16 Jul 2015 10:34:12 +0000 (19:34 +0900)
committerfumihiko kakuma <kakuma@valinux.co.jp>
Fri, 17 Jul 2015 04:21:31 +0000 (13:21 +0900)
map() returns an iterator in python 3. In a case that a list is expected,
we wrap map() in a list call.

Change-Id: I623d854c410176c8ec43b732dc8f4e087dadefd9
Blueprint: neutron-python3

neutron/agent/common/ovs_lib.py
neutron/agent/linux/utils.py
neutron/agent/windows/utils.py
neutron/db/db_base_plugin_v2.py
neutron/db/migration/cli.py
neutron/plugins/ml2/drivers/cisco/apic/apic_topology.py
neutron/plugins/ml2/plugin.py
neutron/tests/api/test_routers.py
neutron/tests/unit/agent/l3/test_agent.py
neutron/tests/unit/plugins/ml2/test_security_group.py

index 49c7a6e9c19d0c8efb688dd954d0c895f2fa2ea4..00e2de18c806969a5e76de3f28421bb20f49b207 100644 (file)
@@ -557,7 +557,7 @@ class DeferredOVSBridge(object):
                                     key=operator.itemgetter(0))
         itemgetter_1 = operator.itemgetter(1)
         for action, action_flow_list in grouped:
-            flows = map(itemgetter_1, action_flow_list)
+            flows = list(map(itemgetter_1, action_flow_list))
             self.br.do_action_flows(action, flows)
 
     def __enter__(self):
index b646aa8f428494549a1e6b7bef548ca834faa3cf..3140adb4c7f9001e183eac0324c4e908124a18b6 100644 (file)
@@ -79,7 +79,7 @@ def create_process(cmd, run_as_root=False, addl_env=None):
     The return value will be a tuple of the process object and the
     list of command arguments used to create it.
     """
-    cmd = map(str, addl_env_args(addl_env) + cmd)
+    cmd = list(map(str, addl_env_args(addl_env) + cmd))
     if run_as_root:
         cmd = shlex.split(config.get_root_helper(cfg.CONF)) + cmd
     LOG.debug("Running command: %s", cmd)
@@ -92,7 +92,7 @@ def create_process(cmd, run_as_root=False, addl_env=None):
 
 
 def execute_rootwrap_daemon(cmd, process_input, addl_env):
-    cmd = map(str, addl_env_args(addl_env) + cmd)
+    cmd = list(map(str, addl_env_args(addl_env) + cmd))
     # NOTE(twilson) oslo_rootwrap.daemon will raise on filter match
     # errors, whereas oslo_rootwrap.cmd converts them to return codes.
     # In practice, no neutron code should be trying to execute something that
index 8c878395a30a9e7467c791d310637fdcade65de5..5221534a63bd27317c285cf8719b43673f909a2d 100644 (file)
@@ -25,7 +25,7 @@ LOG = logging.getLogger(__name__)
 
 
 def create_process(cmd, addl_env=None):
-    cmd = map(str, cmd)
+    cmd = list(map(str, cmd))
 
     LOG.debug("Running command: %s", cmd)
     env = os.environ.copy()
index d2b5f89972fdc49989affe84ae9cae4b23f38409..e681bdfa7e18e60014496d2a78a968252e6d3875 100644 (file)
@@ -612,7 +612,8 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
                     in_(AUTO_DELETE_PORT_OWNERS)))
             network_ports = qry_network_ports.all()
             if network_ports:
-                map(context.session.delete, network_ports)
+                for port in network_ports:
+                    context.session.delete(port)
             # Check if there are more IP allocations, unless
             # is_auto_address_subnet is True. In that case the check is
             # unnecessary. This additional check not only would be wasteful
index 51b49508a26b6d628f0d769c7e95bce9fb12a90d..738fd605496233d028c601de5f1e007036fcad51 100644 (file)
@@ -33,7 +33,7 @@ MIGRATION_BRANCHES = ('expand', 'contract')
 
 
 mods = repos.NeutronModules()
-VALID_SERVICES = map(mods.alembic_name, mods.installed_list())
+VALID_SERVICES = list(map(mods.alembic_name, mods.installed_list()))
 
 
 _core_opts = [
index 8a1be65a1b04c1392c8aeb4f4417e802e052202f..a64eee1fdbca2c4d1ea4d6660b207d3adc71f743 100644 (file)
@@ -167,7 +167,7 @@ class ApicTopologyAgent(manager.Manager):
         self.interfaces = {}
         self.lldpcmd = None
         self.peers = {}
-        self.port_desc_re = map(re.compile, ACI_PORT_DESCR_FORMATS)
+        self.port_desc_re = list(map(re.compile, ACI_PORT_DESCR_FORMATS))
         self.service_agent = ApicTopologyServiceNotifierApi()
         self.state = None
         self.state_agent = None
index 89a64609a327678b57f9174c49b71f23e224bdd2..f965c6bbba944f76340434a4a793b2a6dc61f025 100644 (file)
@@ -864,7 +864,8 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
                 allocated = qry_allocated.all()
                 # Delete all the IPAllocation that can be auto-deleted
                 if allocated:
-                    map(session.delete, allocated)
+                    for x in allocated:
+                        session.delete(x)
                 LOG.debug("Ports to auto-deallocate: %s", allocated)
                 # Check if there are more IP allocations, unless
                 # is_auto_address_subnet is True. In that case the check is
index 6593f9799628f4eaa76f0f90756de8414ebc20d5..4cde8fb82c12d63fa5a83994c572db597a150ee8 100644 (file)
@@ -189,7 +189,7 @@ class RoutersTest(base.BaseRouterTest):
             CONF.network.public_network_id)
         public_subnet_id = public_net_body['network']['subnets'][0]
         self.assertIn(public_subnet_id,
-                      map(lambda x: x['subnet_id'], fixed_ips))
+                      [x['subnet_id'] for x in fixed_ips])
 
     @test.attr(type='smoke')
     @test.idempotent_id('6cc285d8-46bf-4f36-9b1a-783e3008ba79')
index 09416ba0a176d7dacf0755a683a7f571f69e8244..159b2a11c82829120824d8eed225b52298be4cb9 100644 (file)
@@ -1520,7 +1520,7 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework):
         ri.router = {'distributed': False}
         ri._handle_router_snat_rules(ex_gw_port, "iface", "add_rules")
 
-        nat_rules = map(str, ri.iptables_manager.ipv4['nat'].rules)
+        nat_rules = list(map(str, ri.iptables_manager.ipv4['nat'].rules))
         wrap_name = ri.iptables_manager.wrap_name
 
         jump_float_rule = "-A %s-snat -j %s-float-snat" % (wrap_name,
@@ -1539,7 +1539,7 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework):
         self.assertThat(nat_rules.index(jump_float_rule),
                         matchers.LessThan(nat_rules.index(snat_rule1)))
 
-        mangle_rules = map(str, ri.iptables_manager.ipv4['mangle'].rules)
+        mangle_rules = list(map(str, ri.iptables_manager.ipv4['mangle'].rules))
         mangle_rule = ("-A %s-mark -i iface "
                        "-j MARK --set-xmark 0x2/0xffffffff") % wrap_name
         self.assertIn(mangle_rule, mangle_rules)
index 897cadf58aae4a884efd2cb4a125eed5d6584663..a9b92201371223923bc5cd49e941906cc775710d 100644 (file)
@@ -117,7 +117,7 @@ class TestMl2SecurityGroups(Ml2SecurityGroupsTestCase,
                 plugin.get_ports_from_devices(self.ctx,
                     ['%s%s' % (const.TAP_DEVICE_PREFIX, i)
                      for i in range(ports_to_query)])
-                all_call_args = map(lambda x: x[1][1], get_mock.mock_calls)
+                all_call_args = [x[1][1] for x in get_mock.mock_calls]
                 last_call_args = all_call_args.pop()
                 # all but last should be getting MAX_PORTS_PER_QUERY ports
                 self.assertTrue(