L2 Gateway create using Edge Bridge Profile and Vlan Tz.

Replacing to use Edge Bridge Profile instead of ESX Bridge Cluster.

Also using Interface as Vlan TZ.

Change-Id: I8b21a3af8ca20c9a8d2e14cf13221db1cabfac15
This commit is contained in:
Nilesh Lokhande 2019-05-29 09:38:06 +00:00
parent 34ae8e3545
commit 2f7ad519fe
3 changed files with 117 additions and 35 deletions

View File

@ -488,6 +488,25 @@ class FeatureManager(traffic_manager.IperfManager,
raise RuntimeError(_("NSX bridge profile information is null")) raise RuntimeError(_("NSX bridge profile information is null"))
return [(x.get("id"), x.get("display_name")) for x in response] return [(x.get("id"), x.get("display_name")) for x in response]
def nsx_transport_zone_info(self):
"""Collect the Vlan Transport zone.
:return: nsx vlan transport zone.
"""
response = self.nsx_client.get_transport_zones()
if len(response) == 0:
raise RuntimeError(_("NSX bridge profile information is null"))
vlan_zone = None
for zone in response:
if zone['transport_type'] == 'VLAN':
if zone['display_name'] == 'transportzone2':
vlan_zone = zone['id']
if vlan_zone:
return vlan_zone
else:
raise RuntimeError(_("Vlan Transport zone not found"))
def create_l2gw_connection(self, l2gwc_param): def create_l2gw_connection(self, l2gwc_param):
"""Creates L2GWC and return the response. """Creates L2GWC and return the response.

View File

@ -50,6 +50,10 @@ class NSXClient(object):
return self.nsx.get_bridge_profile_info( return self.nsx.get_bridge_profile_info(
*args, **kwargs) *args, **kwargs)
def get_transport_zones(self):
if self.backend == "nsxv3":
return self.nsx.get_transport_zones()
def get_qos_switching_profile(self, policy_name): def get_qos_switching_profile(self, policy_name):
""" """
Retrieve attributes of a given nsx switching profile Retrieve attributes of a given nsx switching profile

View File

@ -66,7 +66,6 @@ class L2GatewayTest(L2GatewayBase):
""" """
Test l2 gateway operations. Test l2 gateway operations.
""" """
@decorators.attr(type="nsxv3") @decorators.attr(type="nsxv3")
@decorators.idempotent_id("e5e3a089-602c-496e-8c17-4ef613266924") @decorators.idempotent_id("e5e3a089-602c-496e-8c17-4ef613266924")
def test_l2_gateway_create_without_vlan(self): def test_l2_gateway_create_without_vlan(self):
@ -80,7 +79,8 @@ class L2GatewayTest(L2GatewayBase):
cluster_info = self.nsx_bridge_cluster_info() cluster_info = self.nsx_bridge_cluster_info()
else: else:
cluster_info = self.nsx_bridge_profile_info() cluster_info = self.nsx_bridge_profile_info()
device_name, interface_name = cluster_info[0][0], cluster_info[0][1] transport_zone = self.nsx_transport_zone_info()
device_name, interface_name = cluster_info[0][0], transport_zone
l2gw_name = data_utils.rand_name(constants.L2GW) l2gw_name = data_utils.rand_name(constants.L2GW)
device_1 = {"dname": device_name, "iname": interface_name} device_1 = {"dname": device_name, "iname": interface_name}
l2gw_param = [device_1] l2gw_param = [device_1]
@ -107,7 +107,8 @@ class L2GatewayTest(L2GatewayBase):
cluster_info = self.nsx_bridge_cluster_info() cluster_info = self.nsx_bridge_cluster_info()
else: else:
cluster_info = self.nsx_bridge_profile_info() cluster_info = self.nsx_bridge_profile_info()
device_name, interface_name = cluster_info[0][0], cluster_info[0][1] transport_zone = self.nsx_transport_zone_info()
device_name, interface_name = cluster_info[0][0], transport_zone
l2gw_name = data_utils.rand_name(constants.L2GW) l2gw_name = data_utils.rand_name(constants.L2GW)
device_1 = {"dname": device_name, "iname": interface_name, device_1 = {"dname": device_name, "iname": interface_name,
"vlans": [self.VLAN_1]} "vlans": [self.VLAN_1]}
@ -146,7 +147,8 @@ class L2GatewayTest(L2GatewayBase):
cluster_info = self.nsx_bridge_cluster_info() cluster_info = self.nsx_bridge_cluster_info()
else: else:
cluster_info = self.nsx_bridge_profile_info() cluster_info = self.nsx_bridge_profile_info()
device_name, interface_name = cluster_info[0][0], cluster_info[0][1] transport_zone = self.nsx_transport_zone_info()
device_name, interface_name = cluster_info[0][0], transport_zone
l2gw_name = data_utils.rand_name(constants.L2GW) l2gw_name = data_utils.rand_name(constants.L2GW)
device_1 = {"dname": device_name, "iname": interface_name, device_1 = {"dname": device_name, "iname": interface_name,
"vlans": [self.VLAN_1, self.VLAN_2]} "vlans": [self.VLAN_1, self.VLAN_2]}
@ -184,7 +186,8 @@ class L2GatewayTest(L2GatewayBase):
cluster_info = self.nsx_bridge_cluster_info() cluster_info = self.nsx_bridge_cluster_info()
else: else:
cluster_info = self.nsx_bridge_profile_info() cluster_info = self.nsx_bridge_profile_info()
device_name, interface_name = cluster_info[0][0], cluster_info[0][1] transport_zone = self.nsx_transport_zone_info()
device_name, interface_name = cluster_info[0][0], transport_zone
l2gw_name = data_utils.rand_name(constants.L2GW) l2gw_name = data_utils.rand_name(constants.L2GW)
device_1 = {"dname": device_name, "iname": interface_name} device_1 = {"dname": device_name, "iname": interface_name}
l2gw_param = [device_1] l2gw_param = [device_1]
@ -216,7 +219,8 @@ class L2GatewayTest(L2GatewayBase):
cluster_info = self.nsx_bridge_cluster_info() cluster_info = self.nsx_bridge_cluster_info()
else: else:
cluster_info = self.nsx_bridge_profile_info() cluster_info = self.nsx_bridge_profile_info()
device_name, interface_name = cluster_info[0][0], cluster_info[0][1] transport_zone = self.nsx_transport_zone_info()
device_name, interface_name = cluster_info[0][0], transport_zone
l2gw_name = data_utils.rand_name(constants.L2GW) l2gw_name = data_utils.rand_name(constants.L2GW)
device_1 = {"dname": device_name, "iname": interface_name} device_1 = {"dname": device_name, "iname": interface_name}
l2gw_param = [device_1] l2gw_param = [device_1]
@ -260,7 +264,8 @@ class L2GatewayTest(L2GatewayBase):
cluster_info = self.nsx_bridge_cluster_info() cluster_info = self.nsx_bridge_cluster_info()
else: else:
cluster_info = self.nsx_bridge_profile_info() cluster_info = self.nsx_bridge_profile_info()
device_name, interface_name = cluster_info[0][0], cluster_info[0][1] transport_zone = self.nsx_transport_zone_info()
device_name, interface_name = cluster_info[0][0], transport_zone
l2gw_name = data_utils.rand_name(constants.L2GW) l2gw_name = data_utils.rand_name(constants.L2GW)
device_1 = {"dname": device_name, "iname": interface_name} device_1 = {"dname": device_name, "iname": interface_name}
l2gw_param = [device_1] l2gw_param = [device_1]
@ -305,7 +310,8 @@ class L2GatewayTest(L2GatewayBase):
cluster_info = self.nsx_bridge_cluster_info() cluster_info = self.nsx_bridge_cluster_info()
else: else:
cluster_info = self.nsx_bridge_profile_info() cluster_info = self.nsx_bridge_profile_info()
device_name, interface_name = cluster_info[0][0], cluster_info[0][1] transport_zone = self.nsx_transport_zone_info()
device_name, interface_name = cluster_info[0][0], transport_zone
l2gw_name = data_utils.rand_name(constants.L2GW) l2gw_name = data_utils.rand_name(constants.L2GW)
device_1 = {"dname": device_name, "iname": interface_name, device_1 = {"dname": device_name, "iname": interface_name,
"vlans": [self.VLAN_1, self.VLAN_2]} "vlans": [self.VLAN_1, self.VLAN_2]}
@ -350,7 +356,8 @@ class L2GatewayTest(L2GatewayBase):
cluster_info = self.nsx_bridge_cluster_info() cluster_info = self.nsx_bridge_cluster_info()
else: else:
cluster_info = self.nsx_bridge_profile_info() cluster_info = self.nsx_bridge_profile_info()
device_name, interface_name = cluster_info[0][0], cluster_info[0][1] transport_zone = self.nsx_transport_zone_info()
device_name, interface_name = cluster_info[0][0], transport_zone
l2gw_name = data_utils.rand_name(constants.L2GW) l2gw_name = data_utils.rand_name(constants.L2GW)
device_1 = {"dname": device_name, "iname": interface_name, device_1 = {"dname": device_name, "iname": interface_name,
"vlans": [self.VLAN_1]} "vlans": [self.VLAN_1]}
@ -389,8 +396,12 @@ class L2GatewayConnectionTest(L2GatewayBase):
""" """
LOG.info("Testing test_l2_gateway_connection_create api") LOG.info("Testing test_l2_gateway_connection_create api")
self.deploy_l2gateway_topology() self.deploy_l2gateway_topology()
if CONF.nsxv3.bridge_cluster:
cluster_info = self.nsx_bridge_cluster_info() cluster_info = self.nsx_bridge_cluster_info()
device_name, interface_name = cluster_info[0][0], cluster_info[0][1] else:
cluster_info = self.nsx_bridge_profile_info()
transport_zone = self.nsx_transport_zone_info()
device_name, interface_name = cluster_info[0][0], transport_zone
l2gw_name = data_utils.rand_name(constants.L2GW) l2gw_name = data_utils.rand_name(constants.L2GW)
device_1 = {"dname": device_name, "iname": interface_name, device_1 = {"dname": device_name, "iname": interface_name,
"vlans": [self.VLAN_1]} "vlans": [self.VLAN_1]}
@ -423,8 +434,12 @@ class L2GatewayConnectionTest(L2GatewayBase):
""" """
LOG.info("Testing test_l2_gateway_connection_create api") LOG.info("Testing test_l2_gateway_connection_create api")
self.deploy_l2gateway_topology() self.deploy_l2gateway_topology()
if CONF.nsxv3.bridge_cluster:
cluster_info = self.nsx_bridge_cluster_info() cluster_info = self.nsx_bridge_cluster_info()
device_name, interface_name = cluster_info[0][0], cluster_info[0][1] else:
cluster_info = self.nsx_bridge_profile_info()
transport_zone = self.nsx_transport_zone_info()
device_name, interface_name = cluster_info[0][0], transport_zone
l2gw_name = data_utils.rand_name(constants.L2GW) l2gw_name = data_utils.rand_name(constants.L2GW)
device_1 = {"dname": device_name, "iname": interface_name, device_1 = {"dname": device_name, "iname": interface_name,
"vlans": [self.VLAN_1, self.VLAN_2]} "vlans": [self.VLAN_1, self.VLAN_2]}
@ -457,8 +472,12 @@ class L2GatewayConnectionTest(L2GatewayBase):
""" """
LOG.info("Testing test_l2_gateway_connection_create api") LOG.info("Testing test_l2_gateway_connection_create api")
self.deploy_l2gateway_topology() self.deploy_l2gateway_topology()
if CONF.nsxv3.bridge_cluster:
cluster_info = self.nsx_bridge_cluster_info() cluster_info = self.nsx_bridge_cluster_info()
device_name, interface_name = cluster_info[0][0], cluster_info[0][1] else:
cluster_info = self.nsx_bridge_profile_info()
transport_zone = self.nsx_transport_zone_info()
device_name, interface_name = cluster_info[0][0], transport_zone
l2gw_name = data_utils.rand_name(constants.L2GW) l2gw_name = data_utils.rand_name(constants.L2GW)
device_1 = {"dname": device_name, "iname": interface_name} device_1 = {"dname": device_name, "iname": interface_name}
l2gw_param = [device_1] l2gw_param = [device_1]
@ -495,8 +514,12 @@ class L2GatewayConnectionTest(L2GatewayBase):
""" """
LOG.info("Testing test_l2_gateway_connection_create api") LOG.info("Testing test_l2_gateway_connection_create api")
self.deploy_l2gateway_topology() self.deploy_l2gateway_topology()
if CONF.nsxv3.bridge_cluster:
cluster_info = self.nsx_bridge_cluster_info() cluster_info = self.nsx_bridge_cluster_info()
device_name, interface_name = cluster_info[0][0], cluster_info[0][1] else:
cluster_info = self.nsx_bridge_profile_info()
transport_zone = self.nsx_transport_zone_info()
device_name, interface_name = cluster_info[0][0], transport_zone
l2gw_name = data_utils.rand_name(constants.L2GW) l2gw_name = data_utils.rand_name(constants.L2GW)
device_1 = {"dname": device_name, "iname": interface_name} device_1 = {"dname": device_name, "iname": interface_name}
l2gw_param = [device_1] l2gw_param = [device_1]
@ -541,8 +564,12 @@ class L2GatewayConnectionTest(L2GatewayBase):
""" """
LOG.info("Testing test_l2_gateway_connection_create api") LOG.info("Testing test_l2_gateway_connection_create api")
self.deploy_l2gateway_topology() self.deploy_l2gateway_topology()
if CONF.nsxv3.bridge_cluster:
cluster_info = self.nsx_bridge_cluster_info() cluster_info = self.nsx_bridge_cluster_info()
device_name, interface_name = cluster_info[0][0], cluster_info[0][1] else:
cluster_info = self.nsx_bridge_profile_info()
transport_zone = self.nsx_transport_zone_info()
device_name, interface_name = cluster_info[0][0], transport_zone
l2gw_name = data_utils.rand_name(constants.L2GW) l2gw_name = data_utils.rand_name(constants.L2GW)
device_1 = {"dname": device_name, "iname": interface_name} device_1 = {"dname": device_name, "iname": interface_name}
l2gw_param = [device_1] l2gw_param = [device_1]
@ -611,8 +638,12 @@ class L2GatewayConnectionTest(L2GatewayBase):
list_rsp = list_rsp["l2_gateway_connections"] list_rsp = list_rsp["l2_gateway_connections"]
l2gwc_ids = [item.get("id") for item in list_rsp if "id" l2gwc_ids = [item.get("id") for item in list_rsp if "id"
in item] in item]
if CONF.nsxv3.bridge_cluster:
cluster_info = self.nsx_bridge_cluster_info() cluster_info = self.nsx_bridge_cluster_info()
device_name, interface_name = cluster_info[0][0], cluster_info[0][1] else:
cluster_info = self.nsx_bridge_profile_info()
transport_zone = self.nsx_transport_zone_info()
device_name, interface_name = cluster_info[0][0], transport_zone
l2gw_name = data_utils.rand_name(constants.L2GW) l2gw_name = data_utils.rand_name(constants.L2GW)
device_1 = {"dname": device_name, "iname": interface_name} device_1 = {"dname": device_name, "iname": interface_name}
l2gw_param = [device_1] l2gw_param = [device_1]
@ -663,8 +694,12 @@ class L2GatewayConnectionTest(L2GatewayBase):
""" """
LOG.info("Testing l2_gateway_connection_delete api") LOG.info("Testing l2_gateway_connection_delete api")
self.deploy_l2gateway_topology() self.deploy_l2gateway_topology()
if CONF.nsxv3.bridge_cluster:
cluster_info = self.nsx_bridge_cluster_info() cluster_info = self.nsx_bridge_cluster_info()
device_name, interface_name = cluster_info[0][0], cluster_info[0][1] else:
cluster_info = self.nsx_bridge_profile_info()
transport_zone = self.nsx_transport_zone_info()
device_name, interface_name = cluster_info[0][0], transport_zone
l2gw_name = data_utils.rand_name(constants.L2GW) l2gw_name = data_utils.rand_name(constants.L2GW)
device_1 = {"dname": device_name, "iname": interface_name} device_1 = {"dname": device_name, "iname": interface_name}
l2gw_param = [device_1] l2gw_param = [device_1]
@ -700,8 +735,12 @@ class L2GatewayConnectionNegative(L2GatewayBase):
""" """
LOG.info("Testing test_l2_gateway_create api") LOG.info("Testing test_l2_gateway_create api")
self.deploy_l2gateway_topology() self.deploy_l2gateway_topology()
if CONF.nsxv3.bridge_cluster:
cluster_info = self.nsx_bridge_cluster_info() cluster_info = self.nsx_bridge_cluster_info()
device_name, interface_name = cluster_info[0][0], cluster_info[0][1] else:
cluster_info = self.nsx_bridge_profile_info()
transport_zone = self.nsx_transport_zone_info()
device_name, interface_name = cluster_info[0][0], transport_zone
l2gw_name = data_utils.rand_name(constants.L2GW) l2gw_name = data_utils.rand_name(constants.L2GW)
device_1 = {"dname": device_name, "iname": interface_name} device_1 = {"dname": device_name, "iname": interface_name}
l2gw_param = [device_1] l2gw_param = [device_1]
@ -728,8 +767,12 @@ class L2GatewayConnectionNegative(L2GatewayBase):
""" """
LOG.info("Testing test_l2_gateway_connection_create api") LOG.info("Testing test_l2_gateway_connection_create api")
self.deploy_l2gateway_topology() self.deploy_l2gateway_topology()
if CONF.nsxv3.bridge_cluster:
cluster_info = self.nsx_bridge_cluster_info() cluster_info = self.nsx_bridge_cluster_info()
device_name, interface_name = cluster_info[0][0], cluster_info[0][1] else:
cluster_info = self.nsx_bridge_profile_info()
transport_zone = self.nsx_transport_zone_info()
device_name, interface_name = cluster_info[0][0], transport_zone
l2gw_name = data_utils.rand_name(constants.L2GW) l2gw_name = data_utils.rand_name(constants.L2GW)
device_1 = {"dname": device_name, "iname": interface_name, device_1 = {"dname": device_name, "iname": interface_name,
"vlans": [self.VLAN_1]} "vlans": [self.VLAN_1]}
@ -756,8 +799,12 @@ class L2GatewayConnectionNegative(L2GatewayBase):
LOG.info("Testing test_l2_gateway_connection_create api") LOG.info("Testing test_l2_gateway_connection_create api")
self.deploy_l2gateway_topology() self.deploy_l2gateway_topology()
non_exist_l2gw_uuid = NON_EXIST_UUID non_exist_l2gw_uuid = NON_EXIST_UUID
if CONF.nsxv3.bridge_cluster:
cluster_info = self.nsx_bridge_cluster_info() cluster_info = self.nsx_bridge_cluster_info()
device_name, interface_name = cluster_info[0][0], cluster_info[0][1] else:
cluster_info = self.nsx_bridge_profile_info()
transport_zone = self.nsx_transport_zone_info()
device_name, interface_name = cluster_info[0][0], transport_zone
l2gw_name = data_utils.rand_name(constants.L2GW) l2gw_name = data_utils.rand_name(constants.L2GW)
device_1 = {"dname": device_name, "iname": interface_name} device_1 = {"dname": device_name, "iname": interface_name}
l2gw_param = [device_1] l2gw_param = [device_1]
@ -778,8 +825,12 @@ class L2GatewayConnectionNegative(L2GatewayBase):
""" """
LOG.info("Testing test_l2_gateway_connection_create api") LOG.info("Testing test_l2_gateway_connection_create api")
non_exist_network_uuid = NON_EXIST_UUID non_exist_network_uuid = NON_EXIST_UUID
if CONF.nsxv3.bridge_cluster:
cluster_info = self.nsx_bridge_cluster_info() cluster_info = self.nsx_bridge_cluster_info()
device_name, interface_name = cluster_info[0][0], cluster_info[0][1] else:
cluster_info = self.nsx_bridge_profile_info()
transport_zone = self.nsx_transport_zone_info()
device_name, interface_name = cluster_info[0][0], transport_zone
l2gw_name = data_utils.rand_name(constants.L2GW) l2gw_name = data_utils.rand_name(constants.L2GW)
device_1 = {"dname": device_name, "iname": interface_name} device_1 = {"dname": device_name, "iname": interface_name}
l2gw_param = [device_1] l2gw_param = [device_1]
@ -799,8 +850,12 @@ class L2GatewayConnectionNegative(L2GatewayBase):
""" """
LOG.info("Testing l2_gateway_create api with segmentation ID") LOG.info("Testing l2_gateway_create api with segmentation ID")
invalid_seg_id = 20000 invalid_seg_id = 20000
if CONF.nsxv3.bridge_cluster:
cluster_info = self.nsx_bridge_cluster_info() cluster_info = self.nsx_bridge_cluster_info()
device_name, interface_name = cluster_info[0][0], cluster_info[0][1] else:
cluster_info = self.nsx_bridge_profile_info()
transport_zone = self.nsx_transport_zone_info()
device_name, interface_name = cluster_info[0][0], transport_zone
l2gw_name = data_utils.rand_name(constants.L2GW) l2gw_name = data_utils.rand_name(constants.L2GW)
device_1 = {"dname": device_name, "iname": interface_name, device_1 = {"dname": device_name, "iname": interface_name,
"vlans": [invalid_seg_id]} "vlans": [invalid_seg_id]}
@ -817,8 +872,12 @@ class L2GatewayConnectionNegative(L2GatewayBase):
""" """
LOG.info("Testing l2_gateway_create api with segmentation ID") LOG.info("Testing l2_gateway_create api with segmentation ID")
invalid_seg_id = 2.45 invalid_seg_id = 2.45
if CONF.nsxv3.bridge_cluster:
cluster_info = self.nsx_bridge_cluster_info() cluster_info = self.nsx_bridge_cluster_info()
device_name, interface_name = cluster_info[0][0], cluster_info[0][1] else:
cluster_info = self.nsx_bridge_profile_info()
transport_zone = self.nsx_transport_zone_info()
device_name, interface_name = cluster_info[0][0], transport_zone
l2gw_name = data_utils.rand_name(constants.L2GW) l2gw_name = data_utils.rand_name(constants.L2GW)
device_1 = {"dname": device_name, "iname": interface_name, device_1 = {"dname": device_name, "iname": interface_name,
"vlans": [invalid_seg_id]} "vlans": [invalid_seg_id]}