Beispiel #1
0
    def initialize_connection(self, volume, connector):
        LOG.info(
            'Initialize FC connection for volume %(id)s, '
            'connector info %(conn)s.', {
                'id': volume.id,
                'conn': connector
            })

        metadata = huawei_utils.get_volume_private_data(volume)
        if metadata.get('hypermetro'):
            if (not connector.get('multipath')
                    and self.configuration.enforce_multipath_for_hypermetro):
                msg = _("Mapping hypermetro volume must use multipath.")
                LOG.error(msg)
                raise exception.VolumeBackendAPIException(data=msg)
            elif (not connector.get('multipath')
                  and not self.configuration.enforce_multipath_for_hypermetro):
                LOG.warning("Mapping hypermetro volume not use multipath,"
                            " so just mapping the local lun.")
            if not self.hypermetro_rmt_cli:
                msg = _("Mapping hypermetro volume requires remote.")
                LOG.error(msg)
                raise exception.VolumeBackendAPIException(data=msg)

        local_mapping = huawei_flow.initialize_fc_connection(
            volume, constants.LUN_TYPE, connector, self.fc_san, self.local_cli,
            self.configuration)
        if metadata.get('hypermetro') and connector.get('multipath'):
            hypermetro = huawei_utils.get_hypermetro(self.local_cli, volume)
            if not hypermetro:
                msg = _("Mapping hypermetro remote volume error.")
                LOG.error(msg)
                raise exception.VolumeBackendAPIException(data=msg)

            remote_mapping = huawei_flow.initialize_remote_fc_connection(
                hypermetro['ID'], connector, self.fc_san,
                self.hypermetro_rmt_cli, self.configuration)
            same_host_lun_id = self._change_same_host_lun_id(
                local_mapping, remote_mapping)
            mapping_info = self._merge_fc_mapping(local_mapping,
                                                  remote_mapping,
                                                  same_host_lun_id)
        else:
            mapping_info = local_mapping

        mapping_info.pop('aval_host_lun_ids', None)
        conn = {'driver_volume_type': 'fibre_channel', 'data': mapping_info}
        LOG.info('Initialize FC connection successfully: %s.', conn)
        zm_utils.add_fc_zone(conn)
        return conn
Beispiel #2
0
    def initialize_connection_snapshot(self, snapshot, connector, **kwargs):
        LOG.info('Initialize FC connection for snapshot %(id)s, '
                 'connector info %(conn)s.',
                 {'id': snapshot.id, 'conn': connector})
        mapping_info = huawei_flow.initialize_fc_connection(
            snapshot, constants.SNAPSHOT_TYPE, connector, self.fc_san,
            self.local_cli, self.configuration)

        mapping_info.pop('aval_host_lun_ids', None)
        conn = {'driver_volume_type': 'fibre_channel',
                'data': mapping_info}
        LOG.info('Initialize FC connection successfully: %s.', conn)
        zm_utils.add_fc_zone(conn)
        return conn