'Test connectivity with trunk and sub ports.
In this test we create a vm that has a trunk on net1 and a vm peer on
the same network. We check connectivity between the peer and the vm.
We create a sub port on net2 and a peer, check connectivity again.'

def test_connectivity(self):

    vlan_net1 = helpers.get_not_used_vlan(self.tester.bridge, VLAN_RANGE)
    vlan_net2 = helpers.get_not_used_vlan(self.tester.bridge, VLAN_RANGE)
    trunk_mac = net.get_random_mac('fa:16:3e:00:00:00'.split(':'))
    sub_port_mac = net.get_random_mac('fa:16:3e:00:00:00'.split(':'))
    sub_port_segmentation_id = helpers.get_not_used_vlan(self.tester.bridge, VLAN_RANGE)
    LOG.debug('Using    %(n1)d    vlan    tag    as    local    vlan    ID    for    net1    and    %(n2)d    for    local    vlan    ID    for    net2', {'n1': vlan_net1, 'n2': vlan_net2})
    self.tester.set_peer_tag(vlan_net1)
    self.trunk_manager.create_trunk(self.trunk.trunk_id, self.trunk.port_id, trunk_mac)
    conn_testers.OVSBaseConnectionTester.set_tag(self.trunk.patch_port_int_name, self.tester.bridge, vlan_net1)
    self.tester.wait_for_connection(self.tester.INGRESS)
    self.tester.wait_for_connection(self.tester.EGRESS)
    self.tester.add_vlan_interface_and_peer(sub_port_segmentation_id, self.net2_cidr)
    conn_testers.OVSBaseConnectionTester.set_tag(self.tester._peer2.port.name, self.tester.bridge, vlan_net2)
    sub_port = trunk_manager.SubPort(self.trunk.trunk_id, uuidutils.generate_uuid(), sub_port_mac, sub_port_segmentation_id)
    self.trunk_manager.add_sub_port(sub_port.trunk_id, sub_port.port_id, sub_port.port_mac, sub_port.segmentation_id)
    conn_testers.OVSBaseConnectionTester.set_tag(sub_port.patch_port_int_name, self.tester.bridge, vlan_net2)
    self.tester.wait_for_sub_port_connectivity(self.tester.INGRESS)
    self.tester.wait_for_sub_port_connectivity(self.tester.EGRESS)
    self.trunk_manager.remove_sub_port(sub_port.trunk_id, sub_port.port_id)
    self.tester.wait_for_sub_port_no_connectivity(self.tester.INGRESS)
    self.tester.wait_for_sub_port_no_connectivity(self.tester.EGRESS)
    self.trunk_manager.remove_trunk(self.trunk.trunk_id, self.trunk.port_id)
    self.tester.wait_for_no_connection(self.tester.INGRESS)
