Merge "use vlantransparent api def from neutron-lib"
This commit is contained in:
commit
913dbe467e
@ -40,12 +40,12 @@ from neutron.db import securitygroups_db
|
|||||||
from neutron.db import vlantransparent_db as vlan_ext_db
|
from neutron.db import vlantransparent_db as vlan_ext_db
|
||||||
from neutron.extensions import providernet
|
from neutron.extensions import providernet
|
||||||
from neutron.extensions import securitygroup as ext_sg
|
from neutron.extensions import securitygroup as ext_sg
|
||||||
from neutron.extensions import vlantransparent as vlan_ext
|
|
||||||
from neutron.plugins.common import utils
|
from neutron.plugins.common import utils
|
||||||
from neutron.quota import resource_registry
|
from neutron.quota import resource_registry
|
||||||
from neutron_lib.api.definitions import multiprovidernet as mpnet_apidef
|
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 portbindings as pbin
|
||||||
from neutron_lib.api.definitions import provider_net as pnet
|
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.api import validators
|
||||||
from neutron_lib import constants
|
from neutron_lib import constants
|
||||||
from neutron_lib import exceptions as n_exc
|
from neutron_lib import exceptions as n_exc
|
||||||
@ -190,7 +190,7 @@ class NsxDvsV2(addr_pair_db.AllowedAddressPairsMixin,
|
|||||||
|
|
||||||
trunk_mode = False
|
trunk_mode = False
|
||||||
# vlan transparent can be an object if not set.
|
# 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
|
trunk_mode = True
|
||||||
|
|
||||||
net_id = None
|
net_id = None
|
||||||
|
@ -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 port_security as psec
|
||||||
from neutron_lib.api.definitions import provider_net as pnet
|
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 subnet as subnet_def
|
||||||
|
from neutron_lib.api.definitions import vlantransparent as vlan_apidef
|
||||||
from neutron_lib.api import validators
|
from neutron_lib.api import validators
|
||||||
from neutron_lib.api.validators import availability_zone as az_validator
|
from neutron_lib.api.validators import availability_zone as az_validator
|
||||||
from neutron_lib.callbacks import events
|
from neutron_lib.callbacks import events
|
||||||
@ -82,7 +83,6 @@ from neutron.db import securitygroups_db
|
|||||||
from neutron.db import vlantransparent_db
|
from neutron.db import vlantransparent_db
|
||||||
from neutron.extensions import providernet
|
from neutron.extensions import providernet
|
||||||
from neutron.extensions import securitygroup as ext_sg
|
from neutron.extensions import securitygroup as ext_sg
|
||||||
from neutron.extensions import vlantransparent as ext_vlan
|
|
||||||
from neutron.objects import securitygroup
|
from neutron.objects import securitygroup
|
||||||
from neutron.plugins.common import utils
|
from neutron.plugins.common import utils
|
||||||
from neutron.quota import resource_registry
|
from neutron.quota import resource_registry
|
||||||
@ -1161,7 +1161,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
|
|||||||
self._validate_network_qos(net_data, backend_network)
|
self._validate_network_qos(net_data, backend_network)
|
||||||
vlt = False
|
vlt = False
|
||||||
if n_utils.is_extension_supported(self, 'vlan-transparent'):
|
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:
|
if backend_network or external_backend_network:
|
||||||
#NOTE(abhiraut): Consider refactoring code below to have more
|
#NOTE(abhiraut): Consider refactoring code below to have more
|
||||||
|
@ -58,12 +58,12 @@ from neutron.db import securitygroups_db
|
|||||||
from neutron.db import vlantransparent_db
|
from neutron.db import vlantransparent_db
|
||||||
from neutron.extensions import providernet
|
from neutron.extensions import providernet
|
||||||
from neutron.extensions import securitygroup as ext_sg
|
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.plugins.common import utils as n_utils
|
||||||
from neutron.quota import resource_registry
|
from neutron.quota import resource_registry
|
||||||
from neutron_lib.api.definitions import extra_dhcp_opt as ext_edo
|
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 portbindings as pbin
|
||||||
from neutron_lib.api.definitions import provider_net as pnet
|
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.api import validators
|
||||||
from neutron_lib.callbacks import events
|
from neutron_lib.callbacks import events
|
||||||
from neutron_lib.callbacks import exceptions as callback_exc
|
from neutron_lib.callbacks import exceptions as callback_exc
|
||||||
@ -1048,7 +1048,7 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
|
|||||||
# Update the transparent vlan if configured
|
# Update the transparent vlan if configured
|
||||||
vlt = False
|
vlt = False
|
||||||
if nc_utils.is_extension_supported(self, 'vlan-transparent'):
|
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
|
nsx_net_id = None
|
||||||
if validators.is_attr_set(external) and external:
|
if validators.is_attr_set(external) and external:
|
||||||
|
@ -19,7 +19,6 @@ from neutron.db import models_v2
|
|||||||
from neutron.extensions import address_scope
|
from neutron.extensions import address_scope
|
||||||
from neutron.extensions import l3
|
from neutron.extensions import l3
|
||||||
from neutron.extensions import securitygroup as secgrp
|
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 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.db import test_db_base_plugin_v2 as test_plugin
|
||||||
from neutron.tests.unit.extensions import test_address_scope
|
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 port_security as psec
|
||||||
from neutron_lib.api.definitions import portbindings
|
from neutron_lib.api.definitions import portbindings
|
||||||
from neutron_lib.api.definitions import provider_net as pnet
|
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.callbacks import exceptions as nc_exc
|
||||||
from neutron_lib import constants
|
from neutron_lib import constants
|
||||||
from neutron_lib import context
|
from neutron_lib import context
|
||||||
@ -519,27 +519,28 @@ class TestNetworksV2(test_plugin.TestNetworksV2, NsxV3PluginTestCaseMixin):
|
|||||||
res['NeutronError']['type'])
|
res['NeutronError']['type'])
|
||||||
|
|
||||||
def test_create_transparent_vlan_network(self):
|
def test_create_transparent_vlan_network(self):
|
||||||
providernet_args = {ext_vlan.VLANTRANSPARENT: True}
|
providernet_args = {vlan_apidef.VLANTRANSPARENT: True}
|
||||||
with mock.patch(
|
with mock.patch(
|
||||||
'vmware_nsxlib.v3.core_resources.NsxLibTransportZone.'
|
'vmware_nsxlib.v3.core_resources.NsxLibTransportZone.'
|
||||||
'get_transport_type', return_value='OVERLAY'),\
|
'get_transport_type', return_value='OVERLAY'),\
|
||||||
self.network(name='vt_net',
|
self.network(name='vt_net',
|
||||||
providernet_args=providernet_args,
|
providernet_args=providernet_args,
|
||||||
arg_list=(ext_vlan.VLANTRANSPARENT, )) as net:
|
arg_list=(vlan_apidef.VLANTRANSPARENT, )) as net:
|
||||||
self.assertTrue(net['network'].get(ext_vlan.VLANTRANSPARENT))
|
self.assertTrue(net['network'].get(vlan_apidef.VLANTRANSPARENT))
|
||||||
|
|
||||||
def test_create_provider_vlan_network_with_transparent(self):
|
def test_create_provider_vlan_network_with_transparent(self):
|
||||||
providernet_args = {pnet.NETWORK_TYPE: 'vlan',
|
providernet_args = {pnet.NETWORK_TYPE: 'vlan',
|
||||||
pnet.SEGMENTATION_ID: 11,
|
pnet.SEGMENTATION_ID: 11,
|
||||||
ext_vlan.VLANTRANSPARENT: True}
|
vlan_apidef.VLANTRANSPARENT: True}
|
||||||
with mock.patch('vmware_nsxlib.v3.core_resources.NsxLibTransportZone.'
|
with mock.patch('vmware_nsxlib.v3.core_resources.NsxLibTransportZone.'
|
||||||
'get_transport_type', return_value='VLAN'):
|
'get_transport_type', return_value='VLAN'):
|
||||||
result = self._create_network(fmt='json', name='badvlan_net',
|
result = self._create_network(fmt='json', name='badvlan_net',
|
||||||
admin_state_up=True,
|
admin_state_up=True,
|
||||||
providernet_args=providernet_args,
|
providernet_args=providernet_args,
|
||||||
arg_list=(pnet.NETWORK_TYPE,
|
arg_list=(
|
||||||
pnet.SEGMENTATION_ID,
|
pnet.NETWORK_TYPE,
|
||||||
ext_vlan.VLANTRANSPARENT))
|
pnet.SEGMENTATION_ID,
|
||||||
|
vlan_apidef.VLANTRANSPARENT))
|
||||||
data = self.deserialize('json', result)
|
data = self.deserialize('json', result)
|
||||||
# should fail
|
# should fail
|
||||||
self.assertIn('NotImplementedError', data)
|
self.assertIn('NotImplementedError', data)
|
||||||
|
Loading…
Reference in New Issue
Block a user