use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.MultiVolumeTaskCompleter in project coprhd-controller by CoprHD.
the class BlockDeviceController method createVolumes.
/**
* {@inheritDoc} NOTE NOTE: The signature here MUST match the Workflow.Method createVolumesMethod just above (except
* opId).
*/
@Override
public void createVolumes(URI systemURI, URI poolURI, List<URI> volumeURIs, VirtualPoolCapabilityValuesWrapper capabilities, String opId) throws ControllerException {
List<Volume> volumes = new ArrayList<Volume>();
try {
StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, systemURI);
List<VolumeTaskCompleter> volumeCompleters = new ArrayList<VolumeTaskCompleter>();
Iterator<URI> volumeURIsIter = volumeURIs.iterator();
StringBuilder logMsgBuilder = new StringBuilder(String.format("createVolumes start - Array:%s Pool:%s", systemURI.toString(), poolURI.toString()));
while (volumeURIsIter.hasNext()) {
URI volumeURI = volumeURIsIter.next();
logMsgBuilder.append(String.format("%nVolume:%s", volumeURI.toString()));
Volume volume = _dbClient.queryObject(Volume.class, volumeURI);
volumes.add(volume);
VolumeCreateCompleter volumeCompleter = new VolumeCreateCompleter(volumeURI, opId);
volumeCompleters.add(volumeCompleter);
}
_log.info(logMsgBuilder.toString());
StoragePool storagePool = _dbClient.queryObject(StoragePool.class, poolURI);
MultiVolumeTaskCompleter completer = new MultiVolumeTaskCompleter(volumeURIs, volumeCompleters, opId);
WorkflowStepCompleter.stepExecuting(completer.getOpId());
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_005);
getDevice(storageSystem.getSystemType()).doCreateVolumes(storageSystem, storagePool, opId, volumes, capabilities, completer);
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_006);
logMsgBuilder = new StringBuilder(String.format("createVolumes end - Array:%s Pool:%s", systemURI.toString(), poolURI.toString()));
volumeURIsIter = volumeURIs.iterator();
while (volumeURIsIter.hasNext()) {
logMsgBuilder.append(String.format("%nVolume:%s", volumeURIsIter.next().toString()));
}
_log.info(logMsgBuilder.toString());
} catch (Exception e) {
_log.error(String.format("createVolume Failed - Array: %s Pool:%s Volume:%s", systemURI.toString(), poolURI.toString(), Joiner.on("\t").join(volumeURIs)), e);
Workflow workflow = WorkflowService.getInstance().getWorkflowFromStepId(opId);
if (workflow != null) {
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
doFailTask(Volume.class, volumeURIs, opId, serviceError);
WorkflowStepCompleter.stepFailed(opId, serviceError);
_dbClient.markForDeletion(volumes);
} else {
_log.info("Workflow is null which means that the workflow has already completed. Not performing any error handling");
}
}
}
use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.MultiVolumeTaskCompleter in project coprhd-controller by CoprHD.
the class BlockDeviceController method untagVolumes.
/**
* Performs an untag operation on all volumes.
*
* @param systemURI
* Underlying system to perform the untag operation on
* @param volumeURIs
* Volumes to untag
* @param opId
* The opId
* @throws ControllerException
*/
public void untagVolumes(URI systemURI, List<URI> volumeURIs, String opId) throws ControllerException {
try {
StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, systemURI);
List<Volume> volumes = new ArrayList<Volume>();
List<VolumeTaskCompleter> volumeCompleters = new ArrayList<VolumeTaskCompleter>();
Iterator<URI> volumeURIsIter = volumeURIs.iterator();
String arrayName = systemURI.toString();
StringBuilder entryLogMsgBuilder = new StringBuilder(String.format("untagVolume start - Array:%s", arrayName));
StringBuilder exitLogMsgBuilder = new StringBuilder(String.format("untagVolume end - Array:%s", arrayName));
while (volumeURIsIter.hasNext()) {
URI volumeURI = volumeURIsIter.next();
Volume volume = _dbClient.queryObject(Volume.class, volumeURI);
if (volume != null) {
entryLogMsgBuilder.append(String.format("%nUntag operation: Volume: [%s](%s)", volume.getLabel(), volumeURI.toString()));
exitLogMsgBuilder.append(String.format("%nUntag operation: Volume: [%s](%s)", volume.getLabel(), volumeURI.toString()));
if (!volume.getInactive()) {
volumes.add(volume);
} else {
// Nothing to do for an inactive volume
continue;
}
// Generic completer is fine here
VolumeWorkflowCompleter volumeCompleter = new VolumeWorkflowCompleter(volumeURI, opId);
volumeCompleters.add(volumeCompleter);
}
}
_log.info(entryLogMsgBuilder.toString());
if (!volumes.isEmpty()) {
WorkflowStepCompleter.stepExecuting(opId);
TaskCompleter completer = new MultiVolumeTaskCompleter(volumeURIs, volumeCompleters, opId);
getDevice(storageSystem.getSystemType()).doUntagVolumes(storageSystem, opId, volumes, completer);
}
doSuccessTask(Volume.class, volumeURIs, opId);
WorkflowStepCompleter.stepSucceded(opId);
_log.info(exitLogMsgBuilder.toString());
} catch (InternalException e) {
doFailTask(Volume.class, volumeURIs, opId, e);
WorkflowStepCompleter.stepFailed(opId, e);
} catch (Exception e) {
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
doFailTask(Volume.class, volumeURIs, opId, serviceError);
WorkflowStepCompleter.stepFailed(opId, DeviceControllerException.exceptions.unexpectedCondition(e.getMessage()));
}
}
Aggregations