use of com.emc.storageos.svcs.errorhandling.model.ServiceError in project coprhd-controller by CoprHD.
the class BlockDeviceController method createFullCopy.
@Override
public void createFullCopy(URI storage, List<URI> fullCopyVolumes, Boolean createInactive, String taskId) throws ControllerException {
_log.info("START fullCopyVolumes");
TaskCompleter taskCompleter = new CloneCreateWorkflowCompleter(fullCopyVolumes, taskId);
Volume clone = _dbClient.queryObject(Volume.class, fullCopyVolumes.get(0));
URI sourceVolume = clone.getAssociatedSourceVolume();
try {
StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, storage);
Workflow workflow = _workflowService.getNewWorkflow(this, FULL_COPY_WORKFLOW, true, taskId);
boolean isCG = false;
Volume source = URIUtil.isType(sourceVolume, Volume.class) ? _dbClient.queryObject(Volume.class, sourceVolume) : null;
VolumeGroup volumeGroup = (source != null) ? source.getApplication(_dbClient) : null;
if (volumeGroup != null) {
/**
* If a Volume is in Volume Group (COPY type),
* Query all volumes belonging to that Volume Group,
* Group full-copies by Array Replication Group and create workflow step for each Array Group,
* these steps runs in parallel
*/
_log.info("Creating full copy for Application {}", volumeGroup.getLabel());
createFullCopyForApplicationCGs(workflow, volumeGroup, fullCopyVolumes, createInactive, taskCompleter);
} else if (checkCloneConsistencyGroup(fullCopyVolumes.get(0), _dbClient, taskCompleter)) {
// check if the clone is in a CG
isCG = true;
_log.info("Creating group full copy");
createCGFullCopy(storage, sourceVolume, fullCopyVolumes, storageSystem, workflow, createInactive, isCG);
} else {
for (URI uri : fullCopyVolumes) {
Workflow.Method createMethod = createFullCopyVolumeMethod(storage, sourceVolume, Arrays.asList(uri), createInactive, isCG);
Workflow.Method rollbackMethod = rollbackFullCopyVolumeMethod(storage, asList(uri));
workflow.createStep(FULL_COPY_CREATE_STEP_GROUP, "Creating full copy", null, storage, storageSystem.getSystemType(), getClass(), createMethod, rollbackMethod, null);
// clone state.
if (!createInactive && !getDriverManager().isDriverManaged(storageSystem.getSystemType())) {
// After all full copies have been created, wait for synchronization to complete
Workflow.Method waitForSyncMethod = waitForSynchronizedMethod(Volume.class, storage, Arrays.asList(uri), isCG);
String waitForSyncStep = workflow.createStep(FULL_COPY_WFS_STEP_GROUP, "Waiting for synchronization", FULL_COPY_CREATE_STEP_GROUP, storage, storageSystem.getSystemType(), getClass(), waitForSyncMethod, rollbackMethodNullMethod(), null);
Volume cloneVol = _dbClient.queryObject(Volume.class, uri);
BlockObject sourceObj = BlockObject.fetch(_dbClient, cloneVol.getAssociatedSourceVolume());
// detach if source is snapshot, or storage system is not vmax/vnx/hds
if (storageSystem.deviceIsType(Type.openstack)) {
setCloneReplicaStateStep(workflow, storageSystem, asList(uri), waitForSyncStep, ReplicationState.SYNCHRONIZED);
} else if (sourceObj instanceof BlockSnapshot || !(storageSystem.deviceIsType(Type.vmax) || storageSystem.deviceIsType(Type.hds) || storageSystem.deviceIsType(Type.vnxblock))) {
Workflow.Method detachMethod = detachFullCopyMethod(storage, asList(uri));
workflow.createStep(FULL_COPY_DETACH_STEP_GROUP, "Detaching full copy", waitForSyncStep, storage, storageSystem.getSystemType(), getClass(), detachMethod, rollbackMethodNullMethod(), null);
} else if (storageSystem.deviceIsType(Type.vnxblock)) {
workflow.createStep(FULL_COPY_FRACTURE_STEP_GROUP, "fracture full copy", waitForSyncStep, storage, storageSystem.getSystemType(), BlockDeviceController.class, fractureCloneMethod(storage, Arrays.asList(uri), isCG), rollbackMethodNullMethod(), null);
} else {
setCloneReplicaStateStep(workflow, storageSystem, asList(uri), waitForSyncStep, ReplicationState.SYNCHRONIZED);
}
}
}
}
String successMsg = String.format("Full copy of %s to %s successful", sourceVolume, fullCopyVolumes);
workflow.executePlan(taskCompleter, successMsg);
} catch (InternalException e) {
_log.error("Failed to create full copy of volume", e);
doFailTask(Volume.class, sourceVolume, taskId, e);
WorkflowStepCompleter.stepFailed(taskId, e);
} catch (Exception e) {
_log.error("Failed to create full copy of volume", e);
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
doFailTask(Volume.class, sourceVolume, taskId, serviceError);
WorkflowStepCompleter.stepFailed(taskId, serviceError);
}
}
use of com.emc.storageos.svcs.errorhandling.model.ServiceError in project coprhd-controller by CoprHD.
the class BlockDeviceController method fractureClone.
public boolean fractureClone(URI storage, List<URI> clone, boolean isCG, String opId) {
_log.info("Fracture clone: {}", clone.get(0));
TaskCompleter completer = null;
try {
StorageSystem storageDevice = _dbClient.queryObject(StorageSystem.class, storage);
WorkflowStepCompleter.stepExecuting(opId);
if (!isCG) {
Volume cloneVol = _dbClient.queryObject(Volume.class, clone.get(0));
completer = new CloneFractureCompleter(clone.get(0), opId);
WorkflowStepCompleter.stepExecuting(opId);
// Synchronous operation
getDevice(storageDevice.getSystemType()).doFractureClone(storageDevice, cloneVol.getAssociatedSourceVolume(), clone.get(0), completer);
} else {
_log.info("Fracture group clone.");
completer = new CloneFractureCompleter(clone, opId);
WorkflowStepCompleter.stepExecuting(opId);
// Synchronous operation
getDevice(storageDevice.getSystemType()).doFractureGroupClone(storageDevice, clone, completer);
}
} catch (Exception e) {
_log.error(String.format("Fracture restore sessions step failed - storage: %s, clone: %s", storage.toString(), clone.toString()));
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
if (completer != null) {
completer.error(_dbClient, serviceError);
}
doFailTask(Volume.class, clone, opId, serviceError);
WorkflowStepCompleter.stepFailed(opId, serviceError);
return false;
}
return true;
}
use of com.emc.storageos.svcs.errorhandling.model.ServiceError in project coprhd-controller by CoprHD.
the class BlockDeviceController method createSingleSnapshot.
@Override
public void createSingleSnapshot(URI storage, List<URI> snapshotList, Boolean createInactive, Boolean readOnly, String opId) throws ControllerException {
WorkflowStepCompleter.stepExecuting(opId);
TaskCompleter completer = null;
try {
StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
completer = new BlockSnapshotCreateCompleter(snapshotList, opId);
getDevice(storageObj.getSystemType()).doCreateSingleSnapshot(storageObj, snapshotList, createInactive, readOnly, completer);
} catch (Exception e) {
if (completer != null) {
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
WorkflowStepCompleter.stepFailed(opId, serviceError);
completer.error(_dbClient, serviceError);
} else {
throw DeviceControllerException.exceptions.createVolumeSnapshotFailed(e);
}
}
}
use of com.emc.storageos.svcs.errorhandling.model.ServiceError in project coprhd-controller by CoprHD.
the class BlockDeviceController method deleteConsistencyGroup.
@Override
public void deleteConsistencyGroup(URI storage, URI consistencyGroup, Boolean markInactive, String opId) throws ControllerException {
_log.info("START delete consistency group");
TaskCompleter wfCompleter = null;
try {
Workflow workflow = _workflowService.getNewWorkflow(this, "deleteReplicationGroupInConsistencyGroup", true, opId);
wfCompleter = new SimpleTaskCompleter(BlockConsistencyGroup.class, consistencyGroup, opId);
StorageSystem system = _dbClient.queryObject(StorageSystem.class, storage);
BlockConsistencyGroup cg = _dbClient.queryObject(BlockConsistencyGroup.class, consistencyGroup);
Set<String> groupNames = BlockConsistencyGroupUtils.getGroupNamesForSystemCG(cg, system);
String stepId = null;
for (String groupName : groupNames) {
Workflow.Method deleteStep = new Workflow.Method("deleteReplicationGroupInConsistencyGroup", storage, consistencyGroup, groupName, false, markInactive, true);
stepId = workflow.createStep("DeleteReplicationGroup", "Deleting replication group", stepId, storage, system.getSystemType(), this.getClass(), deleteStep, rollbackMethodNullMethod(), null);
}
String successMsg = String.format("Successfully deleted replication groups %s", Joiner.on(',').join(groupNames));
workflow.executePlan(wfCompleter, successMsg);
} catch (Exception e) {
if (wfCompleter != null) {
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
wfCompleter.error(_dbClient, serviceError);
}
throw DeviceControllerException.exceptions.deleteConsistencyGroupFailed(e);
}
}
use of com.emc.storageos.svcs.errorhandling.model.ServiceError in project coprhd-controller by CoprHD.
the class BlockDeviceController method activateSnapshot.
@Override
public void activateSnapshot(URI storage, List<URI> snapshotList, String opId) throws ControllerException {
TaskCompleter completer = null;
try {
StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
completer = new BlockSnapshotActivateCompleter(snapshotList, opId);
getDevice(storageObj.getSystemType()).doActivateSnapshot(storageObj, snapshotList, completer);
} catch (Exception e) {
if (completer != null) {
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
completer.error(_dbClient, serviceError);
} else {
throw DeviceControllerException.exceptions.activateVolumeSnapshotFailed(e);
}
}
}
Aggregations