From a8bfef15298d25a507dd6548c1f4702aa3de160d Mon Sep 17 00:00:00 2001 From: Boden R Date: Tue, 23 Jan 2018 15:29:57 -0700 Subject: [PATCH] use vlantransparent api def from neutron-lib The vlantransparent extension's API definition was rehomed into neutron-lib with commit I78c3e0c0b74dd154b6133963dfc8b65f9527bd2c This patch consumes it by using neutron-lib's implementation in prep for Ibfaa1ebf24caec62f5743975b206400fcd30436d Change-Id: I8e2bf3fb75b3ccbcb269677fb2aa826659fbbdd2 --- vmware_nsx/plugins/dvs/plugin.py | 4 ++-- vmware_nsx/plugins/nsx_v/plugin.py | 4 ++-- vmware_nsx/plugins/nsx_v3/plugin.py | 4 ++-- vmware_nsx/tests/unit/nsx_v3/test_plugin.py | 17 +++++++++-------- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/vmware_nsx/plugins/dvs/plugin.py b/vmware_nsx/plugins/dvs/plugin.py index 223caaeedb..852137dfac 100644 --- a/vmware_nsx/plugins/dvs/plugin.py +++ b/vmware_nsx/plugins/dvs/plugin.py @@ -40,12 +40,12 @@ from neutron.db import securitygroups_db from neutron.db import vlantransparent_db as vlan_ext_db from neutron.extensions import providernet from neutron.extensions import securitygroup as ext_sg -from neutron.extensions import vlantransparent as vlan_ext from neutron.plugins.common import utils from neutron.quota import resource_registry from neutron_lib.api.definitions import multiprovidernet as mpnet_apidef from neutron_lib.api.definitions import portbindings as pbin from neutron_lib.api.definitions import provider_net as pnet +from neutron_lib.api.definitions import vlantransparent as vlan_apidef from neutron_lib.api import validators from neutron_lib import constants from neutron_lib import exceptions as n_exc @@ -190,7 +190,7 @@ class NsxDvsV2(addr_pair_db.AllowedAddressPairsMixin, trunk_mode = False # vlan transparent can be an object if not set. - if net_data.get(vlan_ext.VLANTRANSPARENT) is True: + if net_data.get(vlan_apidef.VLANTRANSPARENT) is True: trunk_mode = True net_id = None diff --git a/vmware_nsx/plugins/nsx_v/plugin.py b/vmware_nsx/plugins/nsx_v/plugin.py index b205a4d58c..0db31507c2 100644 --- a/vmware_nsx/plugins/nsx_v/plugin.py +++ b/vmware_nsx/plugins/nsx_v/plugin.py @@ -28,6 +28,7 @@ from neutron_lib.api.definitions import port as port_def from neutron_lib.api.definitions import port_security as psec from neutron_lib.api.definitions import provider_net as pnet from neutron_lib.api.definitions import subnet as subnet_def +from neutron_lib.api.definitions import vlantransparent as vlan_apidef from neutron_lib.api import validators from neutron_lib.api.validators import availability_zone as az_validator from neutron_lib.callbacks import events @@ -82,7 +83,6 @@ from neutron.db import securitygroups_db from neutron.db import vlantransparent_db from neutron.extensions import providernet from neutron.extensions import securitygroup as ext_sg -from neutron.extensions import vlantransparent as ext_vlan from neutron.objects import securitygroup from neutron.plugins.common import utils from neutron.quota import resource_registry @@ -1161,7 +1161,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin, self._validate_network_qos(net_data, backend_network) vlt = False if n_utils.is_extension_supported(self, 'vlan-transparent'): - vlt = ext_vlan.get_vlan_transparent(net_data) + vlt = vlan_apidef.get_vlan_transparent(net_data) if backend_network or external_backend_network: #NOTE(abhiraut): Consider refactoring code below to have more diff --git a/vmware_nsx/plugins/nsx_v3/plugin.py b/vmware_nsx/plugins/nsx_v3/plugin.py index 5a0dcd3aeb..e6a4ecd8d6 100644 --- a/vmware_nsx/plugins/nsx_v3/plugin.py +++ b/vmware_nsx/plugins/nsx_v3/plugin.py @@ -58,12 +58,12 @@ from neutron.db import securitygroups_db from neutron.db import vlantransparent_db from neutron.extensions import providernet from neutron.extensions import securitygroup as ext_sg -from neutron.extensions import vlantransparent as ext_vlan from neutron.plugins.common import utils as n_utils from neutron.quota import resource_registry from neutron_lib.api.definitions import extra_dhcp_opt as ext_edo from neutron_lib.api.definitions import portbindings as pbin from neutron_lib.api.definitions import provider_net as pnet +from neutron_lib.api.definitions import vlantransparent as vlan_apidef from neutron_lib.api import validators from neutron_lib.callbacks import events from neutron_lib.callbacks import exceptions as callback_exc @@ -1048,7 +1048,7 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin, # Update the transparent vlan if configured vlt = False if nc_utils.is_extension_supported(self, 'vlan-transparent'): - vlt = ext_vlan.get_vlan_transparent(net_data) + vlt = vlan_apidef.get_vlan_transparent(net_data) nsx_net_id = None if validators.is_attr_set(external) and external: diff --git a/vmware_nsx/tests/unit/nsx_v3/test_plugin.py b/vmware_nsx/tests/unit/nsx_v3/test_plugin.py index 8e747c6eaf..395d334897 100644 --- a/vmware_nsx/tests/unit/nsx_v3/test_plugin.py +++ b/vmware_nsx/tests/unit/nsx_v3/test_plugin.py @@ -19,7 +19,6 @@ from neutron.db import models_v2 from neutron.extensions import address_scope from neutron.extensions import l3 from neutron.extensions import securitygroup as secgrp -from neutron.extensions import vlantransparent as ext_vlan from neutron.tests.unit import _test_extension_portbindings as test_bindings from neutron.tests.unit.db import test_db_base_plugin_v2 as test_plugin from neutron.tests.unit.extensions import test_address_scope @@ -36,6 +35,7 @@ from neutron_lib.api.definitions import l3_ext_gw_mode as l3_egm_apidef from neutron_lib.api.definitions import port_security as psec from neutron_lib.api.definitions import portbindings from neutron_lib.api.definitions import provider_net as pnet +from neutron_lib.api.definitions import vlantransparent as vlan_apidef from neutron_lib.callbacks import exceptions as nc_exc from neutron_lib import constants from neutron_lib import context @@ -519,27 +519,28 @@ class TestNetworksV2(test_plugin.TestNetworksV2, NsxV3PluginTestCaseMixin): res['NeutronError']['type']) def test_create_transparent_vlan_network(self): - providernet_args = {ext_vlan.VLANTRANSPARENT: True} + providernet_args = {vlan_apidef.VLANTRANSPARENT: True} with mock.patch( 'vmware_nsxlib.v3.core_resources.NsxLibTransportZone.' 'get_transport_type', return_value='OVERLAY'),\ self.network(name='vt_net', providernet_args=providernet_args, - arg_list=(ext_vlan.VLANTRANSPARENT, )) as net: - self.assertTrue(net['network'].get(ext_vlan.VLANTRANSPARENT)) + arg_list=(vlan_apidef.VLANTRANSPARENT, )) as net: + self.assertTrue(net['network'].get(vlan_apidef.VLANTRANSPARENT)) def test_create_provider_vlan_network_with_transparent(self): providernet_args = {pnet.NETWORK_TYPE: 'vlan', pnet.SEGMENTATION_ID: 11, - ext_vlan.VLANTRANSPARENT: True} + vlan_apidef.VLANTRANSPARENT: True} with mock.patch('vmware_nsxlib.v3.core_resources.NsxLibTransportZone.' 'get_transport_type', return_value='VLAN'): result = self._create_network(fmt='json', name='badvlan_net', admin_state_up=True, providernet_args=providernet_args, - arg_list=(pnet.NETWORK_TYPE, - pnet.SEGMENTATION_ID, - ext_vlan.VLANTRANSPARENT)) + arg_list=( + pnet.NETWORK_TYPE, + pnet.SEGMENTATION_ID, + vlan_apidef.VLANTRANSPARENT)) data = self.deserialize('json', result) # should fail self.assertIn('NotImplementedError', data)