use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.MultiVolumeTaskCompleter in project coprhd-controller by CoprHD.
the class XIVSmisStorageDevicePostProcessor method processVolumeDeletion.
/**
* Update DB with SMI-S output, also set task completer status.
*/
public List<Volume> processVolumeDeletion(StorageSystem storageSystem, List<Volume> volumes, CIMArgument[] outArgs, MultiVolumeTaskCompleter multiVolumeTaskCompleter) throws Exception {
CimConnection connection = _cimConnection.getConnection(storageSystem);
WBEMClient client = connection.getCimClient();
List<Volume> volumesToProcess = new ArrayList<Volume>();
for (Volume vol : volumes) {
Volume volume = _dbClient.queryObject(Volume.class, vol.getId());
volumesToProcess.add(volume);
StoragePool storagePool = _dbClient.queryObject(StoragePool.class, volume.getPool());
updateStoragePoolCapacity(client, storagePool);
}
StringBuilder logMsgBuilder = new StringBuilder();
UnsignedInteger32[] returnCoedes = (UnsignedInteger32[]) _cimPath.getFromOutputArgs(outArgs, IBMSmisConstants.CP_RETURN_CODES);
List<Volume> volumesToSave = new ArrayList<Volume>(returnCoedes.length);
for (int i = 0; i < returnCoedes.length; i++) {
Volume volume = volumesToProcess.get(i);
VolumeTaskCompleter deleteTaskCompleter = multiVolumeTaskCompleter.skipTaskCompleter(volume.getId());
if (returnCoedes[i].longValue() == 0L) {
volume.setInactive(true);
volume.setConsistencyGroup(NullColumnValueGetter.getNullURI());
_dbClient.updateAndReindexObject(volume);
deleteTaskCompleter.ready(_dbClient);
if (logMsgBuilder.length() != 0) {
logMsgBuilder.append("\n");
}
logMsgBuilder.append(String.format("Successfully deleted volume %s", volume.getId()));
} else {
// cannot delete volume
String errorMessage = String.format("Failed to delete volume: %s , nativeId: %s with return code: %s", volume.getId(), volume.getNativeId(), returnCoedes[i].toString());
ServiceError error = DeviceControllerErrors.smis.methodFailed("doDeleteVolume", errorMessage);
deleteTaskCompleter.error(_dbClient, error);
if (logMsgBuilder.length() != 0) {
logMsgBuilder.append("\n");
}
logMsgBuilder.append(errorMessage);
}
}
if (logMsgBuilder.length() > 0) {
_log.info(logMsgBuilder.toString());
}
return volumesToSave;
}
use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.MultiVolumeTaskCompleter in project coprhd-controller by CoprHD.
the class BlockStorageDeviceTest method performOperation.
private void performOperation(Operation operation) {
String taskId = UUID.randomUUID().toString();
if (Operation.Create.equals(operation)) {
List<Volume> volumes = createVolumes();
VirtualPoolCapabilityValuesWrapper capabilities = new VirtualPoolCapabilityValuesWrapper();
TaskCompleter taskCompleter = new VolumeCreateCompleter(volumes.get(0).getId(), taskId);
_deviceController.doCreateVolumes(_storageSystem, _storagePool, taskId, volumes, capabilities, taskCompleter);
// TODO - assert vols are created
// update vol labels with real label
} else if (Operation.Expand.equals(operation)) {
List<Volume> volumes = getVolumes(_storageSystem);
Volume volume = volumes.get(0);
StoragePool storagePool = _dbClient.queryObject(StoragePool.class, volume.getPool());
long size = volume.getProvisionedCapacity() * 2;
TaskCompleter taskCompleter = new VolumeExpandCompleter(volume.getId(), size, taskId);
_deviceController.doExpandVolume(_storageSystem, storagePool, volume, size, taskCompleter);
// TODO - assert original vol's size (provisionedCapacity or
// capacity??) are changed
} else if (Operation.Delete.equals(operation)) {
List<Volume> volumes = getVolumes(_storageSystem);
List<URI> ids = new ArrayList<URI>(volumes.size());
List<VolumeTaskCompleter> volumeTaskCompleters = new ArrayList<>(volumes.size());
for (Volume volume : volumes) {
URI uri = volume.getId();
ids.add(uri);
volumeTaskCompleters.add(new VolumeCreateCompleter(uri, taskId));
}
MultiVolumeTaskCompleter multiTaskCompleter = new MultiVolumeTaskCompleter(ids, volumeTaskCompleters, taskId);
_deviceController.doDeleteVolumes(_storageSystem, taskId, volumes, multiTaskCompleter);
// TODO - assert vols are deleted from db
}
}
use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.MultiVolumeTaskCompleter in project coprhd-controller by CoprHD.
the class SmisStorageDevice method doDeleteVolumes.
@Override
public void doDeleteVolumes(final StorageSystem storageSystem, final String opId, final List<Volume> volumes, final TaskCompleter taskCompleter) throws DeviceControllerException {
try {
List<String> volumeNativeIds = new ArrayList<String>();
StringBuilder logMsgBuilder = new StringBuilder(String.format("Delete Volume Start - Array:%s", storageSystem.getSerialNumber()));
MultiVolumeTaskCompleter multiVolumeTaskCompleter = (MultiVolumeTaskCompleter) taskCompleter;
Set<CIMInstance> parkingSLOStorageGroups = new HashSet<>();
Set<Volume> cloneVolumes = new HashSet<Volume>();
_helper.callRefreshSystem(storageSystem, null, false);
Iterator<Volume> volumeItr = volumes.iterator();
Set<String> nativeIdsForParkingSG = new HashSet<String>();
// Flag to indicate whether or not we need to use the EMCForce flag on this operation.
// We currently use this flag when dealing with RP Volumes as they are tagged for RP and the
// operation on these volumes would fail otherwise.
boolean forceFlag = false;
while (volumeItr.hasNext()) {
Volume volume = volumeItr.next();
logMsgBuilder.append(String.format("%nVolume:%s", volume.getLabel()));
// check if the volume is on array, if not, no operation on array side
CIMInstance volumeInstance = _helper.checkExists(storageSystem, _cimPath.getBlockObjectPath(storageSystem, volume), false, false);
if (volumeInstance == null) {
// related volume state (if any) has been deleted. skip processing, if already
// deleted from array.
_log.info(String.format("Volume %s already deleted: ", volume.getNativeId()));
volume.setInactive(true);
_dbClient.updateObject(volume);
// remove the volume from the processing list
volumeItr.remove();
VolumeTaskCompleter deleteTaskCompleter = multiVolumeTaskCompleter.skipTaskCompleter(volume.getId());
deleteTaskCompleter.ready(_dbClient);
continue;
}
nativeIdsForParkingSG.add(volume.getNativeId());
if (!forceFlag) {
forceFlag = ExportUtils.useEMCForceFlag(_dbClient, volume.getId());
}
}
if (storageSystem.checkIfVmax3()) {
parkingSLOStorageGroups = _helper.removeVolumeFromParkingSLOStorageGroup(storageSystem, nativeIdsForParkingSG.toArray(new String[] {}), forceFlag);
_log.info("Done invoking remove volumes from parking SLO storage group");
// delete operation.
if (!parkingSLOStorageGroups.isEmpty()) {
_helper.deleteParkingSLOStorageGroupsIfEmpty(storageSystem, parkingSLOStorageGroups);
}
}
for (Volume volume : volumes) {
if (volume.getConsistencyGroup() != null || NullColumnValueGetter.isNotNullValue(volume.getReplicationGroupInstance())) {
_log.info(String.format("Volume [%s](%s) is a part of CG (%s), extra cleanup operations may be needed.", volume.getLabel(), volume.getId(), volume.getConsistencyGroup()));
// Clean up any group backup snapshots (VNX only), if there are none this step will be skipped.
if (storageSystem.deviceIsType(Type.vnxblock)) {
cleanupAnyGroupBackupSnapshots(storageSystem, volume);
}
// Remove the volume from the backend CG, if it's not actually in a backend CG this step will be skipped.
removeVolumeFromConsistencyGroup(storageSystem, volume);
// Clean up any volume backup snapshots, if there are none this step will be skipped.
cleanupAnyBackupSnapshots(storageSystem, volume);
} else {
// for VMAX3, clean up unlinked snapshot session, which is possible for ingested volume
if (storageSystem.deviceIsType(Type.vnxblock) || storageSystem.checkIfVmax3()) {
cleanupAnyBackupSnapshots(storageSystem, volume);
}
}
if (storageSystem.deviceIsType(Type.vmax)) {
// VMAX2 & VMAX3 - remove volume from Storage Groups if volume is not in any MaskingView
// COP-16705, COP-21770 - Ingested non-exported Volume may be associated with SG outside of ViPR.
_helper.removeVolumeFromStorageGroupsIfVolumeIsNotInAnyMV(storageSystem, volume);
}
_helper.doApplyRecoverPointTag(storageSystem, volume, false);
// Compare the volume labels of the to-be-deleted and existing volumes
/**
* This will fail in the case when the user just changes the label of the
* volume...until we subscribe to indications from the provider, we will live with
* that.
*/
String volToDeleteLabel = volume.getDeviceLabel();
CIMInstance volumeInstance = _helper.checkExists(storageSystem, _cimPath.getBlockObjectPath(storageSystem, volume), false, false);
String volInstanceLabel = CIMPropertyFactory.getPropertyValue(volumeInstance, SmisConstants.CP_ELEMENT_NAME);
if (volToDeleteLabel != null && volInstanceLabel != null && !volToDeleteLabel.equals(volInstanceLabel)) {
// related volume state (if any) has been deleted. skip processing, if already
// deleted from array.
_log.info("VolToDeleteLabel {} : volInstancelabel {}", volToDeleteLabel, volInstanceLabel);
_log.info(String.format("Volume %s already deleted: ", volume.getNativeId()));
volume.setInactive(true);
// clear the associated consistency group from the volume
volume.setConsistencyGroup(NullColumnValueGetter.getNullURI());
_dbClient.updateObject(volume);
VolumeTaskCompleter deleteTaskCompleter = multiVolumeTaskCompleter.skipTaskCompleter(volume.getId());
deleteTaskCompleter.ready(_dbClient);
continue;
}
// dangling meta members as a result of expansion failure (and rollback failure).
if (!storageSystem.checkIfVmax3()) {
boolean cleanupSuccess = cleanupDanglingMetaMembers(storageSystem, volume);
if (!cleanupSuccess) {
// cannot delete volume
String errorMessage = String.format("Failed to delete meta volume: %s , nativeId: %s .\n" + "Could not cleanup dangling meta members.", volume.getId(), volume.getNativeId());
ServiceError error = DeviceControllerErrors.smis.methodFailed("doDeleteVolume", errorMessage);
VolumeTaskCompleter deleteTaskCompleter = multiVolumeTaskCompleter.skipTaskCompleter(volume.getId());
deleteTaskCompleter.error(_dbClient, error);
_log.error(String.format(errorMessage));
continue;
}
}
if (!NullColumnValueGetter.isNullURI(volume.getAssociatedSourceVolume())) {
cloneVolumes.add(volume);
}
volumeNativeIds.add(volume.getNativeId());
}
_log.info(logMsgBuilder.toString());
// execute SMI-S Call , only if any Volumes left for deletion.
if (!multiVolumeTaskCompleter.isVolumeTaskCompletersEmpty()) {
if (!cloneVolumes.isEmpty()) {
processClonesBeforeDeletion(storageSystem, cloneVolumes);
}
CIMObjectPath configSvcPath = _cimPath.getConfigSvcPath(storageSystem);
CIMArgument[] inArgs = _helper.getDeleteVolumesInputArguments(storageSystem, volumeNativeIds.toArray(new String[0]));
CIMArgument[] outArgs = new CIMArgument[5];
String returnElementsMethod;
if (storageSystem.getUsingSmis80()) {
returnElementsMethod = SmisConstants.RETURN_ELEMENTS_TO_STORAGE_POOL;
} else {
returnElementsMethod = SmisConstants.EMC_RETURN_TO_STORAGE_POOL;
}
_helper.invokeMethod(storageSystem, configSvcPath, returnElementsMethod, inArgs, outArgs);
CIMObjectPath job = _cimPath.getCimObjectPathFromOutputArgs(outArgs, SmisConstants.JOB);
if (job != null) {
ControllerServiceImpl.enqueueJob(new QueueJob(new SmisDeleteVolumeJob(job, storageSystem.getId(), taskCompleter)));
}
} else {
// If we are here, there are no volumes to delete, we have
// invoked ready() for the VolumeDeleteCompleter, and told
// the multiVolumeTaskCompleter to skip these completers.
// In this case, the multiVolumeTaskCompleter complete()
// method will not be invoked and the result is that the
// workflow that initiated this delete request will never
// be updated. So, here we just call complete() on the
// multiVolumeTaskCompleter to ensure the workflow status is
// updated.
multiVolumeTaskCompleter.ready(_dbClient);
}
} catch (WBEMException e) {
_log.error("Problem making SMI-S call: ", e);
ServiceError error = DeviceControllerErrors.smis.unableToCallStorageProvider(e.getMessage());
taskCompleter.error(_dbClient, error);
} catch (Exception e) {
_log.error("Problem in doDeleteVolume: ", e);
// Check to see if an Asynchronous job will now handle the task status.
if (!taskCompleter.isAsynchronous()) {
ServiceError error = DeviceControllerErrors.smis.methodFailed("doDeleteVolume", e.getMessage());
taskCompleter.error(_dbClient, error);
}
}
StringBuilder logMsgBuilder = new StringBuilder(String.format("Delete Volume End - Array: %s", storageSystem.getSerialNumber()));
for (Volume volume : volumes) {
logMsgBuilder.append(String.format("%nVolume:%s", volume.getLabel()));
}
_log.info(logMsgBuilder.toString());
}
use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.MultiVolumeTaskCompleter in project coprhd-controller by CoprHD.
the class XIVSmisStorageDevice method doDeleteVolumes.
/*
* (non-Javadoc)
*
* @see
* com.emc.storageos.volumecontroller.BlockStorageDevice#doDeleteVolumes
* (com.emc.storageos.db.client.model.StorageSystem, java.lang.String,
* java.util.List, com.emc.storageos.volumecontroller.TaskCompleter)
*
* Note: assume volumes could be from different consistency groups
*/
@Override
public void doDeleteVolumes(final StorageSystem storageSystem, final String opId, final List<Volume> volumes, final TaskCompleter taskCompleter) throws DeviceControllerException {
try {
List<String> volumeNativeIds = new ArrayList<String>();
StringBuilder logMsgBuilder = new StringBuilder(String.format("Delete Volume Start - Array:%s", storageSystem.getLabel()));
MultiVolumeTaskCompleter multiVolumeTaskCompleter = (MultiVolumeTaskCompleter) taskCompleter;
for (Volume volume : volumes) {
logMsgBuilder.append(String.format("%nVolume:%s", volume.getLabel()));
if (volume.getConsistencyGroup() != null) {
BlockConsistencyGroup cg = _dbClient.queryObject(BlockConsistencyGroup.class, volume.getConsistencyGroup());
if (cg != null && cg.getTypes() != null && cg.getTypes().contains(BlockConsistencyGroup.Types.LOCAL.name())) {
removeVolumeFromConsistencyGroup(storageSystem, cg, volume);
}
}
CIMInstance volumeInstance = _helper.checkExists(storageSystem, volume, false, false);
if (volumeInstance == null) {
// related volume state (if any) has been deleted. skip
// processing, if already
// deleted from array.
_log.info(String.format("Volume %s already deleted: ", volume.getNativeId()));
volume.setInactive(true);
_dbClient.persistObject(volume);
VolumeTaskCompleter deleteTaskCompleter = multiVolumeTaskCompleter.skipTaskCompleter(volume.getId());
deleteTaskCompleter.ready(_dbClient);
continue;
}
// Compare the volume labels of the to-be-deleted and existing
// volumes
/**
* This will fail in the case when the user just changes the
* label of the volume...till we subscribe to indications from
* the provider, we will live with that.
*/
String volToDeleteLabel = volume.getDeviceLabel();
String volInstanceLabel = CIMPropertyFactory.getPropertyValue(volumeInstance, SmisConstants.CP_ELEMENT_NAME);
if (volToDeleteLabel != null && volInstanceLabel != null && !volToDeleteLabel.equals(volInstanceLabel)) {
// related volume state (if any) has been deleted. skip
// processing, if already
// deleted from array.
_log.info("VolToDeleteLabel {} : volInstancelabel {}", volToDeleteLabel, volInstanceLabel);
_log.info(String.format("Volume %s already deleted: ", volume.getNativeId()));
volume.setInactive(true);
// clear the associated consistency groups from the volume
volume.setConsistencyGroup(NullColumnValueGetter.getNullURI());
// TODO - is this needed, or just persistObject? use bulk
// update
_dbClient.updateAndReindexObject(volume);
VolumeTaskCompleter deleteTaskCompleter = multiVolumeTaskCompleter.skipTaskCompleter(volume.getId());
deleteTaskCompleter.ready(_dbClient);
continue;
}
volumeNativeIds.add(volume.getNativeId());
}
_log.info(logMsgBuilder.toString());
// execute SMI-S Call , only if any Volumes left for deletion.
if (!multiVolumeTaskCompleter.isVolumeTaskCompletersEmpty()) {
CIMObjectPath configSvcPath = _cimPath.getConfigSvcPath(storageSystem);
CIMArgument[] inArgs = _helper.getDeleteVolumesInputArguments(storageSystem, volumeNativeIds.toArray(new String[volumeNativeIds.size()]));
CIMArgument[] outArgs = new CIMArgument[5];
_helper.invokeMethod(storageSystem, configSvcPath, SmisConstants.RETURN_ELEMENTS_TO_STORAGE_POOL, inArgs, outArgs);
_smisStorageDevicePostProcessor.processVolumeDeletion(storageSystem, volumes, outArgs, multiVolumeTaskCompleter);
}
// If we are here, there are no more volumes to delete, we have
// invoked ready() for the VolumeDeleteCompleter, and told
// the multiVolumeTaskCompleter to skip these completers.
// In this case, the multiVolumeTaskCompleter complete()
// method will not be invoked and the result is that the
// workflow that initiated this delete request will never
// be updated. So, here we just call complete() on the
// multiVolumeTaskCompleter to ensure the workflow status is
// updated.
multiVolumeTaskCompleter.ready(_dbClient);
} catch (WBEMException e) {
_log.error("Problem making SMI-S call: ", e);
ServiceError error = DeviceControllerErrors.smis.unableToCallStorageProvider(e.getMessage());
taskCompleter.error(_dbClient, error);
} catch (DeviceControllerException e) {
taskCompleter.error(_dbClient, e);
} catch (Exception e) {
_log.error("Problem in doDeleteVolume: ", e);
ServiceError error = DeviceControllerErrors.smis.methodFailed("doDeleteVolume", e.getMessage());
taskCompleter.error(_dbClient, error);
}
StringBuilder logMsgBuilder = new StringBuilder(String.format("Delete Volume End - Array: %s", storageSystem.getLabel()));
for (Volume volume : volumes) {
logMsgBuilder.append(String.format("%nVolume:%s", volume.getLabel()));
}
_log.info(logMsgBuilder.toString());
}
use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.MultiVolumeTaskCompleter in project coprhd-controller by CoprHD.
the class BlockDeviceController method modifyVolumes.
/**
* {@inheritDoc} NOTE NOTE: The signature here MUST match the Workflow.Method modifyVolumesMethod just above (except
* opId).
* Currently this workflow step is used only for Hitachi Thin Volumes modification to update volume tieringPolicy.
* Hitachi allows setting of tieringpolicy at LDEV level, hence We should have a LDEV id of a LogicalUnit.
* But LDEV is only created after we LogicalUnit is created. Hence createVolumes workflow includes creation of LU
* (i.e. LDEV)
* And LDEV modification (to set tieringPolicy.)
*/
@Override
public void modifyVolumes(URI systemURI, URI poolURI, List<URI> volumeURIs, 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("moidfyVolumes 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);
VolumeUpdateCompleter volumeCompleter = new VolumeUpdateCompleter(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());
getDevice(storageSystem.getSystemType()).doModifyVolumes(storageSystem, storagePool, opId, volumes, completer);
logMsgBuilder = new StringBuilder(String.format("modifyVolumes 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 (InternalException e) {
_log.error(String.format("modifyVolumes Failed - Array: %s Pool:%s Volume:%s", systemURI.toString(), poolURI.toString(), Joiner.on("\t").join(volumeURIs)));
doFailTask(Volume.class, volumeURIs, opId, e);
WorkflowStepCompleter.stepFailed(opId, e);
} catch (Exception e) {
_log.error(String.format("modifyVolumes Failed - Array: %s Pool:%s Volume:%s", systemURI.toString(), poolURI.toString(), Joiner.on("\t").join(volumeURIs)));
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
doFailTask(Volume.class, volumeURIs, opId, serviceError);
WorkflowStepCompleter.stepFailed(opId, serviceError);
}
}
Aggregations