Search in sources :

Example 11 with LogicalUnit

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

the class HDSApiVolumeManager method createThinVolumes.

/**
 * Creates the Thin volume with the passed information.
 *
 * @param systemId : represents SystemObjectID.
 * @param arrayGroupId : represents StoragePoolObjectID.
 * @param luCapacityInBytes: Logical Unit Capacity in bytes.
 * @param noOfLus : No. of LU's to created
 * @param volumeName : Logical Unit name.
 * @param formatType : formatType.
 * @param model : model.
 * @return : asyncMessageId
 * @throws Exception
 */
public String createThinVolumes(String systemId, String arrayGroupId, Long luCapacityInBytes, int noOfLus, String volumeName, String formatType, String model) throws Exception {
    Long luCapacityInKB = luCapacityInBytes / 1024;
    InputStream responseStream = null;
    String asyncTaskMessageId = null;
    try {
        Map<String, Object> attributeMap = new HashMap<String, Object>();
        StorageArray storageArray = new StorageArray(systemId);
        Pool arrayGroup = new Pool(null);
        Add addOp = new Add(HDSConstants.VIRTUALVOLUME, noOfLus, null);
        LogicalUnit logicalUnit = new LogicalUnit(arrayGroupId, String.valueOf(luCapacityInKB), volumeName, HDSConstants.EMULATION_OPENV, null);
        attributeMap.put(HDSConstants.STORAGEARRAY, storageArray);
        attributeMap.put(HDSConstants.ARRAY_GROUP, arrayGroup);
        attributeMap.put(HDSConstants.ADD, addOp);
        attributeMap.put(HDSConstants.LOGICALUNIT, logicalUnit);
        attributeMap.put(HDSConstants.MODEL, model);
        String createVolumeInputXML = InputXMLGenerationClient.getInputXMLString(HDSConstants.CREATE_THIN_VOLUMES_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
        log.info("Query to create thin Volume: {}", createVolumeInputXML);
        URI endpointURI = hdsApiClient.getBaseURI();
        ClientResponse response = hdsApiClient.post(endpointURI, createVolumeInputXML);
        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("Thin Volume creation failed status messageID: {}", command.getMessageID());
                log.error("Thin Volume creation failed with error code: {} with message: {}", error.getCode(), error.getDescription());
                throw HDSException.exceptions.notAbleToCreateVolume(error.getCode(), error.getDescription());
            }
        } else {
            log.error("Thin Volume creation failed with invalid response code {}", response.getStatus());
            throw HDSException.exceptions.invalidResponseFromHDS(String.format("Thin Volume creation failed due to invalid response %1$s from server for system %2$s", response.getStatus(), systemId));
        }
    } finally {
        if (null != responseStream) {
            try {
                responseStream.close();
            } catch (IOException e) {
                log.warn("Exception occurred while close thin volume creation response stream");
            }
        }
    }
    return asyncTaskMessageId;
}
Also used : Add(com.emc.storageos.hds.model.Add) 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) IOException(java.io.IOException) URI(java.net.URI) Pool(com.emc.storageos.hds.model.Pool) JavaResult(org.milyn.payload.JavaResult) EchoCommand(com.emc.storageos.hds.model.EchoCommand) StorageArray(com.emc.storageos.hds.model.StorageArray)

Example 12 with LogicalUnit

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

the class HDSApiVolumeManager method deleteThickLogicalUnits.

public String deleteThickLogicalUnits(String systemObjectID, Set<String> logicalUnitIdList, String model) throws Exception {
    InputStream responseStream = null;
    String asyncTaskMessageId = null;
    try {
        // If the LogicalUnits are LUSE, we should release them.
        releaseLUSEVolumesIfPresent(systemObjectID, logicalUnitIdList);
        Map<String, Object> attributeMap = new HashMap<String, Object>();
        StorageArray storageArray = new StorageArray(systemObjectID);
        Delete deleteOp = new Delete(HDSConstants.LOGICALUNIT);
        List<LogicalUnit> luList = new ArrayList<LogicalUnit>();
        for (String logicalUnitId : logicalUnitIdList) {
            LogicalUnit logicalUnit = new LogicalUnit(logicalUnitId, null);
            luList.add(logicalUnit);
        }
        attributeMap.put(HDSConstants.STORAGEARRAY, storageArray);
        attributeMap.put(HDSConstants.DELETE, deleteOp);
        attributeMap.put(HDSConstants.MODEL, model);
        attributeMap.put(HDSConstants.LOGICALUNIT_LIST, luList);
        String deleteVolumesInputXML = InputXMLGenerationClient.getInputXMLString(HDSConstants.DELETE_VOLUMES_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
        log.info("volume delete payload :{}", deleteVolumesInputXML);
        URI endpointURI = hdsApiClient.getBaseURI();
        ClientResponse response = hdsApiClient.post(endpointURI, deleteVolumesInputXML);
        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.info("command failed error code: {}", error.getCode());
                log.info("Command failed: messageID: {} {}", command.getMessageID(), error.getDescription());
                throw HDSException.exceptions.notAbleToDeleteVolume(error.getCode(), error.getDescription());
            }
        } else {
            log.error("LogicalUnit deletion failed with invalid response code {}", response.getStatus());
            throw HDSException.exceptions.invalidResponseFromHDS(String.format("LogicalUnit creation failed due to invalid response %1$s from server for system %2$s", response.getStatus(), systemObjectID));
        }
    } finally {
        if (null != responseStream) {
            try {
                responseStream.close();
            } catch (IOException e) {
                log.error(e.getMessage(), e);
            }
        }
    }
    return asyncTaskMessageId;
}
Also used : Delete(com.emc.storageos.hds.model.Delete) ClientResponse(com.sun.jersey.api.client.ClientResponse) HashMap(java.util.HashMap) InputStream(java.io.InputStream) LogicalUnit(com.emc.storageos.hds.model.LogicalUnit) ArrayList(java.util.ArrayList) Error(com.emc.storageos.hds.model.Error) IOException(java.io.IOException) URI(java.net.URI) JavaResult(org.milyn.payload.JavaResult) EchoCommand(com.emc.storageos.hds.model.EchoCommand) StorageArray(com.emc.storageos.hds.model.StorageArray)

Example 13 with LogicalUnit

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

the class HDSApiVolumeManager method createThickVolumes.

/**
 * Creates the Thick volume with the passed information.
 *
 * @TODO we should add support for multi volume creation by constructing the xml with new attributes. rest will work fine.
 * @param systemId : represents SystemObjectID.
 * @param arrayGroupId : represents StoragePoolObjectID.
 * @param luCapacityInBytes: Logical Unit Capacity in bytes.
 * @param noOfLus : No. of LU's to created
 * @param volumeName : Logical Unit name.
 * @return : asyncMessageId
 * @throws Exception
 */
public String createThickVolumes(String systemId, String arrayGroupId, Long luCapacityInBytes, int noOfLus, String volumeName, String formatType, String model, Integer devNum) throws Exception {
    Long luCapacityInKB = luCapacityInBytes / 1024;
    InputStream responseStream = null;
    String asyncTaskMessageId = null;
    try {
        Map<String, Object> attributeMap = new HashMap<String, Object>();
        StorageArray storageArray = new StorageArray(systemId);
        Pool arrayGroup = new Pool(arrayGroupId);
        Add addOp = new Add(HDSConstants.LOGICALUNIT, noOfLus, formatType);
        addOp.setBulk(Boolean.TRUE);
        LogicalUnit logicalUnit = new LogicalUnit(null, String.valueOf(luCapacityInKB), volumeName, null, devNum);
        attributeMap.put(HDSConstants.STORAGEARRAY, storageArray);
        attributeMap.put(HDSConstants.ARRAY_GROUP, arrayGroup);
        attributeMap.put(HDSConstants.ADD, addOp);
        attributeMap.put(HDSConstants.MODEL, model);
        attributeMap.put(HDSConstants.LOGICALUNIT, logicalUnit);
        String createVolumeInputXML = InputXMLGenerationClient.getInputXMLString(HDSConstants.CREATE_THICK_VOLUMES_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
        log.info("Query to create thick volume: {}", createVolumeInputXML);
        URI endpointURI = hdsApiClient.getBaseURI();
        ClientResponse response = hdsApiClient.post(endpointURI, createVolumeInputXML);
        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("Volume creation failed status messageID: {}", command.getMessageID());
                log.error("Volume creation failed with error code: {} with message: {}", error.getCode(), error.getDescription());
                throw HDSException.exceptions.notAbleToCreateVolume(error.getCode(), error.getDescription());
            }
        } else {
            log.error("LogicalUnit creation failed with invalid response code {}", response.getStatus());
            throw HDSException.exceptions.invalidResponseFromHDS(String.format("LogicalUnit creation failed due to invalid response %1$s from server for system %2$s", response.getStatus(), systemId));
        }
    } finally {
        if (null != responseStream) {
            try {
                responseStream.close();
            } catch (IOException e) {
                log.warn("Exception occurred while close volume creation response stream");
            }
        }
    }
    return asyncTaskMessageId;
}
Also used : Add(com.emc.storageos.hds.model.Add) 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) IOException(java.io.IOException) URI(java.net.URI) Pool(com.emc.storageos.hds.model.Pool) JavaResult(org.milyn.payload.JavaResult) EchoCommand(com.emc.storageos.hds.model.EchoCommand) StorageArray(com.emc.storageos.hds.model.StorageArray)

Example 14 with LogicalUnit

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

Example 15 with LogicalUnit

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

the class HDSApiVolumeManager method addLUSE.

/**
 * Form a single meta volume by concatenating multiple volumes.
 *
 * @param systemObjectId
 * @param ldevIds
 * @return
 * @throws Exception
 */
public LogicalUnit addLUSE(String systemObjectId, String metaHead, List<String> ldevIds) throws Exception {
    String addLUSEQuery = constructAddLUSEQuery(systemObjectId, metaHead, ldevIds);
    URI endpointURI = hdsApiClient.getBaseURI();
    InputStream responseStream = null;
    LogicalUnit logicalUnit = null;
    try {
        log.info("Add LUSE Query payload :{}", addLUSEQuery);
        ClientResponse response = hdsApiClient.post(endpointURI, addLUSEQuery);
        if (HttpStatus.SC_OK == response.getStatus()) {
            responseStream = response.getEntityInputStream();
            JavaResult result = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.SMOOKS_CONFIG_FILE);
            verifyErrorPayload(result);
            logicalUnit = (LogicalUnit) result.getBean(HDSConstants.LOGICALUNIT_BEAN_NAME);
        } else {
            log.error("AddLUSE failed with invalid response code {}", response.getStatus());
            throw HDSException.exceptions.invalidResponseFromHDS(String.format("Not able to Add LUSE due to invalid response %1$s from server for system %2$s", response.getStatus(), systemObjectId));
        }
    } finally {
        if (null != responseStream) {
            try {
                responseStream.close();
            } catch (IOException e) {
                log.warn("IOException occurred while closing the response stream");
            }
        }
    }
    return logicalUnit;
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) InputStream(java.io.InputStream) LogicalUnit(com.emc.storageos.hds.model.LogicalUnit) IOException(java.io.IOException) URI(java.net.URI) JavaResult(org.milyn.payload.JavaResult)

Aggregations

LogicalUnit (com.emc.storageos.hds.model.LogicalUnit)27 URI (java.net.URI)18 ClientResponse (com.sun.jersey.api.client.ClientResponse)13 InputStream (java.io.InputStream)13 HashMap (java.util.HashMap)13 JavaResult (org.milyn.payload.JavaResult)13 StorageArray (com.emc.storageos.hds.model.StorageArray)12 IOException (java.io.IOException)12 HDSApiClient (com.emc.storageos.hds.api.HDSApiClient)10 EchoCommand (com.emc.storageos.hds.model.EchoCommand)9 Error (com.emc.storageos.hds.model.Error)9 LDEV (com.emc.storageos.hds.model.LDEV)7 ArrayList (java.util.ArrayList)7 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)6 Volume (com.emc.storageos.db.client.model.Volume)6 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)5 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)5 HDSException (com.emc.storageos.hds.HDSException)5 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)5 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)5