Пример #1
0
    def get_overlapping_seg_ids(self, dst_info):
        """
        Get list of nets, that have overlapping segmentation IDs with the DST.

        :param dst_info: NetworkInfo instance of DST cloud

        :return: List of networks IDs with overlapping segmentation IDs.
        """

        dst_net_info = dst_info.networks_info
        dst_seg_ids = neutron.get_segmentation_ids_from_net_list(dst_net_info)
        nets_with_overlapping_seg_ids = []

        for network in self.get_networks():
            dst_net = dst_info.by_hash.get(network.hash)
            if dst_net and check_equal_networks(network, dst_net):
                # Current network matches with network on DST
                # Have the same networks on SRC and DST
                LOG.debug("SRC network '%s' and DST network '%s' are the same",
                          network.id, dst_net.id)
            else:
                # Current network does not match with any network on DST
                # Check Segmentation ID overlapping with DST
                LOG.debug("Check segmentation ID for SRC network: '%s'",
                          network.id)
                try:
                    network.check_segmentation_id_overlapping(dst_seg_ids)
                except exception.AbortMigrationError:
                    dst_network = dst_info.get_network_by_segmentation_id(
                        network.network_type, network.seg_id)
                    overlap = {'src_net_id': network.id,
                               'dst_net_id': dst_network.id}
                    nets_with_overlapping_seg_ids.append(overlap)

        return nets_with_overlapping_seg_ids
Пример #2
0
    def test_get_segmentation_ids_from_net_list(self):
        networks_list = [self.net_1_info, self.net_2_info]
        seg_ids = {'gre': [5], 'vlan': [10]}

        result = neutron.get_segmentation_ids_from_net_list(networks_list)

        self.assertEqual(seg_ids, result)
Пример #3
0
    def test_get_segmentation_ids_from_net_list(self):
        networks_list = [self.net_1_info, self.net_2_info]
        seg_ids = {'gre': [5],
                   'vlan': [10]}

        result = neutron.get_segmentation_ids_from_net_list(networks_list)

        self.assertEqual(seg_ids, result)
Пример #4
0
    def missing_vlan_physnets(self, dst_info, dst_neutron_client, ext_net_map):
        """
        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
        :param ext_net_map: External networks mapping dictionary. Format:
                        {<src_external_network>: <dst_external_network>, ...}

        :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

            if network.external and network.id in ext_net_map:
                LOG.debug(
                    "Network '%s' is external and specified in the "
                    "external networks mapping. Skipping network...",
                    network.id)
                continue

            with proxy_client.expect_exception(neutron_exc.BadRequest):
                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
Пример #5
0
    def missing_vlan_physnets(self, dst_info, dst_neutron_client, ext_net_map):
        """
        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
        :param ext_net_map: External networks mapping dictionary. Format:
                        {<src_external_network>: <dst_external_network>, ...}

        :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

            if network.external and network.id in ext_net_map:
                LOG.debug("Network '%s' is external and specified in the "
                          "external networks mapping. Skipping network...",
                          network.id)
                continue

            with proxy_client.expect_exception(neutron_exc.BadRequest):
                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
Пример #6
0
    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
Пример #7
0
    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
Пример #8
0
    def get_overlapping_seg_ids(self, dst_info):
        """
        Get list of nets, that have overlapping segmentation IDs with the DST.

        :param dst_info: NetworkInfo instance of DST cloud

        :return: List of networks IDs with overlapping segmentation IDs.
        """

        dst_net_info = dst_info.networks_info
        dst_seg_ids = neutron.get_segmentation_ids_from_net_list(dst_net_info)
        nets_with_overlapping_seg_ids = []

        for network in self.get_networks():
            dst_net = dst_info.by_hash.get(network.hash)
            if dst_net and check_equal_networks(network, dst_net):
                # Current network matches with network on DST
                # Have the same networks on SRC and DST
                LOG.debug("SRC network '%s' and DST network '%s' are the same",
                          network.id, dst_net.id)
            else:
                # Current network does not match with any network on DST
                # Check Segmentation ID overlapping with DST
                LOG.debug("Check segmentation ID for SRC network: '%s'",
                          network.id)
                try:
                    network.check_segmentation_id_overlapping(dst_seg_ids)
                except exception.AbortMigrationError:
                    dst_network = dst_info.get_network_by_segmentation_id(
                        network.network_type, network.seg_id)
                    overlap = {
                        'src_net_id': network.id,
                        'dst_net_id': dst_network.id
                    }
                    nets_with_overlapping_seg_ids.append(overlap)

        return nets_with_overlapping_seg_ids