Search in sources :

Example 1 with LDEV

use of com.emc.storageos.hds.model.LDEV 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 LDEV

use of com.emc.storageos.hds.model.LDEV in project coprhd-controller by CoprHD.

the class HDSVolumeDiscoverer method getLabelFromLogicalUnit.

/**
 * return the label of the LDEV if user is set else return null.
 *
 * @param logicalUnit
 * @return
 */
private String getLabelFromLogicalUnit(LogicalUnit logicalUnit) {
    String ldevLabel = null;
    if (null != logicalUnit.getLdevList()) {
        Iterator<LDEV> ldevItr = logicalUnit.getLdevList().iterator();
        if (ldevItr.hasNext()) {
            LDEV ldev = ldevItr.next();
            ObjectLabel label = ldev.getLabel();
            if (null != label) {
                ldevLabel = label.getLabel();
            }
        }
    }
    return ldevLabel;
}
Also used : ObjectLabel(com.emc.storageos.hds.model.ObjectLabel) LDEV(com.emc.storageos.hds.model.LDEV)

Example 3 with LDEV

use of com.emc.storageos.hds.model.LDEV in project coprhd-controller by CoprHD.

the class HDSVolumeDiscoverer method fetchLogicalUnitTieringPolicy.

/**
 * Iterate through the logicalUnit LDEV and find the tierLevel of the volume.
 *
 * @param logicalUnit
 * @return
 */
private String fetchLogicalUnitTieringPolicy(StorageSystem system, LogicalUnit logicalUnit, DbClient dbClient) {
    String tieringPolicyName = null;
    if (logicalUnit.getDpType().equals(HDSConstants.DPTYPE_THIN)) {
        if (null != logicalUnit.getLdevList()) {
            Iterator<LDEV> ldevItr = logicalUnit.getLdevList().iterator();
            if (ldevItr.hasNext()) {
                LDEV ldev = ldevItr.next();
                URIQueryResultList tieringPolicyList = new URIQueryResultList();
                if (-1 != ldev.getTierLevel()) {
                    tieringPolicyName = HitachiTieringPolicy.getType(String.valueOf(ldev.getTierLevel())).replaceAll(HDSConstants.UNDERSCORE_OPERATOR, HDSConstants.SLASH_OPERATOR);
                }
            }
        }
    }
    return tieringPolicyName;
}
Also used : LDEV(com.emc.storageos.hds.model.LDEV) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 4 with LDEV

use of com.emc.storageos.hds.model.LDEV in project coprhd-controller by CoprHD.

the class HDSApiVolumeManager method constructAddLUSEQuery.

private String constructAddLUSEQuery(String systemId, String metaHead, List<String> ldevIds) {
    Map<String, Object> attributeMap = new HashMap<String, Object>();
    List<LDEV> ldevsList = new LinkedList<LDEV>();
    StorageArray storageArray = new StorageArray(systemId);
    attributeMap.put(HDSConstants.STORAGEARRAY, storageArray);
    Add addOp = new Add(HDSConstants.LUSE_TARGET, true);
    attributeMap.put(HDSConstants.ADD, addOp);
    if (null != ldevIds && !ldevIds.isEmpty()) {
        LDEV metaHeadLDEV = new LDEV(metaHead);
        ldevsList.add(metaHeadLDEV);
        for (String ldevId : ldevIds) {
            LDEV metaMemberLDEV = new LDEV(ldevId);
            ldevsList.add(metaMemberLDEV);
        }
    }
    attributeMap.put("LDEV_List", ldevsList);
    String addLUSEVolumeInputXML = InputXMLGenerationClient.getInputXMLString(HDSConstants.ADD_LUSE_VOLUME_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
    return addLUSEVolumeInputXML;
}
Also used : Add(com.emc.storageos.hds.model.Add) HashMap(java.util.HashMap) LDEV(com.emc.storageos.hds.model.LDEV) LinkedList(java.util.LinkedList) StorageArray(com.emc.storageos.hds.model.StorageArray)

Example 5 with LDEV

use of com.emc.storageos.hds.model.LDEV in project coprhd-controller by CoprHD.

the class HDSApiVolumeManager method modifyThinVolumeTieringPolicy.

public String modifyThinVolumeTieringPolicy(String systemObjectID, String luObjectID, String ldevObjectID, String tieringPolicyName, String model) {
    InputStream responseStream = null;
    String asyncTaskMessageId = null;
    Map<String, Object> attributeMap = new HashMap<String, Object>();
    Modify modifyOp = new Modify(HDSConstants.VIRTUALVOLUME);
    StorageArray array = new StorageArray(systemObjectID);
    LogicalUnit logicalUnit = new LogicalUnit();
    logicalUnit.setObjectID(luObjectID);
    LDEV ldev = new LDEV(ldevObjectID);
    ldev.setTierLevel(Integer.parseInt(tieringPolicyName));
    attributeMap.put(HDSConstants.STORAGEARRAY, array);
    attributeMap.put(HDSConstants.MODIFY, modifyOp);
    attributeMap.put(HDSConstants.MODEL, model);
    attributeMap.put(HDSConstants.LOGICALUNIT, logicalUnit);
    attributeMap.put(HDSConstants.LDEV, ldev);
    String modifyThinVolumeTieringPolicyPayload = InputXMLGenerationClient.getInputXMLString(HDSConstants.MODIFY_THIN_VOLUME_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
    URI endpointURI = hdsApiClient.getBaseURI();
    log.info("Modify Volume TieringPolicy payload:{}", modifyThinVolumeTieringPolicyPayload);
    ClientResponse response = hdsApiClient.post(endpointURI, modifyThinVolumeTieringPolicyPayload);
    if (HttpStatus.SC_OK == response.getStatus()) {
        responseStream = response.getEntityInputStream();
        JavaResult result = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.SMOOKS_CONFIG_FILE);
        EchoCommand command = result.getBean(EchoCommand.class);
        log.info("command Status :{} MessageId :{}", command.getStatus(), command.getMessageID());
        if (HDSConstants.PROCESSING_STR.equalsIgnoreCase(command.getStatus()) || HDSConstants.COMPLETED_STR.equalsIgnoreCase(command.getStatus())) {
            asyncTaskMessageId = command.getMessageID();
        } else if (HDSConstants.FAILED_STR.equalsIgnoreCase(command.getStatus())) {
            Error error = result.getBean(Error.class);
            log.error("Modify Volume TieringPolicy failed status messageID: {}", command.getMessageID());
            log.error("Modify Volume TieringPolicy failed with error code: {} with message: {}", error.getCode(), error.getDescription());
            throw HDSException.exceptions.notAbleToCreateVolume(error.getCode(), error.getDescription());
        }
    } else {
        log.error("Modify Volume TieringPolicy failed with invalid response code {}", response.getStatus());
        throw HDSException.exceptions.invalidResponseFromHDS(String.format("Modify Volume TieringPolicy failed due to invalid response %1$s from server for system %2$s", response.getStatus(), systemObjectID));
    }
    return asyncTaskMessageId;
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) HashMap(java.util.HashMap) InputStream(java.io.InputStream) LogicalUnit(com.emc.storageos.hds.model.LogicalUnit) Error(com.emc.storageos.hds.model.Error) Modify(com.emc.storageos.hds.model.Modify) LDEV(com.emc.storageos.hds.model.LDEV) URI(java.net.URI) JavaResult(org.milyn.payload.JavaResult) EchoCommand(com.emc.storageos.hds.model.EchoCommand) StorageArray(com.emc.storageos.hds.model.StorageArray)

Aggregations

LDEV (com.emc.storageos.hds.model.LDEV)10 LogicalUnit (com.emc.storageos.hds.model.LogicalUnit)7 Volume (com.emc.storageos.db.client.model.Volume)4 HDSApiClient (com.emc.storageos.hds.api.HDSApiClient)3 ObjectLabel (com.emc.storageos.hds.model.ObjectLabel)3 HDSJob (com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSJob)3 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)2 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)2 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)2 HDSException (com.emc.storageos.hds.HDSException)2 StorageArray (com.emc.storageos.hds.model.StorageArray)2 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)2 HDSModifyVolumeJob (com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSModifyVolumeJob)2 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)2 URI (java.net.URI)2 HashMap (java.util.HashMap)2 DbClient (com.emc.storageos.db.client.DbClient)1 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)1 TenantOrg (com.emc.storageos.db.client.model.TenantOrg)1 Add (com.emc.storageos.hds.model.Add)1