Example #1
0
    def initialize_connection(self, volume, connector):
        """Allow connection to connector and return connection info."""
        initiator_name = connector['initiator']
        eseries_vol = self._get_volume(volume['name_id'])
        existing_maps = host_mapper.get_host_mapping_for_vol_frm_array(
            self._client, eseries_vol)
        host = self._get_or_create_host(initiator_name, self.host_type)
        # There can only be one or zero mappings on a volume in E-Series
        current_map = existing_maps[0] if existing_maps else None

        if self.configuration.netapp_enable_multiattach and current_map:
            self._ensure_multi_attach_host_group_exists()
            mapping = host_mapper.map_volume_to_multiple_hosts(
                self._client, volume, eseries_vol, host, current_map)
        else:
            mapping = host_mapper.map_volume_to_single_host(
                self._client, volume, eseries_vol, host, current_map)

        lun_id = mapping['lun']
        msg = _("Mapped volume %(id)s to the initiator %(initiator_name)s.")
        msg_fmt = {'id': volume['id'], 'initiator_name': initiator_name}
        LOG.debug(msg % msg_fmt)

        iscsi_details = self._get_iscsi_service_details()
        iscsi_portal = self._get_iscsi_portal_for_vol(eseries_vol,
                                                      iscsi_details)
        msg = _("Successfully fetched target details for volume %(id)s and "
                "initiator %(initiator_name)s.")
        LOG.debug(msg % msg_fmt)
        iqn = iscsi_portal['iqn']
        address = iscsi_portal['ip']
        port = iscsi_portal['tcp_port']
        properties = na_utils.get_iscsi_connection_properties(
            lun_id, volume, iqn, address, port)
        return properties
Example #2
0
    def test_get_host_mapping_for_vol_frm_array(self):
        volume_mapping_1 = copy.deepcopy(eseries_fakes.VOLUME_MAPPING)
        volume_mapping_2 = copy.deepcopy(eseries_fakes.VOLUME_MAPPING)
        volume_mapping_2["volumeRef"] = "2"
        self.mock_object(
            self.client, "get_volume_mappings", mock.Mock(return_value=[volume_mapping_1, volume_mapping_2])
        )
        mappings = host_mapper.get_host_mapping_for_vol_frm_array(self.client, eseries_fakes.VOLUME)

        self.assertEqual([volume_mapping_1], mappings)
Example #3
0
    def test_get_host_mapping_for_vol_frm_array(self):
        volume_mapping_1 = copy.deepcopy(eseries_fakes.VOLUME_MAPPING)
        volume_mapping_2 = copy.deepcopy(eseries_fakes.VOLUME_MAPPING)
        volume_mapping_2['volumeRef'] = '2'
        self.mock_object(
            self.client, 'get_volume_mappings',
            mock.Mock(return_value=[volume_mapping_1, volume_mapping_2]))
        mappings = host_mapper.get_host_mapping_for_vol_frm_array(
            self.client, eseries_fakes.VOLUME)

        self.assertEqual([volume_mapping_1], mappings)
Example #4
0
    def initialize_connection(self, volume, connector):
        """Allow connection to connector and return connection info."""
        initiator_name = connector['initiator']
        eseries_vol = self._get_volume(volume['name_id'])
        existing_maps = host_mapper.get_host_mapping_for_vol_frm_array(
            self._client, eseries_vol)
        host = self._get_or_create_host(initiator_name, self.host_type)
        # There can only be one or zero mappings on a volume in E-Series
        current_map = existing_maps[0] if existing_maps else None

        if self.configuration.netapp_enable_multiattach and current_map:
            self._ensure_multi_attach_host_group_exists()
            mapping = host_mapper.map_volume_to_multiple_hosts(self._client,
                                                               volume,
                                                               eseries_vol,
                                                               host,
                                                               current_map)
        else:
            mapping = host_mapper.map_volume_to_single_host(self._client,
                                                            volume,
                                                            eseries_vol,
                                                            host,
                                                            current_map)

        lun_id = mapping['lun']
        msg = _("Mapped volume %(id)s to the initiator %(initiator_name)s.")
        msg_fmt = {'id': volume['id'], 'initiator_name': initiator_name}
        LOG.debug(msg % msg_fmt)

        iscsi_details = self._get_iscsi_service_details()
        iscsi_portal = self._get_iscsi_portal_for_vol(eseries_vol,
                                                      iscsi_details)
        msg = _("Successfully fetched target details for volume %(id)s and "
                "initiator %(initiator_name)s.")
        LOG.debug(msg % msg_fmt)
        iqn = iscsi_portal['iqn']
        address = iscsi_portal['ip']
        port = iscsi_portal['tcp_port']
        properties = na_utils.get_iscsi_connection_properties(lun_id, volume,
                                                              iqn, address,
                                                              port)
        return properties