]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Use DEVICE_OWNER_COMPUTE constant everywhere
authorIhar Hrachyshka <ihrachys@redhat.com>
Wed, 30 Sep 2015 10:50:38 +0000 (12:50 +0200)
committerIhar Hrachyshka <ihrachys@redhat.com>
Sat, 14 Nov 2015 17:54:17 +0000 (18:54 +0100)
Now that we have the constant defined, we should reuse it from other
code to avoid potential typos.

Change-Id: Iebb270be46b116df3441370dc1a6784571311aa9

19 files changed:
neutron/common/constants.py
neutron/common/utils.py
neutron/debug/debug_agent.py
neutron/notifiers/nova.py
neutron/tests/functional/agent/linux/test_iptables_firewall.py
neutron/tests/functional/agent/test_l3_agent.py
neutron/tests/functional/services/l3_router/test_l3_dvr_router_plugin.py
neutron/tests/unit/common/test_utils.py
neutron/tests/unit/db/test_agentschedulers_db.py
neutron/tests/unit/db/test_db_base_plugin_v2.py
neutron/tests/unit/extensions/test_l3.py
neutron/tests/unit/extensions/test_l3_ext_gw_mode.py
neutron/tests/unit/notifiers/test_nova.py
neutron/tests/unit/objects/qos/test_rule.py
neutron/tests/unit/plugins/ml2/drivers/l2pop/test_mech_driver.py
neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_neutron_agent.py
neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_tunnel.py
neutron/tests/unit/plugins/ml2/test_plugin.py
neutron/tests/unit/scheduler/test_l3_agent_scheduler.py

index 8d468d3b8584bc8496b34fad4df72703d98cd33f..173188621c37a200b3dfb381feb1d18ca221b627 100644 (file)
@@ -30,6 +30,8 @@ FLOATINGIP_STATUS_ACTIVE = 'ACTIVE'
 FLOATINGIP_STATUS_DOWN = 'DOWN'
 FLOATINGIP_STATUS_ERROR = 'ERROR'
 
+DEVICE_OWNER_COMPUTE_PREFIX = "compute:"
+
 DEVICE_OWNER_ROUTER_HA_INTF = "network:router_ha_interface"
 DEVICE_OWNER_ROUTER_INTF = "network:router_interface"
 DEVICE_OWNER_ROUTER_GW = "network:router_gateway"
index 83886d5979b48d018143f1042568c1b30530588f..b6d1e7492e76c03684a88fd92d5f6884eab0e099 100644 (file)
@@ -378,7 +378,7 @@ def is_dvr_serviced(device_owner):
     dvr_serviced_device_owners = (n_const.DEVICE_OWNER_LOADBALANCER,
                                   n_const.DEVICE_OWNER_LOADBALANCERV2,
                                   n_const.DEVICE_OWNER_DHCP)
-    return (device_owner.startswith('compute:') or
+    return (device_owner.startswith(n_const.DEVICE_OWNER_COMPUTE_PREFIX) or
             device_owner in dvr_serviced_device_owners)
 
 
index 89f17bd0973c7b4e419998e7bec2bf5708121b40..8c4966b4997350b7743f7c4e628d1a4c42942540 100644 (file)
@@ -23,6 +23,7 @@ from oslo_log import log as logging
 from neutron.agent.linux import dhcp
 from neutron.agent.linux import ip_lib
 from neutron.agent.linux import utils
+from neutron.common import constants
 from neutron.i18n import _LW
 
 
@@ -30,7 +31,7 @@ LOG = logging.getLogger(__name__)
 
 DEVICE_OWNER_NETWORK_PROBE = 'network:probe'
 
-DEVICE_OWNER_COMPUTE_PROBE = 'compute:probe'
+DEVICE_OWNER_COMPUTE_PROBE = constants.DEVICE_OWNER_COMPUTE_PREFIX + 'probe'
 
 
 class NeutronDebugAgent(object):
index adb6520c8b18f3ffcc94c2c8487224921a47c8d9..3479ef91db1566d5731d48738a89c9a2b57b6e2d 100644 (file)
@@ -67,7 +67,8 @@ class Notifier(object):
     def _is_compute_port(self, port):
         try:
             if (port['device_id'] and uuidutils.is_uuid_like(port['device_id'])
-                    and port['device_owner'].startswith('compute:')):
+                    and port['device_owner'].startswith(
+                        constants.DEVICE_OWNER_COMPUTE_PREFIX)):
                 return True
         except (KeyError, AttributeError):
             pass
index 2d82fdd73b8e4dc84b5daa8baf81f76b25f74d3c..625bb7c8ef3fcb855038b67f3129eda24c600dde 100644 (file)
 
 from neutron.agent.linux import iptables_firewall
 from neutron.agent import securitygroups_rpc as sg_cfg
+from neutron.common import constants
 from neutron.tests.common import machine_fixtures
 from neutron.tests.common import net_helpers
 from neutron.tests.functional import base
 from oslo_config import cfg
 
+DEVICE_OWNER_COMPUTE = constants.DEVICE_OWNER_COMPUTE_PREFIX + 'fake'
+
 
 class IptablesFirewallTestCase(base.BaseSudoTestCase):
     MAC_REAL = "fa:16:3e:9a:2f:49"
@@ -51,7 +54,7 @@ class IptablesFirewallTestCase(base.BaseSudoTestCase):
             self.client.port.name)
         self.src_port_desc = {'admin_state_up': True,
                               'device': client_br_port_name,
-                              'device_owner': 'compute:None',
+                              'device_owner': DEVICE_OWNER_COMPUTE,
                               'fixed_ips': [self.client.ip],
                               'mac_address': self.MAC_REAL,
                               'port_security_enabled': True,
index d8eca96307d94b2bcb47264dffc083a00fd200cd..e2bcd9696e1fc1a0fabe92ddc5574b1ff998aa3b 100644 (file)
@@ -59,6 +59,8 @@ _uuid = uuidutils.generate_uuid
 METADATA_REQUEST_TIMEOUT = 60
 METADATA_REQUEST_SLEEP = 5
 
+DEVICE_OWNER_COMPUTE = l3_constants.DEVICE_OWNER_COMPUTE_PREFIX + 'fake'
+
 
 def get_ovs_bridge(br_name):
     return ovs_lib.OVSBridge(br_name)
@@ -1413,7 +1415,7 @@ class TestDvrRouter(L3AgentTestFramework):
         port_data = {
             'fixed_ips': [{'ip_address': expected_neighbor}],
             'mac_address': 'fa:3e:aa:bb:cc:dd',
-            'device_owner': 'compute:None'
+            'device_owner': DEVICE_OWNER_COMPUTE
         }
         self.agent.plugin_rpc.get_ports_by_subnet.return_value = [port_data]
         router1 = self.manage_router(self.agent, router_info)
index da0ba9216d7e303e20b891388480ecb1e6ae7d6b..c65b271c7ab96357ca842cc9f48d7b2ecdcc95e6 100644 (file)
 import mock
 
 from neutron.api.v2 import attributes
-from neutron.common import constants as l3_const
+from neutron.common import constants
 from neutron.extensions import external_net
 from neutron.tests.common import helpers
 from neutron.tests.unit.plugins.ml2 import base as ml2_test_base
 
 
+DEVICE_OWNER_COMPUTE = constants.DEVICE_OWNER_COMPUTE_PREFIX + 'fake'
+
+
 class L3DvrTestCase(ml2_test_base.ML2TestFramework):
     def setUp(self):
         super(L3DvrTestCase, self).setUp()
         self.l3_agent = helpers.register_l3_agent(
-            agent_mode=l3_const.L3_AGENT_MODE_DVR_SNAT)
+            agent_mode=constants.L3_AGENT_MODE_DVR_SNAT)
 
     def _create_router(self, distributed=True):
         return (super(L3DvrTestCase, self).
@@ -45,19 +48,19 @@ class L3DvrTestCase(ml2_test_base.ML2TestFramework):
     def test_get_device_owner_distributed_router_object(self):
         router = self._create_router()
         self.assertEqual(
-            l3_const.DEVICE_OWNER_DVR_INTERFACE,
+            constants.DEVICE_OWNER_DVR_INTERFACE,
             self.l3_plugin._get_device_owner(self.context, router))
 
     def test_get_device_owner_distributed_router_id(self):
         router = self._create_router()
         self.assertEqual(
-            l3_const.DEVICE_OWNER_DVR_INTERFACE,
+            constants.DEVICE_OWNER_DVR_INTERFACE,
             self.l3_plugin._get_device_owner(self.context, router['id']))
 
     def test_get_device_owner_centralized(self):
         router = self._create_router(distributed=False)
         self.assertEqual(
-            l3_const.DEVICE_OWNER_ROUTER_INTF,
+            constants.DEVICE_OWNER_ROUTER_INTF,
             self.l3_plugin._get_device_owner(self.context, router['id']))
 
     def test_get_agent_gw_ports_exist_for_network_no_port(self):
@@ -98,7 +101,7 @@ class L3DvrTestCase(ml2_test_base.ML2TestFramework):
                         self.context, filters={
                             'network_id': [subnet1['subnet']['network_id']],
                             'device_owner':
-                                [l3_const.DEVICE_OWNER_DVR_INTERFACE]})[0]
+                                [constants.DEVICE_OWNER_DVR_INTERFACE]})[0]
                     self.l3_plugin.remove_router_interface(
                         self.context, router['id'],
                         {'port_id': port['id']})
@@ -125,7 +128,7 @@ class L3DvrTestCase(ml2_test_base.ML2TestFramework):
                       'mac_address': attributes.ATTR_NOT_SPECIFIED,
                       'fixed_ips': attributes.ATTR_NOT_SPECIFIED,
                       'device_id': self.l3_agent['id'],
-                      'device_owner': l3_const.DEVICE_OWNER_AGENT_GW,
+                      'device_owner': constants.DEVICE_OWNER_AGENT_GW,
                       'binding:host_id': '',
                       'admin_state_up': True,
                       'name': ''}})
@@ -227,7 +230,7 @@ class L3DvrTestCase(ml2_test_base.ML2TestFramework):
         with self.subnet() as ext_subnet,\
                 self.subnet(cidr='20.0.0.0/24') as int_subnet,\
                 self.port(subnet=int_subnet,
-                          device_owner='compute:None') as int_port:
+                          device_owner=DEVICE_OWNER_COMPUTE) as int_port:
             # make net external
             ext_net_id = ext_subnet['subnet']['network_id']
             self._update('networks', ext_net_id,
@@ -272,9 +275,9 @@ class L3DvrTestCase(ml2_test_base.ML2TestFramework):
                 self.subnet(cidr='20.0.0.0/24') as int_subnet1,\
                 self.subnet(cidr='30.0.0.0/24') as int_subnet2,\
                 self.port(subnet=int_subnet1,
-                          device_owner='compute:None') as int_port1,\
+                          device_owner=DEVICE_OWNER_COMPUTE) as int_port1,\
                 self.port(subnet=int_subnet2,
-                          device_owner='compute:None') as int_port2:
+                          device_owner=DEVICE_OWNER_COMPUTE) as int_port2:
             # locate internal ports on different hosts
             self.core_plugin.update_port(
                 self.context, int_port1['port']['id'],
@@ -284,9 +287,9 @@ class L3DvrTestCase(ml2_test_base.ML2TestFramework):
                 {'port': {'binding:host_id': 'host2'}})
             # and create l3 agents on corresponding hosts
             helpers.register_l3_agent(host='host1',
-                agent_mode=l3_const.L3_AGENT_MODE_DVR)
+                agent_mode=constants.L3_AGENT_MODE_DVR)
             helpers.register_l3_agent(host='host2',
-                agent_mode=l3_const.L3_AGENT_MODE_DVR)
+                agent_mode=constants.L3_AGENT_MODE_DVR)
 
             # make net external
             ext_net_id = ext_subnet['subnet']['network_id']
@@ -350,7 +353,7 @@ class L3DvrTestCase(ml2_test_base.ML2TestFramework):
         with self.subnet() as ext_subnet,\
                 self.subnet(cidr='20.0.0.0/24') as int_subnet,\
                 self.port(subnet=int_subnet,
-                          device_owner='compute:None') as int_port:
+                          device_owner=DEVICE_OWNER_COMPUTE) as int_port:
             # make net external
             ext_net_id = ext_subnet['subnet']['network_id']
             self._update('networks', ext_net_id,
@@ -456,7 +459,7 @@ class L3DvrTestCase(ml2_test_base.ML2TestFramework):
         # register l3 agent in dvr mode in addition to existing dvr_snat agent
         HOST = 'host1'
         dvr_agent = helpers.register_l3_agent(
-            host=HOST, agent_mode=l3_const.L3_AGENT_MODE_DVR)
+            host=HOST, agent_mode=constants.L3_AGENT_MODE_DVR)
         router = self._create_router()
         with self.subnet() as subnet:
             self.l3_plugin.add_router_interface(
@@ -472,7 +475,7 @@ class L3DvrTestCase(ml2_test_base.ML2TestFramework):
             with mock.patch.object(self.l3_plugin,
                                    '_l3_rpc_notifier') as l3_notifier,\
                     self.port(subnet=subnet,
-                              device_owner='compute:None') as port:
+                              device_owner=DEVICE_OWNER_COMPUTE) as port:
                 self.core_plugin.update_port(
                     self.context, port['port']['id'],
                     {'port': {'binding:host_id': HOST}})
index 97939ebaff83de3c426363e661fc27369ad146f8..553c6622b7281ce7d0da46dfab79ce9db6a93edd 100644 (file)
@@ -570,7 +570,7 @@ class TestDvrServices(base.BaseTestCase):
         self._test_is_dvr_serviced(constants.DEVICE_OWNER_DHCP, True)
 
     def test_is_dvr_serviced_with_vm_port(self):
-        self._test_is_dvr_serviced('compute:', True)
+        self._test_is_dvr_serviced(constants.DEVICE_OWNER_COMPUTE_PREFIX, True)
 
 
 class TestIpToCidr(base.BaseTestCase):
index 2a56241ab34ef61c162c892e9f6e3a3b0c9b08e9..65e34e702791e5ced1bfbdeb6fbc4608e56c0991 100644 (file)
@@ -52,6 +52,10 @@ DHCP_HOSTA = 'hosta'
 L3_HOSTB = 'hostb'
 DHCP_HOSTC = 'hostc'
 
+DEVICE_OWNER_COMPUTE = ''.join([constants.DEVICE_OWNER_COMPUTE_PREFIX,
+                                'test:',
+                                DHCP_HOSTA])
+
 
 class AgentSchedulerTestMixIn(object):
 
@@ -402,7 +406,7 @@ class OvsAgentSchedulerTestCase(OvsAgentSchedulerTestCaseBase):
             result0 = len(dhcp_agents['agents'])
             self._register_agent_states()
             with self.port(subnet=subnet,
-                           device_owner="compute:test:" + DHCP_HOSTA) as port:
+                           device_owner=DEVICE_OWNER_COMPUTE) as port:
                 dhcp_agents = self._list_dhcp_agents_hosting_network(
                     port['port']['network_id'])
                 result1 = len(dhcp_agents['agents'])
@@ -417,7 +421,7 @@ class OvsAgentSchedulerTestCase(OvsAgentSchedulerTestCaseBase):
             result0 = len(dhcp_agents['agents'])
             self._register_agent_states()
             with self.port(subnet=subnet,
-                           device_owner="compute:test:" + DHCP_HOSTA) as port:
+                           device_owner=DEVICE_OWNER_COMPUTE) as port:
                 dhcp_agents = self._list_dhcp_agents_hosting_network(
                     port['port']['network_id'])
                 result1 = len(dhcp_agents['agents'])
@@ -432,13 +436,13 @@ class OvsAgentSchedulerTestCase(OvsAgentSchedulerTestCaseBase):
             result0 = len(dhcp_agents['agents'])
             self._register_agent_states()
             with self.port(subnet=subnet,
-                           device_owner="compute:test:" + DHCP_HOSTA) as port:
+                           device_owner=DEVICE_OWNER_COMPUTE) as port:
                 dhcp_agents = self._list_dhcp_agents_hosting_network(
                     port['port']['network_id'])
                 result1 = len(dhcp_agents['agents'])
             helpers.register_dhcp_agent('host1')
             with self.port(subnet=subnet,
-                           device_owner="compute:test:" + DHCP_HOSTA) as port:
+                           device_owner=DEVICE_OWNER_COMPUTE) as port:
                 dhcp_agents = self._list_dhcp_agents_hosting_network(
                     port['port']['network_id'])
                 result2 = len(dhcp_agents['agents'])
index 4f2ee240ed606128eba29a4369c9abc41d9670c8..1834deefccdc5e1f56f01d18c562f2deb4e165a1 100644 (file)
@@ -51,7 +51,7 @@ from neutron.tests.unit import testlib_api
 
 DB_PLUGIN_KLASS = 'neutron.db.db_base_plugin_v2.NeutronDbPluginV2'
 
-DEVICE_OWNER_COMPUTE = 'compute:None'
+DEVICE_OWNER_COMPUTE = constants.DEVICE_OWNER_COMPUTE_PREFIX + 'fake'
 DEVICE_OWNER_NOT_COMPUTE = constants.DEVICE_OWNER_DHCP
 
 
index f9dc6a8c8ca9a07adfcb9e0db660049c19742186..e0e8cee5532aa524bfc03e68855dcff18317b816 100644 (file)
@@ -62,6 +62,9 @@ _uuid = uuidutils.generate_uuid
 _get_path = test_base._get_path
 
 
+DEVICE_OWNER_COMPUTE = l3_constants.DEVICE_OWNER_COMPUTE_PREFIX + 'fake'
+
+
 class L3TestExtensionManager(object):
 
     def get_resources(self):
@@ -2831,7 +2834,7 @@ class L3RpcCallbackTestCase(base.BaseTestCase):
         port_id = 'foo_port_id'
         port = {
             'id': port_id,
-            'device_owner': 'compute:None',
+            'device_owner': DEVICE_OWNER_COMPUTE,
             portbindings.HOST_ID: '',
             portbindings.VIF_TYPE: portbindings.VIF_TYPE_BINDING_FAILED
         }
index 83f2d13c4f2b525c6b9c8ad17882df835d4c960b..28577f57112fc636bf126655f3a34d819b20b60a 100644 (file)
@@ -204,7 +204,7 @@ class TestL3GwModeMixin(testlib_api.SqlTestCase):
             tenant_id=self.tenant_id,
             admin_state_up=True,
             device_id='something',
-            device_owner='compute:nova',
+            device_owner=constants.DEVICE_OWNER_COMPUTE_PREFIX + 'nova',
             status=constants.PORT_STATUS_ACTIVE,
             mac_address=FAKE_FIP_INT_PORT_MAC,
             network_id=self.int_net_id)
index 6f6a24b8c5805f9aa9f899ed56176dbb11cf5a8b..551e912a5efb6cce3facddb11bf52bf83a38b4a5 100644 (file)
@@ -21,11 +21,13 @@ from sqlalchemy.orm import attributes as sql_attr
 
 from oslo_config import cfg
 
-from neutron.common import constants
+from neutron.common import constants as n_const
 from neutron.db import models_v2
 from neutron.notifiers import nova
 from neutron.tests import base
 
+DEVICE_OWNER_COMPUTE = n_const.DEVICE_OWNER_COMPUTE_PREFIX + 'fake'
+
 
 class TestNovaNotify(base.BaseTestCase):
     def setUp(self, plugin=None):
@@ -35,14 +37,14 @@ class TestNovaNotify(base.BaseTestCase):
             def get_port(self, context, port_id):
                 device_id = '32102d7b-1cf4-404d-b50a-97aae1f55f87'
                 return {'device_id': device_id,
-                        'device_owner': 'compute:None'}
+                        'device_owner': DEVICE_OWNER_COMPUTE}
 
         self.nova_notifier = nova.Notifier()
         self.nova_notifier._plugin_ref = FakePlugin()
 
     def test_notify_port_status_all_values(self):
-        states = [constants.PORT_STATUS_ACTIVE, constants.PORT_STATUS_DOWN,
-                  constants.PORT_STATUS_ERROR, constants.PORT_STATUS_BUILD,
+        states = [n_const.PORT_STATUS_ACTIVE, n_const.PORT_STATUS_DOWN,
+                  n_const.PORT_STATUS_ERROR, n_const.PORT_STATUS_BUILD,
                   sql_attr.NO_VALUE]
         device_id = '32102d7b-1cf4-404d-b50a-97aae1f55f87'
         # test all combinations
@@ -50,7 +52,7 @@ class TestNovaNotify(base.BaseTestCase):
             for current_port_status in states:
 
                 port = models_v2.Port(id='port-uuid', device_id=device_id,
-                                      device_owner="compute:",
+                                      device_owner=DEVICE_OWNER_COMPUTE,
                                       status=current_port_status)
                 self._record_port_status_changed_helper(current_port_status,
                                                         previous_port_status,
@@ -58,33 +60,33 @@ class TestNovaNotify(base.BaseTestCase):
 
     def test_port_without_uuid_device_id_no_notify(self):
         port = models_v2.Port(id='port-uuid', device_id='compute_probe:',
-                              device_owner='compute:',
-                              status=constants.PORT_STATUS_ACTIVE)
-        self._record_port_status_changed_helper(constants.PORT_STATUS_ACTIVE,
+                              device_owner=DEVICE_OWNER_COMPUTE,
+                              status=n_const.PORT_STATUS_ACTIVE)
+        self._record_port_status_changed_helper(n_const.PORT_STATUS_ACTIVE,
                                                 sql_attr.NO_VALUE,
                                                 port)
 
     def test_port_without_device_owner_no_notify(self):
         device_id = '32102d7b-1cf4-404d-b50a-97aae1f55f87'
         port = models_v2.Port(id='port-uuid', device_id=device_id,
-                              status=constants.PORT_STATUS_ACTIVE)
-        self._record_port_status_changed_helper(constants.PORT_STATUS_ACTIVE,
+                              status=n_const.PORT_STATUS_ACTIVE)
+        self._record_port_status_changed_helper(n_const.PORT_STATUS_ACTIVE,
                                                 sql_attr.NO_VALUE,
                                                 port)
 
     def test_port_without_device_id_no_notify(self):
         port = models_v2.Port(id='port-uuid', device_owner="network:dhcp",
-                              status=constants.PORT_STATUS_ACTIVE)
-        self._record_port_status_changed_helper(constants.PORT_STATUS_ACTIVE,
+                              status=n_const.PORT_STATUS_ACTIVE)
+        self._record_port_status_changed_helper(n_const.PORT_STATUS_ACTIVE,
                                                 sql_attr.NO_VALUE,
                                                 port)
 
     def test_port_without_id_no_notify(self):
         device_id = '32102d7b-1cf4-404d-b50a-97aae1f55f87'
         port = models_v2.Port(device_id=device_id,
-                              device_owner="compute:",
-                              status=constants.PORT_STATUS_ACTIVE)
-        self._record_port_status_changed_helper(constants.PORT_STATUS_ACTIVE,
+                              device_owner=DEVICE_OWNER_COMPUTE,
+                              status=n_const.PORT_STATUS_ACTIVE)
+        self._record_port_status_changed_helper(n_const.PORT_STATUS_ACTIVE,
                                                 sql_attr.NO_VALUE,
                                                 port)
 
@@ -92,8 +94,8 @@ class TestNovaNotify(base.BaseTestCase):
         device_id = '32102d7b-1cf4-404d-b50a-97aae1f55f87'
         port = models_v2.Port(id='port-uuid', device_id=device_id,
                               device_owner="network:dhcp",
-                              status=constants.PORT_STATUS_ACTIVE)
-        self._record_port_status_changed_helper(constants.PORT_STATUS_ACTIVE,
+                              status=n_const.PORT_STATUS_ACTIVE)
+        self._record_port_status_changed_helper(n_const.PORT_STATUS_ACTIVE,
                                                 sql_attr.NO_VALUE,
                                                 port)
 
@@ -101,19 +103,20 @@ class TestNovaNotify(base.BaseTestCase):
                                            previous_port_status, port):
 
         if not (port.device_id and port.id and port.device_owner and
-                port.device_owner.startswith('compute:') and
+                port.device_owner.startswith(
+                    n_const.DEVICE_OWNER_COMPUTE_PREFIX) and
                 uuidutils.is_uuid_like(port.device_id)):
             return
 
-        if (previous_port_status == constants.PORT_STATUS_ACTIVE and
-                current_port_status == constants.PORT_STATUS_DOWN):
+        if (previous_port_status == n_const.PORT_STATUS_ACTIVE and
+                current_port_status == n_const.PORT_STATUS_DOWN):
             event_name = nova.VIF_UNPLUGGED
 
         elif (previous_port_status in [sql_attr.NO_VALUE,
-                                       constants.PORT_STATUS_DOWN,
-                                       constants.PORT_STATUS_BUILD]
-              and current_port_status in [constants.PORT_STATUS_ACTIVE,
-                                          constants.PORT_STATUS_ERROR]):
+                                       n_const.PORT_STATUS_DOWN,
+                                       n_const.PORT_STATUS_BUILD]
+              and current_port_status in [n_const.PORT_STATUS_ACTIVE,
+                                          n_const.PORT_STATUS_ERROR]):
             event_name = nova.VIF_PLUGGED
 
         else:
@@ -132,7 +135,7 @@ class TestNovaNotify(base.BaseTestCase):
     def test_update_fixed_ip_changed(self):
         device_id = '32102d7b-1cf4-404d-b50a-97aae1f55f87'
         returned_obj = {'port':
-                        {'device_owner': u'compute:dfd',
+                        {'device_owner': DEVICE_OWNER_COMPUTE,
                          'id': u'bee50827-bcee-4cc8-91c1-a27b0ce54222',
                          'device_id': device_id}}
 
@@ -295,7 +298,7 @@ class TestNovaNotify(base.BaseTestCase):
         device_id = '32102d7b-1cf4-404d-b50a-97aae1f55f87'
         port_id = 'bee50827-bcee-4cc8-91c1-a27b0ce54222'
         returned_obj = {'port':
-                        {'device_owner': 'compute:dfd',
+                        {'device_owner': DEVICE_OWNER_COMPUTE,
                          'id': port_id,
                          'device_id': device_id}}
 
index f4e14e7038d34bbb2266360e803c0797886e5394..e73778287e6f4eda09743363e64768518b47a208 100644 (file)
@@ -20,7 +20,7 @@ from neutron.tests.unit import testlib_api
 
 POLICY_ID_A = 'policy-id-a'
 POLICY_ID_B = 'policy-id-b'
-DEVICE_OWNER_COMPUTE = 'compute:None'
+DEVICE_OWNER_COMPUTE = constants.DEVICE_OWNER_COMPUTE_PREFIX + 'fake'
 
 
 class QosRuleObjectTestCase(neutron_test_base.BaseTestCase):
index ef03866572756ab66468bd96a8d1071396f1e25a..ccfe85ba3fd0ad2b2b68e97e159be307ef4a7102 100644 (file)
@@ -43,7 +43,7 @@ HOST_5 = HOST + '_5'
 
 
 NOTIFIER = 'neutron.plugins.ml2.rpc.AgentNotifierApi'
-DEVICE_OWNER_COMPUTE = 'compute:None'
+DEVICE_OWNER_COMPUTE = constants.DEVICE_OWNER_COMPUTE_PREFIX + 'fake'
 
 
 class TestL2PopulationRpcTestCase(test_plugin.Ml2PluginV2TestCase):
@@ -894,7 +894,7 @@ class TestL2PopulationMechDriver(base.BaseTestCase):
 
     def test_update_port_precommit_mac_address_changed_raises(self):
         port = {'status': u'ACTIVE',
-                'device_owner': u'compute:None',
+                'device_owner': DEVICE_OWNER_COMPUTE,
                 'mac_address': u'12:34:56:78:4b:0e',
                 'id': u'1'}
 
index 304d5f02cf930b9057ea172810cc28c60aed2502..25936b77934cca94fee1e50ba3e8062f39d629b0 100644 (file)
@@ -50,6 +50,8 @@ TEST_PORT_ID3 = 'port-id-3'
 TEST_NETWORK_ID1 = 'net-id-1'
 TEST_NETWORK_ID2 = 'net-id-2'
 
+DEVICE_OWNER_COMPUTE = n_const.DEVICE_OWNER_COMPUTE_PREFIX + 'fake'
+
 
 class FakeVif(object):
     ofport = 99
@@ -167,7 +169,7 @@ class TestOvsNeutronAgent(object):
             int_br.set_db_attribute.return_value = True
             needs_binding = self.agent.port_bound(
                 port, net_uuid, 'local', None, None,
-                fixed_ips, "compute:None", False)
+                fixed_ips, DEVICE_OWNER_COMPUTE, False)
         if db_get_val is None:
             self.assertEqual(0, int_br.set_db_attribute.call_count)
             self.assertFalse(needs_binding)
@@ -602,7 +604,7 @@ class TestOvsNeutronAgent(object):
                              'network_type': 'baz',
                              'fixed_ips': [{'subnet_id': 'my-subnet-uuid',
                                             'ip_address': '1.1.1.1'}],
-                             'device_owner': 'compute:None',
+                             'device_owner': DEVICE_OWNER_COMPUTE,
                              'port_security_enabled': True
                              }
 
@@ -2054,13 +2056,13 @@ class TestOvsDvrNeutronAgent(object):
 
     def test_port_bound_for_dvr_with_compute_ports(self):
         self._test_port_bound_for_dvr_on_vlan_network(
-            device_owner="compute:None")
+            device_owner=DEVICE_OWNER_COMPUTE)
         self._test_port_bound_for_dvr_on_vlan_network(
-            device_owner="compute:None", ip_version=6)
+            device_owner=DEVICE_OWNER_COMPUTE, ip_version=6)
         self._test_port_bound_for_dvr_on_vxlan_network(
-            device_owner="compute:None")
+            device_owner=DEVICE_OWNER_COMPUTE)
         self._test_port_bound_for_dvr_on_vxlan_network(
-            device_owner="compute:None", ip_version=6)
+            device_owner=DEVICE_OWNER_COMPUTE, ip_version=6)
 
     def test_port_bound_for_dvr_with_lbaas_vip_ports(self):
         self._test_port_bound_for_dvr_on_vlan_network(
@@ -2348,9 +2350,9 @@ class TestOvsDvrNeutronAgent(object):
 
     def test_treat_devices_removed_for_dvr_with_compute_ports(self):
         self._test_treat_devices_removed_for_dvr(
-            device_owner="compute:None")
+            device_owner=DEVICE_OWNER_COMPUTE)
         self._test_treat_devices_removed_for_dvr(
-            device_owner="compute:None", ip_version=6)
+            device_owner=DEVICE_OWNER_COMPUTE, ip_version=6)
 
     def test_treat_devices_removed_for_dvr_with_lbaas_vip_ports(self):
         self._test_treat_devices_removed_for_dvr(
index 079d2dea083e74df087daa34e887c574c5d10749..c0cecfcb87c9226af78eb1ba4ac652c89870c280 100644 (file)
@@ -23,6 +23,7 @@ import six
 
 from neutron.agent.common import ovs_lib
 from neutron.agent.linux import ip_lib
+from neutron.common import constants as n_const
 from neutron.plugins.common import constants as p_const
 from neutron.plugins.ml2.drivers.openvswitch.agent.common import constants
 from neutron.tests.unit.plugins.ml2.drivers.openvswitch.agent \
@@ -48,7 +49,7 @@ VIF_PORT = ovs_lib.VifPort('port', OFPORT_NUM,
 VIF_PORTS = {VIF_ID: VIF_PORT}
 FIXED_IPS = [{'subnet_id': 'my-subnet-uuid',
               'ip_address': '1.1.1.1'}]
-VM_DEVICE_OWNER = "compute:None"
+VM_DEVICE_OWNER = n_const.DEVICE_OWNER_COMPUTE_PREFIX + 'fake'
 
 TUN_OFPORTS = {p_const.TYPE_GRE: {'ip1': '11', 'ip2': '12'}}
 
index 1db4d7af9f64c3773b93e0c57f10a2cd28e97eaa..bf4df57e8058de6390c996881b731b88eb22b9f0 100644 (file)
@@ -69,7 +69,7 @@ config.cfg.CONF.import_opt('network_vlan_ranges',
 
 PLUGIN_NAME = 'neutron.plugins.ml2.plugin.Ml2Plugin'
 
-DEVICE_OWNER_COMPUTE = 'compute:None'
+DEVICE_OWNER_COMPUTE = constants.DEVICE_OWNER_COMPUTE_PREFIX + 'fake'
 HOST = 'fake_host'
 
 
@@ -643,7 +643,7 @@ class TestMl2PortsV2(test_plugin.TestPortsV2, Ml2PluginV2TestCase):
             self.assertTrue(notify.call_counts)
 
     def test_check_if_compute_port_serviced_by_dvr(self):
-        self.assertTrue(utils.is_dvr_serviced('compute:None'))
+        self.assertTrue(utils.is_dvr_serviced(DEVICE_OWNER_COMPUTE))
 
     def test_check_if_lbaas_vip_port_serviced_by_dvr(self):
         self.assertTrue(utils.is_dvr_serviced(
@@ -795,10 +795,10 @@ class TestMl2DvrPortsV2(TestMl2PortsV2):
                                                         port['port']['id'])
 
     def test_delete_last_vm_port(self):
-        self._test_delete_dvr_serviced_port(device_owner='compute:None')
+        self._test_delete_dvr_serviced_port(device_owner=DEVICE_OWNER_COMPUTE)
 
     def test_delete_last_vm_port_with_floatingip(self):
-        self._test_delete_dvr_serviced_port(device_owner='compute:None',
+        self._test_delete_dvr_serviced_port(device_owner=DEVICE_OWNER_COMPUTE,
                                             floating_ip=True)
 
     def test_delete_lbaas_vip_port(self):
@@ -1757,7 +1757,7 @@ class TestMl2PluginCreateUpdateDeletePort(base.BaseTestCase):
             admin_state_up=True,
             status='ACTIVE',
             device_id='vm_id',
-            device_owner='compute:None')
+            device_owner=DEVICE_OWNER_COMPUTE)
 
         binding = mock.Mock()
         binding.port_id = port_id
index fed5935870740034ddee3ed88a573369e711e123..db20311d35a6b13a146fcb26880589e35c121ebe 100644 (file)
@@ -56,6 +56,8 @@ load_tests = testscenarios.load_tests_apply_scenarios
 
 HOST_DVR = 'my_l3_host_dvr'
 HOST_DVR_SNAT = 'my_l3_host_dvr_snat'
+DEVICE_OWNER_COMPUTE = constants.DEVICE_OWNER_COMPUTE_PREFIX + 'fake'
+DEVICE_OWNER_COMPUTE_NOVA = constants.DEVICE_OWNER_COMPUTE_PREFIX + 'nova'
 
 
 class FakeL3Scheduler(l3_agent_scheduler.L3Scheduler):
@@ -740,7 +742,7 @@ class L3SchedulerTestBaseMixin(object):
         # matching subnet
         port = {'subnet_id': str(uuid.uuid4()),
                 'binding:host_id': 'host_1',
-                'device_owner': 'compute:',
+                'device_owner': constants.DEVICE_OWNER_COMPUTE_PREFIX,
                 'id': 1234}
         subnet = {'id': str(uuid.uuid4()),
                   'enable_dhcp': False}
@@ -934,7 +936,7 @@ class L3DvrSchedulerTestCase(testlib_api.SqlTestCase):
                 'id': port_id,
                 'binding:host_id': 'vm-host',
                 'device_id': 'vm-id',
-                'device_owner': 'compute:None',
+                'device_owner': DEVICE_OWNER_COMPUTE,
                 'mac_address': '02:04:05:17:18:19'
             },
             'mac_address_updated': True
@@ -973,7 +975,7 @@ class L3DvrSchedulerTestCase(testlib_api.SqlTestCase):
                 'id': port_id,
                 'binding:host_id': 'vm-host',
                 'device_id': 'vm-id',
-                'device_owner': 'compute:None'
+                'device_owner': DEVICE_OWNER_COMPUTE
             }
         }
 
@@ -1028,7 +1030,7 @@ class L3DvrSchedulerTestCase(testlib_api.SqlTestCase):
         port = {
                 'id': 'port1',
                 'device_id': 'abcd',
-                'device_owner': 'compute:nova',
+                'device_owner': DEVICE_OWNER_COMPUTE_NOVA,
                 'binding:host_id': 'host1',
                 'fixed_ips': [
                     {
@@ -1140,7 +1142,7 @@ class L3DvrSchedulerTestCase(testlib_api.SqlTestCase):
                 'device_id': 'r1',
                 'status': port_status,
                 'binding:host_id': 'thisHost',
-                'device_owner': 'compute:nova',
+                'device_owner': DEVICE_OWNER_COMPUTE_NOVA,
                 'fixed_ips': [
                     {
                         'subnet_id': '80947d4a-fbc8-484b-9f92-623a6bfcf3e0',
@@ -1215,7 +1217,7 @@ class L3DvrSchedulerTestCase(testlib_api.SqlTestCase):
 
     def _create_port(self, port_name, tenant_id, host, subnet_id, ip_address,
                      status='ACTIVE',
-                     device_owner='compute:nova'):
+                     device_owner=DEVICE_OWNER_COMPUTE_NOVA):
         return {
             'id': port_name + '-port-id',
             'tenant_id': tenant_id,