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);
}
}
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");
}
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);
}
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");
}
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");
}
Aggregations