trunk: add code to remove child and parent port

Change-Id: I52877c74d4a039d09599e11a8f686a170c0a19ed
This commit is contained in:
dkumbhar 2021-11-03 09:49:56 +00:00
parent 312acb7a46
commit e898683a2d
3 changed files with 147 additions and 5 deletions

View File

@ -46,6 +46,7 @@ class BaseTrunkClient(base.BaseNetworkClient):
class TrunkClient(BaseTrunkClient):
create_trunk_path = '/trunks'
delete_trunk_path = '/trunks/%s'
add_sub_port = '/trunks/%s/add_subports'
remove_sub_port = '/trunks/%s/remove_subports'
@ -56,6 +57,13 @@ class TrunkClient(BaseTrunkClient):
response_data = self.create_resource(self.create_trunk_path, post_data)
return response_data['trunk']['id']
def delete_trunk(self, trunkportid):
"""Create a trunk parent port.
"""
delete_trunk_path = self.delete_trunk_path % trunkportid
response_data = self.delete_resource(delete_trunk_path)
return response_data
def add_subport(self, trunkportid, **kwargs):
post_data = kwargs
self.url = self.add_sub_port % trunkportid

View File

@ -316,6 +316,7 @@ class ProviderNetworks(feature_manager.FeatureManager):
provider_network = self.provider_networks_topoloy(
constants.VLAN_TYPE,
tz_id=self.vlan_id)
time.sleep(constants.NSX_NETWORK_REALISE_TIMEOUT)
nsx_network = self.nsx.get_logical_switch(provider_network['name'],
provider_network['id'])
self.assertEqual(4050, nsx_network['vlan'])
@ -344,6 +345,7 @@ class ProviderNetworks(feature_manager.FeatureManager):
constants.VLAN_TYPE,
tz_id=self.vlan_id,
vlan_id_unique=1004)
time.sleep(constants.NSX_NETWORK_REALISE_TIMEOUT)
nsx_network1 = self.nsx.get_logical_switch(provider_network1['name'],
provider_network1['id'])
self.assertEqual(1004, nsx_network1['vlan'])

View File

@ -77,6 +77,10 @@ class TestTrunkService(feature_manager.FeatureManager):
def create_trunks(cls, **kwargs):
return cls.trunk_client.create_trunk(**kwargs)
@classmethod
def delete_trunks(cls, trunkportid):
return cls.trunk_client.delete_trunk(trunkportid)
@classmethod
def add_subports(cls, trunkportid, **kwargs):
return cls.trunk_client.add_subport(trunkportid, **kwargs)
@ -94,6 +98,9 @@ class TestTrunkService(feature_manager.FeatureManager):
trunk_id = self.create_trunks(**kwargs)
return trunk_id
def delete_trunk_config(self, trunkportid):
self.delete_trunks(trunkportid)
def add_subport_to_parent(self, vlan_id, provider, project_id,
child_port, childportname,
trunkportid):
@ -282,7 +289,12 @@ class TestTrunkService(feature_manager.FeatureManager):
ssh_src1 = self._get_remote_client(ip_address, username='ubuntu',
use_password=False,
private_key=keypair['private_key'])
remote_ip = parent2_port['port']['dns_assignment'][0]['ip_address']
if 'dns_assignment' in parent2_port['port'].keys():
remote_ip = \
parent2_port['port']['dns_assignment'][0]['ip_address']
else:
remote_ip = \
parent2_port['port']['fixed_ips'][0]['ip_address']
# Verify connectivity between vms
self._assign_ip_address(ssh_src1, 'eth0.101', child1_ip_vm1)
self._assign_ip_address(ssh_src1, 'eth0.102', child2_ip_vm1)
@ -297,6 +309,26 @@ class TestTrunkService(feature_manager.FeatureManager):
should_succeed=True)
self.check_remote_connectivity(ssh_src1, child2_ip_vm2,
should_succeed=True)
# Remove child subport
print('Removinfg child subport')
self.remove_subports(provider=True,
project_id=project_id,
child_port=child1_p1['port']['id'],
trunkportid=trunk_parent1)
self.remove_subports(provider=True,
project_id=project_id,
child_port=child2_p1['port']['id'],
trunkportid=trunk_parent1)
self.remove_subports(provider=True,
project_id=project_id,
child_port=child1_p2['port']['id'],
trunkportid=trunk_parent2)
self.remove_subports(provider=True,
project_id=project_id,
child_port=child2_p2['port']['id'],
trunkportid=trunk_parent2)
self.delete_trunk_config(trunk_parent1)
self.delete_trunk_config(trunk_parent2)
def _test_trunk_child_subport_add_delete(self, topology):
project_id = topology['project_id']
@ -380,7 +412,12 @@ class TestTrunkService(feature_manager.FeatureManager):
ssh_src1 = self._get_remote_client(ip_address, username='ubuntu',
use_password=False,
private_key=keypair['private_key'])
remote_ip = parent2_port['port']['dns_assignment'][0]['ip_address']
if 'dns_assignment' in parent2_port['port'].keys():
remote_ip = \
parent2_port['port']['dns_assignment'][0]['ip_address']
else:
remote_ip = \
parent2_port['port']['fixed_ips'][0]['ip_address']
# Verify connectivity between vms
self._assign_ip_address(ssh_src1, 'eth0.101', child1_ip_vm1)
self._assign_ip_address(ssh_src1, 'eth0.102', child2_ip_vm1)
@ -415,6 +452,26 @@ class TestTrunkService(feature_manager.FeatureManager):
# Verify connectivity between vms
self.check_remote_connectivity(ssh_src1, child2_ip_vm2,
should_succeed=True)
# Remove child subport
print('Removinfg child subport')
self.remove_subports(provider=True,
project_id=project_id,
child_port=child1_p1['port']['id'],
trunkportid=trunk_parent1)
self.remove_subports(provider=True,
project_id=project_id,
child_port=child2_p1['port']['id'],
trunkportid=trunk_parent1)
self.remove_subports(provider=True,
project_id=project_id,
child_port=child1_p2['port']['id'],
trunkportid=trunk_parent2)
self.remove_subports(provider=True,
project_id=project_id,
child_port=child2_p2['port']['id'],
trunkportid=trunk_parent2)
self.delete_trunk_config(trunk_parent1)
self.delete_trunk_config(trunk_parent2)
def _test_trunk_instance_destroy_deploy(self, topology):
project_id = topology['project_id']
@ -498,7 +555,12 @@ class TestTrunkService(feature_manager.FeatureManager):
ssh_src1 = self._get_remote_client(ip_address, username='ubuntu',
use_password=False,
private_key=keypair['private_key'])
remote_ip = parent2_port['port']['dns_assignment'][0]['ip_address']
if 'dns_assignment' in parent2_port['port'].keys():
remote_ip = \
parent2_port['port']['dns_assignment'][0]['ip_address']
else:
remote_ip = \
parent2_port['port']['fixed_ips'][0]['ip_address']
# Verify connectivity between vms
self._assign_ip_address(ssh_src1, 'eth0.101', child1_ip_vm1)
self._assign_ip_address(ssh_src1, 'eth0.102', child2_ip_vm1)
@ -524,6 +586,26 @@ class TestTrunkService(feature_manager.FeatureManager):
flavor=flavor_name)
self.check_remote_connectivity(ssh_src1, remote_ip,
should_succeed=True)
# Remove child subport
print('Removinfg child subport')
self.remove_subports(provider=True,
project_id=project_id,
child_port=child1_p1['port']['id'],
trunkportid=trunk_parent1)
self.remove_subports(provider=True,
project_id=project_id,
child_port=child2_p1['port']['id'],
trunkportid=trunk_parent1)
self.remove_subports(provider=True,
project_id=project_id,
child_port=child1_p2['port']['id'],
trunkportid=trunk_parent2)
self.remove_subports(provider=True,
project_id=project_id,
child_port=child2_p2['port']['id'],
trunkportid=trunk_parent2)
self.delete_trunk_config(trunk_parent1)
self.delete_trunk_config(trunk_parent2)
def _test_trunk_between_two_vms(self, topology):
project_id = topology['project_id']
@ -605,7 +687,12 @@ class TestTrunkService(feature_manager.FeatureManager):
ssh_src1 = self._get_remote_client(ip_address, username='ubuntu',
use_password=False,
private_key=keypair['private_key'])
remote_ip = parent2_port['port']['dns_assignment'][0]['ip_address']
if 'dns_assignment' in parent2_port['port'].keys():
remote_ip = \
parent2_port['port']['dns_assignment'][0]['ip_address']
else:
remote_ip = \
parent2_port['port']['fixed_ips'][0]['ip_address']
# Verify connectivity between vms
self._assign_ip_address(ssh_src1, 'eth0.101', child1_ip_vm1)
self._assign_ip_address(ssh_src1, 'eth0.102', child2_ip_vm1)
@ -624,6 +711,26 @@ class TestTrunkService(feature_manager.FeatureManager):
should_succeed=True)
self.check_remote_connectivity(ssh_src1, child2_ip_vm2,
should_succeed=True)
# Remove child subport
print('Removinfg child subport')
self.remove_subports(provider=True,
project_id=project_id,
child_port=child1_p1['port']['id'],
trunkportid=trunk_parent1)
self.remove_subports(provider=True,
project_id=project_id,
child_port=child2_p1['port']['id'],
trunkportid=trunk_parent1)
self.remove_subports(provider=True,
project_id=project_id,
child_port=child1_p2['port']['id'],
trunkportid=trunk_parent2)
self.remove_subports(provider=True,
project_id=project_id,
child_port=child2_p2['port']['id'],
trunkportid=trunk_parent2)
self.delete_trunk_config(trunk_parent1)
self.delete_trunk_config(trunk_parent2)
def _test_trunk_instance_vm_vlan_diff_subnet(self, topology):
project_id = topology['project_id']
@ -705,7 +812,12 @@ class TestTrunkService(feature_manager.FeatureManager):
ssh_src1 = self._get_remote_client(ip_address, username='ubuntu',
use_password=False,
private_key=keypair['private_key'])
remote_ip = parent2_port['port']['dns_assignment'][0]['ip_address']
if 'dns_assignment' in parent2_port['port'].keys():
remote_ip = \
parent2_port['port']['dns_assignment'][0]['ip_address']
else:
remote_ip = \
parent2_port['port']['fixed_ips'][0]['ip_address']
# Verify connectivity between vms
self._assign_ip_address(ssh_src1, 'eth0.201', child1_ip_vm1)
self._assign_ip_address(ssh_src1, 'eth0.202', child2_ip_vm1)
@ -724,6 +836,26 @@ class TestTrunkService(feature_manager.FeatureManager):
should_succeed=False)
self.check_remote_connectivity(ssh_src1, child2_ip_vm2,
should_succeed=False)
# Remove child subport
print('Removinfg child subport')
self.remove_subports(provider=True,
project_id=project_id,
child_port=child1_p1['port']['id'],
trunkportid=trunk_parent1)
self.remove_subports(provider=True,
project_id=project_id,
child_port=child2_p1['port']['id'],
trunkportid=trunk_parent1)
self.remove_subports(provider=True,
project_id=project_id,
child_port=child1_p2['port']['id'],
trunkportid=trunk_parent2)
self.remove_subports(provider=True,
project_id=project_id,
child_port=child2_p2['port']['id'],
trunkportid=trunk_parent2)
self.delete_trunk_config(trunk_parent1)
self.delete_trunk_config(trunk_parent2)
@decorators.idempotent_id('9d4192e9-b1b7-48c9-af04-67a82637c359')
def test_trunk_between_two_vms(self):