use of com.emc.storageos.volumecontroller.impl.smis.SmisCommandHelper in project coprhd-controller by CoprHD.
the class SmisAbstractCreateVolumeJob method processVolume.
/**
* Processes a newly created volume.
*
* @param jobContext The job context.
* @param volumePath The CIM object path for the volume.
* @param nativeID The native volume identifier.
* @param volumeId The Bourne volume id.
* @param client The CIM client.
* @param dbClient the database client.
* @param logMsgBuilder Holds a log message.
* @param creationTime Holds the date-time for the volume creation
* @throws java.io.IOException When an error occurs querying the database.
* @throws WorkflowException
*/
private void processVolume(JobContext jobContext, CIMObjectPath volumePath, String nativeID, URI volumeId, WBEMClient client, DbClient dbClient, StringBuilder logMsgBuilder, Calendar creationTime) throws Exception, IOException, DeviceControllerException, WBEMException {
Volume volume = dbClient.queryObject(Volume.class, volumeId);
// Honor that the job failed and do not commit the volume, which would make it active again.
if (volume.getInactive()) {
if (logMsgBuilder.length() != 0) {
logMsgBuilder.append("\n");
}
logMsgBuilder.append(String.format("Create volume job failed and volume set to inactive. Volume was likely created successfully and will be left on the array for ingestion. NativeId: %s, URI: %s", nativeID, getTaskCompleter().getId()));
return;
}
CIMInstance volumeInstance = commonVolumeUpdate(dbClient, client, volume, volumePath);
URI storageSystemURI = volume.getStorageController();
StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, storageSystemURI);
if (volume.getIsComposite() && _cimPath != null) {
// need to set meta volume member size (required for volume expansion).
// this call is context dependent --- this is why we check for cimPath be set.
// first, get meta members list;
// second, get second member and get its size (the first member is a head and it will show size of meta
// volume itself);
// third, set this size as meta volume size in vipr volume
ArrayList<CIMArgument> list = new ArrayList<CIMArgument>();
CIMArgument<CIMObjectPath> volumeReference = new CIMArgument<CIMObjectPath>(SmisConstants.CP_THE_ELEMENT, CIMDataType.getDataType(volumePath), volumePath);
// set request type to "children"
CIMArgument<UnsignedInteger16> requestType = new CIMArgument<UnsignedInteger16>("RequestType", CIMDataType.UINT16_T, new UnsignedInteger16(2));
list.add(volumeReference);
list.add(requestType);
CIMArgument[] inArgs = {};
inArgs = list.toArray(inArgs);
CIMArgument[] outArgs = new CIMArgument[5];
CIMObjectPath elementCompositionServicePath = _cimPath.getElementCompositionSvcPath(storageSystem);
SmisCommandHelper helper = jobContext.getSmisCommandHelper();
StorageSystem forProvider = helper.getStorageSystemForProvider(storageSystem, volume);
helper.invokeMethod(forProvider, elementCompositionServicePath, "GetCompositeElements", inArgs, outArgs);
// get member volumes from output
CIMObjectPath[] metaMembersPaths = (CIMObjectPath[]) _cimPath.getFromOutputArgs(outArgs, "OutElements");
// get meta member size. use second member --- the first member will show size of meta volume itself.
CIMObjectPath metaMemberPath = metaMembersPaths[1];
CIMInstance cimVolume = helper.getInstance(forProvider, metaMemberPath, false, false, new String[] { SmisConstants.CP_CONSUMABLE_BLOCKS, SmisConstants.CP_BLOCK_SIZE });
CIMProperty consumableBlocks = cimVolume.getProperty(SmisConstants.CP_CONSUMABLE_BLOCKS);
CIMProperty blockSize = cimVolume.getProperty(SmisConstants.CP_BLOCK_SIZE);
// calculate size = consumableBlocks * block size
Long size = Long.valueOf(consumableBlocks.getValue().toString()) * Long.valueOf(blockSize.getValue().toString());
// set member size for meta volume (required for volume expansion)
volume.setMetaMemberSize(size);
_log.info(String.format("Meta member info: blocks --- %s, block size --- %s, size --- %s .", consumableBlocks.getValue().toString(), blockSize.getValue().toString(), size));
}
specificProcessing(storageSystem, dbClient, client, volume, volumeInstance, volumePath);
dbClient.updateObject(volume);
if (logMsgBuilder.length() != 0) {
logMsgBuilder.append("\n");
}
logMsgBuilder.append(String.format("Created volume successfully .. NativeId: %s, URI: %s", nativeID, getTaskCompleter().getId()));
}
Aggregations