use of com.emc.storageos.db.client.model.BlockMirror in project coprhd-controller by CoprHD.
the class VolumeIngestionUtil method setupMirrorParentRelations.
/**
* Setup relationships between a mirror and its parent BlockObject.
*
* @param mirror the mirror BlockObject
* @param parentVolume the mirror's parent BlockObject
* @param dbClient a reference to the database client
*/
public static void setupMirrorParentRelations(BlockObject mirror, BlockObject parent, DbClient dbClient) {
_logger.info("Setting up relationship between mirror {} ({}) and parent {} ({})", new Object[] { mirror.getLabel(), mirror.getId(), parent.getLabel(), parent.getId() });
((BlockMirror) mirror).setSource(new NamedURI(parent.getId(), parent.getLabel()));
if (parent instanceof Volume) {
StringSet mirrors = ((Volume) parent).getMirrors();
if (mirrors == null) {
mirrors = new StringSet();
}
mirrors.add(mirror.getId().toString());
((Volume) parent).setMirrors(mirrors);
}
}
use of com.emc.storageos.db.client.model.BlockMirror in project coprhd-controller by CoprHD.
the class BlockDeviceController method createMirror.
/**
* {@inheritDoc} NOTE NOTE: The signature here MUST match the Workflow.Method createMirrorMethod just above (except
* opId).
*/
@Override
public void createMirror(URI storage, List<URI> mirrorList, Boolean isCG, Boolean createInactive, String opId) throws ControllerException {
TaskCompleter completer = null;
try {
WorkflowStepCompleter.stepExecuting(opId);
StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
if (!isCG && mirrorList.size() == 1) {
completer = new BlockMirrorCreateCompleter(mirrorList.get(0), opId);
getDevice(storageObj.getSystemType()).doCreateMirror(storageObj, mirrorList.get(0), createInactive, completer);
} else {
boolean isListReplicaFlow = false;
BlockMirror mirrorObj = _dbClient.queryObject(BlockMirror.class, mirrorList.get(0));
Volume sourceVolume = _dbClient.queryObject(Volume.class, mirrorObj.getSource().getURI());
/**
* VPLEX/RP CG volumes may not be having back end Array Group.
* In this case we should create element replica using createListReplica.
* We should not use createGroup replica as backend cg will not be available in this case.
*/
isListReplicaFlow = isListReplicaFlow(sourceVolume);
completer = new BlockMirrorCreateCompleter(mirrorList, opId);
if (!isListReplicaFlow) {
getDevice(storageObj.getSystemType()).doCreateGroupMirrors(storageObj, mirrorList, createInactive, completer);
} else {
// List Replica
getDevice(storageObj.getSystemType()).doCreateListReplica(storageObj, mirrorList, createInactive, completer);
}
}
} catch (Exception e) {
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
if (completer != null) {
completer.error(_dbClient, serviceError);
}
WorkflowStepCompleter.stepFailed(opId, serviceError);
}
}
use of com.emc.storageos.db.client.model.BlockMirror in project coprhd-controller by CoprHD.
the class BlockDeviceController method pauseNativeContinuousCopies.
@Override
public void pauseNativeContinuousCopies(URI storage, List<URI> mirrors, Boolean sync, String opId) throws ControllerException {
_log.info("START pause continuous copies workflow");
boolean isCG = isCGMirror(mirrors.get(0), _dbClient);
if (mirrors.size() == 1 || isCG) {
fractureMirror(storage, mirrors, isCG, sync, opId);
return;
}
Workflow workflow = _workflowService.getNewWorkflow(this, PAUSE_MIRRORS_WF_NAME, false, opId);
TaskCompleter taskCompleter = null;
BlockMirror mirror = _dbClient.queryObject(BlockMirror.class, mirrors.get(0));
StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
try {
for (URI mirrorUri : mirrors) {
BlockMirror blockMirror = _dbClient.queryObject(BlockMirror.class, mirrorUri);
if (!mirrorIsPausable(asList(blockMirror))) {
String errorMsg = format("Can not pause continuous copy %s with synchronization state %s for volume %s", blockMirror.getId(), blockMirror.getSyncState(), blockMirror.getSource().getURI());
_log.error(errorMsg);
String opName = ResourceOperationTypeEnum.PAUSE_NATIVE_CONTINUOUS_COPIES.getName();
ServiceError serviceError = DeviceControllerException.errors.jobFailedOp(opName);
WorkflowStepCompleter.stepFailed(opId, serviceError);
throw new IllegalStateException(errorMsg);
}
workflow.createStep("pauseMirror", "pause mirror", null, storage, storageObj.getSystemType(), this.getClass(), fractureMirrorMethod(storage, asList(mirrorUri), isCG, sync), null, null);
}
taskCompleter = new BlockMirrorTaskCompleter(Volume.class, asList(mirror.getSource().getURI()), opId);
workflow.executePlan(taskCompleter, "Successfully paused continuous copies");
} catch (Exception e) {
String msg = String.format("Failed to execute pause continuous copies workflow for volume %s", mirror.getSource().getURI());
_log.error(msg, e);
if (taskCompleter != null) {
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
taskCompleter.error(_dbClient, serviceError);
}
}
}
use of com.emc.storageos.db.client.model.BlockMirror in project coprhd-controller by CoprHD.
the class BlockDeviceController method isCGMirror.
private boolean isCGMirror(URI mirrorURI, DbClient dbClient) {
BlockMirror mirror = dbClient.queryObject(BlockMirror.class, mirrorURI);
Volume sourceVolume = dbClient.queryObject(Volume.class, mirror.getSource());
return sourceVolume.isInCG();
}
use of com.emc.storageos.db.client.model.BlockMirror in project coprhd-controller by CoprHD.
the class BlockDeviceController method addStepsForPromoteMirrors.
/**
* Adds the additional steps necessary to promote mirrors to regular block volumes
*
* @param workflow
* @param waitFor
* @param descriptors
* @param promotees
* @return
* @throws ControllerException
*/
public String addStepsForPromoteMirrors(Workflow workflow, String waitFor, List<URI> mirrorList, List<URI> promotees) throws ControllerException {
boolean isCG = isCGMirror(mirrorList.get(0), _dbClient);
List<Volume> promotedVolumes = _dbClient.queryObject(Volume.class, promotees);
if (!isCG) {
List<BlockMirror> mirrors = _dbClient.queryObject(BlockMirror.class, mirrorList);
for (BlockMirror mirror : mirrors) {
URI controller = mirror.getStorageController();
// Add steps for detaching the mirror
String stepId = addStepsForDetachMirror(workflow, waitFor, PROMOTE_MIRROR_STEP_GROUP, mirrorList, isCG);
// Find the volume this mirror will be promoted to
URI promotedVolumeForMirror = findPromotedVolumeForMirror(mirror.getId(), promotedVolumes);
// Create a step for promoting the mirror.
stepId = workflow.createStep(PROMOTE_MIRROR_STEP_GROUP, String.format("Promote mirror: %s", mirror.getId()), stepId, controller, getDeviceType(controller), this.getClass(), promoteMirrorMethod(asList(mirror.getId()), asList(promotedVolumeForMirror), isCG), null, null);
}
} else {
BlockMirror mirror = _dbClient.queryObject(BlockMirror.class, mirrorList.get(0));
URI controller = mirror.getStorageController();
// Add steps for detaching the mirror
String stepId = addStepsForDetachMirror(workflow, waitFor, PROMOTE_MIRROR_STEP_GROUP, mirrorList, isCG);
// Find the volumes this set of mirrors will be promoted to
List<URI> promotedVolumesForMirrors = findPromotedVolumesForMirrors(mirrorList, promotedVolumes);
// Create a step for promoting the mirrors.
stepId = workflow.createStep(PROMOTE_MIRROR_STEP_GROUP, String.format("Promote mirrors: %s", Joiner.on("\t").join(mirrorList)), stepId, controller, getDeviceType(controller), this.getClass(), promoteMirrorMethod(mirrorList, promotedVolumesForMirrors, isCG), null, null);
}
return PROMOTE_MIRROR_STEP_GROUP;
}
Aggregations