Search in sources :

Example 21 with StorageArray

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

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

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

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

the class HDSApiDiscoveryManager method getStoragePoolTierInfo.

/**
 * Returns all storage system information.
 *
 * @return
 * @throws Exception
 */
public Pool getStoragePoolTierInfo(String systemObjectID, String poolObjectID) throws Exception {
    InputStream responseStream = null;
    Pool pool = null;
    URI endpointURI = hdsApiClient.getBaseURI();
    Map<String, Object> attributeMap = new HashMap<String, Object>();
    StorageArray inputStorageArray = new StorageArray(systemObjectID);
    Get getOp = new Get(HDSConstants.STORAGEARRAY);
    attributeMap.put(HDSConstants.STORAGEARRAY, inputStorageArray);
    Pool inputPool = new Pool(poolObjectID);
    attributeMap.put(HDSConstants.JOURNAL_POOL, inputPool);
    attributeMap.put(HDSConstants.GET, getOp);
    String getPoolTieringInfoInputXML = InputXMLGenerationClient.getInputXMLString(HDSConstants.GET_STORAGE_POOL_TIERING_INFO_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
    log.info("Get StoragePool Tiering info query payload :{}", getPoolTieringInfoInputXML);
    ClientResponse response = hdsApiClient.post(endpointURI, getPoolTieringInfoInputXML);
    if (HttpStatus.SC_OK == response.getStatus()) {
        responseStream = response.getEntityInputStream();
        JavaResult result = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.SMOOKS_CONFIG_FILE);
        verifyErrorPayload(result);
        pool = result.getBean(Pool.class);
    } else {
        log.error("Get pool tiering info failed with invalid response code {}", response.getStatus());
        throw HDSException.exceptions.invalidResponseFromHDS(String.format("Not able to query pool tiering info due to invalid response %1$s from server", response.getStatus()));
    }
    return pool;
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) HashMap(java.util.HashMap) InputStream(java.io.InputStream) Get(com.emc.storageos.hds.model.Get) Pool(com.emc.storageos.hds.model.Pool) URI(java.net.URI) JavaResult(org.milyn.payload.JavaResult) StorageArray(com.emc.storageos.hds.model.StorageArray)

Example 25 with StorageArray

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

the class HDSApiDiscoveryManager method getStorageSystemDetails.

/**
 * Returns all storage system information.
 *
 * @return
 * @throws Exception
 */
public StorageArray getStorageSystemDetails(String systemObjectID) throws Exception {
    InputStream responseStream = null;
    StorageArray storageArray = null;
    URI endpointURI = hdsApiClient.getBaseURI();
    Map<String, Object> attributeMap = new HashMap<String, Object>();
    StorageArray inputStorageArray = new StorageArray(systemObjectID);
    Get getOp = new Get(HDSConstants.STORAGEARRAY);
    attributeMap.put(HDSConstants.STORAGEARRAY, inputStorageArray);
    attributeMap.put(HDSConstants.GET, getOp);
    String getSystemDetailsInputXML = InputXMLGenerationClient.getInputXMLString(HDSConstants.GET_SYSTEM_DETAILS_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
    log.info("Get system details query payload :{}", getSystemDetailsInputXML);
    ClientResponse response = hdsApiClient.post(endpointURI, getSystemDetailsInputXML);
    if (HttpStatus.SC_OK == response.getStatus()) {
        responseStream = response.getEntityInputStream();
        JavaResult result = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.SMOOKS_CONFIG_FILE);
        verifyErrorPayload(result);
        storageArray = result.getBean(StorageArray.class);
    } else {
        log.error("Get system details failed with invalid response code {}", response.getStatus());
        throw HDSException.exceptions.invalidResponseFromHDS(String.format("Not able to query system details due to invalid response %1$s from server", response.getStatus()));
    }
    return storageArray;
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) HashMap(java.util.HashMap) InputStream(java.io.InputStream) Get(com.emc.storageos.hds.model.Get) 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