From 4c4d34e2311fa73838cd2eeb64160aac49a36da1 Mon Sep 17 00:00:00 2001 From: Nilesh Lokhande Date: Sat, 6 Apr 2019 11:56:27 +0000 Subject: [PATCH] Bridge Endpoint Profile changes. Change-Id: I02078350c60c9e353293ed403502641b07f1d6c4 --- .../lib/feature_manager.py | 11 +++++ .../services/nsx_client.py | 15 ++++--- .../services/nsxv3_client.py | 8 ++++ .../tests/nsxv3/api/test_l2_gateway.py | 40 +++++++++++++++---- 4 files changed, 61 insertions(+), 13 deletions(-) diff --git a/vmware_nsx_tempest_plugin/lib/feature_manager.py b/vmware_nsx_tempest_plugin/lib/feature_manager.py index 9312f75..fc4368a 100644 --- a/vmware_nsx_tempest_plugin/lib/feature_manager.py +++ b/vmware_nsx_tempest_plugin/lib/feature_manager.py @@ -451,6 +451,17 @@ class FeatureManager(traffic_manager.IperfManager, raise RuntimeError(_("NSX bridge cluster information is null")) return [(x.get("id"), x.get("display_name")) for x in response] + def nsx_bridge_profile_info(self): + """Collect the device and interface name of the nsx brdige profile. + + :return: nsx bridge id and display name. + + """ + response = self.nsx_client.get_bridge_profile_info() + if len(response) == 0: + raise RuntimeError(_("NSX bridge profile information is null")) + return [(x.get("id"), x.get("display_name")) for x in response] + def create_l2gw_connection(self, l2gwc_param): """Creates L2GWC and return the response. diff --git a/vmware_nsx_tempest_plugin/services/nsx_client.py b/vmware_nsx_tempest_plugin/services/nsx_client.py index 819e6d9..1497010 100644 --- a/vmware_nsx_tempest_plugin/services/nsx_client.py +++ b/vmware_nsx_tempest_plugin/services/nsx_client.py @@ -37,7 +37,7 @@ class NSXClient(object): firewall_section) return firewall_section, firewall_section_rules else: - #TODO(ddoshi) define else for nsxv + # TODO(ddoshi) define else for nsxv pass def get_bridge_cluster_info(self, *args, **kwargs): @@ -45,6 +45,11 @@ class NSXClient(object): return self.nsx.get_bridge_cluster_info( *args, **kwargs) + def get_bridge_profile_info(self, *args, **kwargs): + if self.backend == "nsxv3": + return self.nsx.get_bridge_profile_info( + *args, **kwargs) + def get_qos_switching_profile(self, policy_name): """ Retrieve attributes of a given nsx switching profile @@ -52,11 +57,11 @@ class NSXClient(object): if self.backend == "nsxv3": qos_policies = self.nsx.get_switching_profiles() nsx_policy = self.nsx.get_nsx_resource_by_name(qos_policies, - policy_name) + policy_name) qos_policy = self.nsx.get_switching_profile(nsx_policy['id']) return qos_policy else: - #TODO(dkandavarajay) define else for NSXV + # TODO(dkandavarajay) define else for NSXV pass def get_qos_bandwidth_rule(self, nsx_policy_id): @@ -73,7 +78,7 @@ class NSXClient(object): max_burst = cfg['burst_size_bytes'] return avg_bw, peak_bw, max_burst else: - #TODO(dkandavarajay) define else for NSXV + # TODO(dkandavarajay) define else for NSXV pass def get_qos_dscp_rule(self, nsx_policy_id): @@ -85,7 +90,7 @@ class NSXClient(object): shaper_cfg = sw_profiles['dscp'] return shaper_cfg['priority'] else: - #TODO(dkandavarajay) define else for NSXV + # TODO(dkandavarajay) define else for NSXV pass return None diff --git a/vmware_nsx_tempest_plugin/services/nsxv3_client.py b/vmware_nsx_tempest_plugin/services/nsxv3_client.py index ef90520..0780b9f 100644 --- a/vmware_nsx_tempest_plugin/services/nsxv3_client.py +++ b/vmware_nsx_tempest_plugin/services/nsxv3_client.py @@ -324,6 +324,14 @@ class NSXV3Client(object): """ return self.get_logical_resources("/bridge-clusters") + def get_bridge_profile_info(self): + """ + Get bridge profile information. + + :return: returns bridge profile id and bridge profile name. + """ + return self.get_logical_resources("/bridge-endpoint-profiles") + def get_logical_switch(self, os_name, os_uuid): """ Get the logical switch based on the name and uuid provided. diff --git a/vmware_nsx_tempest_plugin/tests/nsxv3/api/test_l2_gateway.py b/vmware_nsx_tempest_plugin/tests/nsxv3/api/test_l2_gateway.py index 6020f3e..917dca9 100644 --- a/vmware_nsx_tempest_plugin/tests/nsxv3/api/test_l2_gateway.py +++ b/vmware_nsx_tempest_plugin/tests/nsxv3/api/test_l2_gateway.py @@ -76,7 +76,10 @@ class L2GatewayTest(L2GatewayBase): bridge cluster UUID (device name) from NSX manager. """ LOG.info("Testing l2_gateway_create api") - cluster_info = self.nsx_bridge_cluster_info() + if CONF.nsxv3.bridge_cluster: + cluster_info = self.nsx_bridge_cluster_info() + else: + cluster_info = self.nsx_bridge_profile_info() device_name, interface_name = cluster_info[0][0], cluster_info[0][1] l2gw_name = data_utils.rand_name(constants.L2GW) device_1 = {"dname": device_name, "iname": interface_name} @@ -100,7 +103,10 @@ class L2GatewayTest(L2GatewayBase): bridge cluster UUID (device name) from NSX manager and vlan id. """ LOG.info("Testing l2_gateway_create api with segmentation ID") - cluster_info = self.nsx_bridge_cluster_info() + if CONF.nsxv3.bridge_cluster: + cluster_info = self.nsx_bridge_cluster_info() + else: + cluster_info = self.nsx_bridge_profile_info() device_name, interface_name = cluster_info[0][0], cluster_info[0][1] l2gw_name = data_utils.rand_name(constants.L2GW) device_1 = {"dname": device_name, "iname": interface_name, @@ -136,7 +142,10 @@ class L2GatewayTest(L2GatewayBase): bridge cluster UUID (device name) from NSX manager and vlan id. """ LOG.info("Testing l2_gateway_create api with segmentation ID") - cluster_info = self.nsx_bridge_cluster_info() + if CONF.nsxv3.bridge_cluster: + cluster_info = self.nsx_bridge_cluster_info() + else: + cluster_info = self.nsx_bridge_profile_info() device_name, interface_name = cluster_info[0][0], cluster_info[0][1] l2gw_name = data_utils.rand_name(constants.L2GW) device_1 = {"dname": device_name, "iname": interface_name, @@ -171,7 +180,10 @@ class L2GatewayTest(L2GatewayBase): delete l2gw we need l2gw id. """ LOG.info("Testing l2_gateway_delete api") - cluster_info = self.nsx_bridge_cluster_info() + if CONF.nsxv3.bridge_cluster: + cluster_info = self.nsx_bridge_cluster_info() + else: + cluster_info = self.nsx_bridge_profile_info() device_name, interface_name = cluster_info[0][0], cluster_info[0][1] l2gw_name = data_utils.rand_name(constants.L2GW) device_1 = {"dname": device_name, "iname": interface_name} @@ -200,7 +212,10 @@ class L2GatewayTest(L2GatewayBase): update l2gw we need l2gw id and payload to update. """ LOG.info("Testing l2_gateway_update api") - cluster_info = self.nsx_bridge_cluster_info() + if CONF.nsxv3.bridge_cluster: + cluster_info = self.nsx_bridge_cluster_info() + else: + cluster_info = self.nsx_bridge_profile_info() device_name, interface_name = cluster_info[0][0], cluster_info[0][1] l2gw_name = data_utils.rand_name(constants.L2GW) device_1 = {"dname": device_name, "iname": interface_name} @@ -241,7 +256,10 @@ class L2GatewayTest(L2GatewayBase): update l2gw we need l2gw id and payload to update. """ LOG.info("Testing l2_gateway_update api") - cluster_info = self.nsx_bridge_cluster_info() + if CONF.nsxv3.bridge_cluster: + cluster_info = self.nsx_bridge_cluster_info() + else: + cluster_info = self.nsx_bridge_profile_info() device_name, interface_name = cluster_info[0][0], cluster_info[0][1] l2gw_name = data_utils.rand_name(constants.L2GW) device_1 = {"dname": device_name, "iname": interface_name} @@ -283,7 +301,10 @@ class L2GatewayTest(L2GatewayBase): show l2gw based on UUID. To see l2gw info we need l2gw id. """ LOG.info("Testing l2_gateway_show api") - cluster_info = self.nsx_bridge_cluster_info() + if CONF.nsxv3.bridge_cluster: + cluster_info = self.nsx_bridge_cluster_info() + else: + cluster_info = self.nsx_bridge_profile_info() device_name, interface_name = cluster_info[0][0], cluster_info[0][1] l2gw_name = data_utils.rand_name(constants.L2GW) device_1 = {"dname": device_name, "iname": interface_name, @@ -325,7 +346,10 @@ class L2GatewayTest(L2GatewayBase): list created l2gw. """ LOG.info("Testing l2_gateway_list api") - cluster_info = self.nsx_bridge_cluster_info() + if CONF.nsxv3.bridge_cluster: + cluster_info = self.nsx_bridge_cluster_info() + else: + cluster_info = self.nsx_bridge_profile_info() device_name, interface_name = cluster_info[0][0], cluster_info[0][1] l2gw_name = data_utils.rand_name(constants.L2GW) device_1 = {"dname": device_name, "iname": interface_name,