Search in sources :

Example 6 with Add

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

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

the class HDSBatchApiExportManager method constructISCSINamesQuery.

/**
 * Constructs a batch query for given HSD's and each with a set of
 * WorldWideName's to add. This query should be used to add FC initiators to
 * the FC HSD.
 *
 * @param systemId
 *            - Represents the storage system objectID.
 * @param hsdList
 *            - List of HostStorageDomain objects.
 * @return
 */
private String constructISCSINamesQuery(String systemId, List<HostStorageDomain> hsdList, 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);
    attributeMap.put(HDSConstants.HOSTGROUP_LIST, hsdList);
    String addWWNQuery = InputXMLGenerationClient.getInputXMLString(HDSConstants.BATCH_ADD_WWN_TO_HSD_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
    return addWWNQuery;
}
Also used : Add(com.emc.storageos.hds.model.Add) HashMap(java.util.HashMap) StorageArray(com.emc.storageos.hds.model.StorageArray)

Example 8 with Add

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

the class HDSBatchApiExportManager method constructWWNQuery.

/**
 * Constructs a batch query for given HSD's and the WorldWideName's to add.
 * This query should be used to add FC initiators to the FC HSD. This
 * constructs the xml input string for multiple HSD's and each HSD with
 * multiple WWN's.
 *
 * @param systemId
 *            - StorageSystem ObjectID.
 * @param hsdList
 *            - List of HSD objects.
 * @return - XML String to add HSD's with WWN's.
 */
private String constructWWNQuery(String systemId, List<HostStorageDomain> hsdList, String model) {
    Map<String, Object> attributeMap = new HashMap<String, Object>();
    StorageArray array = new StorageArray(systemId);
    Add addOp = new Add(HDSConstants.ADD_WWN_TO_HSD_TARGET);
    attributeMap.put(HDSConstants.STORAGEARRAY, array);
    attributeMap.put(HDSConstants.ADD, addOp);
    attributeMap.put(HDSConstants.MODEL, model);
    attributeMap.put(HDSConstants.HOSTGROUP_LIST, hsdList);
    return InputXMLGenerationClient.getInputXMLString(HDSConstants.BATCH_ADD_WWN_TO_HSD_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
}
Also used : Add(com.emc.storageos.hds.model.Add) HashMap(java.util.HashMap) StorageArray(com.emc.storageos.hds.model.StorageArray)

Example 9 with Add

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

the class HDSBatchApiExportManager method addHostStorageDomains.

/**
 * This method makes http POST call with a payload of bulk
 * HostStorageDomains.
 *
 * @param systemId
 *            - SystemObjectID.
 * @param hostGroups
 *            - List of HostStorageDomain objects.
 * @return - Returns a List of created HostStorageDomain on Array.
 * @throws Exception
 *             - In case processing errors.
 */
public List<HostStorageDomain> addHostStorageDomains(String systemId, List<HostStorageDomain> hostGroups, String model) throws Exception {
    InputStream responseStream = null;
    List<HostStorageDomain> hsdList = null;
    try {
        Map<String, Object> attributeMap = new HashMap<String, Object>();
        StorageArray array = new StorageArray(systemId);
        Add addOp = new Add(HDSConstants.HOST_STORAGE_DOMAIN);
        attributeMap.put(HDSConstants.STORAGEARRAY, array);
        attributeMap.put(HDSConstants.ADD, addOp);
        attributeMap.put(HDSConstants.MODEL, model);
        attributeMap.put(HDSConstants.HOSTGROUP_LIST, hostGroups);
        String addHSDToSystemQuery = InputXMLGenerationClient.getInputXMLString(HDSConstants.BATCH_ADD_HSDS_TO_SYSTEM_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
        log.info("Batch query to create HostStorageDomains: {}", addHSDToSystemQuery);
        URI endpointURI = hdsApiClient.getBaseURI();
        ClientResponse response = hdsApiClient.post(endpointURI, addHSDToSystemQuery);
        if (HttpStatus.SC_OK == response.getStatus()) {
            responseStream = response.getEntityInputStream();
            JavaResult javaResult = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.SMOOKS_CONFIG_FILE);
            verifyErrorPayload(javaResult);
            hsdList = (List<HostStorageDomain>) javaResult.getBean(HDSConstants.HSD_RESPONSE_BEAN_ID);
            if (null == hsdList || hsdList.isEmpty()) {
                throw HDSException.exceptions.notAbleToAddHSD(systemId);
            }
        } else {
            throw HDSException.exceptions.invalidResponseFromHDS(String.format("Not able to add HostStorageDomains due to invalid response %1$s from server", response.getStatus()));
        }
    } finally {
        if (null != responseStream) {
            try {
                responseStream.close();
            } catch (IOException e) {
                log.warn("IOException occurred while closing the response stream addHostStorageDomains");
            }
        }
    }
    return hsdList;
}
Also used : Add(com.emc.storageos.hds.model.Add) ClientResponse(com.sun.jersey.api.client.ClientResponse) HashMap(java.util.HashMap) InputStream(java.io.InputStream) IOException(java.io.IOException) URI(java.net.URI) HostStorageDomain(com.emc.storageos.hds.model.HostStorageDomain) JavaResult(org.milyn.payload.JavaResult) StorageArray(com.emc.storageos.hds.model.StorageArray)

Example 10 with Add

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

the class HDSApiExportManager method constructAddFCInitiatorHostQuery.

/**
 * Constructs the addHostQuery.
 *
 * @param hostName
 * @param ipAddress
 * @param portWWNList
 * @return
 */
private String constructAddFCInitiatorHostQuery(HDSHost hdshost, List<String> portWWNList) {
    Map<String, Object> attributeMap = new HashMap<String, Object>();
    List<WorldWideName> wwnList = new ArrayList<WorldWideName>();
    Add addOp = new Add(HDSConstants.HOST);
    attributeMap.put(HDSConstants.HOST, hdshost);
    attributeMap.put(HDSConstants.ADD, addOp);
    if (null != portWWNList && !portWWNList.isEmpty()) {
        for (String portWWN : portWWNList) {
            WorldWideName wwn = new WorldWideName(portWWN);
            wwnList.add(wwn);
        }
        hdshost.setWwnList(wwnList);
    }
    attributeMap.put(HDSConstants.WWN_LIST, wwnList);
    String addHostWithWorldWideNamesQuery = InputXMLGenerationClient.getInputXMLString(HDSConstants.ADD_HOST_WITH_WWN_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
    return addHostWithWorldWideNamesQuery;
}
Also used : Add(com.emc.storageos.hds.model.Add) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) WorldWideName(com.emc.storageos.hds.model.WorldWideName)

Aggregations

Add (com.emc.storageos.hds.model.Add)19 HashMap (java.util.HashMap)19 StorageArray (com.emc.storageos.hds.model.StorageArray)13 ClientResponse (com.sun.jersey.api.client.ClientResponse)10 InputStream (java.io.InputStream)10 URI (java.net.URI)10 JavaResult (org.milyn.payload.JavaResult)10 IOException (java.io.IOException)9 EchoCommand (com.emc.storageos.hds.model.EchoCommand)5 Error (com.emc.storageos.hds.model.Error)5 HostStorageDomain (com.emc.storageos.hds.model.HostStorageDomain)4 LogicalUnit (com.emc.storageos.hds.model.LogicalUnit)4 ArrayList (java.util.ArrayList)4 HDSHost (com.emc.storageos.hds.model.HDSHost)2 ISCSIName (com.emc.storageos.hds.model.ISCSIName)2 Pool (com.emc.storageos.hds.model.Pool)2 ReplicationInfo (com.emc.storageos.hds.model.ReplicationInfo)2 WorldWideName (com.emc.storageos.hds.model.WorldWideName)2 ArrayGroup (com.emc.storageos.hds.model.ArrayGroup)1 LDEV (com.emc.storageos.hds.model.LDEV)1