Merge "use multiprovidernet api definition from neutron-lib"
This commit is contained in:
commit
6268a1f313
@ -13,7 +13,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from neutron.extensions import multiprovidernet as mpnet
|
from neutron_lib.api.definitions import multiprovidernet as mpnet_apidef
|
||||||
from neutron_lib.api.definitions import provider_net as pnet
|
from neutron_lib.api.definitions import provider_net as pnet
|
||||||
from neutron_lib.api import validators
|
from neutron_lib.api import validators
|
||||||
from neutron_lib import constants
|
from neutron_lib import constants
|
||||||
@ -309,7 +309,7 @@ def convert_to_nsx_transport_zones(
|
|||||||
|
|
||||||
# Convert fields from provider request to nsx format
|
# Convert fields from provider request to nsx format
|
||||||
if (network and not validators.is_attr_set(
|
if (network and not validators.is_attr_set(
|
||||||
network.get(mpnet.SEGMENTS))):
|
network.get(mpnet_apidef.SEGMENTS))):
|
||||||
return [{"zone_uuid": default_tz_uuid,
|
return [{"zone_uuid": default_tz_uuid,
|
||||||
"transport_type": default_transport_type}]
|
"transport_type": default_transport_type}]
|
||||||
|
|
||||||
@ -320,4 +320,4 @@ def convert_to_nsx_transport_zones(
|
|||||||
# If we end up here we need to convert multiprovider segments into nsx
|
# If we end up here we need to convert multiprovider segments into nsx
|
||||||
# transport zone configurations
|
# transport zone configurations
|
||||||
return _convert_segments_to_nsx_transport_zones(
|
return _convert_segments_to_nsx_transport_zones(
|
||||||
network.get(mpnet.SEGMENTS), default_tz_uuid)
|
network.get(mpnet_apidef.SEGMENTS), default_tz_uuid)
|
||||||
|
@ -38,12 +38,12 @@ from neutron.db import portbindings_db
|
|||||||
from neutron.db import portsecurity_db
|
from neutron.db import portsecurity_db
|
||||||
from neutron.db import securitygroups_db
|
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 multiprovidernet as mpnet
|
|
||||||
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.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 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 import validators
|
from neutron_lib.api import validators
|
||||||
@ -163,7 +163,7 @@ class NsxDvsV2(addr_pair_db.AllowedAddressPairsMixin,
|
|||||||
network[pnet.SEGMENTATION_ID] = bindings[0].vlan_id
|
network[pnet.SEGMENTATION_ID] = bindings[0].vlan_id
|
||||||
else:
|
else:
|
||||||
# network come in though multiprovider networks api
|
# network come in though multiprovider networks api
|
||||||
network[mpnet.SEGMENTS] = [
|
network[mpnet_apidef.SEGMENTS] = [
|
||||||
{pnet.NETWORK_TYPE: binding.binding_type,
|
{pnet.NETWORK_TYPE: binding.binding_type,
|
||||||
pnet.PHYSICAL_NETWORK: binding.phy_uuid,
|
pnet.PHYSICAL_NETWORK: binding.phy_uuid,
|
||||||
pnet.SEGMENTATION_ID: binding.vlan_id}
|
pnet.SEGMENTATION_ID: binding.vlan_id}
|
||||||
|
@ -60,16 +60,17 @@ from neutron.db import portbindings_db
|
|||||||
from neutron.db import portsecurity_db
|
from neutron.db import portsecurity_db
|
||||||
from neutron.db import quota_db # noqa
|
from neutron.db import quota_db # noqa
|
||||||
from neutron.db import securitygroups_db
|
from neutron.db import securitygroups_db
|
||||||
from neutron.extensions import multiprovidernet as mpnet
|
|
||||||
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.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 extra_dhcp_opt as edo_ext
|
from neutron_lib.api.definitions import extra_dhcp_opt as edo_ext
|
||||||
from neutron_lib.api.definitions import extraroute as xroute_apidef
|
from neutron_lib.api.definitions import extraroute as xroute_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.exceptions import extraroute as xroute_exc
|
from neutron_lib.exceptions import extraroute as xroute_exc
|
||||||
|
from neutron_lib.exceptions import multiprovidernet as mpnet_exc
|
||||||
|
|
||||||
import vmware_nsx
|
import vmware_nsx
|
||||||
from vmware_nsx._i18n import _
|
from vmware_nsx._i18n import _
|
||||||
@ -778,11 +779,11 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
|
|||||||
webob.exc.HTTPBadRequest})
|
webob.exc.HTTPBadRequest})
|
||||||
|
|
||||||
def _validate_provider_create(self, context, network):
|
def _validate_provider_create(self, context, network):
|
||||||
segments = network.get(mpnet.SEGMENTS)
|
segments = network.get(mpnet_apidef.SEGMENTS)
|
||||||
if not validators.is_attr_set(segments):
|
if not validators.is_attr_set(segments):
|
||||||
return
|
return
|
||||||
|
|
||||||
mpnet.check_duplicate_segments(segments)
|
mpnet_apidef.check_duplicate_segments(segments)
|
||||||
for segment in segments:
|
for segment in segments:
|
||||||
network_type = segment.get(pnet.NETWORK_TYPE)
|
network_type = segment.get(pnet.NETWORK_TYPE)
|
||||||
physical_network = segment.get(pnet.PHYSICAL_NETWORK)
|
physical_network = segment.get(pnet.PHYSICAL_NETWORK)
|
||||||
@ -867,7 +868,7 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
|
|||||||
network[pnet.SEGMENTATION_ID] = bindings[0].vlan_id
|
network[pnet.SEGMENTATION_ID] = bindings[0].vlan_id
|
||||||
else:
|
else:
|
||||||
# network come in though multiprovider networks api
|
# network come in though multiprovider networks api
|
||||||
network[mpnet.SEGMENTS] = [
|
network[mpnet_apidef.SEGMENTS] = [
|
||||||
{pnet.NETWORK_TYPE: binding.binding_type,
|
{pnet.NETWORK_TYPE: binding.binding_type,
|
||||||
pnet.PHYSICAL_NETWORK: binding.phy_uuid,
|
pnet.PHYSICAL_NETWORK: binding.phy_uuid,
|
||||||
pnet.SEGMENTATION_ID: binding.vlan_id}
|
pnet.SEGMENTATION_ID: binding.vlan_id}
|
||||||
@ -919,10 +920,10 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
|
|||||||
if any(validators.is_attr_set(network.get(f))
|
if any(validators.is_attr_set(network.get(f))
|
||||||
for f in (pnet.NETWORK_TYPE, pnet.PHYSICAL_NETWORK,
|
for f in (pnet.NETWORK_TYPE, pnet.PHYSICAL_NETWORK,
|
||||||
pnet.SEGMENTATION_ID)):
|
pnet.SEGMENTATION_ID)):
|
||||||
if validators.is_attr_set(network.get(mpnet.SEGMENTS)):
|
if validators.is_attr_set(network.get(mpnet_apidef.SEGMENTS)):
|
||||||
raise mpnet.SegmentsSetInConjunctionWithProviders()
|
raise mpnet_exc.SegmentsSetInConjunctionWithProviders()
|
||||||
# convert to transport zone list
|
# convert to transport zone list
|
||||||
network[mpnet.SEGMENTS] = [
|
network[mpnet_apidef.SEGMENTS] = [
|
||||||
{pnet.NETWORK_TYPE: network[pnet.NETWORK_TYPE],
|
{pnet.NETWORK_TYPE: network[pnet.NETWORK_TYPE],
|
||||||
pnet.PHYSICAL_NETWORK: network[pnet.PHYSICAL_NETWORK],
|
pnet.PHYSICAL_NETWORK: network[pnet.PHYSICAL_NETWORK],
|
||||||
pnet.SEGMENTATION_ID: network[pnet.SEGMENTATION_ID]}]
|
pnet.SEGMENTATION_ID: network[pnet.SEGMENTATION_ID]}]
|
||||||
@ -930,7 +931,7 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
|
|||||||
del network[pnet.PHYSICAL_NETWORK]
|
del network[pnet.PHYSICAL_NETWORK]
|
||||||
del network[pnet.SEGMENTATION_ID]
|
del network[pnet.SEGMENTATION_ID]
|
||||||
return False
|
return False
|
||||||
if validators.is_attr_set(mpnet.SEGMENTS):
|
if validators.is_attr_set(mpnet_apidef.SEGMENTS):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def create_network(self, context, network):
|
def create_network(self, context, network):
|
||||||
@ -985,10 +986,10 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
|
|||||||
nsx_db.add_neutron_nsx_network_mapping(
|
nsx_db.add_neutron_nsx_network_mapping(
|
||||||
context.session, new_net['id'],
|
context.session, new_net['id'],
|
||||||
lswitch['uuid'])
|
lswitch['uuid'])
|
||||||
if (net_data.get(mpnet.SEGMENTS) and
|
if (net_data.get(mpnet_apidef.SEGMENTS) and
|
||||||
isinstance(provider_type, bool)):
|
isinstance(provider_type, bool)):
|
||||||
net_bindings = []
|
net_bindings = []
|
||||||
for tz in net_data[mpnet.SEGMENTS]:
|
for tz in net_data[mpnet_apidef.SEGMENTS]:
|
||||||
segmentation_id = tz.get(pnet.SEGMENTATION_ID, 0)
|
segmentation_id = tz.get(pnet.SEGMENTATION_ID, 0)
|
||||||
segmentation_id_set = validators.is_attr_set(
|
segmentation_id_set = validators.is_attr_set(
|
||||||
segmentation_id)
|
segmentation_id)
|
||||||
|
@ -23,6 +23,7 @@ from neutron_lib.api.definitions import availability_zone as az_def
|
|||||||
from neutron_lib.api.definitions import external_net as extnet_apidef
|
from neutron_lib.api.definitions import external_net as extnet_apidef
|
||||||
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 l3 as l3_apidef
|
from neutron_lib.api.definitions import l3 as l3_apidef
|
||||||
|
from neutron_lib.api.definitions import multiprovidernet as mpnet_apidef
|
||||||
from neutron_lib.api.definitions import port as port_def
|
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
|
||||||
@ -39,6 +40,7 @@ from neutron_lib import exceptions as n_exc
|
|||||||
from neutron_lib.exceptions import allowedaddresspairs as addr_exc
|
from neutron_lib.exceptions import allowedaddresspairs as addr_exc
|
||||||
from neutron_lib.exceptions import flavors as flav_exc
|
from neutron_lib.exceptions import flavors as flav_exc
|
||||||
from neutron_lib.exceptions import l3 as l3_exc
|
from neutron_lib.exceptions import l3 as l3_exc
|
||||||
|
from neutron_lib.exceptions import multiprovidernet as mpnet_exc
|
||||||
from neutron_lib.exceptions import port_security as psec_exc
|
from neutron_lib.exceptions import port_security as psec_exc
|
||||||
from neutron_lib.plugins import constants as plugin_const
|
from neutron_lib.plugins import constants as plugin_const
|
||||||
from neutron_lib.plugins import directory
|
from neutron_lib.plugins import directory
|
||||||
@ -78,7 +80,6 @@ from neutron.db import portsecurity_db
|
|||||||
from neutron.db import quota_db # noqa
|
from neutron.db import quota_db # noqa
|
||||||
from neutron.db import securitygroups_db
|
from neutron.db import securitygroups_db
|
||||||
from neutron.db import vlantransparent_db
|
from neutron.db import vlantransparent_db
|
||||||
from neutron.extensions import multiprovidernet as mpnet
|
|
||||||
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.extensions import vlantransparent as ext_vlan
|
||||||
@ -639,11 +640,11 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
|
|||||||
return az.vdn_scope_id
|
return az.vdn_scope_id
|
||||||
|
|
||||||
def _validate_provider_create(self, context, network):
|
def _validate_provider_create(self, context, network):
|
||||||
if not validators.is_attr_set(network.get(mpnet.SEGMENTS)):
|
if not validators.is_attr_set(network.get(mpnet_apidef.SEGMENTS)):
|
||||||
return
|
return
|
||||||
|
|
||||||
az_dvs = self._get_network_az_dvs_id(network)
|
az_dvs = self._get_network_az_dvs_id(network)
|
||||||
for segment in network[mpnet.SEGMENTS]:
|
for segment in network[mpnet_apidef.SEGMENTS]:
|
||||||
network_type = segment.get(pnet.NETWORK_TYPE)
|
network_type = segment.get(pnet.NETWORK_TYPE)
|
||||||
physical_network = segment.get(pnet.PHYSICAL_NETWORK)
|
physical_network = segment.get(pnet.PHYSICAL_NETWORK)
|
||||||
segmentation_id = segment.get(pnet.SEGMENTATION_ID)
|
segmentation_id = segment.get(pnet.SEGMENTATION_ID)
|
||||||
@ -761,7 +762,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
|
|||||||
network[pnet.SEGMENTATION_ID] = bindings[0].vlan_id
|
network[pnet.SEGMENTATION_ID] = bindings[0].vlan_id
|
||||||
else:
|
else:
|
||||||
# network come in though multiprovider networks api
|
# network come in though multiprovider networks api
|
||||||
network[mpnet.SEGMENTS] = [
|
network[mpnet_apidef.SEGMENTS] = [
|
||||||
{pnet.NETWORK_TYPE: binding.binding_type,
|
{pnet.NETWORK_TYPE: binding.binding_type,
|
||||||
pnet.PHYSICAL_NETWORK: binding.phy_uuid,
|
pnet.PHYSICAL_NETWORK: binding.phy_uuid,
|
||||||
pnet.SEGMENTATION_ID: binding.vlan_id}
|
pnet.SEGMENTATION_ID: binding.vlan_id}
|
||||||
@ -850,10 +851,10 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
|
|||||||
if any(validators.is_attr_set(network.get(f))
|
if any(validators.is_attr_set(network.get(f))
|
||||||
for f in (pnet.NETWORK_TYPE, pnet.PHYSICAL_NETWORK,
|
for f in (pnet.NETWORK_TYPE, pnet.PHYSICAL_NETWORK,
|
||||||
pnet.SEGMENTATION_ID)):
|
pnet.SEGMENTATION_ID)):
|
||||||
if validators.is_attr_set(network.get(mpnet.SEGMENTS)):
|
if validators.is_attr_set(network.get(mpnet_apidef.SEGMENTS)):
|
||||||
raise mpnet.SegmentsSetInConjunctionWithProviders()
|
raise mpnet_exc.SegmentsSetInConjunctionWithProviders()
|
||||||
# convert to transport zone list
|
# convert to transport zone list
|
||||||
network[mpnet.SEGMENTS] = [
|
network[mpnet_apidef.SEGMENTS] = [
|
||||||
{pnet.NETWORK_TYPE: network[pnet.NETWORK_TYPE],
|
{pnet.NETWORK_TYPE: network[pnet.NETWORK_TYPE],
|
||||||
pnet.PHYSICAL_NETWORK: network[pnet.PHYSICAL_NETWORK],
|
pnet.PHYSICAL_NETWORK: network[pnet.PHYSICAL_NETWORK],
|
||||||
pnet.SEGMENTATION_ID: network[pnet.SEGMENTATION_ID]}]
|
pnet.SEGMENTATION_ID: network[pnet.SEGMENTATION_ID]}]
|
||||||
@ -861,7 +862,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
|
|||||||
del network[pnet.PHYSICAL_NETWORK]
|
del network[pnet.PHYSICAL_NETWORK]
|
||||||
del network[pnet.SEGMENTATION_ID]
|
del network[pnet.SEGMENTATION_ID]
|
||||||
return False
|
return False
|
||||||
if validators.is_attr_set(network.get(mpnet.SEGMENTS)):
|
if validators.is_attr_set(network.get(mpnet_apidef.SEGMENTS)):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _delete_backend_network(self, moref, dvs_id=None):
|
def _delete_backend_network(self, moref, dvs_id=None):
|
||||||
@ -908,7 +909,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
|
|||||||
|
|
||||||
def _create_vlan_network_at_backend(self, net_data, dvs_id):
|
def _create_vlan_network_at_backend(self, net_data, dvs_id):
|
||||||
network_name = self._get_vlan_network_name(net_data, dvs_id)
|
network_name = self._get_vlan_network_name(net_data, dvs_id)
|
||||||
segment = net_data[mpnet.SEGMENTS][0]
|
segment = net_data[mpnet_apidef.SEGMENTS][0]
|
||||||
vlan_tag = 0
|
vlan_tag = 0
|
||||||
if (segment.get(pnet.NETWORK_TYPE) ==
|
if (segment.get(pnet.NETWORK_TYPE) ==
|
||||||
c_utils.NsxVNetworkTypes.VLAN):
|
c_utils.NsxVNetworkTypes.VLAN):
|
||||||
@ -1099,7 +1100,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
|
|||||||
free_ids = list(vlan_ids ^ used_ids_in_range)
|
free_ids = list(vlan_ids ^ used_ids_in_range)
|
||||||
if len(free_ids) == 0:
|
if len(free_ids) == 0:
|
||||||
raise n_exc.NoNetworkAvailable()
|
raise n_exc.NoNetworkAvailable()
|
||||||
net_data[mpnet.SEGMENTS][0][pnet.SEGMENTATION_ID] = free_ids[0]
|
net_data[mpnet_apidef.SEGMENTS][0][pnet.SEGMENTATION_ID] = free_ids[0]
|
||||||
|
|
||||||
def create_network(self, context, network):
|
def create_network(self, context, network):
|
||||||
net_data = network['network']
|
net_data = network['network']
|
||||||
@ -1118,7 +1119,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
|
|||||||
generate_segmenation_id = False
|
generate_segmenation_id = False
|
||||||
lock_vlan_creation = False
|
lock_vlan_creation = False
|
||||||
if provider_type is not None:
|
if provider_type is not None:
|
||||||
segment = net_data[mpnet.SEGMENTS][0]
|
segment = net_data[mpnet_apidef.SEGMENTS][0]
|
||||||
network_type = segment.get(pnet.NETWORK_TYPE)
|
network_type = segment.get(pnet.NETWORK_TYPE)
|
||||||
if network_type == c_utils.NsxVNetworkTypes.VLAN:
|
if network_type == c_utils.NsxVNetworkTypes.VLAN:
|
||||||
physical_network = segment.get(pnet.PHYSICAL_NETWORK)
|
physical_network = segment.get(pnet.PHYSICAL_NETWORK)
|
||||||
@ -1174,7 +1175,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
|
|||||||
config_spec = {"virtualWireCreateSpec": virtual_wire}
|
config_spec = {"virtualWireCreateSpec": virtual_wire}
|
||||||
vdn_scope_id = self._get_network_vdn_scope_id(net_data)
|
vdn_scope_id = self._get_network_vdn_scope_id(net_data)
|
||||||
if provider_type is not None:
|
if provider_type is not None:
|
||||||
segment = net_data[mpnet.SEGMENTS][0]
|
segment = net_data[mpnet_apidef.SEGMENTS][0]
|
||||||
if validators.is_attr_set(
|
if validators.is_attr_set(
|
||||||
segment.get(pnet.PHYSICAL_NETWORK)):
|
segment.get(pnet.PHYSICAL_NETWORK)):
|
||||||
vdn_scope_id = segment.get(pnet.PHYSICAL_NETWORK)
|
vdn_scope_id = segment.get(pnet.PHYSICAL_NETWORK)
|
||||||
@ -1191,11 +1192,11 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
|
|||||||
if vlt:
|
if vlt:
|
||||||
raise NotImplementedError(_("Transparent support only "
|
raise NotImplementedError(_("Transparent support only "
|
||||||
"for VXLANs"))
|
"for VXLANs"))
|
||||||
segment = net_data[mpnet.SEGMENTS][0]
|
segment = net_data[mpnet_apidef.SEGMENTS][0]
|
||||||
net_morefs = [segment.get(pnet.PHYSICAL_NETWORK)]
|
net_morefs = [segment.get(pnet.PHYSICAL_NETWORK)]
|
||||||
dvs_net_ids = [net_data['name']]
|
dvs_net_ids = [net_data['name']]
|
||||||
else:
|
else:
|
||||||
segment = net_data[mpnet.SEGMENTS][0]
|
segment = net_data[mpnet_apidef.SEGMENTS][0]
|
||||||
physical_network = segment.get(pnet.PHYSICAL_NETWORK)
|
physical_network = segment.get(pnet.PHYSICAL_NETWORK)
|
||||||
# Retrieve the list of dvs-ids from physical network.
|
# Retrieve the list of dvs-ids from physical network.
|
||||||
# If physical_network attr is not set, retrieve a list
|
# If physical_network attr is not set, retrieve a list
|
||||||
@ -1276,10 +1277,10 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
|
|||||||
|
|
||||||
# DB Operations for setting the network as external
|
# DB Operations for setting the network as external
|
||||||
self._process_l3_create(context, new_net, net_data)
|
self._process_l3_create(context, new_net, net_data)
|
||||||
if (net_data.get(mpnet.SEGMENTS) and
|
if (net_data.get(mpnet_apidef.SEGMENTS) and
|
||||||
isinstance(provider_type, bool)):
|
isinstance(provider_type, bool)):
|
||||||
net_bindings = []
|
net_bindings = []
|
||||||
for tz in net_data[mpnet.SEGMENTS]:
|
for tz in net_data[mpnet_apidef.SEGMENTS]:
|
||||||
network_type = tz.get(pnet.NETWORK_TYPE)
|
network_type = tz.get(pnet.NETWORK_TYPE)
|
||||||
segmentation_id = tz.get(pnet.SEGMENTATION_ID, 0)
|
segmentation_id = tz.get(pnet.SEGMENTATION_ID, 0)
|
||||||
segmentation_id_set = validators.is_attr_set(
|
segmentation_id_set = validators.is_attr_set(
|
||||||
|
@ -17,10 +17,10 @@
|
|||||||
import xml.etree.ElementTree as et
|
import xml.etree.ElementTree as et
|
||||||
|
|
||||||
import netaddr
|
import netaddr
|
||||||
from neutron.extensions import multiprovidernet as mpnet
|
|
||||||
from neutron.ipam import exceptions as ipam_exc
|
from neutron.ipam import exceptions as ipam_exc
|
||||||
from neutron.ipam import requests as ipam_req
|
from neutron.ipam import requests as ipam_req
|
||||||
from neutron_lib.api.definitions import external_net as extnet_apidef
|
from neutron_lib.api.definitions import external_net as extnet_apidef
|
||||||
|
from neutron_lib.api.definitions import multiprovidernet as mpnet_apidef
|
||||||
from neutron_lib.api.definitions import provider_net as pnet
|
from neutron_lib.api.definitions import provider_net as pnet
|
||||||
from neutron_lib.api import validators
|
from neutron_lib.api import validators
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
@ -54,7 +54,7 @@ class NsxvIpamDriver(common.NsxAbstractIpamDriver, NsxVIpamBase):
|
|||||||
if network.get(extnet_apidef.EXTERNAL):
|
if network.get(extnet_apidef.EXTERNAL):
|
||||||
# external network
|
# external network
|
||||||
return True
|
return True
|
||||||
if (validators.is_attr_set(network.get(mpnet.SEGMENTS)) or
|
if (validators.is_attr_set(network.get(mpnet_apidef.SEGMENTS)) or
|
||||||
validators.is_attr_set(network.get(pnet.NETWORK_TYPE))):
|
validators.is_attr_set(network.get(pnet.NETWORK_TYPE))):
|
||||||
# provider network
|
# provider network
|
||||||
return True
|
return True
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
import webob.exc
|
import webob.exc
|
||||||
|
|
||||||
from neutron.extensions import multiprovidernet as mpnet
|
from neutron_lib.api.definitions import multiprovidernet as mpnet_apidef
|
||||||
from neutron_lib.api.definitions import provider_net as pnet
|
from neutron_lib.api.definitions import provider_net as pnet
|
||||||
from vmware_nsx.tests import unit as vmware
|
from vmware_nsx.tests import unit as vmware
|
||||||
from vmware_nsx.tests.unit.nsx_mh import test_plugin as test_nsx_plugin
|
from vmware_nsx.tests.unit.nsx_mh import test_plugin as test_nsx_plugin
|
||||||
@ -79,7 +79,7 @@ class TestMultiProviderNetworks(test_nsx_plugin.NsxPluginV2TestCase):
|
|||||||
self.assertEqual(network['network'][pnet.NETWORK_TYPE], 'vlan')
|
self.assertEqual(network['network'][pnet.NETWORK_TYPE], 'vlan')
|
||||||
self.assertEqual(network['network'][pnet.PHYSICAL_NETWORK], 'physnet1')
|
self.assertEqual(network['network'][pnet.PHYSICAL_NETWORK], 'physnet1')
|
||||||
self.assertEqual(network['network'][pnet.SEGMENTATION_ID], 1)
|
self.assertEqual(network['network'][pnet.SEGMENTATION_ID], 1)
|
||||||
self.assertNotIn(mpnet.SEGMENTS, network['network'])
|
self.assertNotIn(mpnet_apidef.SEGMENTS, network['network'])
|
||||||
|
|
||||||
def test_create_network_provider_flat(self):
|
def test_create_network_provider_flat(self):
|
||||||
data = {'network': {'name': 'net1',
|
data = {'network': {'name': 'net1',
|
||||||
@ -92,11 +92,11 @@ class TestMultiProviderNetworks(test_nsx_plugin.NsxPluginV2TestCase):
|
|||||||
self.assertEqual('flat', network['network'][pnet.NETWORK_TYPE])
|
self.assertEqual('flat', network['network'][pnet.NETWORK_TYPE])
|
||||||
self.assertEqual('physnet1', network['network'][pnet.PHYSICAL_NETWORK])
|
self.assertEqual('physnet1', network['network'][pnet.PHYSICAL_NETWORK])
|
||||||
self.assertEqual(0, network['network'][pnet.SEGMENTATION_ID])
|
self.assertEqual(0, network['network'][pnet.SEGMENTATION_ID])
|
||||||
self.assertNotIn(mpnet.SEGMENTS, network['network'])
|
self.assertNotIn(mpnet_apidef.SEGMENTS, network['network'])
|
||||||
|
|
||||||
def test_create_network_single_multiple_provider(self):
|
def test_create_network_single_multiple_provider(self):
|
||||||
data = {'network': {'name': 'net1',
|
data = {'network': {'name': 'net1',
|
||||||
mpnet.SEGMENTS:
|
mpnet_apidef.SEGMENTS:
|
||||||
[{pnet.NETWORK_TYPE: 'vlan',
|
[{pnet.NETWORK_TYPE: 'vlan',
|
||||||
pnet.PHYSICAL_NETWORK: 'physnet1',
|
pnet.PHYSICAL_NETWORK: 'physnet1',
|
||||||
pnet.SEGMENTATION_ID: 1}],
|
pnet.SEGMENTATION_ID: 1}],
|
||||||
@ -106,7 +106,7 @@ class TestMultiProviderNetworks(test_nsx_plugin.NsxPluginV2TestCase):
|
|||||||
for provider_field in [pnet.NETWORK_TYPE, pnet.PHYSICAL_NETWORK,
|
for provider_field in [pnet.NETWORK_TYPE, pnet.PHYSICAL_NETWORK,
|
||||||
pnet.SEGMENTATION_ID]:
|
pnet.SEGMENTATION_ID]:
|
||||||
self.assertNotIn(provider_field, network['network'])
|
self.assertNotIn(provider_field, network['network'])
|
||||||
tz = network['network'][mpnet.SEGMENTS][0]
|
tz = network['network'][mpnet_apidef.SEGMENTS][0]
|
||||||
self.assertEqual(tz[pnet.NETWORK_TYPE], 'vlan')
|
self.assertEqual(tz[pnet.NETWORK_TYPE], 'vlan')
|
||||||
self.assertEqual(tz[pnet.PHYSICAL_NETWORK], 'physnet1')
|
self.assertEqual(tz[pnet.PHYSICAL_NETWORK], 'physnet1')
|
||||||
self.assertEqual(tz[pnet.SEGMENTATION_ID], 1)
|
self.assertEqual(tz[pnet.SEGMENTATION_ID], 1)
|
||||||
@ -114,14 +114,14 @@ class TestMultiProviderNetworks(test_nsx_plugin.NsxPluginV2TestCase):
|
|||||||
# Tests get_network()
|
# Tests get_network()
|
||||||
net_req = self.new_show_request('networks', network['network']['id'])
|
net_req = self.new_show_request('networks', network['network']['id'])
|
||||||
network = self.deserialize(self.fmt, net_req.get_response(self.api))
|
network = self.deserialize(self.fmt, net_req.get_response(self.api))
|
||||||
tz = network['network'][mpnet.SEGMENTS][0]
|
tz = network['network'][mpnet_apidef.SEGMENTS][0]
|
||||||
self.assertEqual(tz[pnet.NETWORK_TYPE], 'vlan')
|
self.assertEqual(tz[pnet.NETWORK_TYPE], 'vlan')
|
||||||
self.assertEqual(tz[pnet.PHYSICAL_NETWORK], 'physnet1')
|
self.assertEqual(tz[pnet.PHYSICAL_NETWORK], 'physnet1')
|
||||||
self.assertEqual(tz[pnet.SEGMENTATION_ID], 1)
|
self.assertEqual(tz[pnet.SEGMENTATION_ID], 1)
|
||||||
|
|
||||||
def test_create_network_multprovider(self):
|
def test_create_network_multprovider(self):
|
||||||
data = {'network': {'name': 'net1',
|
data = {'network': {'name': 'net1',
|
||||||
mpnet.SEGMENTS:
|
mpnet_apidef.SEGMENTS:
|
||||||
[{pnet.NETWORK_TYPE: 'vlan',
|
[{pnet.NETWORK_TYPE: 'vlan',
|
||||||
pnet.PHYSICAL_NETWORK: 'physnet1',
|
pnet.PHYSICAL_NETWORK: 'physnet1',
|
||||||
pnet.SEGMENTATION_ID: 1},
|
pnet.SEGMENTATION_ID: 1},
|
||||||
@ -131,8 +131,8 @@ class TestMultiProviderNetworks(test_nsx_plugin.NsxPluginV2TestCase):
|
|||||||
network_req = self.new_create_request('networks', data)
|
network_req = self.new_create_request('networks', data)
|
||||||
network = self.deserialize(self.fmt,
|
network = self.deserialize(self.fmt,
|
||||||
network_req.get_response(self.api))
|
network_req.get_response(self.api))
|
||||||
tz = network['network'][mpnet.SEGMENTS]
|
tz = network['network'][mpnet_apidef.SEGMENTS]
|
||||||
for tz in data['network'][mpnet.SEGMENTS]:
|
for tz in data['network'][mpnet_apidef.SEGMENTS]:
|
||||||
for field in [pnet.NETWORK_TYPE, pnet.PHYSICAL_NETWORK,
|
for field in [pnet.NETWORK_TYPE, pnet.PHYSICAL_NETWORK,
|
||||||
pnet.SEGMENTATION_ID]:
|
pnet.SEGMENTATION_ID]:
|
||||||
self.assertEqual(tz.get(field), tz.get(field))
|
self.assertEqual(tz.get(field), tz.get(field))
|
||||||
@ -140,15 +140,15 @@ class TestMultiProviderNetworks(test_nsx_plugin.NsxPluginV2TestCase):
|
|||||||
# Tests get_network()
|
# Tests get_network()
|
||||||
net_req = self.new_show_request('networks', network['network']['id'])
|
net_req = self.new_show_request('networks', network['network']['id'])
|
||||||
network = self.deserialize(self.fmt, net_req.get_response(self.api))
|
network = self.deserialize(self.fmt, net_req.get_response(self.api))
|
||||||
tz = network['network'][mpnet.SEGMENTS]
|
tz = network['network'][mpnet_apidef.SEGMENTS]
|
||||||
for tz in data['network'][mpnet.SEGMENTS]:
|
for tz in data['network'][mpnet_apidef.SEGMENTS]:
|
||||||
for field in [pnet.NETWORK_TYPE, pnet.PHYSICAL_NETWORK,
|
for field in [pnet.NETWORK_TYPE, pnet.PHYSICAL_NETWORK,
|
||||||
pnet.SEGMENTATION_ID]:
|
pnet.SEGMENTATION_ID]:
|
||||||
self.assertEqual(tz.get(field), tz.get(field))
|
self.assertEqual(tz.get(field), tz.get(field))
|
||||||
|
|
||||||
def test_create_network_with_provider_and_multiprovider_fail(self):
|
def test_create_network_with_provider_and_multiprovider_fail(self):
|
||||||
data = {'network': {'name': 'net1',
|
data = {'network': {'name': 'net1',
|
||||||
mpnet.SEGMENTS:
|
mpnet_apidef.SEGMENTS:
|
||||||
[{pnet.NETWORK_TYPE: 'vlan',
|
[{pnet.NETWORK_TYPE: 'vlan',
|
||||||
pnet.PHYSICAL_NETWORK: 'physnet1',
|
pnet.PHYSICAL_NETWORK: 'physnet1',
|
||||||
pnet.SEGMENTATION_ID: 1}],
|
pnet.SEGMENTATION_ID: 1}],
|
||||||
@ -163,7 +163,7 @@ class TestMultiProviderNetworks(test_nsx_plugin.NsxPluginV2TestCase):
|
|||||||
|
|
||||||
def test_create_network_duplicate_segments(self):
|
def test_create_network_duplicate_segments(self):
|
||||||
data = {'network': {'name': 'net1',
|
data = {'network': {'name': 'net1',
|
||||||
mpnet.SEGMENTS:
|
mpnet_apidef.SEGMENTS:
|
||||||
[{pnet.NETWORK_TYPE: 'vlan',
|
[{pnet.NETWORK_TYPE: 'vlan',
|
||||||
pnet.PHYSICAL_NETWORK: 'physnet1',
|
pnet.PHYSICAL_NETWORK: 'physnet1',
|
||||||
pnet.SEGMENTATION_ID: 1},
|
pnet.SEGMENTATION_ID: 1},
|
||||||
|
@ -15,8 +15,8 @@
|
|||||||
|
|
||||||
import mock
|
import mock
|
||||||
from neutron.db import api as db_api
|
from neutron.db import api as db_api
|
||||||
from neutron.extensions import multiprovidernet as mpnet
|
|
||||||
from neutron.tests import base
|
from neutron.tests import base
|
||||||
|
from neutron_lib.api.definitions import multiprovidernet as mpnet_apidef
|
||||||
from neutron_lib.api.definitions import provider_net as pnet
|
from neutron_lib.api.definitions import provider_net as pnet
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
|
|
||||||
@ -358,7 +358,8 @@ class NsxUtilsTestCase(base.BaseTestCase):
|
|||||||
pnet.PHYSICAL_NETWORK: 'whatever_tz_2'},
|
pnet.PHYSICAL_NETWORK: 'whatever_tz_2'},
|
||||||
]
|
]
|
||||||
results = nsx_utils.convert_to_nsx_transport_zones(
|
results = nsx_utils.convert_to_nsx_transport_zones(
|
||||||
'meh_zone_uuid', {'id': 'whatever_net', mpnet.SEGMENTS: segments})
|
'meh_zone_uuid',
|
||||||
|
{'id': 'whatever_net', mpnet_apidef.SEGMENTS: segments})
|
||||||
self._verify_nsx_transport_zones(results)
|
self._verify_nsx_transport_zones(results)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user