Search in sources :

Example 31 with StorageArray

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

the class HDSApiExportManager method constructISCSIQuery.

/**
 * Construct the iSCSINames Query by adding multiple WWNs.
 * This query should be used to add the iSCSI initiators to the iSCSI HSD.
 *
 * @param systemId
 * @param hsdId
 * @param wwnList
 * @return
 */
private String constructISCSIQuery(String systemId, String hsdId, List<String> scsiNameList, String model) {
    Map<String, Object> attributeMap = new HashMap<String, Object>();
    StorageArray array = new StorageArray(systemId);
    Add addOp = new Add(HDSConstants.ISCSI_NAME_FOR_HSD_TARGET);
    attributeMap.put(HDSConstants.STORAGEARRAY, array);
    attributeMap.put(HDSConstants.ADD, addOp);
    attributeMap.put(HDSConstants.MODEL, model);
    HostStorageDomain hsd = new HostStorageDomain(hsdId);
    attributeMap.put(HDSConstants.HOST_STORAGE_DOMAIN, hsd);
    List<ISCSIName> iSCSIObjList = new ArrayList<ISCSIName>();
    if (null != scsiNameList && !scsiNameList.isEmpty()) {
        for (String iScsiName : scsiNameList) {
            ISCSIName iSCSIName = new ISCSIName(iScsiName, null);
            iSCSIObjList.add(iSCSIName);
        }
    }
    attributeMap.put(HDSConstants.ISCSINAME_LIST, iSCSIObjList);
    String addISCSINamesToHSDQuery = InputXMLGenerationClient.getInputXMLString(HDSConstants.ADD_ISCSI_NAME_TO_HSD_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
    return addISCSINamesToHSDQuery;
}
Also used : Add(com.emc.storageos.hds.model.Add) HashMap(java.util.HashMap) HostStorageDomain(com.emc.storageos.hds.model.HostStorageDomain) ISCSIName(com.emc.storageos.hds.model.ISCSIName) ArrayList(java.util.ArrayList) StorageArray(com.emc.storageos.hds.model.StorageArray)

Example 32 with StorageArray

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

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

the class HDSApiVolumeManager method deleteThinLogicalUnits.

public String deleteThinLogicalUnits(String systemObjectID, Set<String> logicalUnitIdList, String model) throws Exception {
    InputStream responseStream = null;
    String asyncTaskMessageId = null;
    try {
        Map<String, Object> attributeMap = new HashMap<String, Object>();
        StorageArray storageArray = new StorageArray(systemObjectID);
        Delete deleteOp = new Delete(HDSConstants.VIRTUALVOLUME, true);
        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();
                log.info("Async task id : {}", asyncTaskMessageId);
            } 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 34 with StorageArray

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

Example 35 with StorageArray

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

the class HDSApiVolumeManager method releaseLUSE.

/**
 * This client method is responsible to release all the volumes in LUSE volume.
 *
 * @param systemObjectId
 * @param logicalUnitId
 * @return
 * @throws Exception
 */
public LogicalUnit releaseLUSE(String systemObjectId, String logicalUnitId) throws Exception {
    Map<String, Object> attributeMap = new HashMap<String, Object>();
    StorageArray storageArray = new StorageArray(systemObjectId);
    attributeMap.put(HDSConstants.STORAGEARRAY, storageArray);
    Add addOp = new Add(HDSConstants.LUSE_TARGET);
    attributeMap.put(HDSConstants.GET, addOp);
    attributeMap.put(HDSConstants.LOGICALUNIT, logicalUnitId);
    String releaseLUSEVolumeInputXML = InputXMLGenerationClient.getInputXMLString(HDSConstants.RELEASE_LUSE_VOLUME_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
    URI endpointURI = hdsApiClient.getBaseURI();
    InputStream responseStream = null;
    LogicalUnit logicalUnit = null;
    try {
        log.info("release LUSE Query payload :{}", releaseLUSEVolumeInputXML);
        ClientResponse response = hdsApiClient.post(endpointURI, releaseLUSEVolumeInputXML);
        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("deleteLUSE failed with invalid response code {}", response.getStatus());
            throw HDSException.exceptions.invalidResponseFromHDS(String.format("Not able to delete 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 : 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) IOException(java.io.IOException) URI(java.net.URI) JavaResult(org.milyn.payload.JavaResult) StorageArray(com.emc.storageos.hds.model.StorageArray)

Aggregations

StorageArray (com.emc.storageos.hds.model.StorageArray)41 HashMap (java.util.HashMap)37 ClientResponse (com.sun.jersey.api.client.ClientResponse)25 InputStream (java.io.InputStream)25 URI (java.net.URI)25 JavaResult (org.milyn.payload.JavaResult)25 IOException (java.io.IOException)19 Add (com.emc.storageos.hds.model.Add)13 Get (com.emc.storageos.hds.model.Get)12 LogicalUnit (com.emc.storageos.hds.model.LogicalUnit)12 HostStorageDomain (com.emc.storageos.hds.model.HostStorageDomain)10 Delete (com.emc.storageos.hds.model.Delete)9 EchoCommand (com.emc.storageos.hds.model.EchoCommand)9 Error (com.emc.storageos.hds.model.Error)9 ArrayList (java.util.ArrayList)7 Pool (com.emc.storageos.hds.model.Pool)5 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)3 HDSException (com.emc.storageos.hds.HDSException)3 HDSApiClient (com.emc.storageos.hds.api.HDSApiClient)3 Modify (com.emc.storageos.hds.model.Modify)3