Search in sources :

Example 6 with SmisCommandHelper

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()));
}
Also used : ArrayList(java.util.ArrayList) CIMObjectPath(javax.cim.CIMObjectPath) URI(java.net.URI) CIMInstance(javax.cim.CIMInstance) UnsignedInteger16(javax.cim.UnsignedInteger16) Volume(com.emc.storageos.db.client.model.Volume) CIMProperty(javax.cim.CIMProperty) SmisCommandHelper(com.emc.storageos.volumecontroller.impl.smis.SmisCommandHelper) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) CIMArgument(javax.cim.CIMArgument)

Aggregations

SmisCommandHelper (com.emc.storageos.volumecontroller.impl.smis.SmisCommandHelper)6 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)5 Volume (com.emc.storageos.db.client.model.Volume)5 URI (java.net.URI)5 DbClient (com.emc.storageos.db.client.DbClient)4 ArrayList (java.util.ArrayList)3 CIMObjectPath (javax.cim.CIMObjectPath)3 BlockObject (com.emc.storageos.db.client.model.BlockObject)2 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)2 VolumeURIHLU (com.emc.storageos.volumecontroller.impl.VolumeURIHLU)2 CIMInstance (javax.cim.CIMInstance)2 CIMProperty (javax.cim.CIMProperty)2 WBEMException (javax.wbem.WBEMException)2 CimConnection (com.emc.storageos.cimadapter.connections.cim.CimConnection)1 StoragePool (com.emc.storageos.db.client.model.StoragePool)1 StringMap (com.emc.storageos.db.client.model.StringMap)1 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)1 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)1 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)1 VolumeExpandCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeExpandCompleter)1