use of com.emc.storageos.db.client.model.StringMap in project coprhd-controller by CoprHD.
the class XIVSmisStorageDevicePostProcessor method processVolumeExpansion.
/**
* Update DB with SMI-S output.
*/
public void processVolumeExpansion(StorageSystem storageSystem, URI storagePoolURI, URI volumeId, CIMArgument[] outArgs) throws Exception {
StringBuilder logMsgBuilder = new StringBuilder(String.format("Processing volume expansion - "));
CimConnection connection = _cimConnection.getConnection(storageSystem);
WBEMClient client = connection.getCimClient();
StoragePool storagePool = _dbClient.queryObject(StoragePool.class, storagePoolURI);
StringMap reservationMap = storagePool.getReservedCapacityMap();
reservationMap.remove(volumeId.toString());
updateStoragePoolCapacity(client, storagePool);
_dbClient.persistObject(storagePool);
Volume volume = _dbClient.queryObject(Volume.class, volumeId);
CIMObjectPath volumePath = (CIMObjectPath) _cimPath.getFromOutputArgs(outArgs, IBMSmisConstants.CP_THE_ELEMENT);
boolean isSuccess = false;
if (volumePath != null) {
CIMInstance volumeInstance = client.getInstance(volumePath, true, false, null);
if (volumeInstance != null) {
isSuccess = true;
volume.setProvisionedCapacity(getProvisionedCapacityInformation(volumeInstance));
volume.setAllocatedCapacity(getAllocatedCapacityInformation(client, volumeInstance));
_dbClient.persistObject(volume);
logMsgBuilder.append(String.format("%n Capacity: %s, Provisioned capacity: %s, Allocated Capacity: %s", volume.getCapacity(), volume.getProvisionedCapacity(), volume.getAllocatedCapacity()));
}
}
if (!isSuccess) {
UnsignedInteger32 returnCoede = (UnsignedInteger32) _cimPath.getFromOutputArgs(outArgs, IBMSmisConstants.CP_RETURN_CODE);
logMsgBuilder.append("\n");
logMsgBuilder.append(String.format("Failed to expand volume: %s with return code: %s", volume.getId(), returnCoede.toString()));
}
_log.info(logMsgBuilder.toString());
}
use of com.emc.storageos.db.client.model.StringMap 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.db.client.model.StringMap in project coprhd-controller by CoprHD.
the class SmisAbstractCreateVolumeJob method updateStatus.
/**
* Called to update the job status when the volume create job completes.
* <p/>
* This is common update code for volume create operations.
*
* @param jobContext The job context.
*/
@Override
public void updateStatus(JobContext jobContext) throws Exception {
CloseableIterator<CIMObjectPath> iterator = null;
DbClient dbClient = jobContext.getDbClient();
JobStatus jobStatus = getJobStatus();
try {
if (jobStatus == JobStatus.IN_PROGRESS) {
return;
}
int volumeCount = 0;
String opId = getTaskCompleter().getOpId();
StringBuilder logMsgBuilder = new StringBuilder(String.format("Updating status of job %s to %s", opId, jobStatus.name()));
CIMConnectionFactory cimConnectionFactory = jobContext.getCimConnectionFactory();
WBEMClient client = getWBEMClient(dbClient, cimConnectionFactory);
iterator = client.associatorNames(getCimJob(), null, SmisConstants.CIM_STORAGE_VOLUME, null, null);
Calendar now = Calendar.getInstance();
// from pool's reserved capacity map.
if (jobStatus == JobStatus.SUCCESS || jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
SmisUtils.updateStoragePoolCapacity(dbClient, client, _storagePool);
StoragePool pool = dbClient.queryObject(StoragePool.class, _storagePool);
StringMap reservationMap = pool.getReservedCapacityMap();
for (URI volumeId : getTaskCompleter().getIds()) {
// remove from reservation map
reservationMap.remove(volumeId.toString());
}
dbClient.persistObject(pool);
}
if (jobStatus == JobStatus.SUCCESS) {
List<URI> volumes = new ArrayList<URI>();
while (iterator.hasNext()) {
CIMObjectPath volumePath = iterator.next();
CIMProperty<String> deviceID = (CIMProperty<String>) volumePath.getKey(SmisConstants.CP_DEVICE_ID);
String nativeID = deviceID.getValue();
URI volumeId = getTaskCompleter().getId(volumeCount++);
volumes.add(volumeId);
persistVolumeNativeID(dbClient, volumeId, nativeID, now);
processVolume(jobContext, volumePath, nativeID, volumeId, client, dbClient, logMsgBuilder, now);
}
// Add Volumes to Consistency Group (if needed)
addVolumesToConsistencyGroup(jobContext, volumes);
} else if (jobStatus == JobStatus.FAILED) {
if (iterator.hasNext()) {
while (iterator.hasNext()) {
CIMObjectPath volumePath = iterator.next();
CIMProperty<String> deviceID = (CIMProperty<String>) volumePath.getKey(SmisConstants.CP_DEVICE_ID);
String nativeID = deviceID.getValue();
URI volumeId = getTaskCompleter().getId(volumeCount++);
if ((nativeID != null) && (nativeID.length() != 0)) {
persistVolumeNativeID(dbClient, volumeId, nativeID, now);
processVolume(jobContext, volumePath, nativeID, volumeId, client, dbClient, logMsgBuilder, now);
} else {
logMsgBuilder.append("\n");
logMsgBuilder.append(String.format("Task %s failed to create volume: %s", opId, volumeId));
Volume volume = dbClient.queryObject(Volume.class, volumeId);
volume.setInactive(true);
dbClient.persistObject(volume);
}
}
} else {
for (URI id : getTaskCompleter().getIds()) {
logMsgBuilder.append("\n");
logMsgBuilder.append(String.format("Task %s failed to create volume: %s", opId, id.toString()));
Volume volume = dbClient.queryObject(Volume.class, id);
volume.setInactive(true);
dbClient.persistObject(volume);
}
}
}
_log.info(logMsgBuilder.toString());
} catch (Exception e) {
_log.error("Caught an exception while trying to updateStatus for SmisCreateVolumeJob", e);
setPostProcessingErrorStatus("Encountered an internal error during volume create job status processing : " + e.getMessage());
} finally {
super.updateStatus(jobContext);
if (iterator != null) {
iterator.close();
}
}
}
use of com.emc.storageos.db.client.model.StringMap in project coprhd-controller by CoprHD.
the class SmisCloneVolumeJob method updateStatus.
@Override
public void updateStatus(JobContext jobContext) throws Exception {
_log.info("START updateStatus for clone volume");
CloseableIterator<CIMObjectPath> iterator = null;
DbClient dbClient = jobContext.getDbClient();
JobStatus jobStatus = getJobStatus();
try {
CIMConnectionFactory cimConnectionFactory;
WBEMClient client = null;
CloneCreateCompleter completer = (CloneCreateCompleter) getTaskCompleter();
Volume cloneVolume = dbClient.queryObject(Volume.class, completer.getId());
// from pool's reserved capacity map.
if (jobStatus == JobStatus.SUCCESS || jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
cimConnectionFactory = jobContext.getCimConnectionFactory();
client = getWBEMClient(dbClient, cimConnectionFactory);
URI poolURI = cloneVolume.getPool();
SmisUtils.updateStoragePoolCapacity(dbClient, client, poolURI);
StoragePool pool = dbClient.queryObject(StoragePool.class, poolURI);
StringMap reservationMap = pool.getReservedCapacityMap();
// remove from reservation map
reservationMap.remove(cloneVolume.getId().toString());
dbClient.persistObject(pool);
}
if (jobStatus == JobStatus.SUCCESS) {
_log.info("Clone creation success");
iterator = client.associatorNames(getCimJob(), null, SmisConstants.CIM_STORAGE_VOLUME, null, null);
if (iterator.hasNext()) {
CIMObjectPath cloneVolumePath = iterator.next();
CIMInstance syncVolume = client.getInstance(cloneVolumePath, false, false, null);
String deviceId = cloneVolumePath.getKey(SmisConstants.CP_DEVICE_ID).getValue().toString();
String elementName = CIMPropertyFactory.getPropertyValue(syncVolume, SmisConstants.CP_ELEMENT_NAME);
String wwn = CIMPropertyFactory.getPropertyValue(syncVolume, SmisConstants.CP_WWN_NAME);
String alternateName = CIMPropertyFactory.getPropertyValue(syncVolume, SmisConstants.CP_NAME);
cloneVolume.setProvisionedCapacity(getProvisionedCapacityInformation(client, syncVolume));
cloneVolume.setAllocatedCapacity(getAllocatedCapacityInformation(client, syncVolume));
cloneVolume.setWWN(wwn.toUpperCase());
cloneVolume.setAlternateName(alternateName);
cloneVolume.setNativeId(deviceId);
cloneVolume.setDeviceLabel(elementName);
cloneVolume.setNativeGuid(NativeGUIDGenerator.generateNativeGuid(dbClient, cloneVolume));
cloneVolume.setInactive(false);
if (cloneVolume.getSyncActive()) {
cloneVolume.setReplicaState(ReplicationState.CREATED.name());
} else {
cloneVolume.setReplicaState(ReplicationState.INACTIVE.name());
}
dbClient.persistObject(cloneVolume);
}
/*
* for (URI id : completer.getIds()) {
* completer.ready(dbClient);
* }
*/
} else if (jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
String msg = String.format("Failed job to create full copy from %s to %s", cloneVolume.getAssociatedSourceVolume(), cloneVolume.getId());
_log.error(msg);
cloneVolume.setInactive(true);
dbClient.persistObject(cloneVolume);
}
} catch (Exception e) {
String errorMsg = String.format("Encountered an internal error during block create clone job status " + "processing: %s", e.getMessage());
setPostProcessingErrorStatus(errorMsg);
_log.error("Failed to update status for " + getClass().getSimpleName(), e);
} finally {
if (iterator != null) {
iterator.close();
}
super.updateStatus(jobContext);
_log.info("FINISH updateStatus for clone volume");
}
}
use of com.emc.storageos.db.client.model.StringMap in project coprhd-controller by CoprHD.
the class MultipleVmaxMaskForVolumesValidator method checkRequestedVolumesBelongToMask.
private void checkRequestedVolumesBelongToMask() {
StringMap userAddedVolumes = exportMask.getUserAddedVolumes();
if (userAddedVolumes == null) {
return;
}
Collection<String> masKVolumeURIs = userAddedVolumes.values();
Collection<String> reqVolumeURIs = transform(dataObjects, FCTN_VOLUME_URI_TO_STR);
for (String reqVolumeURI : reqVolumeURIs) {
if (!masKVolumeURIs.contains(reqVolumeURI)) {
String msg = format("Requested volume %s does not belong in mask %s", reqVolumeURI, exportMask);
throw new IllegalArgumentException(msg);
}
}
}
Aggregations