diff --git a/vmware_nsx_tempest_plugin/config.py b/vmware_nsx_tempest_plugin/config.py index d20a404..faaedc9 100644 --- a/vmware_nsx_tempest_plugin/config.py +++ b/vmware_nsx_tempest_plugin/config.py @@ -244,3 +244,15 @@ NsxEdgeGroup = [ default='', help="failure domain2 id"), ] + +trunk_group = cfg.OptGroup(name='trunk', + title="trunk Configuration Options") + +TrunkGroup = [ + cfg.StrOpt('image_name', + default='ubuntu', + help="image for trunk"), + cfg.StrOpt('flavor_id', + default='m3.small', + help="flavor for trunk"), +] diff --git a/vmware_nsx_tempest_plugin/lib/appliance_manager.py b/vmware_nsx_tempest_plugin/lib/appliance_manager.py index dcdaab0..8135d47 100644 --- a/vmware_nsx_tempest_plugin/lib/appliance_manager.py +++ b/vmware_nsx_tempest_plugin/lib/appliance_manager.py @@ -474,7 +474,7 @@ class ApplianceManager(manager.NetworkScenarioTest): def create_topology_instance( self, server_name, networks=None, security_groups=None, - config_drive=None, keypair=None, image_id=None, + config_drive=None, keypair=None, image_id=None, flavor=None, clients=None, create_floating_ip=True, port=None, **kwargs): # Define security group for server. if security_groups: @@ -513,8 +513,8 @@ class ApplianceManager(manager.NetworkScenarioTest): port_ = {"port": port['id']} networks_.append(port_) # Deploy server with all the args. - server = self.create_server( - name=server_name_, networks=networks_, clients=clients, **kwargs) + server = self.create_server(name=server_name_, networks=networks_, + flavor=flavor, clients=clients, **kwargs) floating_ips = [] if create_floating_ip: ports = self._get_server_portid_and_ip4(server) @@ -610,6 +610,29 @@ class ApplianceManager(manager.NetworkScenarioTest): self.assertIsNotNone(image_id, msg) return image_id + def get_flavor_id(self, params): + """ + Get the flavor id based on the params + + :param params: List of sub-string of flavor + :return: + """ + # Retrieve the list of images that meet the filter + flavors_list = self.os_admin.flavors_client.list_flavors()['flavors'] + # Validate that the list was fetched sorted accordingly + msg = "No flavors were found that met the filter criteria." + self.assertNotEmpty(flavors_list, msg) + flavor_id = None + for flavor in flavors_list: + for param in params: + if not param.lower() in flavor["name"].lower(): + break + else: + flavor_id = flavor["id"] + break + self.assertIsNotNone(flavor_id, msg) + return flavor_id + def get_user_id(self, client_id): """ Get the user id based on the openstack client diff --git a/vmware_nsx_tempest_plugin/plugin.py b/vmware_nsx_tempest_plugin/plugin.py index b60ef23..865cae0 100644 --- a/vmware_nsx_tempest_plugin/plugin.py +++ b/vmware_nsx_tempest_plugin/plugin.py @@ -30,7 +30,8 @@ _opts = [ (config_nsx.nsxv3_group, config_nsx.NSXv3Group), (config_nsx.dns_group, config_nsx.DNSGroup), (config_nsx.barbican_group, config_nsx.BarbicanGroup), - (config_nsx.nsx_edge_group, config_nsx.NsxEdgeGroup) + (config_nsx.nsx_edge_group, config_nsx.NsxEdgeGroup), + (config_nsx.trunk_group, config_nsx.TrunkGroup) ] diff --git a/vmware_nsx_tempest_plugin/services/trunk_client.py b/vmware_nsx_tempest_plugin/services/trunk_client.py new file mode 100644 index 0000000..26301fe --- /dev/null +++ b/vmware_nsx_tempest_plugin/services/trunk_client.py @@ -0,0 +1,85 @@ +# Copyright 2016 VMware, Inc. +# All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from oslo_serialization import jsonutils + +from tempest.lib.services.network import base + +from vmware_nsx_tempest_plugin.services import network_client_base \ + as base_client + + +class BaseTrunkClient(base.BaseNetworkClient): + """Why base client for trunk_client: + + https://bugs.launchpad.net/neutron/+bug/1606659 + tag-add is a CREATE operation; then expected resp_code is 201 + however it is using http PUT operation to accomplish it. + """ + + def update_resource(self, uri, post_data, resp_code=None): + """allow different response code.""" + if resp_code: + req_uri = self.uri_prefix + uri + req_post_data = jsonutils.dumps(post_data) + resp, body = self.put(req_uri, req_post_data) + body = jsonutils.loads(body) + self.expected_success(resp_code, resp.status) + return base.rest_client.ResponseBody( + resp, body) + else: + return super(BaseTrunkClient, self).update_resource( + uri, post_data) + + +class TrunkClient(BaseTrunkClient): + create_trunk_path = '/trunks' + add_sub_port = '/trunks/%s/add_subports' + + def create_trunk(self, **kwargs): + """Create a trunk parent port. + """ + post_data = kwargs + response_data = self.create_resource(self.create_trunk_path, post_data) + return response_data['trunk']['id'] + + def add_subport(self, trunkportid, **kwargs): + post_data = kwargs + self.url = self.add_sub_port % trunkportid + response_data = self.update_resource(self.url, post_data) + return response_data + + +def get_client(client_mgr, + set_property=False, with_name="trunk_client"): + """create trunk_client from networks_client. + + Create network trunk_client from manager or networks_client. + client = trunk_client.get_client(manager) + """ + manager = getattr(client_mgr, 'manager', client_mgr) + net_client = getattr(manager, 'networks_client') + try: + _params = base_client.default_params_with_timeout_values.copy() + except Exception: + _params = {} + client = TrunkClient(net_client.auth_provider, + net_client.service, + net_client.region, + net_client.endpoint_type, + **_params) + if set_property: + setattr(manager, with_name, client) + return client diff --git a/vmware_nsx_tempest_plugin/tests/scenario/test_trunk.py b/vmware_nsx_tempest_plugin/tests/scenario/test_trunk.py new file mode 100644 index 0000000..81d6110 --- /dev/null +++ b/vmware_nsx_tempest_plugin/tests/scenario/test_trunk.py @@ -0,0 +1,546 @@ +# Copyright 2017 VMware Inc +# All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import re +import time + + +from tempest import config +from tempest.lib.common.utils import data_utils + +from tempest.lib import decorators + +from vmware_nsx_tempest_plugin.common import constants +from vmware_nsx_tempest_plugin.lib import feature_manager +from vmware_nsx_tempest_plugin.services import nsxv3_client +from vmware_nsx_tempest_plugin.services import nsxv_client +from vmware_nsx_tempest_plugin.services import trunk_client + +CONF = config.CONF + + +class TestTrunkService(feature_manager.FeatureManager): + + """Test New Cases Scenario + + """ + @classmethod + def setup_clients(cls): + super(TestTrunkService, cls).setup_clients() + cls.cmgr_adm = cls.get_client_manager('admin') + cls.cmgr_alt = cls.get_client_manager('alt') + cls.cmgr_adm = cls.get_client_manager('admin') + cls.routers_client = cls.cmgr_adm.routers_client + cls.networks_client = cls.cmgr_adm.networks_client + cls.subnets_client = cls.cmgr_adm.subnets_client + cls.sec_rule_client = cls.cmgr_adm.security_group_rules_client + cls.sec_client = cls.cmgr_adm.security_groups_client + cls.trunk_client = trunk_client.get_client(cls.cmgr_adm) + + @classmethod + def resource_setup(cls): + super(TestTrunkService, cls).resource_setup() + if CONF.network.backend == "nsxv3" \ + or CONF.network.backend == "nsxp": + cls.nsx = nsxv3_client.NSXV3Client(CONF.nsxv3.nsx_manager, + CONF.nsxv3.nsx_user, + CONF.nsxv3.nsx_password) + elif CONF.network.backend == "nsxv": + manager_ip = re.search(r"(\d{1,3}\.){3}\d{1,3}", + CONF.nsxv.manager_uri).group(0) + cls.vsm = nsxv_client.VSMClient( + manager_ip, CONF.nsxv.user, CONF.nsxv.password) + + cls.namestart = 'lbaas-ops' + cls.poke_counters = 12 + cls.hm_delay = 4 + cls.hm_max_retries = 3 + cls.hm_timeout = 10 + cls.server_names = [] + cls.loadbalancer = None + cls.vip_fip = None + cls.web_service_start_delay = 2.5 + + @classmethod + def create_trunks(cls, **kwargs): + return cls.trunk_client.create_trunk(**kwargs) + + @classmethod + def add_subports(cls, trunkportid, **kwargs): + return cls.trunk_client.add_subport(trunkportid, **kwargs) + + def create_trunk_parent_port(self, provider, project_id, + parent_port, trunkportname): + kwargs = {} + kwargs['trunk'] = dict(port_id=parent_port, + admin_state_up='true', + name=trunkportname) + trunk_id = self.create_trunks(**kwargs) + return trunk_id + + def add_subport_to_parent(self, vlan_id, provider, project_id, + child_port, childportname, + trunkportid): + kwargs = {} + subport_dict = dict(segmentation_id=vlan_id, + port_id=child_port, + segmentation_type='vlan', + name=childportname) + subport_detail = [] + subport_detail.append(subport_dict) + kwargs['sub_ports'] = subport_detail + child_port = self.add_subports(trunkportid, **kwargs) + return child_port + + def remove_subports(self, provider, project_id, child_port, trunkportid): + kwargs = {} + subport_dict = dict(port_id=child_port) + subport_detail = [] + subport_detail.append(subport_dict) + kwargs['sub_ports'] = subport_detail + delete_child_port = self.remove_subport(trunkportid, **kwargs) + return delete_child_port + + def _assign_ip_address(self, ssh_source, interface_name, ip_address): + int_face = interface_name.split('.')[0] + vlan_id = interface_name.split('.')[1] + ssh_source.exec_command("sudo ip link add link %s name %s type vlan\ + id %s" % (int_face, interface_name, vlan_id)) + + ssh_source.exec_command("sudo ifconfig %s %s/24 \ + up" % (interface_name, ip_address)) + + def create_trunk_network_topo(self, + create_instance=True, + set_gateway=True): + rtr_name = data_utils.rand_name(name='tempest-router') + network_name1 = data_utils.rand_name(name='tempest-Parent') + network_name2 = data_utils.rand_name(name='tempest-child1') + network_name3 = data_utils.rand_name(name='tempest-child2') + subnet_name1 = data_utils.rand_name(name='tempest-subnetParent') + subnet_name2 = data_utils.rand_name(name='tempest-subneChild1') + subnet_name3 = data_utils.rand_name(name='tempest-subneChild2') + nw_client = self.cmgr_adm.networks_client + rtr_client = self.cmgr_adm.routers_client + router = self.create_topology_router(rtr_name, + set_gateway=set_gateway, + routers_client=rtr_client) + networkParent = self.create_topology_network(network_name1, + networks_client=nw_client) + networkChild1 = self.create_topology_network(network_name2, + networks_client=nw_client) + networkChild2 = self.create_topology_network(network_name3, + networks_client=nw_client) + self.create_topology_subnet(subnet_name1, + networkParent, + router_id=router["id"], + cidr='10.198.1.0/24') + self.create_topology_subnet(subnet_name2, + networkChild1, + router_id=router["id"], + cidr='10.198.2.0/24') + self.create_topology_subnet(subnet_name3, + networkChild2, + router_id=router["id"], + cidr='10.198.3.0/24') + port_client = self.cmgr_adm.ports_client + + kwargs = dict(tenant_id=networkParent['tenant_id'], + security_group_rules_client=self.sec_rule_client, + security_groups_client=self.sec_client) + self.sg = self.create_topology_security_group(**kwargs) + create_port_body = {} + create_port_body['security_groups'] = [self.sg['id']] + self.parent1_port = self.create_topology_port(network=networkParent, + ports_client=port_client, + **create_port_body) + self.parent2_port = self.create_topology_port(network=networkParent, + ports_client=port_client, + **create_port_body) + kwargs = {'mac_address': self.parent1_port['port']['mac_address'], + 'security_groups': [self.sg['id']]} + self.child1_p1 = self.create_topology_port(network=networkChild1, + ports_client=port_client, + **kwargs) + self.child2_p1 = self.create_topology_port(network=networkChild2, + ports_client=port_client, + **kwargs) + kwargs = {'mac_address': self.parent2_port['port']['mac_address'], + 'security_groups': [self.sg['id']]} + self.child1_p2 = self.create_topology_port(network=networkChild1, + ports_client=port_client, + **kwargs) + self.child2_p2 = self.create_topology_port(network=networkChild2, + ports_client=port_client, + **kwargs) + project_id = self.parent1_port['port']['tenant_id'] + networks = dict(project_id=project_id, + parent1_port=self.parent1_port, + parent2_port=self.parent2_port, + child1_p1=self.child1_p1, + child2_p1=self.child2_p1, + child1_p2=self.child1_p2, + child2_p2=self.child2_p2, + sg=self.sg) + return networks + + def _test_trunk_child_subport_add_delete(self, topology): + project_id = topology['project_id'] + parent1_port = topology['parent1_port'] + parent2_port = topology['parent2_port'] + child1_p1 = topology['child1_p1'] + child2_p1 = topology['child2_p1'] + child1_p2 = topology['child1_p2'] + child2_p2 = topology['child2_p2'] + sg_name_dict = dict(name=topology['sg']['name']) + parent1_id = parent1_port['port']['id'] + parent2_id = parent2_port['port']['id'] + trunk_parent1 = self.create_trunk_parent_port(provider=True, + project_id=project_id, + parent_port=parent1_id, + trunkportname='p11') + print("parent1 Trunk port id:::::" + str(trunk_parent1)) + child1_id = child1_p1['port']['id'] + child2_id = child2_p1['port']['id'] + child1_trunk_p1 = self.add_subport_to_parent(provider=True, + vlan_id=101, + project_id=project_id, + child_port=child1_id, + childportname='child11', + trunkportid=trunk_parent1) + print("Child trunk port is " + str(child1_trunk_p1)) + child2_trunk_p1 = self.add_subport_to_parent(provider=True, + vlan_id=102, + project_id=project_id, + child_port=child2_id, + childportname='child22', + trunkportid=trunk_parent1) + print("Child trunk port is " + str(child2_trunk_p1)) + trunk_parent2 = self.create_trunk_parent_port(provider=True, + project_id=project_id, + parent_port=parent2_id, + trunkportname='p22') + print("parent2 Trunk port id:::::" + str(trunk_parent2)) + child1_id = child1_p2['port']['id'] + child2_id = child2_p2['port']['id'] + child1_trunk_p2 = self.add_subport_to_parent(provider=True, + vlan_id=101, + project_id=project_id, + child_port=child1_id, + childportname='ch11_p2', + trunkportid=trunk_parent2) + print("Child trunk port is " + str(child1_trunk_p2)) + child2_trunk_p2 = self.add_subport_to_parent(provider=True, + vlan_id=102, + project_id=project_id, + child_port=child2_id, + childportname='ch22_p2', + trunkportid=trunk_parent2) + print("Child trunk port is " + str(child2_trunk_p2)) + child1_ip_vm1 = child1_p1['port']['fixed_ips'][0]['ip_address'] + child2_ip_vm1 = child2_p1['port']['fixed_ips'][0]['ip_address'] + child1_ip_vm2 = child1_p2['port']['fixed_ips'][0]['ip_address'] + child2_ip_vm2 = child2_p2['port']['fixed_ips'][0]['ip_address'] + server_name1_default = data_utils.rand_name('server1-default') + server_name2_default = data_utils.rand_name('server2-default') + image_id = self.get_glance_image_id([CONF.trunk.image_name]) + flavor_name = self.get_flavor_id([CONF.trunk.flavor_id]) + keypair = self.create_keypair(self.cmgr_adm.keypairs_client) + server1 = self.create_topology_instance(server_name1_default, + create_floating_ip=True, + image_id=image_id, + port=parent1_port['port'], + security_groups=[sg_name_dict], + clients=self.cmgr_adm, + keypair=keypair, + flavor=flavor_name) + server2 = self.create_topology_instance(server_name2_default, + create_floating_ip=True, + image_id=image_id, + port=parent2_port['port'], + security_groups=[sg_name_dict], + clients=self.cmgr_adm, + keypair=keypair, + flavor=flavor_name) + ip_address = server1['floating_ips'][0]['floating_ip_address'] + ssh_source = 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'] + # Verify connectivity between vms + self._assign_ip_address(ssh_source, 'eth0.101', child1_ip_vm1) + self._assign_ip_address(ssh_source, 'eth0.102', child2_ip_vm1) + ip_address = server2['floating_ips'][0]['floating_ip_address'] + ssh_sourc2 = self._get_remote_client(ip_address, username='ubuntu', + use_password=False, + private_key=keypair['private_key'] + ) + # Verify connectivity between vms + self._assign_ip_address(ssh_sourc2, 'eth0.102', child1_ip_vm2) + self._assign_ip_address(ssh_sourc2, 'eth0.102', child2_ip_vm2) + self.check_remote_connectivity(ssh_source, remote_ip, + should_succeed=True) + self.check_remote_connectivity(ssh_source, child2_ip_vm2, + should_succeed=True) + # Remove subport & check connectivity should fail # + child2_trunk_p2 = self.remove_subport(provider=True, + project_id=project_id, + child_port=child2_id, + trunkportid=trunk_parent2) + self.check_remote_connectivity(ssh_source, child2_ip_vm2, + should_succeed=False) + child2_trunk_p2 = self.add_subport_to_parent(provider=True, + vlan_id=102, + project_id=project_id, + child_port=child2_id, + childportname='ch22_p2', + trunkportid=trunk_parent2) + ip_address = server2['floating_ips'][0]['floating_ip_address'] + ssh_sourc2 = self._get_remote_client(ip_address, username='ubuntu', + use_password=False, + private_key=keypair['private_key'] + ) + # Verify connectivity between vms + self._assign_ip_address(ssh_sourc2, 'eth0.102', child1_ip_vm2) + self._assign_ip_address(ssh_sourc2, 'eth0.102', child2_ip_vm2) + self.check_remote_connectivity(ssh_source, child2_ip_vm2, + should_succeed=True) + + def _test_trunk_instance_destroy_deploy(self, topology): + project_id = topology['project_id'] + parent1_port = topology['parent1_port'] + parent2_port = topology['parent2_port'] + child1_p1 = topology['child1_p1'] + child2_p1 = topology['child2_p1'] + child1_p2 = topology['child1_p2'] + child2_p2 = topology['child2_p2'] + sg_name_dict = dict(name=topology['sg']['name']) + parent1_id = parent1_port['port']['id'] + parent2_id = parent2_port['port']['id'] + trunk_parent1 = self.create_trunk_parent_port(provider=True, + project_id=project_id, + parent_port=parent1_id, + trunkportname='p11') + print("parent1 Trunk port id:::::" + str(trunk_parent1)) + child1_id = child1_p1['port']['id'] + child2_id = child2_p1['port']['id'] + child1_trunk_p1 = self.add_subport_to_parent(provider=True, + vlan_id=101, + project_id=project_id, + child_port=child1_id, + childportname='child11', + trunkportid=trunk_parent1) + print("Child trunk port is " + str(child1_trunk_p1)) + child2_trunk_p1 = self.add_subport_to_parent(provider=True, + vlan_id=102, + project_id=project_id, + child_port=child2_id, + childportname='child22', + trunkportid=trunk_parent1) + print("Child trunk port is " + str(child2_trunk_p1)) + trunk_parent2 = self.create_trunk_parent_port(provider=True, + project_id=project_id, + parent_port=parent2_id, + trunkportname='p22') + print("parent2 Trunk port id:::::" + str(trunk_parent2)) + child1_id = child1_p2['port']['id'] + child2_id = child2_p2['port']['id'] + child1_trunk_p2 = self.add_subport_to_parent(provider=True, + vlan_id=101, + project_id=project_id, + child_port=child1_id, + childportname='ch11_p2', + trunkportid=trunk_parent2) + print("Child trunk port is " + str(child1_trunk_p2)) + child2_trunk_p2 = self.add_subport_to_parent(provider=True, + vlan_id=102, + project_id=project_id, + child_port=child2_id, + childportname='ch22_p2', + trunkportid=trunk_parent2) + print("Child trunk port is " + str(child2_trunk_p2)) + child1_ip_vm1 = child1_p1['port']['fixed_ips'][0]['ip_address'] + child2_ip_vm1 = child2_p1['port']['fixed_ips'][0]['ip_address'] + child1_ip_vm2 = child1_p2['port']['fixed_ips'][0]['ip_address'] + child2_ip_vm2 = child2_p2['port']['fixed_ips'][0]['ip_address'] + server_name1_default = data_utils.rand_name('server1-default') + server_name2_default = data_utils.rand_name('server2-default') + image_id = self.get_glance_image_id([CONF.trunk.image_name]) + flavor_name = self.get_flavor_id([CONF.trunk.flavor_id]) + keypair = self.create_keypair(self.cmgr_adm.keypairs_client) + server1 = self.create_topology_instance(server_name1_default, + create_floating_ip=True, + image_id=image_id, + port=parent1_port['port'], + security_groups=[sg_name_dict], + clients=self.cmgr_adm, + keypair=keypair, + flavor=flavor_name) + server2 = self.create_topology_instance(server_name2_default, + create_floating_ip=True, + image_id=image_id, + port=parent2_port['port'], + security_groups=[sg_name_dict], + clients=self.cmgr_adm, + keypair=keypair, + flavor=flavor_name) + ip_address = server1['floating_ips'][0]['floating_ip_address'] + ssh_source = 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'] + # Verify connectivity between vms + self._assign_ip_address(ssh_source, 'eth0.101', child1_ip_vm1) + self._assign_ip_address(ssh_source, 'eth0.102', child2_ip_vm1) + ip_address = server2['floating_ips'][0]['floating_ip_address'] + ssh_sourc2 = self._get_remote_client(ip_address, username='ubuntu', + use_password=False, + private_key=keypair['private_key'] + ) + self._assign_ip_address(ssh_sourc2, 'eth0.102', child1_ip_vm2) + self._assign_ip_address(ssh_sourc2, 'eth0.102', child2_ip_vm2) + self.check_remote_connectivity(ssh_source, remote_ip, + should_succeed=True) + self.os_admin.servers_client.delete_server(server2['id']) + self.check_remote_connectivity(ssh_source, remote_ip, + should_succeed=False) + time.sleep(constants.NSX_BACKEND_SMALL_TIME_INTERVAL) + server2 = self.create_topology_instance(server_name2_default, + create_floating_ip=False, + image_id=image_id, + port=parent2_port['port'], + security_groups=[sg_name_dict], + clients=self.cmgr_adm) + self.check_remote_connectivity(ssh_source, remote_ip, + should_succeed=True) + + def _test_trunk_between_two_vms(self, topology): + project_id = topology['project_id'] + parent1_port = topology['parent1_port'] + parent2_port = topology['parent2_port'] + child1_p1 = topology['child1_p1'] + child2_p1 = topology['child2_p1'] + child1_p2 = topology['child1_p2'] + child2_p2 = topology['child2_p2'] + sg_name_dict = dict(name=topology['sg']['name']) + parent1_id = parent1_port['port']['id'] + parent2_id = parent2_port['port']['id'] + trunk_parent1 = self.create_trunk_parent_port(provider=True, + project_id=project_id, + parent_port=parent1_id, + trunkportname='p11') + print("parent1 Trunk port id:::::" + str(trunk_parent1)) + child1_id = child1_p1['port']['id'] + child2_id = child2_p1['port']['id'] + child1_trunk_p1 = self.add_subport_to_parent(provider=True, + vlan_id=101, + project_id=project_id, + child_port=child1_id, + childportname='child11', + trunkportid=trunk_parent1) + print("Child trunk port is " + str(child1_trunk_p1)) + child2_trunk_p1 = self.add_subport_to_parent(provider=True, + vlan_id=102, + project_id=project_id, + child_port=child2_id, + childportname='child22', + trunkportid=trunk_parent1) + print("Child trunk port is " + str(child2_trunk_p1)) + trunk_parent2 = self.create_trunk_parent_port(provider=True, + project_id=project_id, + parent_port=parent2_id, + trunkportname='p22') + print("parent2 Trunk port id:::::" + str(trunk_parent2)) + child1_id = child1_p2['port']['id'] + child2_id = child2_p2['port']['id'] + child1_trunk_p2 = self.add_subport_to_parent(provider=True, + vlan_id=101, + project_id=project_id, + child_port=child1_id, + childportname='ch11_p2', + trunkportid=trunk_parent2) + print("Child trunk port is " + str(child1_trunk_p2)) + child2_trunk_p2 = self.add_subport_to_parent(provider=True, + vlan_id=102, + project_id=project_id, + child_port=child2_id, + childportname='ch22_p2', + trunkportid=trunk_parent2) + print("Child trunk port is " + str(child2_trunk_p2)) + child1_ip_vm1 = child1_p1['port']['fixed_ips'][0]['ip_address'] + child2_ip_vm1 = child2_p1['port']['fixed_ips'][0]['ip_address'] + server_name1_default = data_utils.rand_name('server1-default') + server_name2_default = data_utils.rand_name('server2-default') + image_id = self.get_glance_image_id([CONF.trunk.image_name]) + flavor_name = self.get_flavor_id([CONF.trunk.flavor_id]) + keypair = self.create_keypair(self.cmgr_adm.keypairs_client) + server1 = self.create_topology_instance(server_name1_default, + create_floating_ip=True, + image_id=image_id, + port=parent1_port['port'], + security_groups=[sg_name_dict], + clients=self.cmgr_adm, + keypair=keypair, + flavor=flavor_name) + server2 = self.create_topology_instance(server_name2_default, + create_floating_ip=True, + image_id=image_id, + port=parent2_port['port'], + security_groups=[sg_name_dict], + clients=self.cmgr_adm, + keypair=keypair, + flavor=flavor_name) + ip_address = server1['floating_ips'][0]['floating_ip_address'] + ssh_source = 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'] + # Verify connectivity between vms + self._assign_ip_address(ssh_source, 'eth0.101', child1_ip_vm1) + self._assign_ip_address(ssh_source, 'eth0.102', child2_ip_vm1) + ip_address = server2['floating_ips'][0]['floating_ip_address'] + ssh_sourc2 = self._get_remote_client(ip_address, username='ubuntu', + use_password=False, + private_key=keypair['private_key'] + ) + # Verify connectivity between vms + child1_ip_vm2 = child1_p2['port']['fixed_ips'][0]['ip_address'] + child2_ip_vm2 = child2_p2['port']['fixed_ips'][0]['ip_address'] + self._assign_ip_address(ssh_sourc2, 'eth0.101', child1_ip_vm2) + self._assign_ip_address(ssh_sourc2, 'eth0.102', child2_ip_vm2) + self.check_remote_connectivity(ssh_source, remote_ip, + should_succeed=True) + self.check_remote_connectivity(ssh_source, child1_ip_vm2, + should_succeed=True) + self.check_remote_connectivity(ssh_source, child2_ip_vm2, + should_succeed=True) + + @decorators.idempotent_id('9d4192e9-b1b7-48c9-af04-67a82637c359') + def test_trunk_between_two_vms(self): + self.network_topo = self.create_trunk_network_topo(False, True) + self._test_trunk_between_two_vms(self.network_topo) + + @decorators.idempotent_id('8d4192e9-b1b7-48c9-af04-68a82637c359') + def test_trunk_child_subport_add_delete(self): + self.network_topo = self.create_trunk_network_topo(False, True) + self._test_trunk_child_subport_add_delete(self.network_topo) + + @decorators.idempotent_id('7e4192e9-b1b7-48c9-af04-68a82637c359') + def test_trunk_destroy_deploy_with_existing_parent_port(self): + self.network_topo = self.create_trunk_network_topo(False, True) + self._test_trunk_instance_destroy_deploy(self.network_topo)