Search in sources :

Example 86 with StringMap

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());
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap) StoragePool(com.emc.storageos.db.client.model.StoragePool) Volume(com.emc.storageos.db.client.model.Volume) CimConnection(com.emc.storageos.cimadapter.connections.cim.CimConnection) CIMObjectPath(javax.cim.CIMObjectPath) UnsignedInteger32(javax.cim.UnsignedInteger32) WBEMClient(javax.wbem.client.WBEMClient) CIMInstance(javax.cim.CIMInstance)

Example 87 with StringMap

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);
    }
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap) DbClient(com.emc.storageos.db.client.DbClient) StoragePool(com.emc.storageos.db.client.model.StoragePool) VolumeExpandCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeExpandCompleter) CIMObjectPath(javax.cim.CIMObjectPath) URI(java.net.URI) CIMInstance(javax.cim.CIMInstance) CIMConnectionFactory(com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory) Volume(com.emc.storageos.db.client.model.Volume) CIMProperty(javax.cim.CIMProperty) SmisCommandHelper(com.emc.storageos.volumecontroller.impl.smis.SmisCommandHelper) WBEMClient(javax.wbem.client.WBEMClient) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 88 with StringMap

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();
        }
    }
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap) DbClient(com.emc.storageos.db.client.DbClient) StoragePool(com.emc.storageos.db.client.model.StoragePool) Calendar(java.util.Calendar) CIMObjectPath(javax.cim.CIMObjectPath) ArrayList(java.util.ArrayList) URI(java.net.URI) WBEMException(javax.wbem.WBEMException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) IOException(java.io.IOException) CIMConnectionFactory(com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory) CIMProperty(javax.cim.CIMProperty) Volume(com.emc.storageos.db.client.model.Volume) WBEMClient(javax.wbem.client.WBEMClient)

Example 89 with StringMap

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");
    }
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap) DbClient(com.emc.storageos.db.client.DbClient) StoragePool(com.emc.storageos.db.client.model.StoragePool) CloneCreateCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneCreateCompleter) CIMObjectPath(javax.cim.CIMObjectPath) URI(java.net.URI) CIMInstance(javax.cim.CIMInstance) CIMConnectionFactory(com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory) Volume(com.emc.storageos.db.client.model.Volume) WBEMClient(javax.wbem.client.WBEMClient)

Example 90 with StringMap

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);
        }
    }
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap)

Aggregations

StringMap (com.emc.storageos.db.client.model.StringMap)257 URI (java.net.URI)108 ArrayList (java.util.ArrayList)90 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)59 StringSet (com.emc.storageos.db.client.model.StringSet)57 HashMap (java.util.HashMap)57 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)48 ExportMask (com.emc.storageos.db.client.model.ExportMask)43 Volume (com.emc.storageos.db.client.model.Volume)42 NamedURI (com.emc.storageos.db.client.model.NamedURI)41 StoragePool (com.emc.storageos.db.client.model.StoragePool)39 Initiator (com.emc.storageos.db.client.model.Initiator)38 List (java.util.List)34 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)33 VirtualArray (com.emc.storageos.db.client.model.VirtualArray)31 HashSet (java.util.HashSet)30 Project (com.emc.storageos.db.client.model.Project)24 StoragePort (com.emc.storageos.db.client.model.StoragePort)23 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)22 Network (com.emc.storageos.db.client.model.Network)21