Esempio n. 1
0
    def test_iscsi_connection_properties_ipv6(self):
        actual_properties = na_utils.get_iscsi_connection_properties(
            '1', fake.ISCSI_FAKE_VOLUME_NO_AUTH, fake.ISCSI_FAKE_IQN,
            [fake.ISCSI_FAKE_ADDRESS_IPV6], [fake.ISCSI_FAKE_PORT])

        self.assertDictEqual(actual_properties['data'],
                             fake.FC_ISCSI_TARGET_INFO_DICT_IPV6)
Esempio n. 2
0
    def test_iscsi_connection_properties_ipv6(self):
        actual_properties = na_utils.get_iscsi_connection_properties(
            '1', fake.ISCSI_FAKE_VOLUME_NO_AUTH, fake.ISCSI_FAKE_IQN,
            [fake.ISCSI_FAKE_ADDRESS_IPV6], [fake.ISCSI_FAKE_PORT])

        self.assertDictEqual(actual_properties['data'],
                             fake.FC_ISCSI_TARGET_INFO_DICT_IPV6)
Esempio n. 3
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
Esempio n. 4
0
    def test_iscsi_connection_properties(self):

        actual_properties = na_utils.get_iscsi_connection_properties(
            fake.ISCSI_FAKE_LUN_ID, fake.ISCSI_FAKE_VOLUME,
            fake.ISCSI_FAKE_IQN, fake.ISCSI_FAKE_ADDRESS, fake.ISCSI_FAKE_PORT)

        actual_properties_mapped = actual_properties['data']

        self.assertDictEqual(actual_properties_mapped,
                             fake.FC_ISCSI_TARGET_INFO_DICT)
Esempio n. 5
0
    def test_iscsi_connection_lun_id_type_str(self):
        FAKE_LUN_ID = '1'

        actual_properties = na_utils.get_iscsi_connection_properties(
            FAKE_LUN_ID, fake.ISCSI_FAKE_VOLUME, fake.ISCSI_FAKE_IQN,
            fake.ISCSI_FAKE_ADDRESS, fake.ISCSI_FAKE_PORT)

        actual_properties_mapped = actual_properties['data']

        self.assertIs(type(actual_properties_mapped['target_lun']), int)
Esempio n. 6
0
    def test_iscsi_connection_properties(self):
        FAKE_LUN_ID = 1

        actual_properties = na_utils.get_iscsi_connection_properties(
            fake.ISCSI_FAKE_ADDRESS, fake.ISCSI_FAKE_PORT,
            fake.ISCSI_FAKE_IQN, FAKE_LUN_ID, fake.ISCSI_FAKE_VOLUME)

        actual_properties_mapped = actual_properties['data']

        self.assertDictEqual(actual_properties_mapped, fake.ISCSI_FAKE_DICT)
Esempio n. 7
0
    def test_iscsi_connection_lun_id_type_str(self):
        FAKE_LUN_ID = '1'

        actual_properties = na_utils.get_iscsi_connection_properties(
            FAKE_LUN_ID, fake.ISCSI_FAKE_VOLUME, fake.ISCSI_FAKE_IQN,
            fake.ISCSI_FAKE_ADDRESS, fake.ISCSI_FAKE_PORT)

        actual_properties_mapped = actual_properties['data']

        self.assertIs(type(actual_properties_mapped['target_lun']), int)
Esempio n. 8
0
    def test_iscsi_connection_properties(self):
        actual_properties = na_utils.get_iscsi_connection_properties(
            fake.ISCSI_FAKE_LUN_ID, fake.ISCSI_FAKE_VOLUME,
            [fake.ISCSI_FAKE_IQN, fake.ISCSI_FAKE_IQN2],
            [fake.ISCSI_FAKE_ADDRESS_IPV4, fake.ISCSI_FAKE_ADDRESS2_IPV4],
            [fake.ISCSI_FAKE_PORT, fake.ISCSI_FAKE_PORT])

        actual_properties_mapped = actual_properties['data']

        self.assertDictEqual(actual_properties_mapped,
                             fake.ISCSI_MP_TARGET_INFO_DICT)
Esempio n. 9
0
    def test_iscsi_connection_lun_id_type_str(self):
        FAKE_LUN_ID = '1'

        actual_properties = na_utils.get_iscsi_connection_properties(
            FAKE_LUN_ID, fake.ISCSI_FAKE_VOLUME, fake.ISCSI_FAKE_IQN,
            [fake.ISCSI_FAKE_ADDRESS_IPV4], [fake.ISCSI_FAKE_PORT])

        actual_properties_mapped = actual_properties['data']

        self.assertIs(int, type(actual_properties_mapped['target_lun']))
        self.assertDictEqual(actual_properties_mapped,
                             fake.FC_ISCSI_TARGET_INFO_DICT)
Esempio n. 10
0
    def test_iscsi_connection_lun_id_type_str(self):
        FAKE_LUN_ID = '1'

        actual_properties = na_utils.get_iscsi_connection_properties(
            FAKE_LUN_ID, fake.ISCSI_FAKE_VOLUME, fake.ISCSI_FAKE_IQN,
            [fake.ISCSI_FAKE_ADDRESS_IPV4], [fake.ISCSI_FAKE_PORT])

        actual_properties_mapped = actual_properties['data']

        self.assertIs(int, type(actual_properties_mapped['target_lun']))
        self.assertDictEqual(actual_properties_mapped,
                             fake.FC_ISCSI_TARGET_INFO_DICT)
Esempio n. 11
0
    def initialize_connection_iscsi(self, volume, connector):
        """Driver entry point to attach a volume to an instance.

        Do the LUN masking on the storage system so the initiator can access
        the LUN on the target. Also return the iSCSI properties so the
        initiator can find the LUN. This implementation does not call
        _get_iscsi_properties() to get the properties because cannot store the
        LUN number in the database. We only find out what the LUN number will
        be during this method call so we construct the properties dictionary
        ourselves.
        """

        initiator_name = connector['initiator']
        name = volume['name']
        lun_id = self._map_lun(name, [initiator_name], 'iscsi', None)

        LOG.debug("Mapped LUN %(name)s to the initiator %(initiator_name)s", {
            'name': name,
            'initiator_name': initiator_name
        })

        target_list = self.zapi_client.get_iscsi_target_details()
        if not target_list:
            raise exception.VolumeBackendAPIException(
                data=_('Failed to get LUN target list for the LUN %s') % name)

        LOG.debug(
            "Successfully fetched target list for LUN %(name)s and "
            "initiator %(initiator_name)s", {
                'name': name,
                'initiator_name': initiator_name
            })

        preferred_target = self._get_preferred_target_from_list(target_list)
        if preferred_target is None:
            msg = _('Failed to get target portal for the LUN %s')
            raise exception.VolumeBackendAPIException(data=msg % name)
        (address, port) = (preferred_target['address'],
                           preferred_target['port'])

        iqn = self.zapi_client.get_iscsi_service_details()
        if not iqn:
            msg = _('Failed to get target IQN for the LUN %s')
            raise exception.VolumeBackendAPIException(data=msg % name)

        properties = na_utils.get_iscsi_connection_properties(
            lun_id, volume, iqn, address, port)

        if self.configuration.use_chap_auth:
            chap_username, chap_password = self._configure_chap(initiator_name)
            self._add_chap_properties(properties, chap_username, chap_password)

        return properties
Esempio n. 12
0
    def test_iscsi_connection_properties_single_iqn(self):
        actual_properties = na_utils.get_iscsi_connection_properties(
            fake.ISCSI_FAKE_LUN_ID, fake.ISCSI_FAKE_VOLUME,
            fake.ISCSI_FAKE_IQN,
            [fake.ISCSI_FAKE_ADDRESS_IPV4, fake.ISCSI_FAKE_ADDRESS2_IPV4],
            [fake.ISCSI_FAKE_PORT, fake.ISCSI_FAKE_PORT])

        actual_properties_mapped = actual_properties['data']
        expected = fake.ISCSI_MP_TARGET_INFO_DICT.copy()
        expected['target_iqns'][1] = expected['target_iqns'][0]

        self.assertDictEqual(actual_properties_mapped,
                             fake.ISCSI_MP_TARGET_INFO_DICT)
Esempio n. 13
0
    def test_iscsi_connection_properties(self):

        actual_properties = na_utils.get_iscsi_connection_properties(
            fake.ISCSI_FAKE_LUN_ID,
            fake.ISCSI_FAKE_VOLUME,
            fake.ISCSI_FAKE_IQN,
            fake.ISCSI_FAKE_ADDRESS,
            fake.ISCSI_FAKE_PORT,
        )

        actual_properties_mapped = actual_properties["data"]

        self.assertDictEqual(actual_properties_mapped, fake.FC_ISCSI_TARGET_INFO_DICT)
Esempio n. 14
0
    def test_iscsi_connection_properties_single_iqn(self):
        actual_properties = na_utils.get_iscsi_connection_properties(
            fake.ISCSI_FAKE_LUN_ID, fake.ISCSI_FAKE_VOLUME,
            fake.ISCSI_FAKE_IQN,
            [fake.ISCSI_FAKE_ADDRESS_IPV4, fake.ISCSI_FAKE_ADDRESS2_IPV4],
            [fake.ISCSI_FAKE_PORT, fake.ISCSI_FAKE_PORT])

        actual_properties_mapped = actual_properties['data']
        expected = fake.ISCSI_MP_TARGET_INFO_DICT.copy()
        expected['target_iqns'][1] = expected['target_iqns'][0]

        self.assertDictEqual(actual_properties_mapped,
                             fake.ISCSI_MP_TARGET_INFO_DICT)
Esempio n. 15
0
    def initialize_connection_iscsi(self, volume, connector):
        """Driver entry point to attach a volume to an instance.

        Do the LUN masking on the storage system so the initiator can access
        the LUN on the target. Also return the iSCSI properties so the
        initiator can find the LUN. This implementation does not call
        _get_iscsi_properties() to get the properties because cannot store the
        LUN number in the database. We only find out what the LUN number will
        be during this method call so we construct the properties dictionary
        ourselves.
        """

        initiator_name = connector['initiator']
        name = volume['name']
        lun_id = self._map_lun(name, [initiator_name], 'iscsi', None)
        msg = _("Mapped LUN %(name)s to the initiator %(initiator_name)s")
        msg_fmt = {'name': name, 'initiator_name': initiator_name}
        LOG.debug(msg % msg_fmt)
        target_details_list = self.zapi_client.get_iscsi_target_details()
        msg = _("Successfully fetched target details for LUN %(name)s and "
                "initiator %(initiator_name)s")
        msg_fmt = {'name': name, 'initiator_name': initiator_name}
        LOG.debug(msg % msg_fmt)

        if not target_details_list:
            msg = _('Failed to get LUN target details for the LUN %s')
            raise exception.VolumeBackendAPIException(data=msg % name)
        target_details = None
        for tgt_detail in target_details_list:
            if tgt_detail.get('interface-enabled', 'true') == 'true':
                target_details = tgt_detail
                break
        if not target_details:
            target_details = target_details_list[0]

        (address, port) = (target_details['address'], target_details['port'])

        if not target_details['address'] and target_details['port']:
            msg = _('Failed to get target portal for the LUN %s')
            raise exception.VolumeBackendAPIException(data=msg % name)

        iqn = self.zapi_client.get_iscsi_service_details()
        if not iqn:
            msg = _('Failed to get target IQN for the LUN %s')
            raise exception.VolumeBackendAPIException(data=msg % name)

        properties = na_utils.get_iscsi_connection_properties(lun_id, volume,
                                                              iqn, address,
                                                              port)

        return properties
Esempio n. 16
0
    def initialize_connection_iscsi(self, volume, connector):
        """Driver entry point to attach a volume to an instance.

        Do the LUN masking on the storage system so the initiator can access
        the LUN on the target. Also return the iSCSI properties so the
        initiator can find the LUN. This implementation does not call
        _get_iscsi_properties() to get the properties because cannot store the
        LUN number in the database. We only find out what the LUN number will
        be during this method call so we construct the properties dictionary
        ourselves.
        """

        initiator_name = connector['initiator']
        name = volume['name']
        lun_id = self._map_lun(name, [initiator_name], 'iscsi', None)
        msg = _("Mapped LUN %(name)s to the initiator %(initiator_name)s")
        msg_fmt = {'name': name, 'initiator_name': initiator_name}
        LOG.debug(msg % msg_fmt)
        target_details_list = self.zapi_client.get_iscsi_target_details()
        msg = _("Successfully fetched target details for LUN %(name)s and "
                "initiator %(initiator_name)s")
        msg_fmt = {'name': name, 'initiator_name': initiator_name}
        LOG.debug(msg % msg_fmt)

        if not target_details_list:
            msg = _('Failed to get LUN target details for the LUN %s')
            raise exception.VolumeBackendAPIException(data=msg % name)
        target_details = None
        for tgt_detail in target_details_list:
            if tgt_detail.get('interface-enabled', 'true') == 'true':
                target_details = tgt_detail
                break
        if not target_details:
            target_details = target_details_list[0]

        (address, port) = (target_details['address'], target_details['port'])

        if not target_details['address'] and target_details['port']:
            msg = _('Failed to get target portal for the LUN %s')
            raise exception.VolumeBackendAPIException(data=msg % name)

        iqn = self.zapi_client.get_iscsi_service_details()
        if not iqn:
            msg = _('Failed to get target IQN for the LUN %s')
            raise exception.VolumeBackendAPIException(data=msg % name)

        properties = na_utils.get_iscsi_connection_properties(
            lun_id, volume, iqn, address, port)

        return properties
Esempio n. 17
0
    def initialize_connection_iscsi(self, volume, connector):
        """Driver entry point to attach a volume to an instance.

        Do the LUN masking on the storage system so the initiator can access
        the LUN on the target. Also return the iSCSI properties so the
        initiator can find the LUN. This implementation does not call
        _get_iscsi_properties() to get the properties because cannot store the
        LUN number in the database. We only find out what the LUN number will
        be during this method call so we construct the properties dictionary
        ourselves.
        """

        initiator_name = connector['initiator']
        name = volume['name']
        lun_id = self._map_lun(name, [initiator_name], 'iscsi', None)

        LOG.debug("Mapped LUN %(name)s to the initiator %(initiator_name)s",
                  {'name': name, 'initiator_name': initiator_name})

        target_list = self.zapi_client.get_iscsi_target_details()
        if not target_list:
            raise exception.VolumeBackendAPIException(
                data=_('Failed to get LUN target list for the LUN %s') % name)

        LOG.debug("Successfully fetched target list for LUN %(name)s and "
                  "initiator %(initiator_name)s",
                  {'name': name, 'initiator_name': initiator_name})

        preferred_target = self._get_preferred_target_from_list(
            target_list)
        if preferred_target is None:
            msg = _('Failed to get target portal for the LUN %s')
            raise exception.VolumeBackendAPIException(data=msg % name)
        (address, port) = (preferred_target['address'],
                           preferred_target['port'])

        iqn = self.zapi_client.get_iscsi_service_details()
        if not iqn:
            msg = _('Failed to get target IQN for the LUN %s')
            raise exception.VolumeBackendAPIException(data=msg % name)

        properties = na_utils.get_iscsi_connection_properties(lun_id, volume,
                                                              iqn, address,
                                                              port)

        if self.configuration.use_chap_auth:
            chap_username, chap_password = self._configure_chap(initiator_name)
            self._add_chap_properties(properties, chap_username, chap_password)

        return properties
Esempio n. 18
0
    def initialize_connection_iscsi(self, volume, connector):
        """Allow connection to connector and return connection info."""
        initiator_name = connector["initiator"]
        eseries_vol = self._get_volume(volume["name_id"])
        mapping = self.map_volume_to_host(volume, eseries_vol, [initiator_name])

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

        iscsi_details = self._get_iscsi_service_details()
        iscsi_portal = self._get_iscsi_portal_for_vol(eseries_vol, iscsi_details)
        LOG.debug("Successfully fetched target details for volume %(id)s and " "initiator %(initiator_name)s.", 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
Esempio n. 19
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
Esempio n. 20
0
 def initialize_connection(self, volume, connector):
     """Allow connection to connector and return connection info."""
     initiator_name = connector['initiator']
     vol = self._get_latest_volume(volume['name_id'])
     iscsi_details = self._get_iscsi_service_details()
     iscsi_portal = self._get_iscsi_portal_for_vol(vol, iscsi_details)
     mapping = self._map_volume_to_host(vol, initiator_name)
     lun_id = mapping['lun']
     self._cache_vol_mapping(mapping)
     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)
     msg = _("Successfully fetched target details for volume %(id)s and "
             "initiator %(initiator_name)s.")
     LOG.debug(msg % msg_fmt)
     address = iscsi_portal['ip']
     port = iscsi_portal['tcp_port']
     iqn = iscsi_portal['iqn']
     return utils.get_iscsi_connection_properties(address, port, iqn,
                                                  lun_id, volume)
Esempio n. 21
0
 def initialize_connection(self, volume, connector):
     """Allow connection to connector and return connection info."""
     initiator_name = connector['initiator']
     vol = self._get_latest_volume(volume['name_id'])
     iscsi_details = self._get_iscsi_service_details()
     iscsi_portal = self._get_iscsi_portal_for_vol(vol, iscsi_details)
     mapping = self._map_volume_to_host(vol, initiator_name)
     lun_id = mapping['lun']
     self._cache_vol_mapping(mapping)
     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)
     msg = _("Successfully fetched target details for volume %(id)s and "
             "initiator %(initiator_name)s.")
     LOG.debug(msg % msg_fmt)
     address = iscsi_portal['ip']
     port = iscsi_portal['tcp_port']
     iqn = iscsi_portal['iqn']
     return utils.get_iscsi_connection_properties(address, port, iqn,
                                                  lun_id, volume)
Esempio n. 22
0
    def initialize_connection_iscsi(self, volume, connector):
        """Allow connection to connector and return connection info."""
        initiator_name = connector['initiator']
        eseries_vol = self._get_volume(volume['name_id'])
        mapping = self.map_volume_to_host(volume, eseries_vol,
                                          [initiator_name])

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

        iscsi_details = self._get_iscsi_service_details()
        iscsi_portal = self._get_iscsi_portal_for_vol(eseries_vol,
                                                      iscsi_details)
        LOG.debug(
            "Successfully fetched target details for volume %(id)s and "
            "initiator %(initiator_name)s.", 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