def test_generate_new_segmentation_id(self): dst_seg_ids = {'gre': [2, 4, 6, 14, 21], 'vlan': [3, 5, 7, 10, 12], 'vxlan': [10, 30, 40]} seg_id = neutron.generate_new_segmentation_id(self.segmentation_ids, dst_seg_ids, 'gre') self.assertEqual(3, seg_id)
def test_generate_new_segmentation_id(self): dst_seg_ids = { 'gre': [2, 4, 6, 14, 21], 'vlan': [3, 5, 7, 10, 12], 'vxlan': [10, 30, 40] } seg_id = neutron.generate_new_segmentation_id(self.segmentation_ids, dst_seg_ids, 'gre') self.assertEqual(3, seg_id)
def missing_vlan_physnets(self, dst_info, dst_neutron_client): """ Get list of missing physical networks for VLAN network type. :param dst_info: NetworkInfo instance of DST cloud :param dst_neutron_client: DST neutron client :return: List of missing VLAN physnets. """ missing_vlan_physnets = [] dst_vlan_physnets = [net.physnet for net in dst_info.get_networks() if net.network_type == 'vlan'] # We need to specify segmentation ID in case of VLAN network creation # in OpenStack versions earlier than Juno (f.e. Icehouse, Grizzly etc.) dst_seg_ids = neutron.get_segmentation_ids_from_net_list( dst_info.networks_info) # We do not care about free segmentation ID on source cloud, we only # need to have destination one for checking purpose free_seg_id = neutron.generate_new_segmentation_id(dst_seg_ids, dst_seg_ids, 'vlan') for network in self.get_networks(): if network.network_type != 'vlan': continue if network.physnet in dst_vlan_physnets: continue try: network_info = { 'network': { 'provider:physical_network': network.physnet, 'provider:network_type': 'vlan', 'provider:segmentation_id': free_seg_id } } new_net = dst_neutron_client.create_network(network_info) except neutron_exc.NeutronClientException: missing_vlan_physnets.append(network.physnet) else: dst_neutron_client.delete_network(new_net['network']['id']) return missing_vlan_physnets