Search in sources :

Example 11 with Get

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

the class HDSApiVolumeManager method getAllLogicalUnits.

/**
 * Returns all LogicalUnits of a given system.
 *
 * @param systemObjectId
 * @return
 */
public List<LogicalUnit> getAllLogicalUnits(String systemObjectId) throws Exception {
    InputStream responseStream = null;
    List<LogicalUnit> luList = null;
    Map<String, Object> attributeMap = new HashMap<String, Object>();
    StorageArray storageArray = new StorageArray(systemObjectId);
    attributeMap.put(HDSConstants.STORAGEARRAY, storageArray);
    Get getOp = new Get(HDSConstants.STORAGEARRAY);
    attributeMap.put(HDSConstants.GET, getOp);
    LogicalUnit lu = new LogicalUnit();
    attributeMap.put(HDSConstants.LOGICALUNIT, lu);
    String getLogicalUnitsInputXML = InputXMLGenerationClient.getInputXMLString(HDSConstants.GET_LOGICALUNITS_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
    URI endpointURI = hdsApiClient.getBaseURI();
    log.info("Get all LogicalUnits query payload :{}", getLogicalUnitsInputXML);
    ClientResponse response = hdsApiClient.post(endpointURI, getLogicalUnitsInputXML);
    if (HttpStatus.SC_OK == response.getStatus()) {
        responseStream = response.getEntityInputStream();
        JavaResult result = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.SMOOKS_CONFIG_FILE);
        verifyErrorPayload(result);
        luList = (List<LogicalUnit>) result.getBean(HDSConstants.LOGICALUNIT_LIST_BEAN_NAME);
    } else {
        log.error("Get all LogicalUnits failed with invalid response code {}", response.getStatus());
        throw HDSException.exceptions.invalidResponseFromHDS(String.format("Not able to query all LogicalUnits due to invalid response %1$s from server for system %2$s", response.getStatus(), systemObjectId));
    }
    return luList;
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) HashMap(java.util.HashMap) InputStream(java.io.InputStream) LogicalUnit(com.emc.storageos.hds.model.LogicalUnit) Get(com.emc.storageos.hds.model.Get) URI(java.net.URI) JavaResult(org.milyn.payload.JavaResult) StorageArray(com.emc.storageos.hds.model.StorageArray)

Example 12 with Get

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

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

Example 14 with Get

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

the class HDSApiDiscoveryManager method getProviderAPIVersion.

/**
 * Returns HiCommand Device Manager's API version
 *
 * @return api version
 * @throws Exception
 */
public String getProviderAPIVersion() throws Exception {
    String apiVersion = null;
    InputStream responseStream = null;
    URI endpointURI = hdsApiClient.getBaseURI();
    Map<String, Object> attributeMap = new HashMap<String, Object>();
    Get getOp = new Get(HDSConstants.SERVER_INFO);
    attributeMap.put(HDSConstants.GET, getOp);
    String getAPIVersionInputXML = InputXMLGenerationClient.getInputXMLString(HDSConstants.GET_API_VERSION_INFO_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
    log.info("Get api version query payload :{}", getAPIVersionInputXML);
    ClientResponse response = hdsApiClient.post(endpointURI, getAPIVersionInputXML);
    if (HttpStatus.SC_OK == response.getStatus()) {
        responseStream = response.getEntityInputStream();
        JavaResult result = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.SMOOKS_CONFIG_FILE);
        verifyErrorPayload(result);
        apiVersion = result.getBean(ServerInfo.class).getApiVersion();
        log.info("HiCommand Device Manager's API Version :{}", apiVersion);
    } else {
        log.error("Get api version query failed with invalid response code {}", response.getStatus());
        throw HDSException.exceptions.invalidResponseFromHDS(String.format("Not able to query api version due to invalid response %1$s from server", response.getStatus()));
    }
    return apiVersion;
}
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)

Example 15 with Get

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

the class HDSApiExportManager method getHostStorageDomains.

/**
 * Return the existing HSD's configured on the storage array.
 *
 * @param systemId
 * @param type
 * @return
 * @throws Exception
 */
public List<HostStorageDomain> getHostStorageDomains(String systemId) throws Exception {
    InputStream responseStream = null;
    StorageArray storageArray = null;
    List<HostStorageDomain> hsdList = null;
    try {
        Map<String, Object> attributeMap = new HashMap<String, Object>();
        StorageArray array = new StorageArray(systemId);
        attributeMap.put(HDSConstants.STORAGEARRAY, array);
        Get getOp = new Get(HDSConstants.STORAGEARRAY);
        attributeMap.put(HDSConstants.GET, getOp);
        HostStorageDomain hsd = new HostStorageDomain();
        attributeMap.put(HDSConstants.HOST_STORAGE_DOMAIN, hsd);
        String getAllHSDQuery = InputXMLGenerationClient.getInputXMLString(HDSConstants.GET_HSD_INFO_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
        log.info("Query to get HostStorageDomain: {}", getAllHSDQuery);
        URI endpointURI = hdsApiClient.getBaseURI();
        ClientResponse response = hdsApiClient.post(endpointURI, getAllHSDQuery);
        if (HttpStatus.SC_OK == response.getStatus()) {
            responseStream = response.getEntityInputStream();
            JavaResult javaResult = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.SMOOKS_CONFIG_FILE);
            verifyErrorPayload(javaResult);
            storageArray = javaResult.getBean(StorageArray.class);
            if (null != storageArray) {
                hsdList = storageArray.getHsdList();
            }
        } else {
            throw HDSException.exceptions.invalidResponseFromHDS(String.format("Not able to query HostStorageDomain's 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");
            }
        }
    }
    return hsdList;
}
Also used : 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) Get(com.emc.storageos.hds.model.Get) JavaResult(org.milyn.payload.JavaResult) StorageArray(com.emc.storageos.hds.model.StorageArray)

Aggregations

Get (com.emc.storageos.hds.model.Get)16 ClientResponse (com.sun.jersey.api.client.ClientResponse)16 InputStream (java.io.InputStream)16 URI (java.net.URI)16 HashMap (java.util.HashMap)16 JavaResult (org.milyn.payload.JavaResult)16 StorageArray (com.emc.storageos.hds.model.StorageArray)12 IOException (java.io.IOException)8 HDSHost (com.emc.storageos.hds.model.HDSHost)3 HostStorageDomain (com.emc.storageos.hds.model.HostStorageDomain)3 Pool (com.emc.storageos.hds.model.Pool)3 LogicalUnit (com.emc.storageos.hds.model.LogicalUnit)2 Condition (com.emc.storageos.hds.model.Condition)1 FreeLun (com.emc.storageos.hds.model.FreeLun)1 SnapshotGroup (com.emc.storageos.hds.model.SnapshotGroup)1 List (java.util.List)1