]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Use the constant HOST_ID instead of 'binding:host_id'
authorGary Kotton <gkotton@vmware.com>
Sun, 13 Dec 2015 12:52:27 +0000 (04:52 -0800)
committergaryk <gkotton@vmware.com>
Sun, 20 Dec 2015 14:00:29 +0000 (14:00 +0000)
This patch makes use of the constant defined in the extension.
In addition to this having value of debing defined in one place it
also enables the caller to understand that the portbindings
extension is required.

Note: the constant is not used in the API tests. This has import
issues so it is not relevant.

TrivialFix

Change-Id: I7bfe2528dbbd8017ddbdcf949dbb6264ce1eb5d8

17 files changed:
neutron/agent/l3/ha_router.py
neutron/db/l3_agentschedulers_db.py
neutron/db/l3_dvr_db.py
neutron/db/l3_dvrscheduler_db.py
neutron/debug/debug_agent.py
neutron/tests/fullstack/resources/client.py
neutron/tests/functional/agent/l3/test_dvr_router.py
neutron/tests/functional/services/l3_router/test_l3_dvr_router_plugin.py
neutron/tests/unit/agent/l3/test_agent.py
neutron/tests/unit/agent/l3/test_dvr_local_router.py
neutron/tests/unit/api/rpc/handlers/test_dhcp_rpc.py
neutron/tests/unit/db/test_l3_dvr_db.py
neutron/tests/unit/debug/test_commands.py
neutron/tests/unit/extensions/test_l3.py
neutron/tests/unit/plugins/ml2/drivers/l2pop/test_mech_driver.py
neutron/tests/unit/plugins/ml2/test_plugin.py
neutron/tests/unit/scheduler/test_l3_agent_scheduler.py

index 196d70c9bb982e979a2f802f407e1466bdbefa37..d1d1a1f395c41bd9309e10e1e02a9d7578d32c0d 100644 (file)
@@ -25,6 +25,7 @@ from neutron.agent.linux import ip_lib
 from neutron.agent.linux import keepalived
 from neutron.common import constants as n_consts
 from neutron.common import utils as common_utils
+from neutron.extensions import portbindings
 
 LOG = logging.getLogger(__name__)
 HA_DEV_PREFIX = 'ha-'
@@ -345,7 +346,7 @@ class HaRouter(router.RouterInfo):
         def _get_filtered_dict(d, ignore):
             return {k: v for k, v in d.items() if k not in ignore}
 
-        keys_to_ignore = set(['binding:host_id'])
+        keys_to_ignore = set([portbindings.HOST_ID])
         port1_filtered = _get_filtered_dict(port1, keys_to_ignore)
         port2_filtered = _get_filtered_dict(port2, keys_to_ignore)
         return port1_filtered == port2_filtered
index ff0010c8b1ba634fd0a3e3eb4b76a0b99281b911..5ee651f794e16953bf72e8eefd324b0216adea9d 100644 (file)
@@ -34,6 +34,7 @@ from neutron.db import agentschedulers_db
 from neutron.db import l3_attrs_db
 from neutron.db import model_base
 from neutron.extensions import l3agentscheduler
+from neutron.extensions import portbindings
 from neutron.extensions import router_availability_zone as router_az
 from neutron import manager
 from neutron.plugins.common import constants as service_constants
@@ -482,7 +483,7 @@ class L3AgentSchedulerDbMixin(l3agentscheduler.L3AgentSchedulerPluginBase,
         ports = core_plugin.get_ports(context, filters=filter)
         for port in ports:
             if (n_utils.is_dvr_serviced(port['device_owner']) and
-                l3_agent['host'] == port['binding:host_id']):
+                l3_agent['host'] == port[portbindings.HOST_ID]):
                     return True
 
         return False
index a97b07ef0fb6614df0f05264ca24fb43131d43e9..99ae7aef72fda03310287017fff404c34e48f808 100644 (file)
@@ -606,7 +606,7 @@ class L3_NAT_with_dvr_db_mixin(l3_db.L3_NAT_db_mixin,
                              'network_id': network_id,
                              'device_id': l3_agent_db['id'],
                              'device_owner': l3_const.DEVICE_OWNER_AGENT_GW,
-                             'binding:host_id': host,
+                             portbindings.HOST_ID: host,
                              'admin_state_up': True,
                              'name': ''}
                 agent_port = p_utils.create_port(self._core_plugin, context,
index c0941c78f4a3be4ff770bd005301eaa958bd36ba..a70b0e49525825a813428f799c1dced290c6ffd0 100644 (file)
@@ -32,6 +32,7 @@ from neutron.db import l3_agentschedulers_db as l3agent_sch_db
 from neutron.db import model_base
 from neutron.db import models_v2
 from neutron.extensions import l3agentscheduler
+from neutron.extensions import portbindings
 from neutron import manager
 from neutron.plugins.common import constants as service_constants
 from neutron.plugins.ml2 import db as ml2_db
@@ -100,7 +101,7 @@ class L3_DVRsch_db_mixin(l3agent_sch_db.L3AgentSchedulerDbMixin):
 
     def dvr_update_router_addvm(self, context, port):
         port_dict = self._core_plugin.get_port(context, port['id'])
-        port_host = port_dict['binding:host_id']
+        port_host = port_dict[portbindings.HOST_ID]
         l3_agent_on_host = (self.get_l3_agents(
             context, filters={'host': [port_host]}) or [None])[0]
         if not l3_agent_on_host:
@@ -157,7 +158,7 @@ class L3_DVRsch_db_mixin(l3agent_sch_db.L3AgentSchedulerDbMixin):
         ports = self._core_plugin.get_ports(context, filters=filter_sub)
         for port in ports:
             if (n_utils.is_dvr_serviced(port['device_owner'])
-                and port['binding:host_id'] == host
+                and port[portbindings.HOST_ID] == host
                 and port['id'] != port_id):
                 LOG.debug('DVR: %(port_status)s port exists for subnet '
                           '%(subnet_id)s on host %(host)s',
@@ -496,8 +497,9 @@ def _notify_l3_agent_port_update(resource, event, trigger, **kwargs):
             n_utils.is_dvr_serviced(original_device_owner) and
             not n_utils.is_dvr_serviced(new_device_owner))
         is_port_moved = (
-            original_port['binding:host_id'] and
-            original_port['binding:host_id'] != new_port['binding:host_id'])
+            original_port[portbindings.HOST_ID] and
+            original_port[portbindings.HOST_ID] !=
+            new_port[portbindings.HOST_ID])
         if is_port_no_longer_serviced or is_port_moved:
             l3plugin = manager.NeutronManager.get_service_plugins().get(
                 service_constants.L3_ROUTER_NAT)
@@ -505,7 +507,7 @@ def _notify_l3_agent_port_update(resource, event, trigger, **kwargs):
             removed_routers = l3plugin.dvr_deletens_if_no_port(
                 context,
                 original_port['id'],
-                port_host=original_port['binding:host_id'])
+                port_host=original_port[portbindings.HOST_ID])
             if removed_routers:
                 removed_router_args = {
                     'context': context,
index a83a8b0601288ce3bc2da014864a085bea850bb4..d1f069c9b6cb1b20ebffa06849f5f773af6dd5c8 100644 (file)
@@ -23,7 +23,7 @@ from neutron._i18n import _LW
 from neutron.agent.linux import dhcp
 from neutron.agent.linux import ip_lib
 from neutron.common import constants
-
+from neutron.extensions import portbindings
 
 LOG = logging.getLogger(__name__)
 
@@ -173,7 +173,7 @@ class NeutronDebugAgent(object):
                          'device_id': '%s' % socket.gethostname(),
                          'device_owner': '%s:probe' % device_owner,
                          'tenant_id': network.tenant_id,
-                         'binding:host_id': host,
+                         portbindings.HOST_ID: host,
                          'fixed_ips': [dict(subnet_id=s.id)
                                        for s in network.subnets]}}
         port_dict = self.client.create_port(body)['port']
index b781c8e1419c9f4aa9244b857dea459b37410767..449c3539df2a1dee3ac099466c32d7aa24c29cba 100644 (file)
@@ -17,6 +17,7 @@ import functools
 import fixtures
 from neutronclient.common import exceptions
 
+from neutron.extensions import portbindings
 from neutron.tests import base
 
 
@@ -81,7 +82,7 @@ class ClientFixture(fixtures.Fixture):
         spec = {
             'network_id': network_id,
             'tenant_id': tenant_id,
-            'binding:host_id': hostname,
+            portbindings.HOST_ID: hostname,
         }
         if qos_policy_id:
             spec['qos_policy_id'] = qos_policy_id
index 3ade35cc13d0523261d068f9c48c6919b756cafc..831d670a695517f8faa728943035dd181a49a322 100644 (file)
@@ -25,6 +25,7 @@ from neutron.agent.l3 import namespaces
 from neutron.agent.linux import ip_lib
 from neutron.agent.linux import utils
 from neutron.common import constants as l3_constants
+from neutron.extensions import portbindings
 from neutron.tests.common import l3_test_common
 from neutron.tests.common import net_helpers
 from neutron.tests.functional.agent.l3 import framework
@@ -192,7 +193,7 @@ class TestDvrRouter(framework.L3AgentTestFramework):
         internal_ports = router.get(l3_constants.INTERFACE_KEY, [])
         router['distributed'] = True
         router['gw_port_host'] = agent.conf.host
-        router['gw_port']['binding:host_id'] = agent.conf.host
+        router['gw_port'][portbindings.HOST_ID] = agent.conf.host
         floating_ip = router['_floatingips'][0]
         floating_ip['floating_network_id'] = router['gw_port']['network_id']
         floating_ip['host'] = agent.conf.host
@@ -229,7 +230,7 @@ class TestDvrRouter(framework.L3AgentTestFramework):
                  'network_id': external_gw_port['network_id'],
                  'device_owner': l3_constants.DEVICE_OWNER_AGENT_GW,
                  'mac_address': 'fa:16:3e:80:8d:89',
-                 'binding:host_id': self.agent.conf.host,
+                 portbindings.HOST_ID: self.agent.conf.host,
                  'fixed_ips': [{'subnet_id': fixed_ip['subnet_id'],
                                 'ip_address': fip_gw_port_ip,
                                 'prefixlen': prefixlen}],
index a6981f2515472b31660cf2f160e07a76aa870578..0e6e386857513daf5bdd548d0b2d8c5bc2fc5c86 100644 (file)
@@ -17,6 +17,7 @@ import mock
 from neutron.api.v2 import attributes
 from neutron.common import constants
 from neutron.extensions import external_net
+from neutron.extensions import portbindings
 from neutron.tests.common import helpers
 from neutron.tests.unit.plugins.ml2 import base as ml2_test_base
 
@@ -129,7 +130,7 @@ class L3DvrTestCase(ml2_test_base.ML2TestFramework):
                       'fixed_ips': attributes.ATTR_NOT_SPECIFIED,
                       'device_id': self.l3_agent['id'],
                       'device_owner': constants.DEVICE_OWNER_AGENT_GW,
-                      'binding:host_id': '',
+                      portbindings.HOST_ID: '',
                       'admin_state_up': True,
                       'name': ''}})
         return network_id, port
@@ -256,7 +257,7 @@ class L3DvrTestCase(ml2_test_base.ML2TestFramework):
                 if dvr:
                     l3_notif.routers_updated_on_host.assert_called_once_with(
                         self.context, [router['id']],
-                        int_port['port']['binding:host_id'])
+                        int_port['port'][portbindings.HOST_ID])
                     self.assertFalse(l3_notif.routers_updated.called)
                 else:
                     l3_notif.routers_updated.assert_called_once_with(
@@ -281,10 +282,10 @@ class L3DvrTestCase(ml2_test_base.ML2TestFramework):
             # locate internal ports on different hosts
             self.core_plugin.update_port(
                 self.context, int_port1['port']['id'],
-                {'port': {'binding:host_id': 'host1'}})
+                {'port': {portbindings.HOST_ID: 'host1'}})
             self.core_plugin.update_port(
                 self.context, int_port2['port']['id'],
-                {'port': {'binding:host_id': 'host2'}})
+                {'port': {portbindings.HOST_ID: 'host2'}})
             # and create l3 agents on corresponding hosts
             helpers.register_l3_agent(host='host1',
                 agent_mode=constants.L3_AGENT_MODE_DVR)
@@ -381,7 +382,7 @@ class L3DvrTestCase(ml2_test_base.ML2TestFramework):
                 if dvr:
                     l3_notif.routers_updated_on_host.assert_called_once_with(
                         self.context, [router['id']],
-                        int_port['port']['binding:host_id'])
+                        int_port['port'][portbindings.HOST_ID])
                     self.assertFalse(l3_notif.routers_updated.called)
                 else:
                     l3_notif.routers_updated.assert_called_once_with(
@@ -483,7 +484,7 @@ class L3DvrTestCase(ml2_test_base.ML2TestFramework):
                     constants.AGENT_TYPE_L3] = l3_notifier
                 self.core_plugin.update_port(
                     self.context, port['port']['id'],
-                    {'port': {'binding:host_id': HOST1}})
+                    {'port': {portbindings.HOST_ID: HOST1}})
 
                 # now router should be scheduled to dvr_snat agent and
                 # dvr agent on host1
@@ -503,7 +504,7 @@ class L3DvrTestCase(ml2_test_base.ML2TestFramework):
                 l3_notifier.reset_mock()
                 self.core_plugin.update_port(
                     self.context, port['port']['id'],
-                    {'port': {'binding:host_id': HOST2}})
+                    {'port': {portbindings.HOST_ID: HOST2}})
                 # now router should be scheduled to dvr_snat agent and
                 # dvr agent on host2
                 agents = self.l3_plugin.list_l3_agents_hosting_router(
index 22576d70914b3072bddb1c16040e1bacda57d5b7..f187f1e41d12e9f6f064a7422d2dd6d10c0f5713 100644 (file)
@@ -46,6 +46,7 @@ from neutron.agent import rpc as agent_rpc
 from neutron.common import config as base_config
 from neutron.common import constants as l3_constants
 from neutron.common import exceptions as n_exc
+from neutron.extensions import portbindings
 from neutron.plugins.common import constants as p_const
 from neutron.tests import base
 from neutron.tests.common import l3_test_common
@@ -352,7 +353,7 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework):
                       'subnets': [{'gateway_ip': '20.0.0.1'}],
                       'extra_subnets': [{'cidr': '172.16.0.0/24'}],
                       'id': _uuid(),
-                      'binding:host_id': HOSTNAME,
+                      portbindings.HOST_ID: HOSTNAME,
                       'network_id': _uuid(),
                       'mac_address': 'ca:fe:de:ad:be:ef'}
         ri.snat_ports = sn_port
index 36a8b1a105f0bf4162e9c2d444265a5933ff917b..b200cf57e8732c959717ca71e6dec536a804cb67 100644 (file)
@@ -31,6 +31,7 @@ from neutron.agent.linux import ip_lib
 from neutron.common import config as base_config
 from neutron.common import constants as l3_constants
 from neutron.common import utils as common_utils
+from neutron.extensions import portbindings
 from neutron.tests import base
 from neutron.tests.common import l3_test_common
 
@@ -487,7 +488,7 @@ class TestDvrRouterOperations(base.BaseTestCase):
                            'cidr': '20.0.0.0/24',
                            'gateway_ip': '20.0.0.1'}],
               'id': _uuid(),
-              'binding:host_id': 'myhost',
+              portbindings.HOST_ID: 'myhost',
               'device_owner': l3_constants.DEVICE_OWNER_AGENT_GW,
               'network_id': fake_network_id,
               'mac_address': 'ca:fe:de:ad:be:ef'}]
index 9e772bf06665d9c441e6c087a631102dc5d86b16..1786b732cbcdb596bf2f0c1225533bd1706d87b0 100644 (file)
@@ -20,6 +20,7 @@ from neutron.api.rpc.handlers import dhcp_rpc
 from neutron.common import constants
 from neutron.common import exceptions as n_exc
 from neutron.common import utils
+from neutron.extensions import portbindings
 from neutron.tests import base
 
 
@@ -169,7 +170,7 @@ class TestDhcpRpcCallback(base.BaseTestCase):
                 }
         expected_port = {'port': {'network_id': 'foo_network_id',
                                   'device_owner': constants.DEVICE_OWNER_DHCP,
-                                  'binding:host_id': 'foo_host',
+                                  portbindings.HOST_ID: 'foo_host',
                                   'fixed_ips': [{'subnet_id': 'foo_subnet_id'}]
                                   },
                          'id': 'foo_port_id'
@@ -193,7 +194,7 @@ class TestDhcpRpcCallback(base.BaseTestCase):
                 }
         expected_port = {'port': {'network_id': 'foo_network_id',
                                   'device_owner': constants.DEVICE_OWNER_DHCP,
-                                  'binding:host_id': 'foo_host',
+                                  portbindings.HOST_ID: 'foo_host',
                                   'fixed_ips': [{'subnet_id': 'foo_subnet_id'}]
                                   },
                          'id': 'foo_port_id'
@@ -225,7 +226,7 @@ class TestDhcpRpcCallback(base.BaseTestCase):
                 }
         expected_port = {'port': {'network_id': 'foo_network_id',
                                   'device_owner': constants.DEVICE_OWNER_DHCP,
-                                  'binding:host_id': 'foo_host',
+                                  portbindings.HOST_ID: 'foo_host',
                                   'fixed_ips': [{'subnet_id': 'foo_subnet_id'}]
                                   },
                          'id': 'foo_port_id'
index a0dd2c4c98b37a13145f0ae55b872944d69b5092..e752ca90fb9f99ef95991d47c7288c402985034e 100644 (file)
@@ -23,6 +23,7 @@ from neutron.db import agents_db
 from neutron.db import common_db_mixin
 from neutron.db import l3_agentschedulers_db
 from neutron.db import l3_dvr_db
+from neutron.extensions import portbindings
 from neutron import manager
 from neutron.plugins.common import constants as plugin_const
 from neutron.tests.unit.db import test_db_base_plugin_v2
@@ -267,13 +268,13 @@ class L3DvrTestCase(test_db_base_plugin_v2.NeutronDbPluginV2TestCase):
     def _helper_delete_floatingip_agent_gateway_port(self, port_host):
         ports = [{
             'id': 'my_port_id',
-            'binding:host_id': 'foo_host',
+            portbindings.HOST_ID: 'foo_host',
             'network_id': 'ext_network_id',
             'device_owner': l3_const.DEVICE_OWNER_ROUTER_GW
         },
                 {
             'id': 'my_new_port_id',
-            'binding:host_id': 'my_foo_host',
+            portbindings.HOST_ID: 'my_foo_host',
             'network_id': 'ext_network_id',
             'device_owner': l3_const.DEVICE_OWNER_ROUTER_GW
         }]
@@ -429,7 +430,7 @@ class L3DvrTestCase(test_db_base_plugin_v2.NeutronDbPluginV2TestCase):
         self, fip, floatingip_db, router_db):
         port = {
             'id': '1234',
-            'binding:host_id': 'myhost',
+            portbindings.HOST_ID: 'myhost',
             'network_id': 'external_net'
         }
 
index 331257410346f311860882b680a2d0756956e365..60c6edea9c886a697f5878499bd3aad1ec5f6568 100644 (file)
@@ -23,6 +23,7 @@ from neutron.agent.linux import interface
 from neutron.common import config as common_config
 from neutron.debug import commands
 from neutron.debug import debug_agent
+from neutron.extensions import portbindings
 from neutron.tests import base
 
 
@@ -114,7 +115,7 @@ class TestDebugCommands(base.BaseTestCase):
                      'admin_state_up': True,
                      'network_id': 'fake_net',
                      'tenant_id': 'fake_tenant',
-                     'binding:host_id': cfg.CONF.host,
+                     portbindings.HOST_ID: cfg.CONF.host,
                      'fixed_ips': [{'subnet_id': 'fake_subnet'}],
                      'device_id': socket.gethostname()}}
         namespace = 'qprobe-fake_port'
@@ -159,7 +160,7 @@ class TestDebugCommands(base.BaseTestCase):
                      'admin_state_up': True,
                      'network_id': 'fake_net',
                      'tenant_id': 'fake_tenant',
-                     'binding:host_id': cfg.CONF.host,
+                     portbindings.HOST_ID: cfg.CONF.host,
                      'fixed_ips': [{'subnet_id': 'fake_subnet'}],
                      'device_id': socket.gethostname()}}
         namespace = 'qprobe-fake_port'
@@ -288,7 +289,7 @@ class TestDebugCommands(base.BaseTestCase):
                      'admin_state_up': True,
                      'network_id': 'fake_net',
                      'tenant_id': 'fake_tenant',
-                     'binding:host_id': cfg.CONF.host,
+                     portbindings.HOST_ID: cfg.CONF.host,
                      'fixed_ips': [{'subnet_id': 'fake_subnet'}],
                      'device_id': socket.gethostname()}}
         expected = [mock.call.show_network('fake_net'),
index ac0e0ef4eb99a18af2e792eae32744e77a0a3887..efb5d53d0e8b82d2d1fab64b5d8ddddcfc2c6051 100644 (file)
@@ -2882,7 +2882,7 @@ class L3RpcCallbackTestCase(base.BaseTestCase):
             self.l3_rpc_cb._ensure_host_set_on_port(
                 mock.ANY, mock.ANY, port, router_id)
         self.l3_rpc_cb.plugin.update_port.assert_called_once_with(
-            mock.ANY, port_id, {'port': {'binding:host_id': mock.ANY}})
+            mock.ANY, port_id, {'port': {portbindings.HOST_ID: mock.ANY}})
         self.assertTrue(mock_log.call_count)
         expected_message = ('Port foo_port_id not found while updating '
                             'agent binding for router foo_router_id.')
index 7402cc49f57295a044e0b79b94c9dece778c81df..c45f9a337daa7232a516967d6b9c10a6b77a74a1 100644 (file)
@@ -731,11 +731,11 @@ class TestL2PopulationRpcTestCase(test_plugin.Ml2PluginV2TestCase):
                 self.assertEqual(port_id, details['port_id'])
 
     def _update_and_check_portbinding(self, port_id, host_id):
-        data = {'port': {'binding:host_id': host_id}}
+        data = {'port': {portbindings.HOST_ID: host_id}}
         req = self.new_update_request('ports', data, port_id)
         res = self.deserialize(self.fmt,
                                req.get_response(self.api))
-        self.assertEqual(host_id, res['port']['binding:host_id'])
+        self.assertEqual(host_id, res['port'][portbindings.HOST_ID])
 
     def _test_host_changed(self, twice):
         self._register_ml2_agents()
index c0011fb30adb929bb3e557a04cc32946dc22027b..b8b6af3f72b99343905ad4d4305d2146d61dc002 100644 (file)
@@ -995,7 +995,7 @@ class TestMl2PortBinding(Ml2PluginV2TestCase,
         plugin = manager.NeutronManager.get_plugin()
         port = {
             'id': 'foo_port_id',
-            'binding:host_id': 'foo_host',
+            portbindings.HOST_ID: 'foo_host',
         }
         with mock.patch.object(ml2_db, 'ensure_dvr_port_binding') as mock_dvr:
             plugin.update_dvr_port_binding(
index 3cc9588d85e7a2a9d16d9e94976782d93453c9b9..32730f457a46f5c752105a9e1c9660b167009de9 100644 (file)
@@ -39,6 +39,7 @@ from neutron.db import l3_hamode_db
 from neutron.db import l3_hascheduler_db
 from neutron.extensions import l3_ext_ha_mode as l3_ha
 from neutron.extensions import l3agentscheduler as l3agent
+from neutron.extensions import portbindings
 from neutron import manager
 from neutron.scheduler import l3_agent_scheduler
 from neutron.tests import base
@@ -758,7 +759,7 @@ class L3SchedulerTestBaseMixin(object):
         l3_agent = self._prepare_check_ports_exist_tests()
         # matching subnet
         port = {'subnet_id': str(uuid.uuid4()),
-                'binding:host_id': 'host_1',
+                portbindings.HOST_ID: 'host_1',
                 'device_owner': constants.DEVICE_OWNER_COMPUTE_PREFIX,
                 'id': 1234}
         subnet = {'id': str(uuid.uuid4()),
@@ -949,7 +950,7 @@ class L3DvrSchedulerTestCase(testlib_api.SqlTestCase):
             'port': None,
             'original_port': {
                 'id': port_id,
-                'binding:host_id': 'vm-host',
+                portbindings.HOST_ID: 'vm-host',
                 'device_id': 'vm-id',
                 'device_owner': DEVICE_OWNER_COMPUTE,
                 'mac_address': '02:04:05:17:18:19'
@@ -981,14 +982,14 @@ class L3DvrSchedulerTestCase(testlib_api.SqlTestCase):
             'context': self.adminContext,
             'port': {
                 'id': port_id,
-                'binding:host_id': None,
+                portbindings.HOST_ID: None,
                 'device_id': '',
                 'device_owner': ''
             },
             'mac_address_updated': False,
             'original_port': {
                 'id': port_id,
-                'binding:host_id': 'vm-host',
+                portbindings.HOST_ID: 'vm-host',
                 'device_id': 'vm-id',
                 'device_owner': DEVICE_OWNER_COMPUTE
             }
@@ -1046,7 +1047,7 @@ class L3DvrSchedulerTestCase(testlib_api.SqlTestCase):
                 'id': 'port1',
                 'device_id': 'abcd',
                 'device_owner': DEVICE_OWNER_COMPUTE_NOVA,
-                'binding:host_id': 'host1',
+                portbindings.HOST_ID: 'host1',
                 'fixed_ips': [
                     {
                         'subnet_id': '80947d4a-fbc8-484b-9f92-623a6bfcf3e0',
@@ -1094,7 +1095,8 @@ class L3DvrSchedulerTestCase(testlib_api.SqlTestCase):
             self.dut.dvr_update_router_addvm(self.adminContext, port)
 
             get_l3_agents.assert_called_once_with(
-                self.adminContext, filters={'host': [port['binding:host_id']]})
+                self.adminContext,
+                filters={'host': [port[portbindings.HOST_ID]]})
             (self.dut.l3_rpc_notifier.routers_updated_on_host.
                 assert_called_once_with(
                     self.adminContext, {'r1', 'r2'}, 'host1'))
@@ -1173,7 +1175,7 @@ class L3DvrSchedulerTestCase(testlib_api.SqlTestCase):
                 'id': 'fake_id',
                 'device_id': 'r1',
                 'status': port_status,
-                'binding:host_id': 'thisHost',
+                portbindings.HOST_ID: 'thisHost',
                 'device_owner': DEVICE_OWNER_COMPUTE_NOVA,
                 'fixed_ips': [
                     {
@@ -1228,7 +1230,7 @@ class L3DvrSchedulerTestCase(testlib_api.SqlTestCase):
                 'id': 'lbaas-vip-port1',
                 'device_id': 'vip-pool-id',
                 'status': 'ACTIVE',
-                'binding:host_id': 'thisHost',
+                portbindings.HOST_ID: 'thisHost',
                 'device_owner': device_owner,
                 'fixed_ips': [
                     {
@@ -1256,7 +1258,7 @@ class L3DvrSchedulerTestCase(testlib_api.SqlTestCase):
             'device_id': port_name,
             'device_owner': device_owner,
             'status': status,
-            'binding:host_id': host,
+            portbindings.HOST_ID: host,
             'fixed_ips': [
                 {
                     'subnet_id': subnet_id,
@@ -1443,7 +1445,7 @@ class L3DvrSchedulerTestCase(testlib_api.SqlTestCase):
                 'id': 'dhcp-port1',
                 'device_id': 'dhcp-net-id',
                 'status': 'ACTIVE',
-                'binding:host_id': 'thisHost',
+                portbindings.HOST_ID: 'thisHost',
                 'device_owner': constants.DEVICE_OWNER_DHCP,
                 'fixed_ips': [
                     {