Search in sources :

Example 31 with HDSApiClient

use of com.emc.storageos.hds.api.HDSApiClient in project coprhd-controller by CoprHD.

the class HDSMirrorOperations method createSingleVolumeMirror.

/**
 * 1. Find ReplicationGroup objId from Device Manager
 * 2. Check dummy Host Group available on Storage System. if not available create a dummy Host Group name.
 * 3. Create a secondary volume and add dummy host group on it.
 * 4. create a SI pair.
 *
 * @param storageSystem {@link StorageSystem}
 * @param mirrorVolumeURI {@link URI}
 * @param createInactive {@link Boolean}
 * @param taskCompleter {@link TaskCompleter}
 */
@Override
public void createSingleVolumeMirror(StorageSystem storageSystem, URI mirrorVolumeURI, Boolean createInactive, TaskCompleter taskCompleter) throws DeviceControllerException {
    log.info("START createSingleVolumeMirror operation");
    try {
        HDSApiClient hdsApiClient = hdsApiFactory.getClient(HDSUtils.getHDSServerManagementServerInfo(storageSystem), storageSystem.getSmisUserName(), storageSystem.getSmisPassword());
        HDSApiProtectionManager hdsApiProtectionManager = hdsApiClient.getHdsApiProtectionManager();
        String replicationGroupObjectID = hdsApiClient.getHdsApiProtectionManager().getReplicationGroupObjectId();
        if (replicationGroupObjectID == null) {
            log.error("Unable to find replication group information/pair management server for pair configuration");
            throw HDSException.exceptions.replicationGroupNotAvailable();
        }
        BlockMirror mirrorObj = dbClient.queryObject(BlockMirror.class, mirrorVolumeURI);
        Volume source = dbClient.queryObject(Volume.class, mirrorObj.getSource());
        hdsProtectionOperations.createSecondaryVolumeForMirror(storageSystem, source.getId(), mirrorObj);
        mirrorObj = dbClient.queryObject(BlockMirror.class, mirrorVolumeURI);
        hdsProtectionOperations.addDummyLunPath(hdsApiClient, mirrorObj);
        String pairName = hdsProtectionOperations.generatePairName(source, mirrorObj);
        log.info("Pair Name :{}", pairName);
        ReplicationInfo replicationInfo = hdsApiProtectionManager.createShadowImagePair(replicationGroupObjectID, pairName, HDSUtils.getSystemArrayType(storageSystem), HDSUtils.getSystemSerialNumber(storageSystem), source.getNativeId(), mirrorObj.getNativeId(), storageSystem.getModel());
        mirrorObj.setSyncState(SynchronizationState.SYNCHRONIZED.name());
        dbClient.persistObject(mirrorObj);
        log.info("Replication Info object :{}", replicationInfo.toXMLString());
        taskCompleter.ready(dbClient);
    } catch (Exception e) {
        String errorMsg = String.format(CREATE_ERROR_MSG_FORMAT, mirrorVolumeURI);
        log.error(errorMsg, e);
        ServiceError serviceError = DeviceControllerErrors.hds.methodFailed("createSingleVolumeMirror", e.getMessage());
        taskCompleter.error(dbClient, serviceError);
    }
    log.info("FINISHED createSingleVolumeMirror operation");
}
Also used : HDSApiClient(com.emc.storageos.hds.api.HDSApiClient) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BlockMirror(com.emc.storageos.db.client.model.BlockMirror) Volume(com.emc.storageos.db.client.model.Volume) HDSApiProtectionManager(com.emc.storageos.hds.api.HDSApiProtectionManager) ReplicationInfo(com.emc.storageos.hds.model.ReplicationInfo) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) HDSException(com.emc.storageos.hds.HDSException)

Example 32 with HDSApiClient

use of com.emc.storageos.hds.api.HDSApiClient in project coprhd-controller by CoprHD.

the class HDSProtectionOperations method removeDummyLunPath.

/**
 * Removes Dummy Lun Path from Secondary Volume
 *
 * @param storageSystem
 * @param blockObjectURI
 * @throws Exception
 */
public void removeDummyLunPath(StorageSystem storageSystem, URI blockObjectURI) throws Exception {
    log.info("Started dummy lun path removal from secondary volume");
    HDSApiClient apiClient = HDSUtils.getHDSApiClient(hdsApiFactory, storageSystem);
    HDSApiExportManager apiExportManager = apiClient.getHDSApiExportManager();
    String systemObjectId = HDSUtils.getSystemObjectID(storageSystem);
    // Volume volume=dbClient.queryObject(Volume.class, volumeURI);
    BlockObject blockObj = BlockObject.fetch(dbClient, blockObjectURI);
    String dummyLunPathId = getDummyHSDPathId(storageSystem, blockObj);
    if (dummyLunPathId != null) {
        apiExportManager.deleteLunPathsFromSystem(systemObjectId, Arrays.asList(dummyLunPathId), storageSystem.getModel());
        log.info("Deleted Dummy Lun path from secondary volume");
    } else {
        log.info("Dummy lun path has been removed already");
    }
}
Also used : HDSApiClient(com.emc.storageos.hds.api.HDSApiClient) HDSApiExportManager(com.emc.storageos.hds.api.HDSApiExportManager) BlockObject(com.emc.storageos.db.client.model.BlockObject)

Example 33 with HDSApiClient

use of com.emc.storageos.hds.api.HDSApiClient in project coprhd-controller by CoprHD.

the class HDSProtectionOperations method createSecondaryVolumeForMirror.

/**
 * Creates secondary volume for ShadowImage pair operations.
 *
 * @param storageSystem
 * @param sourceVolume
 * @param mirror
 * @throws Exception
 */
public void createSecondaryVolumeForMirror(StorageSystem storageSystem, URI sourceVolume, BlockMirror mirror) throws Exception {
    log.info("SecondaryVolume for mirror creation operation started");
    String taskId = UUID.randomUUID().toString();
    TaskCompleter taskCompleter = new BlockMirrorCreateCompleter(mirror.getId(), taskId);
    String asyncTaskMessageId = null;
    HDSApiClient hdsApiClient = HDSUtils.getHDSApiClient(hdsApiFactory, storageSystem);
    String systemObjectID = HDSUtils.getSystemObjectID(storageSystem);
    StoragePool targetPool = dbClient.queryObject(StoragePool.class, mirror.getPool());
    Volume source = dbClient.queryObject(Volume.class, sourceVolume);
    TenantOrg tenant = dbClient.queryObject(TenantOrg.class, source.getTenant().getURI());
    String tenantName = tenant.getLabel();
    String targetLabelToUse = nameGenerator.generate(tenantName, mirror.getLabel(), mirror.getId().toString(), '-', HDSConstants.MAX_VOLUME_NAME_LENGTH);
    if (mirror.getThinlyProvisioned()) {
        asyncTaskMessageId = hdsApiClient.createThinVolumes(systemObjectID, targetPool.getNativeId(), mirror.getCapacity(), 1, targetLabelToUse, HDSConstants.QUICK_FORMAT_TYPE, storageSystem.getModel());
    } else {
        String poolObjectID = HDSUtils.getPoolObjectID(targetPool);
        asyncTaskMessageId = hdsApiClient.createThickVolumes(systemObjectID, poolObjectID, mirror.getCapacity(), 1, targetLabelToUse, null, storageSystem.getModel(), null);
    }
    if (asyncTaskMessageId != null) {
        HDSJob createHDSJob = new HDSBlockCreateMirrorJob(asyncTaskMessageId, mirror.getStorageController(), targetPool.getId(), taskCompleter);
        hdsCommandHelper.waitForAsyncHDSJob(createHDSJob);
    } else {
        throw HDSException.exceptions.asyncTaskFailed("Unable to get async taskId from HiCommand Device Manager for the create volume call");
    }
    log.info("SecondaryVolume for mirror creation operation completed successfully");
}
Also used : HDSApiClient(com.emc.storageos.hds.api.HDSApiClient) StoragePool(com.emc.storageos.db.client.model.StoragePool) HDSJob(com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSJob) Volume(com.emc.storageos.db.client.model.Volume) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) TaskCompleter(com.emc.storageos.volumecontroller.TaskCompleter) BlockMirrorCreateCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockMirrorCreateCompleter) HDSBlockCreateMirrorJob(com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSBlockCreateMirrorJob)

Example 34 with HDSApiClient

use of com.emc.storageos.hds.api.HDSApiClient in project coprhd-controller by CoprHD.

the class HDSProtectionOperations method createSecondaryVolumeForClone.

/**
 * Creates secondary volume for ShadowImage pair operations.
 *
 * @param storageSystem
 * @param sourceVolume
 * @param targetVolume
 * @throws Exception
 */
public void createSecondaryVolumeForClone(StorageSystem storageSystem, URI sourceVolume, Volume targetVolume) throws Exception {
    log.info("SecondaryVolume creation operation started");
    String taskId = UUID.randomUUID().toString();
    TaskCompleter taskCompleter = new VolumeCreateCompleter(targetVolume.getId(), taskId);
    String asyncTaskMessageId = null;
    HDSApiClient hdsApiClient = HDSUtils.getHDSApiClient(hdsApiFactory, storageSystem);
    String systemObjectID = HDSUtils.getSystemObjectID(storageSystem);
    BlockObject sourceObj = BlockObject.fetch(dbClient, sourceVolume);
    URI tenantUri = null;
    StoragePool targetPool = dbClient.queryObject(StoragePool.class, targetVolume.getPool());
    if (sourceObj instanceof BlockSnapshot) {
        // In case of snapshot, get the tenant from its parent volume
        NamedURI parentVolUri = ((BlockSnapshot) sourceObj).getParent();
        Volume parentVolume = dbClient.queryObject(Volume.class, parentVolUri);
        tenantUri = parentVolume.getTenant().getURI();
        TenantOrg tenantOrg = dbClient.queryObject(TenantOrg.class, tenantUri);
    // String cloneLabel = generateLabel(tenantOrg, cloneObj);
    } else {
        // This is a default flow
        tenantUri = ((Volume) sourceObj).getTenant().getURI();
    }
    if (targetVolume.getThinlyProvisioned()) {
        asyncTaskMessageId = hdsApiClient.createThinVolumes(systemObjectID, targetPool.getNativeId(), targetVolume.getCapacity(), 1, targetVolume.getLabel(), HDSConstants.QUICK_FORMAT_TYPE, storageSystem.getModel());
    } else {
        String poolObjectID = HDSUtils.getPoolObjectID(targetPool);
        asyncTaskMessageId = hdsApiClient.createThickVolumes(systemObjectID, poolObjectID, targetVolume.getCapacity(), 1, targetVolume.getLabel(), null, storageSystem.getModel(), null);
    }
    if (asyncTaskMessageId != null) {
        HDSJob createHDSJob = new HDSCreateVolumeJob(asyncTaskMessageId, targetVolume.getStorageController(), targetPool.getId(), taskCompleter);
        hdsCommandHelper.waitForAsyncHDSJob(createHDSJob);
    } else {
        throw HDSException.exceptions.asyncTaskFailed("Unable to get async taskId from HiCommand Device Manager for the create volume call");
    }
    log.info("SecondaryVolume creation operation completed successfully");
}
Also used : HDSApiClient(com.emc.storageos.hds.api.HDSApiClient) StoragePool(com.emc.storageos.db.client.model.StoragePool) HDSJob(com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSJob) HDSCreateVolumeJob(com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSCreateVolumeJob) NamedURI(com.emc.storageos.db.client.model.NamedURI) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) Volume(com.emc.storageos.db.client.model.Volume) VolumeCreateCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeCreateCompleter) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) TaskCompleter(com.emc.storageos.volumecontroller.TaskCompleter) BlockObject(com.emc.storageos.db.client.model.BlockObject)

Example 35 with HDSApiClient

use of com.emc.storageos.hds.api.HDSApiClient in project coprhd-controller by CoprHD.

the class HDSProtectionOperations method getDummyHSDPathId.

/**
 * Get Dummy Lun Path's path objectID
 *
 * @param storageSystem
 * @param volume
 * @return
 * @throws Exception
 */
private String getDummyHSDPathId(StorageSystem storageSystem, BlockObject blockObj) throws Exception {
    String dummyLunPathId = null;
    HDSApiClient apiClient = HDSUtils.getHDSApiClient(hdsApiFactory, storageSystem);
    HDSApiExportManager apiExportManager = apiClient.getHDSApiExportManager();
    String systemObjectId = HDSUtils.getSystemObjectID(storageSystem);
    List<HostStorageDomain> hsdList = apiExportManager.getHostStorageDomains(systemObjectId);
    if (hsdList != null) {
        for (HostStorageDomain hsd : hsdList) {
            if (hsd != null && HDSConstants.DUMMY_HSD.equalsIgnoreCase(hsd.getNickname())) {
                if (hsd.getPathList() != null) {
                    for (Path path : hsd.getPathList()) {
                        if (path.getDevNum().equalsIgnoreCase(blockObj.getNativeId())) {
                            dummyLunPathId = path.getObjectID();
                            log.info("Found secondary volume's dummy lun path id :{}", dummyLunPathId);
                            return dummyLunPathId;
                        }
                    }
                }
            }
        }
    }
    log.info("Dummy lun path has been removed already for this secondary volume");
    return dummyLunPathId;
}
Also used : Path(com.emc.storageos.hds.model.Path) HDSApiClient(com.emc.storageos.hds.api.HDSApiClient) HostStorageDomain(com.emc.storageos.hds.model.HostStorageDomain) HDSApiExportManager(com.emc.storageos.hds.api.HDSApiExportManager)

Aggregations

HDSApiClient (com.emc.storageos.hds.api.HDSApiClient)45 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)26 HDSException (com.emc.storageos.hds.HDSException)26 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)21 Volume (com.emc.storageos.db.client.model.Volume)14 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)13 HDSApiExportManager (com.emc.storageos.hds.api.HDSApiExportManager)12 HostStorageDomain (com.emc.storageos.hds.model.HostStorageDomain)12 ArrayList (java.util.ArrayList)12 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)11 HashSet (java.util.HashSet)11 ExportMask (com.emc.storageos.db.client.model.ExportMask)10 LogicalUnit (com.emc.storageos.hds.model.LogicalUnit)10 URI (java.net.URI)10 HDSJob (com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSJob)9 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)8 ReplicationInfo (com.emc.storageos.hds.model.ReplicationInfo)7 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)7 StoragePool (com.emc.storageos.db.client.model.StoragePool)6 HDSApiProtectionManager (com.emc.storageos.hds.api.HDSApiProtectionManager)6