Example #1
0
    def test_unmap_volume_from_host_volume_mapped_to_host(self):
        fake_eseries_volume = copy.deepcopy(eseries_fakes.VOLUME)
        fake_eseries_volume["listOfMappings"] = [eseries_fakes.VOLUME_MAPPING]
        self.mock_object(self.client, "list_volumes", mock.Mock(return_value=[fake_eseries_volume]))
        self.mock_object(self.client, "delete_volume_mapping")

        host_mapper.unmap_volume_from_host(
            self.client, get_fake_volume(), eseries_fakes.HOST, eseries_fakes.VOLUME_MAPPING
        )

        self.assertTrue(self.client.delete_volume_mapping.called)
Example #2
0
    def test_unmap_volume_from_host_volume_mapped_to_host(self):
        fake_eseries_volume = copy.deepcopy(eseries_fakes.VOLUME)
        fake_eseries_volume['listOfMappings'] = [eseries_fakes.VOLUME_MAPPING]
        self.mock_object(self.client, 'list_volumes',
                         mock.Mock(return_value=[fake_eseries_volume]))
        self.mock_object(self.client, 'delete_volume_mapping')

        host_mapper.unmap_volume_from_host(self.client, get_fake_volume(),
                                           eseries_fakes.HOST,
                                           eseries_fakes.VOLUME_MAPPING)

        self.assertTrue(self.client.delete_volume_mapping.called)
Example #3
0
    def terminate_connection_iscsi(self, volume, connector, **kwargs):
        """Disallow connection from connector."""
        eseries_vol = self._get_volume(volume["name_id"])
        initiator = connector["initiator"]
        host = self._get_host_with_matching_port([initiator])
        mappings = eseries_vol.get("listOfMappings", [])

        # There can only be one or zero mappings on a volume in E-Series
        mapping = mappings[0] if mappings else None

        if not mapping:
            raise eseries_exc.VolumeNotMapped(volume_id=volume["id"], host=host["label"])
        host_mapper.unmap_volume_from_host(self._client, volume, host, mapping)
Example #4
0
    def test_unmap_volume_from_host_volume_mapped_to_multiattach_host_group_and_migrating(self):  # noqa
        fake_eseries_volume = copy.deepcopy(eseries_fakes.VOLUME)
        fake_volume_mapping = copy.deepcopy(eseries_fakes.VOLUME_MAPPING)
        fake_volume_mapping["mapRef"] = eseries_fakes.MULTIATTACH_HOST_GROUP["clusterRef"]
        fake_eseries_volume["listOfMappings"] = [fake_volume_mapping]
        self.mock_object(self.client, "delete_volume_mapping")
        self.mock_object(self.client, "list_volumes", mock.Mock(return_value=[fake_eseries_volume]))
        fake_volume = get_fake_volume()
        fake_volume["status"] = "in-use"

        host_mapper.unmap_volume_from_host(self.client, fake_volume, eseries_fakes.HOST, fake_volume_mapping)

        self.assertFalse(self.client.delete_volume_mapping.called)
Example #5
0
    def terminate_connection(self, volume, connector, **kwargs):
        """Disallow connection from connector."""
        eseries_vol = self._get_volume(volume['name_id'])
        initiator = connector['initiator']
        host = self._get_host_with_port(initiator)
        mappings = eseries_vol.get('listOfMappings', [])

        # There can only be one or zero mappings on a volume in E-Series
        mapping = mappings[0] if mappings else None

        if not mapping:
            raise eseries_exc.VolumeNotMapped(volume_id=volume['id'],
                                              host=host['label'])
        host_mapper.unmap_volume_from_host(self._client, volume, host, mapping)
Example #6
0
    def terminate_connection(self, volume, connector, **kwargs):
        """Disallow connection from connector."""
        eseries_vol = self._get_volume(volume['name_id'])
        initiator = connector['initiator']
        host = self._get_host_with_port(initiator)
        mappings = eseries_vol.get('listOfMappings', [])

        # There can only be one or zero mappings on a volume in E-Series
        mapping = mappings[0] if mappings else None

        if not mapping:
            raise eseries_exc.VolumeNotMapped(volume_id=volume['id'],
                                              host=host['label'])
        host_mapper.unmap_volume_from_host(self._client, volume, host, mapping)
Example #7
0
    def terminate_connection_fc(self, volume, connector, **kwargs):
        """Disallow connection from connector.

        Return empty data if other volumes are in the same zone.
        The FibreChannel ZoneManager doesn't remove zones
        if there isn't an initiator_target_map in the
        return of terminate_connection.

        :returns: data - the target_wwns and initiator_target_map if the
                         zone is to be removed, otherwise the same map with
                         an empty dict for the 'data' key
        """

        eseries_vol = self._get_volume(volume['name_id'])
        initiators = [
            fczm_utils.get_formatted_wwn(wwpn) for wwpn in connector['wwpns']
        ]
        host = self._get_host_with_matching_port(initiators)
        mappings = eseries_vol.get('listOfMappings', [])

        # There can only be one or zero mappings on a volume in E-Series
        mapping = mappings[0] if mappings else None

        if not mapping:
            raise eseries_exc.VolumeNotMapped(volume_id=volume['id'],
                                              host=host['label'])
        host_mapper.unmap_volume_from_host(self._client, volume, host, mapping)

        info = {'driver_volume_type': 'fibre_channel', 'data': {}}

        if len(self._client.get_volume_mappings_for_host(
                host['hostRef'])) == 0:
            # No more exports for this host, so tear down zone.
            LOG.info(
                _LI("Need to remove FC Zone, building initiator "
                    "target map."))

            initiator_info = self._build_initiator_target_map_fc(connector)
            target_wwpns, initiator_target_map, num_paths = initiator_info

            info['data'] = {
                'target_wwn': target_wwpns,
                'initiator_target_map': initiator_target_map
            }

        return info
Example #8
0
    def test_unmap_volume_from_host_volume_mapped_to_multiattach_host_group_and_migrating(  # noqa
            self):
        fake_eseries_volume = copy.deepcopy(eseries_fakes.VOLUME)
        fake_volume_mapping = copy.deepcopy(eseries_fakes.VOLUME_MAPPING)
        fake_volume_mapping['mapRef'] = eseries_fakes.MULTIATTACH_HOST_GROUP[
            'clusterRef']
        fake_eseries_volume['listOfMappings'] = [fake_volume_mapping]
        self.mock_object(self.client, 'delete_volume_mapping')
        self.mock_object(self.client, 'list_volumes',
                         mock.Mock(return_value=[fake_eseries_volume]))
        fake_volume = get_fake_volume()
        fake_volume['status'] = 'in-use'

        host_mapper.unmap_volume_from_host(self.client, fake_volume,
                                           eseries_fakes.HOST,
                                           fake_volume_mapping)

        self.assertFalse(self.client.delete_volume_mapping.called)
Example #9
0
    def test_unmap_volume_from_host_volume_mapped_to_multiattach_host_group_and_migrating(  # noqa
            self):
        fake_eseries_volume = copy.deepcopy(eseries_fakes.VOLUME)
        fake_volume_mapping = copy.deepcopy(eseries_fakes.VOLUME_MAPPING)
        fake_volume_mapping['mapRef'] = eseries_fakes.MULTIATTACH_HOST_GROUP[
            'clusterRef']
        fake_eseries_volume['listOfMappings'] = [fake_volume_mapping]
        self.mock_object(self.client, 'delete_volume_mapping')
        self.mock_object(self.client, 'list_volumes',
                         mock.Mock(return_value=[fake_eseries_volume]))
        fake_volume = get_fake_volume()
        fake_volume['status'] = 'in-use'

        host_mapper.unmap_volume_from_host(self.client, fake_volume,
                                           eseries_fakes.HOST,
                                           fake_volume_mapping)

        self.assertFalse(self.client.delete_volume_mapping.called)
Example #10
0
    def terminate_connection_fc(self, volume, connector, **kwargs):
        """Disallow connection from connector.

        Return empty data if other volumes are in the same zone.
        The FibreChannel ZoneManager doesn't remove zones
        if there isn't an initiator_target_map in the
        return of terminate_connection.

        :returns: data - the target_wwns and initiator_target_map if the
                         zone is to be removed, otherwise the same map with
                         an empty dict for the 'data' key
        """

        eseries_vol = self._get_volume(volume['name_id'])
        initiators = [fczm_utils.get_formatted_wwn(wwpn)
                      for wwpn in connector['wwpns']]
        host = self._get_host_with_matching_port(initiators)
        mappings = eseries_vol.get('listOfMappings', [])

        # There can only be one or zero mappings on a volume in E-Series
        mapping = mappings[0] if mappings else None

        if not mapping:
            raise eseries_exc.VolumeNotMapped(volume_id=volume['id'],
                                              host=host['label'])
        host_mapper.unmap_volume_from_host(self._client, volume, host, mapping)

        info = {'driver_volume_type': 'fibre_channel',
                'data': {}}

        if len(self._client.get_volume_mappings_for_host(
                host['hostRef'])) == 0:
            # No more exports for this host, so tear down zone.
            LOG.info(_LI("Need to remove FC Zone, building initiator "
                         "target map."))

            initiator_info = self._build_initiator_target_map_fc(connector)
            target_wwpns, initiator_target_map, num_paths = initiator_info

            info['data'] = {'target_wwn': target_wwpns,
                            'initiator_target_map': initiator_target_map}

        return info