Search in sources :

Example 1 with HDSApiProtectionManager

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

the class HDSCloneOperations method createSingleClone.

/**
 * 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
 *
 * Note that if createInactive is false, then a subsequent step in the
 * full copy creation workflow will do a wait for synchronization. This
 * will split the pair, which makes the clone active.
 *
 * @param storageSystem {@link StorageSystem}
 * @param sourceVolumeURI {@link URI}
 * @param cloneVolumeURI {@link URI}
 * @param createInactive {@link Boolean}
 * @param taskCompleter {@link TaskCompleter}
 */
@Override
public void createSingleClone(StorageSystem storageSystem, URI sourceVolumeURI, URI cloneVolumeURI, Boolean createInactive, TaskCompleter taskCompleter) {
    log.info("START createSingleClone operation");
    Volume cloneVolume = null;
    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();
        }
        cloneVolume = dbClient.queryObject(Volume.class, cloneVolumeURI);
        hdsProtectionOperations.createSecondaryVolumeForClone(storageSystem, sourceVolumeURI, cloneVolume);
        // Need to fetch clone volume from db to get volume's nativeId
        cloneVolume = dbClient.queryObject(Volume.class, cloneVolumeURI);
        hdsProtectionOperations.addDummyLunPath(hdsApiClient, cloneVolume);
        BlockObject source = BlockObject.fetch(dbClient, sourceVolumeURI);
        String pairName = hdsProtectionOperations.generatePairName(source, cloneVolume);
        log.info("Pair Name :{}", pairName);
        ReplicationInfo replicationInfo = hdsApiProtectionManager.createShadowImagePair(replicationGroupObjectID, pairName, HDSUtils.getSystemArrayType(storageSystem), HDSUtils.getSystemSerialNumber(storageSystem), source.getNativeId(), cloneVolume.getNativeId(), storageSystem.getModel());
        log.info("Replication Info object :{}", replicationInfo.toXMLString());
        log.info("createInactive :{}", createInactive);
        cloneVolume.setSyncActive(false);
        cloneVolume.setReplicaState(ReplicationState.INACTIVE.name());
        dbClient.persistObject(cloneVolume);
        taskCompleter.ready(dbClient);
    } catch (Exception e) {
        String errorMsg = String.format(CREATE_ERROR_MSG_FORMAT, sourceVolumeURI, cloneVolumeURI);
        log.error(errorMsg, e);
        Volume clone = dbClient.queryObject(Volume.class, cloneVolumeURI);
        if (clone != null) {
            clone.setInactive(true);
            dbClient.persistObject(clone);
        }
        ServiceError serviceError = DeviceControllerErrors.hds.methodFailed("createSingleClone", e.getMessage());
        taskCompleter.error(dbClient, serviceError);
    }
}
Also used : HDSApiClient(com.emc.storageos.hds.api.HDSApiClient) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) Volume(com.emc.storageos.db.client.model.Volume) HDSApiProtectionManager(com.emc.storageos.hds.api.HDSApiProtectionManager) ReplicationInfo(com.emc.storageos.hds.model.ReplicationInfo) BlockObject(com.emc.storageos.db.client.model.BlockObject) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) HDSException(com.emc.storageos.hds.HDSException)

Example 2 with HDSApiProtectionManager

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

the class HDSProtectionOperations method deleteShadowImagePair.

/**
 * Deletes shadowImage Pair
 *
 * @param storageSystem
 * @param source
 * @param target
 * @throws Exception
 */
public void deleteShadowImagePair(StorageSystem storageSystem, Volume source, Volume target) throws Exception {
    log.info("Delete pair operation started");
    HDSApiClient apiClient = HDSUtils.getHDSApiClient(hdsApiFactory, storageSystem);
    HDSApiProtectionManager apiProtectionManager = apiClient.getHdsApiProtectionManager();
    Map<String, String> repliMap = apiProtectionManager.getReplicationRelatedObjectIds(source.getNativeId(), target.getNativeId());
    log.info("Replication Obj Ids :{}", repliMap);
    String replicationGroupObjId = repliMap.get(HDSConstants.REPLICATION_GROUP_OBJ_ID);
    String replicationInfoObjId = repliMap.get(HDSConstants.REPLICATION_INFO_OBJ_ID);
    apiProtectionManager.deleteShadowImagePair(replicationGroupObjId, replicationInfoObjId, storageSystem.getModel());
    log.info("Delete pair operation completed");
}
Also used : HDSApiClient(com.emc.storageos.hds.api.HDSApiClient) HDSApiProtectionManager(com.emc.storageos.hds.api.HDSApiProtectionManager)

Example 3 with HDSApiProtectionManager

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

the class HDSProtectionOperations method modifyShadowImagePair.

/**
 * Modifies pair operation to split|resync|restore
 *
 * @param storageSystem
 * @param sourceVolumeNativeId
 * @param targetVolumeNativeId
 * @param operationType
 * @throws Exception
 */
public boolean modifyShadowImagePair(StorageSystem storageSystem, String sourceVolumeNativeId, String targetVolumeNativeId, HDSApiProtectionManager.ShadowImageOperationType operationType) throws Exception {
    HDSApiClient apiClient = HDSUtils.getHDSApiClient(hdsApiFactory, storageSystem);
    HDSApiProtectionManager apiProtectionManager = apiClient.getHdsApiProtectionManager();
    log.info("{} pair operation started", operationType.name());
    Map<String, String> repliMap = apiProtectionManager.getReplicationRelatedObjectIds(sourceVolumeNativeId, targetVolumeNativeId);
    log.info("Replication Obj Ids :{}", repliMap);
    String replicationGroupObjId = repliMap.get(HDSConstants.REPLICATION_GROUP_OBJ_ID);
    String replicationInfoObjId = repliMap.get(HDSConstants.REPLICATION_INFO_OBJ_ID);
    ReplicationInfo replicationInfo = apiProtectionManager.modifyShadowImagePair(replicationGroupObjId, replicationInfoObjId, operationType, storageSystem.getModel());
    log.info("{} pair operation completed", operationType.name());
    return (replicationInfo != null);
}
Also used : HDSApiClient(com.emc.storageos.hds.api.HDSApiClient) HDSApiProtectionManager(com.emc.storageos.hds.api.HDSApiProtectionManager) ReplicationInfo(com.emc.storageos.hds.model.ReplicationInfo)

Example 4 with HDSApiProtectionManager

use of com.emc.storageos.hds.api.HDSApiProtectionManager 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 5 with HDSApiProtectionManager

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

the class HDSStorageDevice method doWaitForSynchronized.

/*
     * (non-Javadoc)
     * 
     * @see
     * com.emc.storageos.volumecontroller.BlockStorageDevice#doWaitForSynchronized
     * (java.lang.Class, com.emc.storageos.db.client.model.StorageSystem,
     * java.net.URI, com.emc.storageos.volumecontroller.TaskCompleter)
     */
@Override
public void doWaitForSynchronized(Class<? extends BlockObject> clazz, StorageSystem storageObj, URI target, TaskCompleter completer) {
    log.info("START waitForSynchronized for {}", target);
    try {
        Volume targetObj = dbClient.queryObject(Volume.class, target);
        // Source could be either Volume or BlockSnapshot
        BlockObject sourceObj = BlockObject.fetch(dbClient, targetObj.getAssociatedSourceVolume());
        // We split the pair which causes the data to be synchronized.
        // When the split is complete that data is synchronized.
        HDSApiClient hdsApiClient = hdsApiFactory.getClient(HDSUtils.getHDSServerManagementServerInfo(storageObj), storageObj.getSmisUserName(), storageObj.getSmisPassword());
        HDSApiProtectionManager hdsApiProtectionManager = hdsApiClient.getHdsApiProtectionManager();
        String replicationGroupObjectID = hdsApiProtectionManager.getReplicationGroupObjectId();
        ReplicationInfo replicationInfo = hdsApiProtectionManager.getReplicationInfoFromSystem(sourceObj.getNativeId(), targetObj.getNativeId()).first;
        hdsApiProtectionManager.modifyShadowImagePair(replicationGroupObjectID, replicationInfo.getObjectID(), HDSApiProtectionManager.ShadowImageOperationType.split, storageObj.getModel());
        // Update state in case we are waiting for synchronization
        // after creation of a new full copy that was not created
        // inactive.
        String state = targetObj.getReplicaState();
        if (!ReplicationState.SYNCHRONIZED.name().equals(state)) {
            targetObj.setSyncActive(true);
            targetObj.setReplicaState(ReplicationState.SYNCHRONIZED.name());
            dbClient.persistObject(targetObj);
        }
        // Queue job to wait for replication status to move to split.
        ControllerServiceImpl.enqueueJob(new QueueJob(new HDSReplicationSyncJob(storageObj.getId(), sourceObj.getNativeId(), targetObj.getNativeId(), ReplicationStatus.SPLIT, completer)));
    } catch (Exception e) {
        log.error("Exception occurred while waiting for synchronization", e);
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        completer.error(dbClient, serviceError);
    }
    log.info("completed doWaitForSynchronized");
}
Also used : HDSReplicationSyncJob(com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSReplicationSyncJob) HDSApiClient(com.emc.storageos.hds.api.HDSApiClient) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) Volume(com.emc.storageos.db.client.model.Volume) HDSApiProtectionManager(com.emc.storageos.hds.api.HDSApiProtectionManager) ReplicationInfo(com.emc.storageos.hds.model.ReplicationInfo) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) BlockObject(com.emc.storageos.db.client.model.BlockObject) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) HDSException(com.emc.storageos.hds.HDSException)

Aggregations

HDSApiClient (com.emc.storageos.hds.api.HDSApiClient)6 HDSApiProtectionManager (com.emc.storageos.hds.api.HDSApiProtectionManager)6 ReplicationInfo (com.emc.storageos.hds.model.ReplicationInfo)5 Volume (com.emc.storageos.db.client.model.Volume)3 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)3 HDSException (com.emc.storageos.hds.HDSException)3 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)3 BlockObject (com.emc.storageos.db.client.model.BlockObject)2 BlockMirror (com.emc.storageos.db.client.model.BlockMirror)1 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)1 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)1 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)1 HDSReplicationSyncJob (com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSReplicationSyncJob)1 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)1