Search in sources :

Example 1 with HDSModifyVolumeJob

use of com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSModifyVolumeJob in project coprhd-controller by CoprHD.

the class HDSStorageDevice method doModifyVolumes.

@Override
public void doModifyVolumes(StorageSystem storage, StoragePool storagePool, String opId, List<Volume> volumes, TaskCompleter taskCompleter) throws DeviceControllerException {
    StringBuilder logMsgBuilder = new StringBuilder(String.format("Modify Volume Start - Array:%s, Pool:%s", storage.getSerialNumber(), storagePool.getNativeGuid()));
    String systemObjectID = HDSUtils.getSystemObjectID(storage);
    for (Volume volume : volumes) {
        try {
            HDSApiClient hdsApiClient = hdsApiFactory.getClient(HDSUtils.getHDSServerManagementServerInfo(storage), storage.getSmisUserName(), storage.getSmisPassword());
            logMsgBuilder.append(String.format("%nVolume:%s , IsThinlyProvisioned: %s, tieringPolicy: %s", volume.getLabel(), volume.getThinlyProvisioned(), volume.getAutoTieringPolicyUri()));
            LogicalUnit logicalUnit = hdsApiClient.getLogicalUnitInfo(systemObjectID, HDSUtils.getLogicalUnitObjectId(volume.getNativeId(), storage));
            String policyName = ControllerUtils.getAutoTieringPolicyName(volume.getId(), dbClient);
            String autoTierPolicyName = null;
            if (policyName.equals(Constants.NONE)) {
                autoTierPolicyName = null;
            } else {
                autoTierPolicyName = HitachiTieringPolicy.getPolicy(policyName.replaceAll(HDSConstants.SLASH_OPERATOR, HDSConstants.UNDERSCORE_OPERATOR)).getKey();
            }
            if (null != logicalUnit && null != logicalUnit.getLdevList() && !logicalUnit.getLdevList().isEmpty()) {
                Iterator<LDEV> ldevItr = logicalUnit.getLdevList().iterator();
                if (ldevItr.hasNext()) {
                    LDEV ldev = ldevItr.next();
                    String asyncMessageId = hdsApiClient.modifyThinVolumeTieringPolicy(systemObjectID, logicalUnit.getObjectID(), ldev.getObjectID(), autoTierPolicyName, storage.getModel());
                    if (null != asyncMessageId) {
                        HDSJob modifyHDSJob = new HDSModifyVolumeJob(asyncMessageId, volume.getStorageController(), taskCompleter, HDSModifyVolumeJob.VOLUME_MODIFY_JOB);
                        ControllerServiceImpl.enqueueJob(new QueueJob(modifyHDSJob));
                    } else {
                        throw HDSException.exceptions.asyncTaskFailed("Unable to get async taskId from HiCommand Device Manager for the modify volume call");
                    }
                }
            } else {
                String errorMsg = String.format("No LDEV's found for volume: %s", volume.getId());
                log.info(errorMsg);
                ServiceError serviceError = DeviceControllerErrors.hds.methodFailed("doModifyVolumes", errorMsg);
                taskCompleter.error(dbClient, serviceError);
            }
        } catch (final Exception e) {
            log.error("Problem in doModifyVolumes: ", e);
            ServiceError serviceError = DeviceControllerErrors.hds.methodFailed("doModifyVolumes", e.getMessage());
            taskCompleter.error(dbClient, serviceError);
        }
    }
}
Also used : HDSModifyVolumeJob(com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSModifyVolumeJob) HDSApiClient(com.emc.storageos.hds.api.HDSApiClient) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) HDSJob(com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSJob) Volume(com.emc.storageos.db.client.model.Volume) LogicalUnit(com.emc.storageos.hds.model.LogicalUnit) LDEV(com.emc.storageos.hds.model.LDEV) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) HDSException(com.emc.storageos.hds.HDSException)

Example 2 with HDSModifyVolumeJob

use of com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSModifyVolumeJob in project coprhd-controller by CoprHD.

the class HDSExportOperations method updateStorageGroupPolicyAndLimits.

@Override
public void updateStorageGroupPolicyAndLimits(StorageSystem storage, ExportMask exportMask, List<URI> volumeURIs, VirtualPool newVirtualPool, boolean rollback, TaskCompleter taskCompleter) throws Exception {
    String message = rollback ? ("updateAutoTieringPolicy" + "(rollback)") : ("updateAutoTieringPolicy");
    log.info("{} {} START...", storage.getSerialNumber(), message);
    log.info("{} : volumeURIs: {}", message, volumeURIs);
    try {
        String newPolicyName = ControllerUtils.getFastPolicyNameFromVirtualPool(dbClient, storage, newVirtualPool);
        log.info("{} : AutoTieringPolicy: {}", message, newPolicyName);
        List<Volume> volumes = dbClient.queryObject(Volume.class, volumeURIs);
        HDSApiClient hdsApiClient = hdsApiFactory.getClient(HDSUtils.getHDSServerManagementServerInfo(storage), storage.getSmisUserName(), storage.getSmisPassword());
        String systemObjectID = HDSUtils.getSystemObjectID(storage);
        for (Volume volume : volumes) {
            String luObjectId = HDSUtils.getLogicalUnitObjectId(volume.getNativeId(), storage);
            LogicalUnit logicalUnit = hdsApiClient.getLogicalUnitInfo(systemObjectID, luObjectId);
            if (null != logicalUnit && null != logicalUnit.getLdevList() && !logicalUnit.getLdevList().isEmpty()) {
                Iterator<LDEV> ldevItr = logicalUnit.getLdevList().iterator();
                if (ldevItr.hasNext()) {
                    LDEV ldev = ldevItr.next();
                    hdsApiClient.getLogicalUnitInfo(systemObjectID, luObjectId);
                    String tieringPolicyName = ControllerUtils.getAutoTieringPolicyName(volume.getId(), dbClient);
                    String policId = HitachiTieringPolicy.getPolicy(tieringPolicyName.replaceAll(HDSConstants.SLASH_OPERATOR, HDSConstants.UNDERSCORE_OPERATOR)).getKey();
                    String asyncMessageId = hdsApiClient.modifyThinVolumeTieringPolicy(systemObjectID, luObjectId, ldev.getObjectID(), policId, storage.getModel());
                    if (null != asyncMessageId) {
                        HDSJob modifyHDSJob = new HDSModifyVolumeJob(asyncMessageId, volume.getStorageController(), taskCompleter, HDSModifyVolumeJob.VOLUME_VPOOL_CHANGE_JOB);
                        ControllerServiceImpl.enqueueJob(new QueueJob(modifyHDSJob));
                    } else {
                        throw HDSException.exceptions.asyncTaskFailed("Unable to get async taskId from HiCommand Device Manager for the modify volume call");
                    }
                }
            }
        }
    } catch (Exception e) {
        String errMsg = String.format("An error occurred while updating Auto-tiering policy for Volumes %s", volumeURIs);
        log.error(errMsg, e);
        ServiceError serviceError = DeviceControllerException.errors.jobFailedMsg(e.getMessage(), e);
        taskCompleter.error(dbClient, serviceError);
    }
    log.info("{} {} updateAutoTieringPolicy END...", storage.getSerialNumber(), message);
}
Also used : HDSModifyVolumeJob(com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSModifyVolumeJob) HDSApiClient(com.emc.storageos.hds.api.HDSApiClient) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) HDSJob(com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSJob) Volume(com.emc.storageos.db.client.model.Volume) LogicalUnit(com.emc.storageos.hds.model.LogicalUnit) LDEV(com.emc.storageos.hds.model.LDEV) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) HDSException(com.emc.storageos.hds.HDSException)

Aggregations

Volume (com.emc.storageos.db.client.model.Volume)2 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)2 HDSException (com.emc.storageos.hds.HDSException)2 HDSApiClient (com.emc.storageos.hds.api.HDSApiClient)2 LDEV (com.emc.storageos.hds.model.LDEV)2 LogicalUnit (com.emc.storageos.hds.model.LogicalUnit)2 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)2 HDSJob (com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSJob)2 HDSModifyVolumeJob (com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSModifyVolumeJob)2 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)2 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)1 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)1