Search in sources :

Example 1 with SmisCommandHelper

use of com.emc.storageos.volumecontroller.impl.smis.SmisCommandHelper in project coprhd-controller by CoprHD.

the class SmisMaskingViewAddVolumeJob method updateStatus.

@Override
public void updateStatus(JobContext jobContext) throws Exception {
    DbClient dbClient = jobContext.getDbClient();
    JobStatus jobStatus = getJobStatus();
    _log.info("Updating status of SmisMaskingViewAddVolumeJob");
    try {
        if (jobStatus == JobStatus.SUCCESS) {
            StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, getStorageSystemURI());
            CimConnection cimConnection = jobContext.getCimConnectionFactory().getConnection(storageSystem);
            List<URI> volumeUriList = new ArrayList<URI>();
            // Now perform RP protection tagging, if required for the
            // objects being added.
            SmisCommandHelper helper = jobContext.getSmisCommandHelper();
            for (VolumeURIHLU volumeUriHlu : _volumeURIHLUs) {
                BlockObject bo = Volume.fetchExportMaskBlockObject(dbClient, volumeUriHlu.getVolumeURI());
                if (bo != null && bo instanceof Volume) {
                    Volume volume = (Volume) bo;
                    if (volume != null && volume.checkForRp()) {
                        List<CIMObjectPath> volumePathList = new ArrayList<CIMObjectPath>();
                        volumePathList.add(helper.getVolumeMember(storageSystem, volume));
                        helper.setRecoverPointTag(storageSystem, volumePathList, true);
                    }
                }
                volumeUriList.add(volumeUriHlu.getVolumeURI());
            }
            // for proper roll back , that is volume removal, if exception is thrown during update
            if (_newCreatedGroup != null) {
                helper.setHostIOLimits(cimConnection.getCimClient(), _newCreatedGroup, _volumeURIHLUs);
            }
            String[] volumeNames = ExportMaskUtils.getBlockObjectAlternateNames(volumeUriList, dbClient);
            CIMObjectPath[] volumes = _cimPath.getVolumePaths(storageSystem, volumeNames);
            _log.info("{} volumes processed for HLU updation", volumes.length);
            // Now set the HLU on the volume URIs, if they haven't been set// by user.
            ExportMaskOperationsHelper.setHLUFromProtocolControllersOnAddVolume(dbClient, cimConnection, _exportMaskURI, _volumeURIHLUs, volumes, getTaskCompleter());
        }
    } catch (WBEMException e) {
        _log.error(String.format("updateHostIOLimits failed - new created group: %s", _newCreatedGroup.toString()), e);
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        getTaskCompleter().error(dbClient, serviceError);
    } catch (Exception e) {
        _log.error("Caught an exception while trying to updateStatus for SmisMaskingViewAddVolumeJob", e);
        setPostProcessingErrorStatus("Encountered an internal error during add volume to masking view job status processing : " + e.getMessage());
    } finally {
        super.updateStatus(jobContext);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) DbClient(com.emc.storageos.db.client.DbClient) ArrayList(java.util.ArrayList) CIMObjectPath(javax.cim.CIMObjectPath) WBEMException(javax.wbem.WBEMException) URI(java.net.URI) WBEMException(javax.wbem.WBEMException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) Volume(com.emc.storageos.db.client.model.Volume) SmisCommandHelper(com.emc.storageos.volumecontroller.impl.smis.SmisCommandHelper) CimConnection(com.emc.storageos.cimadapter.connections.cim.CimConnection) BlockObject(com.emc.storageos.db.client.model.BlockObject) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) VolumeURIHLU(com.emc.storageos.volumecontroller.impl.VolumeURIHLU)

Example 2 with SmisCommandHelper

use of com.emc.storageos.volumecontroller.impl.smis.SmisCommandHelper 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 3 with SmisCommandHelper

use of com.emc.storageos.volumecontroller.impl.smis.SmisCommandHelper in project coprhd-controller by CoprHD.

the class SmisBlockRestoreSnapshotJob method updateStatus.

/**
 * Called to update the job status when the restore snapshot job completes.
 *
 * @param jobContext The job context.
 */
@Override
public void updateStatus(JobContext jobContext) throws Exception {
    _log.info("Updating status of SmisBlockRestoreSnapshotJob");
    DbClient dbClient = jobContext.getDbClient();
    JobStatus jobStatus = getJobStatus();
    URI snapshotId = getTaskCompleter().getId();
    if (jobStatus == JobStatus.SUCCESS && snapshotId != null && URIUtil.isType(snapshotId, BlockSnapshot.class)) {
        BlockSnapshot snapshot = dbClient.queryObject(BlockSnapshot.class, snapshotId);
        if (snapshot != null && !NullColumnValueGetter.isNullNamedURI(snapshot.getParent())) {
            Volume parentVolume = dbClient.queryObject(Volume.class, snapshot.getParent());
            if (parentVolume != null) {
                StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, parentVolume.getStorageController());
                if (parentVolume.checkForRp() && !NullColumnValueGetter.isNullURI(parentVolume.getProtectionController()) && storageSystem.getSystemType() != null && storageSystem.getSystemType().equalsIgnoreCase(DiscoveredDataObject.Type.vmax.toString())) {
                    // Now re-enable the RP tag on the volume. The tag was removed initially to perform the
                    // restore so it must be tagged again now that the restore is complete.
                    SmisCommandHelper helper = jobContext.getSmisCommandHelper();
                    _log.info(String.format("Enabling the RecoverPoint tag on volume %s", parentVolume.getId().toString()));
                    helper.doApplyRecoverPointTag(storageSystem, parentVolume, true);
                }
            }
        }
    }
    super.updateStatus(jobContext);
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) Volume(com.emc.storageos.db.client.model.Volume) SmisCommandHelper(com.emc.storageos.volumecontroller.impl.smis.SmisCommandHelper) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) URI(java.net.URI) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 4 with SmisCommandHelper

use of com.emc.storageos.volumecontroller.impl.smis.SmisCommandHelper in project coprhd-controller by CoprHD.

the class SmisCreateMaskingViewJob method enableRecoverPointTagOn803.

/**
 * Method will set the EMCRecoverPointEnabled flag on all the volumes within 8.0.3 Provider.
 * 8.0.3 Provider doesnt support setting RP tag on Storage Groups.
 *
 * @param dbClient [in] - Client instance for reading/writing from/to DB
 * @param client [in] - WBEMClient used for reading/writing from/to SMI-S
 * @param deviceGroupPath [in] - CIMObjectPath referencing the volume
 */
private void enableRecoverPointTagOn803(DbClient dbClient, WBEMClient client, StorageSystem storage, JobContext jobContext) {
    try {
        boolean isRPTagNeeded = false;
        List<URI> blockObjectUris = new ArrayList<URI>();
        for (VolumeURIHLU volUriHlu : _volumeURIHLUs) {
            URI volumeURI = volUriHlu.getVolumeURI();
            BlockObject bo = null;
            if (URIUtil.isType(volumeURI, BlockSnapshot.class)) {
                bo = dbClient.queryObject(BlockSnapshot.class, volumeURI);
            } else if (URIUtil.isType(volumeURI, Volume.class)) {
                bo = dbClient.queryObject(Volume.class, volumeURI);
            }
            if (bo != null) {
                blockObjectUris.add(bo.getId());
                if (BlockObject.checkForRP(dbClient, bo.getId())) {
                    isRPTagNeeded = true;
                }
            }
        }
        // Do nothing and return from if none of the volumes are RP protected
        if (isRPTagNeeded) {
            SmisCommandHelper helper = jobContext.getSmisCommandHelper();
            helper.setRecoverPointTag(storage, helper.getVolumeMembers(storage, blockObjectUris), true);
        }
    } catch (WBEMException e) {
        _log.error("Encountered an error while trying to set the RecoverPoint tag", e);
    } catch (DatabaseException e) {
        _log.error("Encountered an error while trying to set the RecoverPoint tag", e);
    } catch (Exception e) {
        _log.error("Encountered an error while trying to set the RecoverPoint tag", e);
    }
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) SmisCommandHelper(com.emc.storageos.volumecontroller.impl.smis.SmisCommandHelper) ArrayList(java.util.ArrayList) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) WBEMException(javax.wbem.WBEMException) URI(java.net.URI) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) BlockObject(com.emc.storageos.db.client.model.BlockObject) WBEMException(javax.wbem.WBEMException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) VolumeURIHLU(com.emc.storageos.volumecontroller.impl.VolumeURIHLU)

Example 5 with SmisCommandHelper

use of com.emc.storageos.volumecontroller.impl.smis.SmisCommandHelper in project coprhd-controller by CoprHD.

the class SmisMaskingViewRemoveVolumeJob method updateStatus.

/*
     * (non-Javadoc)
     * 
     * @see com.emc.storageos.volumecontroller.impl.smis.job.SmisJob#updateStatus(com.emc.storageos.volumecontroller.JobContext)
     */
public void updateStatus(JobContext jobContext) throws Exception {
    try {
        JobStatus jobStatus = getJobStatus();
        if (jobStatus == JobStatus.SUCCESS) {
            DbClient dbClient = jobContext.getDbClient();
            SmisCommandHelper helper = jobContext.getSmisCommandHelper();
            StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, getStorageSystemURI());
            _log.info("Updating status of SmisMaskingViewRemoveVolumeJob");
            removeEmptyStorageGroups(helper, storageSystem);
        }
    } catch (Exception e) {
        _log.error("Caught an exception while trying to updateStatus for SmisRemoveMaskingViewJob", e);
        setPostProcessingErrorStatus("Encountered an internal error during masking view remove job status processing : " + e.getMessage());
    } finally {
        super.updateStatus(jobContext);
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) SmisCommandHelper(com.emc.storageos.volumecontroller.impl.smis.SmisCommandHelper) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

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