diff --git a/neutron_lbaas/db/loadbalancer/loadbalancer_dbv2.py b/neutron_lbaas/db/loadbalancer/loadbalancer_dbv2.py index 1ab67a835..a5d74f274 100644 --- a/neutron_lbaas/db/loadbalancer/loadbalancer_dbv2.py +++ b/neutron_lbaas/db/loadbalancer/loadbalancer_dbv2.py @@ -98,7 +98,7 @@ class LoadBalancerPluginDbv2(base_db.CommonDbMixin, 'network_id': subnet['network_id'], 'mac_address': attributes.ATTR_NOT_SPECIFIED, 'admin_state_up': False, - 'device_id': '', + 'device_id': lb_db.id, 'device_owner': n_constants.DEVICE_OWNER_LOADBALANCERV2, 'fixed_ips': [fixed_ip] } diff --git a/neutron_lbaas/drivers/common/agent_callbacks.py b/neutron_lbaas/drivers/common/agent_callbacks.py index 02e6ab5f2..a4d5cb837 100644 --- a/neutron_lbaas/drivers/common/agent_callbacks.py +++ b/neutron_lbaas/drivers/common/agent_callbacks.py @@ -12,8 +12,6 @@ # License for the specific language governing permissions and limitations # under the License. -import uuid - from neutron.common import exceptions as n_exc from neutron.extensions import portbindings from neutron.i18n import _LW @@ -166,8 +164,6 @@ class LoadBalancerCallbacks(object): return port['admin_state_up'] = True - port['device_owner'] = 'neutron:' + constants.LOADBALANCERV2 - port['device_id'] = str(uuid.uuid5(uuid.NAMESPACE_DNS, str(host))) port[portbindings.HOST_ID] = host self.plugin.db._core_plugin.update_port( context, diff --git a/neutron_lbaas/drivers/haproxy/synchronous_namespace_driver.py b/neutron_lbaas/drivers/haproxy/synchronous_namespace_driver.py index 10974fcf3..4063ba962 100644 --- a/neutron_lbaas/drivers/haproxy/synchronous_namespace_driver.py +++ b/neutron_lbaas/drivers/haproxy/synchronous_namespace_driver.py @@ -15,7 +15,6 @@ import os import shutil import socket -import uuid import netaddr from neutron.agent.common import config @@ -148,10 +147,6 @@ class HaproxyNSDriver(driver_base.LoadBalancerBaseDriver): def _build_port_dict(self): return {'admin_state_up': True, - 'device_owner': 'neutron:{0}'.format( - constants.LOADBALANCER), - 'device_id': str(uuid.uuid5(uuid.NAMESPACE_DNS, - str(self.conf.host))), portbindings.HOST_ID: self.conf.host} def _get_state_file_path(self, loadbalancer_id, kind, diff --git a/neutron_lbaas/tests/unit/drivers/common/test_agent_callbacks.py b/neutron_lbaas/tests/unit/drivers/common/test_agent_callbacks.py index 35ce2b1da..32d6ce8b4 100644 --- a/neutron_lbaas/tests/unit/drivers/common/test_agent_callbacks.py +++ b/neutron_lbaas/tests/unit/drivers/common/test_agent_callbacks.py @@ -162,6 +162,8 @@ class TestLoadBalancerCallbacks( with self.loadbalancer() as loadbalancer: lb_id = loadbalancer['loadbalancer']['id'] + if 'device_id' not in expected: + expected['device_id'] = lb_id self.plugin_instance.db.update_loadbalancer_provisioning_status( context.get_admin_context(), loadbalancer['loadbalancer']['id']) @@ -175,7 +177,6 @@ class TestLoadBalancerCallbacks( def test_plug_vip_port(self): exp = { 'device_owner': 'neutron:' + constants.LOADBALANCERV2, - 'device_id': 'c596ce11-db30-5c72-8243-15acaae8690f', 'admin_state_up': True } self._update_port_test_helper( @@ -187,7 +188,6 @@ class TestLoadBalancerCallbacks( def test_plug_vip_port_mock_with_host(self): exp = { 'device_owner': 'neutron:' + constants.LOADBALANCERV2, - 'device_id': 'c596ce11-db30-5c72-8243-15acaae8690f', 'admin_state_up': True, portbindings.HOST_ID: 'host' } diff --git a/neutron_lbaas/tests/unit/drivers/haproxy/test_synchronous_driver.py b/neutron_lbaas/tests/unit/drivers/haproxy/test_synchronous_driver.py index 9fa217fc0..75fd4c4bf 100644 --- a/neutron_lbaas/tests/unit/drivers/haproxy/test_synchronous_driver.py +++ b/neutron_lbaas/tests/unit/drivers/haproxy/test_synchronous_driver.py @@ -15,7 +15,6 @@ import collections import contextlib -import uuid import mock from neutron.common import exceptions @@ -138,9 +137,6 @@ class TestHaproxyNSDriver(base.BaseTestCase): def test_build_port_dict(self): self.driver.conf.host = 'host1' ret = {'admin_state_up': True, - 'device_owner': 'neutron:LOADBALANCER', - 'device_id': str(uuid.uuid5(uuid.NAMESPACE_DNS, - str(self.conf.host))), portbindings.HOST_ID: self.conf.host} self.assertEqual(ret, self.driver._build_port_dict()) diff --git a/neutron_lbaas/tests/unit/services/loadbalancer/drivers/test_agent_driver_base.py b/neutron_lbaas/tests/unit/services/loadbalancer/drivers/test_agent_driver_base.py index e4ee50586..3a084f223 100644 --- a/neutron_lbaas/tests/unit/services/loadbalancer/drivers/test_agent_driver_base.py +++ b/neutron_lbaas/tests/unit/services/loadbalancer/drivers/test_agent_driver_base.py @@ -330,7 +330,6 @@ class TestLoadBalancerCallbacks(TestLoadBalancerPluginBase): def test_plug_vip_port(self): exp = { 'device_owner': 'neutron:' + constants.LOADBALANCER, - 'device_id': 'c596ce11-db30-5c72-8243-15acaae8690f', 'admin_state_up': True } self._update_port_test_helper( @@ -342,7 +341,6 @@ class TestLoadBalancerCallbacks(TestLoadBalancerPluginBase): def test_plug_vip_port_mock_with_host(self): exp = { 'device_owner': 'neutron:' + constants.LOADBALANCER, - 'device_id': 'c596ce11-db30-5c72-8243-15acaae8690f', 'admin_state_up': True, portbindings.HOST_ID: 'host' }