use of com.emc.storageos.svcs.errorhandling.model.ServiceCoded in project coprhd-controller by CoprHD.
the class BlockDeviceController method linkNewTargetVolumesToSnapshotSession.
/**
* {@inheritDoc}
*/
@Override
public void linkNewTargetVolumesToSnapshotSession(URI systemURI, URI snapSessionURI, List<List<URI>> snapshotURIs, String copyMode, String opId) throws InternalException {
TaskCompleter completer = new BlockSnapshotSessionLinkTargetsWorkflowCompleter(snapSessionURI, snapshotURIs, opId);
try {
// Get a new workflow to execute the linking of the target volumes
// to the new session.
Workflow workflow = _workflowService.getNewWorkflow(this, LINK_SNAPSHOT_SESSION_TARGETS_WF_NAME, false, opId);
_log.info("Created new workflow to create and link new targets for snapshot session {} with operation id {}", snapSessionURI, opId);
if (checkSnapshotSessionConsistencyGroup(snapSessionURI, _dbClient, completer)) {
String waitFor = null;
for (List<URI> snapshotURI : snapshotURIs) {
waitFor = workflow.createStep(LINK_SNAPSHOT_SESSION_TARGET_STEP_GROUP, String.format("Linking target for snapshot session %s", snapSessionURI), waitFor, systemURI, getDeviceType(systemURI), getClass(), linkBlockSnapshotSessionTargetGroupMethod(systemURI, snapSessionURI, snapshotURI, copyMode, Boolean.FALSE), null, null);
}
} else {
for (List<URI> snapshotURI : snapshotURIs) {
workflow.createStep(LINK_SNAPSHOT_SESSION_TARGET_STEP_GROUP, String.format("Linking target for snapshot session %s", snapSessionURI), null, systemURI, getDeviceType(systemURI), getClass(), linkBlockSnapshotSessionTargetMethod(systemURI, snapSessionURI, snapshotURI.get(0), copyMode, Boolean.FALSE), rollbackLinkBlockSnapshotSessionTargetMethod(systemURI, snapSessionURI, snapshotURI.get(0)), null);
}
}
workflow.executePlan(completer, "Create and link new target volumes for block snapshot session successful");
} catch (Exception e) {
_log.error("Create and link new target volumes for block snapshot session failed", e);
ServiceCoded serviceException = DeviceControllerException.exceptions.linkBlockSnapshotSessionTargetsFailed(e);
completer.error(_dbClient, serviceException);
}
}
use of com.emc.storageos.svcs.errorhandling.model.ServiceCoded in project coprhd-controller by CoprHD.
the class BlockDeviceController method unlinkTargetsFromSnapshotSession.
/**
* {@inheritDoc}
*/
@Override
public void unlinkTargetsFromSnapshotSession(URI systemURI, URI snapSessionURI, Map<URI, Boolean> snapshotDeletionMap, OperationTypeEnum opType, String opId) {
TaskCompleter completer = new BlockSnapshotSessionUnlinkTargetsWorkflowCompleter(snapSessionURI, opType, opId);
try {
// Get a new workflow to unlinking of the targets from session.
Workflow workflow = _workflowService.getNewWorkflow(this, UNLINK_SNAPSHOT_SESSION_TARGETS_WF_NAME, false, opId);
_log.info("Created new workflow to unlink targets for snapshot session {} with operation id {}", snapSessionURI, opId);
Set<URI> targetKeys = snapshotDeletionMap.keySet();
BlockSnapshotSession snapSession = _dbClient.queryObject(BlockSnapshotSession.class, snapSessionURI);
// For CG's, ensure 1 target per ReplicationGroup
if (snapSession.hasConsistencyGroup() && NullColumnValueGetter.isNotNullValue(snapSession.getReplicationGroupInstance())) {
Iterator<BlockSnapshot> snapshots = _dbClient.queryIterativeObjects(BlockSnapshot.class, snapshotDeletionMap.keySet());
final Set<String> replicationGroups = new HashSet<>();
final Map<URI, BlockSnapshot> uriToSnapshotCache = new HashMap<>();
while (snapshots.hasNext()) {
BlockSnapshot snapshot = snapshots.next();
uriToSnapshotCache.put(snapshot.getId(), snapshot);
}
Map<URI, Boolean> filtered = Maps.filterEntries(snapshotDeletionMap, new Predicate<Map.Entry<URI, Boolean>>() {
@Override
public boolean apply(Map.Entry<URI, Boolean> input) {
BlockSnapshot blockSnapshot = uriToSnapshotCache.get(input.getKey());
String repGrpInstance = blockSnapshot.getReplicationGroupInstance();
if (replicationGroups.contains(repGrpInstance)) {
return false;
}
replicationGroups.add(repGrpInstance);
return true;
}
});
// assign to targetKeys filtered keySet view of snapshotDeletionMap.
targetKeys = filtered.keySet();
}
// TODO Use ModifyListSettingsDefineState here and remove the for-loop.
String waitFor = null;
// Create a workflow step to unlink each target specified in targetKeys
for (URI snapshotURI : targetKeys) {
waitFor = workflow.createStep(UNLINK_SNAPSHOT_SESSION_TARGET_STEP_GROUP, String.format("Unlinking target for snapshot session %s", snapSessionURI), waitFor, systemURI, getDeviceType(systemURI), getClass(), unlinkBlockSnapshotSessionTargetMethod(systemURI, snapSessionURI, snapshotURI, snapshotDeletionMap.get(snapshotURI)), null, null);
}
// Execute the workflow.
workflow.executePlan(completer, "Unlink block snapshot session targets successful");
} catch (Exception e) {
_log.error("Unlink block snapshot session targets failed", e);
ServiceCoded serviceException = DeviceControllerException.exceptions.unlinkBlockSnapshotSessionTargetsFailed(e);
completer.error(_dbClient, serviceException);
}
}
use of com.emc.storageos.svcs.errorhandling.model.ServiceCoded in project coprhd-controller by CoprHD.
the class FileDeviceController method checkIfMountExistsOnHost.
public void checkIfMountExistsOnHost(URI fsId, String opId) {
try {
WorkflowStepCompleter.stepExecuting(opId);
ContainmentConstraint containmentConstraint = ContainmentConstraint.Factory.getFileMountsConstraint(fsId);
List<FileMountInfo> fsDBMounts = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, FileMountInfo.class, containmentConstraint);
FileShare fs = _dbClient.queryObject(FileShare.class, fsId);
for (FileMountInfo fsMount : fsDBMounts) {
LinuxMountUtils mountUtils = new LinuxMountUtils(_dbClient.queryObject(Host.class, fsMount.getHostId()));
ExportRule export = FileOperationUtils.findExport(fs, fsMount.getSubDirectory(), fsMount.getSecurityType(), _dbClient);
if (mountUtils.verifyMountPoints(export.getMountPoint(), fsMount.getMountPath())) {
String errMsg = new String("delete file system from ViPR database failed because mounts exist for file system " + fs.getLabel() + " and once deleted the mounts cannot be ingested into ViPR");
final ServiceCoded serviceCoded = DeviceControllerException.errors.jobFailedOpMsg(OperationTypeEnum.DELETE_FILE_SYSTEM.toString(), errMsg);
WorkflowStepCompleter.stepFailed(opId, serviceCoded);
}
}
for (FileMountInfo fsMount : fsDBMounts) {
fsMount.setInactive(true);
}
_dbClient.updateObject(fsDBMounts);
WorkflowStepCompleter.stepSucceded(opId);
} catch (ControllerException ex) {
WorkflowStepCompleter.stepFailed(opId, ex);
_log.error("Couldn't verify dependencies: ", fsId);
throw ex;
}
}
use of com.emc.storageos.svcs.errorhandling.model.ServiceCoded in project coprhd-controller by CoprHD.
the class FileDeviceController method updateTaskStatus.
private void updateTaskStatus(String opId, DataObject fsObj, Exception e) {
final ServiceCoded serviceCoded;
if ((opId == null) || (fsObj == null)) {
return;
}
if (e instanceof ServiceCoded) {
serviceCoded = (ServiceCoded) e;
} else {
serviceCoded = DeviceControllerException.errors.jobFailed(e);
}
final BiosCommandResult result = BiosCommandResult.createErrorResult(serviceCoded);
fsObj.getOpStatus().updateTaskStatus(opId, result.toOperation());
_dbClient.updateObject(fsObj);
_log.debug("updateTaskStatus:afterUpdate:" + fsObj.getOpStatus().get(opId));
}
Aggregations