Esempio n. 1
0
    def _configure_wwpns_for_migration(self, fabric):
        """Configures the WWPNs for a migration.

        During a NPIV migration, the WWPNs need to be flipped and attached to
        the management VM.  This is so that the peer WWPN is brought online.

        The WWPNs will be removed from the management partition via the
        pre_live_migration_on_destination method.  The WWPNs invocation is
        done prior to the migration, when the volume connector is gathered.

        :param fabric: The fabric to configure.
        :return: An updated port mapping.
        """
        LOG.info(
            _LI("Mapping instance %(inst)s to the mgmt partition for "
                "fabric %(fabric)s because the VM is migrating to "
                "this host."), {
                    'inst': self.instance.name,
                    'fabric': fabric
                })

        mgmt_uuid = mgmt.get_mgmt_partition(self.adapter).uuid

        # When we migrate...flip the WWPNs around.  This is so the other
        # WWPN logs in on the target fabric.  But we should only flip new
        # WWPNs.  There may already be some on the overall fabric...and if
        # there are, we keep those 'as-is'
        #
        # TODO(thorst) pending API change should be able to indicate which
        # wwpn is active.
        port_maps = self._get_fabric_meta(fabric)
        existing_wwpns = []
        new_wwpns = []

        for port_map in port_maps:
            c_wwpns = port_map[1].split()

            # Only add it as a 'new' mapping if it isn't on a VIOS already.  If
            # it is, then we know that it has already been serviced, perhaps
            # by a previous volume.
            vios_w, vfc_map = pvm_vfcm.has_client_wwpns(
                self.stg_ftsk.feed, c_wwpns)
            if vfc_map is None:
                c_wwpns.reverse()
                new_wwpns.extend(c_wwpns)
            else:
                existing_wwpns.extend(c_wwpns)

        # Now derive the mapping to THESE VIOSes physical ports
        port_mappings = pvm_vfcm.derive_npiv_map(self.stg_ftsk.feed,
                                                 self._fabric_ports(fabric),
                                                 new_wwpns + existing_wwpns)

        # Add the port maps to the mgmt partition
        if len(new_wwpns) > 0:
            pvm_vfcm.add_npiv_port_mappings(self.adapter, self.host_uuid,
                                            mgmt_uuid, port_mappings)
        return port_mappings
Esempio n. 2
0
    def test_has_client_wwpns(self):
        v_wrap_1 = self.entries[0]
        v_wrap_2 = self.entries[1]
        vio_w, vfc_map = vfc_mapper.has_client_wwpns(
            self.entries, ['c05076079cff0e56', 'c05076079cff0e57'])
        self.assertEqual(v_wrap_1, vio_w)
        self.assertEqual('10000090FA5371F2', vfc_map.backing_port.wwpn)

        # Second vios.  Reversed WWPNs.  Mixed Case.
        vio_w, vfc_map = vfc_mapper.has_client_wwpns(
            self.entries, ['c05076079cff0e83', 'c05076079cff0E82'])
        self.assertEqual(v_wrap_2, vio_w)
        self.assertEqual('10000090FA537209', vfc_map.backing_port.wwpn)

        # Not found.
        vio_w, vfc_map = vfc_mapper.has_client_wwpns(self.entries,
                                                     ['AAA', 'bbb'])
        self.assertIsNone(vio_w)
        self.assertIsNone(vfc_map)
Esempio n. 3
0
    def test_has_client_wwpns(self):
        v_wrap_1 = self.entries[0]
        v_wrap_2 = self.entries[1]
        vio_w, vfc_map = vfc_mapper.has_client_wwpns(
            self.entries, ['c05076079cff0e56', 'c05076079cff0e57'])
        self.assertEqual(v_wrap_1, vio_w)
        self.assertEqual('10000090FA5371F2', vfc_map.backing_port.wwpn)

        # Second vios.  Reversed WWPNs.  Mixed Case.
        vio_w, vfc_map = vfc_mapper.has_client_wwpns(
            self.entries, ['c05076079cff0e83', 'c05076079cff0E82'])
        self.assertEqual(v_wrap_2, vio_w)
        self.assertEqual('10000090FA537209', vfc_map.backing_port.wwpn)

        # Not found.
        vio_w, vfc_map = vfc_mapper.has_client_wwpns(
            self.entries, ['AAA', 'bbb'])
        self.assertIsNone(vio_w)
        self.assertIsNone(vfc_map)
Esempio n. 4
0
    def _configure_wwpns_for_migration(self, fabric):
        """Configures the WWPNs for a migration.

        During a NPIV migration, the WWPNs need to be flipped and attached to
        the management VM.  This is so that the peer WWPN is brought online.

        The WWPNs will be removed from the management partition via the
        pre_live_migration_on_destination method.  The WWPNs invocation is
        done prior to the migration, when the volume connector is gathered.

        :param fabric: The fabric to configure.
        :return: An updated port mapping.
        """
        LOG.info(_LI("Mapping instance %(inst)s to the mgmt partition for "
                     "fabric %(fabric)s because the VM is migrating to "
                     "this host."),
                 {'inst': self.instance.name, 'fabric': fabric})

        mgmt_uuid = mgmt.get_mgmt_partition(self.adapter).uuid

        # When we migrate...flip the WWPNs around.  This is so the other
        # WWPN logs in on the target fabric.  But we should only flip new
        # WWPNs.  There may already be some on the overall fabric...and if
        # there are, we keep those 'as-is'
        #
        # TODO(thorst) pending API change should be able to indicate which
        # wwpn is active.
        port_maps = self._get_fabric_meta(fabric)
        existing_wwpns = []
        new_wwpns = []

        for port_map in port_maps:
            c_wwpns = port_map[1].split()

            # Only add it as a 'new' mapping if it isn't on a VIOS already.  If
            # it is, then we know that it has already been serviced, perhaps
            # by a previous volume.
            vios_w, vfc_map = pvm_vfcm.has_client_wwpns(self.stg_ftsk.feed,
                                                        c_wwpns)
            if vfc_map is None:
                c_wwpns.reverse()
                new_wwpns.extend(c_wwpns)
            else:
                existing_wwpns.extend(c_wwpns)

        # Now derive the mapping to THESE VIOSes physical ports
        port_mappings = pvm_vfcm.derive_npiv_map(
            self.stg_ftsk.feed, self._fabric_ports(fabric),
            new_wwpns + existing_wwpns)

        # Add the port maps to the mgmt partition
        if len(new_wwpns) > 0:
            pvm_vfcm.add_npiv_port_mappings(
                self.adapter, self.host_uuid, mgmt_uuid, port_mappings)
        return port_mappings