use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeExpandCompleter in project coprhd-controller by CoprHD.
the class BlockDeviceController method expandVolume.
@Override
public void expandVolume(URI storage, URI pool, URI volume, Long size, String opId) throws ControllerException {
try {
StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
Volume volumeObj = _dbClient.queryObject(Volume.class, volume);
_log.info(String.format("expandVolume start - Array: %s Pool:%s Volume:%s, IsMetaVolume: %s, OldSize: %s, NewSize: %s", storage.toString(), pool.toString(), volume.toString(), volumeObj.getIsComposite(), volumeObj.getCapacity(), size));
StoragePool poolObj = _dbClient.queryObject(StoragePool.class, pool);
VolumeExpandCompleter completer = new VolumeExpandCompleter(volume, size, opId);
long metaMemberSize = volumeObj.getIsComposite() ? volumeObj.getMetaMemberSize() : volumeObj.getCapacity();
long metaCapacity = volumeObj.getIsComposite() ? volumeObj.getTotalMetaMemberCapacity() : volumeObj.getCapacity();
VirtualPool vpool = _dbClient.queryObject(VirtualPool.class, volumeObj.getVirtualPool());
boolean isThinlyProvisioned = volumeObj.getThinlyProvisioned();
MetaVolumeRecommendation recommendation = MetaVolumeUtils.getExpandRecommendation(storageObj, poolObj, metaCapacity, size, metaMemberSize, isThinlyProvisioned, vpool.getFastExpansion());
if (recommendation.isCreateMetaVolumes()) {
// Also check that this is not recovery to clean dangling meta volumes with zero-capacity expansion.
if (recommendation.getMetaMemberCount() == 0 && (volumeObj.getMetaVolumeMembers() == null || volumeObj.getMetaVolumeMembers().isEmpty())) {
volumeObj.setCapacity(size);
_dbClient.updateObject(volumeObj);
_log.info(String.format("Expanded volume within its total meta volume capacity (simple case) - Array: %s Pool:%s Volume:%s, IsMetaVolume: %s, Total meta volume capacity: %s, NewSize: %s", storage.toString(), pool.toString(), volume.toString(), volumeObj.getIsComposite(), volumeObj.getTotalMetaMemberCapacity(), volumeObj.getCapacity()));
completer.ready(_dbClient);
} else {
// set meta related data in task completer
long metaMemberCount = volumeObj.getIsComposite() ? recommendation.getMetaMemberCount() + volumeObj.getMetaMemberCount() : recommendation.getMetaMemberCount() + 1;
completer.setMetaMemberSize(recommendation.getMetaMemberSize());
completer.setMetaMemberCount((int) metaMemberCount);
completer.setTotalMetaMembersSize(metaMemberCount * recommendation.getMetaMemberSize());
completer.setComposite(true);
completer.setMetaVolumeType(recommendation.getMetaVolumeType().toString());
getDevice(storageObj.getSystemType()).doExpandAsMetaVolume(storageObj, poolObj, volumeObj, size, recommendation, completer);
}
} else {
// expand as regular volume
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_080);
getDevice(storageObj.getSystemType()).doExpandVolume(storageObj, poolObj, volumeObj, size, completer);
}
_log.info(String.format("expandVolume end - Array: %s Pool:%s Volume:%s", storage.toString(), pool.toString(), volume.toString()));
} catch (Exception e) {
_log.error(String.format("expandVolume Failed - Array: %s Pool:%s Volume:%s", storage.toString(), pool.toString(), volume.toString()), e);
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
List<URI> volumes = Arrays.asList(volume);
doFailTask(Volume.class, volumes, opId, serviceError);
WorkflowStepCompleter.stepFailed(opId, serviceError);
}
}
use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeExpandCompleter in project coprhd-controller by CoprHD.
the class HDSVolumeExpandJob method updateStatus.
/**
* Called to update the job status when the volume expand job completes.
*
* @param jobContext
* The job context.
*/
@Override
public void updateStatus(JobContext jobContext) throws Exception {
LogicalUnit logicalUnit = null;
try {
if (_status == JobStatus.IN_PROGRESS) {
return;
}
DbClient dbClient = jobContext.getDbClient();
StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, getStorageSystemURI());
HDSApiClient hdsApiClient = jobContext.getHdsApiFactory().getClient(HDSUtils.getHDSServerManagementServerInfo(storageSystem), storageSystem.getSmisUserName(), storageSystem.getSmisPassword());
// from pool's reserved capacity map.
if (_status == JobStatus.SUCCESS || _status == JobStatus.FAILED) {
StoragePool storagePool = dbClient.queryObject(StoragePool.class, storagePoolURI);
HDSUtils.updateStoragePoolCapacity(dbClient, hdsApiClient, storagePool);
StringMap reservationMap = storagePool.getReservedCapacityMap();
URI volumeId = getTaskCompleter().getId();
// remove from reservation map
reservationMap.remove(volumeId.toString());
dbClient.persistObject(storagePool);
}
String opId = getTaskCompleter().getOpId();
StringBuilder logMsgBuilder = new StringBuilder(String.format("Updating status of job %s to %s, task: %s", this.getJobName(), _status.name(), opId));
if (_status == JobStatus.SUCCESS) {
VolumeExpandCompleter taskCompleter = (VolumeExpandCompleter) getTaskCompleter();
Volume volume = dbClient.queryObject(Volume.class, taskCompleter.getId());
// set requested capacity
volume.setCapacity(taskCompleter.getSize());
// set meta related properties
volume.setIsComposite(taskCompleter.isComposite());
volume.setCompositionType(taskCompleter.getMetaVolumeType());
logicalUnit = (LogicalUnit) _javaResult.getBean("logicalunit");
if (null != logicalUnit) {
long capacityInBytes = (Long.valueOf(logicalUnit.getCapacityInKB())) * 1024L;
volume.setProvisionedCapacity(capacityInBytes);
volume.setAllocatedCapacity(capacityInBytes);
}
logMsgBuilder.append(String.format("%n Capacity: %s, Provisioned capacity: %s, Allocated Capacity: %s", volume.getCapacity(), volume.getProvisionedCapacity(), volume.getAllocatedCapacity()));
if (volume.getIsComposite()) {
logMsgBuilder.append(String.format("%n Is Meta: %s, Total meta member capacity: %s, Meta member count %s, Meta member size: %s", volume.getIsComposite(), volume.getTotalMetaMemberCapacity(), volume.getMetaMemberCount(), volume.getMetaMemberSize()));
}
_log.info(logMsgBuilder.toString());
dbClient.persistObject(volume);
// Reset list of meta members native ids in WF data (when meta
// is created meta members are removed from array)
WorkflowService.getInstance().storeStepData(opId, new ArrayList<String>());
}
} catch (Exception e) {
_log.error("Caught an exception while trying to updateStatus for HDSVolumeExpandJob", e);
setErrorStatus("Encountered an internal error during volume expand job status processing : " + e.getMessage());
} finally {
super.updateStatus(jobContext);
}
}
use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeExpandCompleter in project coprhd-controller by CoprHD.
the class CinderVolumeExpandJob method updateStatus.
@Override
public void updateStatus(JobContext jobContext) throws Exception {
DbClient dbClient = jobContext.getDbClient();
try {
// Do nothing if the job is not completed yet
if (status == JobStatus.IN_PROGRESS) {
return;
}
String opId = getTaskCompleter().getOpId();
_logger.info(String.format("Updating status of job %s to %s", opId, status.name()));
StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, getStorageSystemURI());
CinderApi cinderApi = jobContext.getCinderApiFactory().getApi(storageSystem.getActiveProviderURI(), getEndPointInfo());
URI volumeId = getTaskCompleter().getId();
// If terminal state update storage pool capacity and remove reservation for volume capacity
// from pool's reserved capacity map.
StoragePool storagePool = null;
if (status == JobStatus.SUCCESS || status == JobStatus.FAILED) {
storagePool = dbClient.queryObject(StoragePool.class, storagePoolUri);
StringMap reservationMap = storagePool.getReservedCapacityMap();
// remove from reservation map
reservationMap.remove(volumeId.toString());
dbClient.persistObject(storagePool);
}
if (status == JobStatus.SUCCESS) {
VolumeExpandCompleter taskCompleter = (VolumeExpandCompleter) getTaskCompleter();
Volume volume = dbClient.queryObject(Volume.class, taskCompleter.getId());
long oldCapacity = volume.getCapacity();
long newCapacity = taskCompleter.getSize();
// set requested capacity
volume.setCapacity(newCapacity / CinderConstants.BYTES_TO_GB);
volume.setProvisionedCapacity(taskCompleter.getSize());
volume.setAllocatedCapacity(taskCompleter.getSize());
dbClient.persistObject(volume);
long increasedCapacity = newCapacity - oldCapacity;
CinderUtils.updateStoragePoolCapacity(dbClient, cinderApi, storagePool, String.valueOf(increasedCapacity / CinderConstants.BYTES_TO_GB), false);
}
} catch (Exception e) {
_logger.error("Caught an exception while trying to updateStatus for CinderExpandVolumeJob", e);
setErrorStatus("Encountered an internal error during expand volume job status processing : " + e.getMessage());
} finally {
super.updateStatus(jobContext);
}
}
use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeExpandCompleter in project coprhd-controller by CoprHD.
the class SmisVolumeExpandJob method updateStatus.
/**
* Called to update the job status when the volume expand job completes.
*
* @param jobContext The job context.
*/
public void updateStatus(JobContext jobContext) throws Exception {
CloseableIterator<CIMObjectPath> associatorIterator = null;
CloseableIterator<CIMInstance> instanceIterator = null;
JobStatus jobStatus = getJobStatus();
try {
if (jobStatus == JobStatus.IN_PROGRESS) {
return;
}
DbClient dbClient = jobContext.getDbClient();
CIMConnectionFactory cimConnectionFactory = jobContext.getCimConnectionFactory();
WBEMClient client = getWBEMClient(dbClient, cimConnectionFactory);
// from pool's reserved capacity map.
if (jobStatus == JobStatus.SUCCESS || jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
SmisUtils.updateStoragePoolCapacity(dbClient, client, _storagePoolURI);
StoragePool pool = dbClient.queryObject(StoragePool.class, _storagePoolURI);
StringMap reservationMap = pool.getReservedCapacityMap();
URI volumeId = getTaskCompleter().getId();
// remove from reservation map
reservationMap.remove(volumeId.toString());
dbClient.persistObject(pool);
}
String opId = getTaskCompleter().getOpId();
StringBuilder logMsgBuilder = new StringBuilder(String.format("Updating status of job %s to %s, task: %s", this.getJobName(), jobStatus.name(), opId));
if (jobStatus == JobStatus.SUCCESS) {
VolumeExpandCompleter taskCompleter = (VolumeExpandCompleter) getTaskCompleter();
Volume volume = dbClient.queryObject(Volume.class, taskCompleter.getId());
// set requested capacity
volume.setCapacity(taskCompleter.getSize());
// set meta related properties
volume.setTotalMetaMemberCapacity(taskCompleter.getTotalMetaMembersSize());
volume.setMetaMemberCount(taskCompleter.getMetaMemberCount());
volume.setMetaMemberSize(taskCompleter.getMetaMemberSize());
volume.setIsComposite(taskCompleter.isComposite());
volume.setCompositionType(taskCompleter.getMetaVolumeType());
// set provisioned capacity
associatorIterator = client.associatorNames(getCimJob(), null, SmisConstants.CIM_STORAGE_VOLUME, null, null);
if (associatorIterator.hasNext()) {
CIMObjectPath volumePath = associatorIterator.next();
CIMInstance volumeInstance = client.getInstance(volumePath, true, false, null);
if (volumeInstance != null) {
CIMProperty consumableBlocks = volumeInstance.getProperty(SmisConstants.CP_CONSUMABLE_BLOCKS);
CIMProperty blockSize = volumeInstance.getProperty(SmisConstants.CP_BLOCK_SIZE);
// calculate provisionedCapacity = consumableBlocks * block size
Long provisionedCapacity = Long.valueOf(consumableBlocks.getValue().toString()) * Long.valueOf(blockSize.getValue().toString());
volume.setProvisionedCapacity(provisionedCapacity);
}
// set allocated capacity
instanceIterator = client.referenceInstances(volumePath, SmisConstants.CIM_ALLOCATED_FROM_STORAGEPOOL, null, false, SmisConstants.PS_SPACE_CONSUMED);
if (instanceIterator.hasNext()) {
CIMInstance allocatedFromStoragePoolPath = instanceIterator.next();
CIMProperty spaceConsumed = allocatedFromStoragePoolPath.getProperty(SmisConstants.CP_SPACE_CONSUMED);
if (null != spaceConsumed) {
volume.setAllocatedCapacity(Long.valueOf(spaceConsumed.getValue().toString()));
}
}
}
logMsgBuilder.append(String.format("%n Capacity: %s, Provisioned capacity: %s, Allocated Capacity: %s", volume.getCapacity(), volume.getProvisionedCapacity(), volume.getAllocatedCapacity()));
if (volume.getIsComposite()) {
logMsgBuilder.append(String.format("%n Is Meta: %s, Total meta member capacity: %s, Meta member count %s, Meta member size: %s", volume.getIsComposite(), volume.getTotalMetaMemberCapacity(), volume.getMetaMemberCount(), volume.getMetaMemberSize()));
}
_log.info(logMsgBuilder.toString());
// Reset list of meta member volumes in the volume
if (volume.getMetaVolumeMembers() != null) {
volume.getMetaVolumeMembers().clear();
}
StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, volume.getStorageController());
// set the RP tag on the volume if the volume is RP protected
if (volume.checkForRp()) {
SmisCommandHelper helper = jobContext.getSmisCommandHelper();
boolean tagSet = helper.doApplyRecoverPointTag(storageSystem, volume, true);
if (!tagSet) {
_log.error("Encountered an error while trying to enable the RecoverPoint tag.");
jobStatus = JobStatus.FAILED;
}
}
dbClient.persistObject(volume);
// Reset list of meta members native ids in WF data (when meta is created meta members are removed from array)
WorkflowService.getInstance().storeStepData(opId, new ArrayList<String>());
}
} catch (Exception e) {
_log.error("Caught an exception while trying to updateStatus for SmisVolumeExpandJob", e);
setPostProcessingErrorStatus("Encountered an internal error during volume expand job status processing : " + e.getMessage());
} finally {
_metaVolumeTaskCompleter.setLastStepStatus(jobStatus);
if (associatorIterator != null) {
associatorIterator.close();
}
if (instanceIterator != null) {
instanceIterator.close();
}
super.updateStatus(jobContext);
}
}
use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeExpandCompleter 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
}
}
Aggregations