Search in sources :

Example 61 with CIMProperty

use of javax.cim.CIMProperty in project coprhd-controller by CoprHD.

the class XIVSmisStorageDevicePostProcessor method getProvisionedCapacityInformation.

/*
     * (non-Javadoc) Get provisioned capacity.
     * 
     * @see SmisReplicaCreationJobs#getProvisionedCapacityInformation
     */
private long getProvisionedCapacityInformation(CIMInstance volumeInstance) {
    Long provisionedCapacity = 0L;
    try {
        if (volumeInstance != null) {
            CIMProperty consumableBlocks = volumeInstance.getProperty(IBMSmisConstants.CP_CONSUMABLE_BLOCKS);
            CIMProperty blockSize = volumeInstance.getProperty(IBMSmisConstants.CP_BLOCK_SIZE);
            // calculate provisionedCapacity = consumableBlocks * block size
            provisionedCapacity = Long.valueOf(consumableBlocks.getValue().toString()) * Long.valueOf(blockSize.getValue().toString());
        }
    } catch (Exception e) {
        _log.error("Updating ProvisionedCapacity failed for Volume {}", volumeInstance.getObjectPath(), e);
    }
    return provisionedCapacity;
}
Also used : CIMProperty(javax.cim.CIMProperty) WBEMException(javax.wbem.WBEMException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) IOException(java.io.IOException)

Example 62 with CIMProperty

use of javax.cim.CIMProperty in project coprhd-controller by CoprHD.

the class XIVSmisStorageDevicePostProcessor method processVolumeCreation.

/*
     * (non-Javadoc) Update DB with volume creation output from SMI-S.
     * 
     * @see
     * com.emc.storageos.volumecontroller.impl.smis.job.SmisAbstractCreateVolumeJob
     * #updateStatus
     */
public Set<URI> processVolumeCreation(StorageSystem storageSystem, URI storagePoolURI, List<Volume> volumes, CIMArgument[] outArgs) throws Exception {
    Set<URI> volumeURIs = new HashSet<URI>(volumes.size());
    StringBuilder logMsgBuilder = new StringBuilder(String.format("Processing volume creation"));
    CimConnection connection = _cimConnection.getConnection(storageSystem);
    WBEMClient client = connection.getCimClient();
    Calendar now = Calendar.getInstance();
    StoragePool storagePool = _dbClient.queryObject(StoragePool.class, storagePoolURI);
    updateStoragePoolCapacity(client, storagePool);
    StringMap reservationMap = storagePool.getReservedCapacityMap();
    for (Volume volume : volumes) {
        reservationMap.remove(volume.getId().toString());
    }
    _dbClient.persistObject(storagePool);
    CIMObjectPath[] elements = (CIMObjectPath[]) _cimPath.getFromOutputArgs(outArgs, IBMSmisConstants.CP_THE_ELEMENTS);
    UnsignedInteger32[] returnCoedes = (UnsignedInteger32[]) _cimPath.getFromOutputArgs(outArgs, IBMSmisConstants.CP_RETURN_CODES);
    List<Volume> volumesToSave = new ArrayList<Volume>(elements.length);
    if (elements != null && returnCoedes != null) {
        for (int i = 0; i < elements.length; i++) {
            URI volumeId = volumes.get(i).getId();
            Volume volume = _dbClient.queryObject(Volume.class, volumeId);
            volumesToSave.add(volume);
            volumeURIs.add(volumeId);
            boolean isSuccess = false;
            CIMObjectPath volumePath = elements[i];
            if (volumePath != null) {
                CIMProperty<String> deviceID = (CIMProperty<String>) volumePath.getKey(IBMSmisConstants.CP_DEVICE_ID);
                if (deviceID != null) {
                    String nativeID = deviceID.getValue();
                    if ((nativeID != null) && (nativeID.length() != 0)) {
                        isSuccess = true;
                        volume.setPool(storagePoolURI);
                        processVolume(volumePath, nativeID, volume, client, logMsgBuilder, now);
                    }
                }
            }
            if (!isSuccess) {
                logMsgBuilder.append("\n");
                logMsgBuilder.append(String.format("Failed to create volume: %s with return code: %s", volumeId, returnCoedes[i].toString()));
                volume.setInactive(true);
            }
        }
    }
    if (!volumesToSave.isEmpty()) {
        _dbClient.persistObject(volumesToSave);
    }
    _log.info(logMsgBuilder.toString());
    return volumeURIs;
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap) StoragePool(com.emc.storageos.db.client.model.StoragePool) Calendar(java.util.Calendar) CIMObjectPath(javax.cim.CIMObjectPath) UnsignedInteger32(javax.cim.UnsignedInteger32) ArrayList(java.util.ArrayList) URI(java.net.URI) Volume(com.emc.storageos.db.client.model.Volume) CIMProperty(javax.cim.CIMProperty) CimConnection(com.emc.storageos.cimadapter.connections.cim.CimConnection) WBEMClient(javax.wbem.client.WBEMClient) HashSet(java.util.HashSet)

Example 63 with CIMProperty

use of javax.cim.CIMProperty 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)

Example 64 with CIMProperty

use of javax.cim.CIMProperty in project coprhd-controller by CoprHD.

the class AbstractCIMObjectPathFactory method getMaskingGroupName.

/**
 * This method extracts the group name from the group path.
 *
 * @param storageDevice The reference to storage device
 * @param groupPath storage group path
 * @return the group name
 */
public String getMaskingGroupName(StorageSystem storageDevice, CIMObjectPath groupPath) {
    String groupName = null;
    CIMProperty<?>[] keys = groupPath.getKeys();
    for (CIMProperty key : keys) {
        if (key.getName().equals(CP_INSTANCE_ID)) {
            String groupNameProperty = key.getValue().toString();
            int lastDelimIndex = 0;
            if (storageDevice.getUsingSmis80()) {
                lastDelimIndex = groupNameProperty.lastIndexOf(Constants.SMIS80_DELIMITER);
                // For V3 provider example:
                // if groupNameProperty = SYMMETRIX-+-000196700567-+-stdummyhost3_567_SG_BRONZE_DSS_SRP_1
                // substring will get stdummyhost3_567_SG_BRONZE_DSS_SRP_1 as a groupName
                groupName = groupNameProperty.substring(lastDelimIndex + 3);
            } else {
                lastDelimIndex = groupNameProperty.lastIndexOf(Constants.PLUS);
                // For V2 provider example:
                // if groupNameProperty = SYMMETRIX+000195701505+stdummyhost3_505_SG_GOLD
                // substring will get stdummyhost3_505_SG_GOLD as a groupName
                groupName = groupNameProperty.substring(lastDelimIndex + 1);
            }
        }
    }
    return groupName;
}
Also used : CIMProperty(javax.cim.CIMProperty)

Example 65 with CIMProperty

use of javax.cim.CIMProperty in project coprhd-controller by CoprHD.

the class AbstractSnapshotOperations method deactivateSnapshot.

/**
 * Method for deactivating a single snapshot instance. To be used as a common utility.
 *
 * @param storage [required] - StorageSystem object representing the array
 * @param snapshot [required] - BlockSnapshot URI representing the previously created
 *            snap for the volume
 * @param syncObjectPath [required] - The CIMObjectPath representing the block snapshot's
 *            SE_Synchronization object.
 * @throws Exception
 */
protected void deactivateSnapshot(StorageSystem storage, BlockSnapshot snapshot, CIMObjectPath syncObjectPath) throws Exception {
    CIMInstance syncObject = _helper.getInstance(storage, syncObjectPath, false, false, new String[] { SmisConstants.EMC_COPY_STATE_DESC });
    String value = syncObject.getProperty(SmisConstants.EMC_COPY_STATE_DESC).getValue().toString();
    _log.info(String.format("Attempting to deactivate snapshot %s, EMCCopyStateDesc = %s", syncObjectPath.toString(), value));
    if (value.equalsIgnoreCase(SmisConstants.ACTIVE)) {
        CIMArgument[] outArgs = new CIMArgument[5];
        _helper.callModifyReplica(storage, _helper.getDeactivateSnapshotSynchronousInputArguments(syncObjectPath), outArgs);
        CIMProperty<CIMObjectPath> settingsData = (CIMProperty<CIMObjectPath>) _cimPath.getCimObjectPathFromOutputArgs(outArgs, SmisConstants.CP_SETTINGS_STATE).getKey(SmisConstants.CP_SETTING_DATA);
        String settingsInstance = settingsData.getValue().getKey(SmisConstants.CP_INSTANCE_ID).getValue().toString();
        snapshot.setSettingsInstance(settingsInstance);
        _dbClient.persistObject(snapshot);
    }
}
Also used : CIMProperty(javax.cim.CIMProperty) CIMObjectPath(javax.cim.CIMObjectPath) CIMInstance(javax.cim.CIMInstance) CIMArgument(javax.cim.CIMArgument)

Aggregations

CIMProperty (javax.cim.CIMProperty)74 CIMObjectPath (javax.cim.CIMObjectPath)57 CIMInstance (javax.cim.CIMInstance)37 ArrayList (java.util.ArrayList)26 WBEMException (javax.wbem.WBEMException)25 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)18 CIMArgument (javax.cim.CIMArgument)16 WBEMClient (javax.wbem.client.WBEMClient)14 IOException (java.io.IOException)11 Volume (com.emc.storageos.db.client.model.Volume)10 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)10 URI (java.net.URI)9 ServiceCodeException (com.emc.storageos.svcs.errorhandling.resources.ServiceCodeException)8 UnsignedInteger16 (javax.cim.UnsignedInteger16)8 DbClient (com.emc.storageos.db.client.DbClient)7 SmisException (com.emc.storageos.volumecontroller.impl.smis.SmisException)7 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)6 HashMap (java.util.HashMap)6 ExportMask (com.emc.storageos.db.client.model.ExportMask)5 Initiator (com.emc.storageos.db.client.model.Initiator)5