Search in sources :

Example 6 with Get

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

the class HDSApiExportManager method getFreeLUNInfo.

/**
 * Return the Free Lun's available for a Given HSD in a System.
 *
 * @throws Exception
 */
public List<FreeLun> getFreeLUNInfo(String systemId, String hsdId) throws Exception {
    InputStream responseStream = null;
    HostStorageDomain hostStorageDomain = null;
    List<FreeLun> freeLunList = null;
    try {
        Map<String, Object> attributeMap = new HashMap<String, Object>();
        StorageArray array = new StorageArray(systemId);
        Get getOp = new Get(HDSConstants.STORAGEARRAY);
        attributeMap.put(HDSConstants.STORAGEARRAY, array);
        HostStorageDomain hsd = new HostStorageDomain(hsdId);
        FreeLun freeLun = new FreeLun();
        attributeMap.put(HDSConstants.GET, getOp);
        attributeMap.put(HDSConstants.HOST_STORAGE_DOMAIN, hsd);
        attributeMap.put(HDSConstants.FREELUN, freeLun);
        String getFreeLunQueryInputXML = InputXMLGenerationClient.getInputXMLString(HDSConstants.GET_FREE_LUN_INFO_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
        log.info("Query to get FreeLUN's of a HostStorageDomain: {}", getFreeLunQueryInputXML);
        URI endpointURI = hdsApiClient.getBaseURI();
        ClientResponse response = hdsApiClient.post(endpointURI, getFreeLunQueryInputXML);
        if (HttpStatus.SC_OK == response.getStatus()) {
            responseStream = response.getEntityInputStream();
            JavaResult javaResult = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.SMOOKS_CONFIG_FILE);
            verifyErrorPayload(javaResult);
            hostStorageDomain = javaResult.getBean(HostStorageDomain.class);
            if (null != hostStorageDomain && null != hostStorageDomain.getFreeLunList()) {
                freeLunList = hostStorageDomain.getFreeLunList();
            } else {
                throw HDSException.exceptions.notAbleToGetFreeLunInfoForHSD(hsdId, systemId);
            }
        } else {
            throw HDSException.exceptions.invalidResponseFromHDS(String.format("Not able to get FreeLun info for HostStorageDomain 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 freeLunList;
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) FreeLun(com.emc.storageos.hds.model.FreeLun) 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)

Example 7 with Get

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

the class HDSApiExportManager method getHostStorageDomain.

/**
 * Return the existing HSD's configured on the storage array.
 *
 * @param systemId
 * @param type
 * @return
 * @throws Exception
 */
public HostStorageDomain getHostStorageDomain(String systemId, String hsdId) throws Exception {
    InputStream responseStream = null;
    HostStorageDomain hsd = 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 inputHsd = new HostStorageDomain(hsdId);
        attributeMap.put(HDSConstants.HOST_STORAGE_DOMAIN, inputHsd);
        String getHSDQuery = 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: {}", getHSDQuery);
        URI endpointURI = hdsApiClient.getBaseURI();
        ClientResponse response = hdsApiClient.post(endpointURI, getHSDQuery);
        if (HttpStatus.SC_OK == response.getStatus()) {
            responseStream = response.getEntityInputStream();
            JavaResult javaResult = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.SMOOKS_CONFIG_FILE);
            verifyErrorPayload(javaResult);
            hsd = javaResult.getBean(HostStorageDomain.class);
        } else {
            throw HDSException.exceptions.invalidResponseFromHDS(String.format("Not able to query HostStorageDomain 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 hsd;
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) HostStorageDomain(com.emc.storageos.hds.model.HostStorageDomain) HashMap(java.util.HashMap) InputStream(java.io.InputStream) Get(com.emc.storageos.hds.model.Get) IOException(java.io.IOException) URI(java.net.URI) JavaResult(org.milyn.payload.JavaResult) StorageArray(com.emc.storageos.hds.model.StorageArray)

Example 8 with Get

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

the class HDSApiProtectionManager method getHDSHostList.

/**
 * Returns Host List collected from Device Manager.
 *
 * @return
 * @throws Exception
 */
private List<HDSHost> getHDSHostList() throws Exception {
    List<HDSHost> hostList = null;
    InputStream responseStream = null;
    try {
        Map<String, Object> attributeMap = new HashMap<String, Object>();
        Get getOp = new Get(HDSConstants.HOST);
        attributeMap.put(HDSConstants.GET, getOp);
        HDSHost host = new HDSHost();
        host.setName("*");
        attributeMap.put(HDSConstants.HOST, host);
        String getAllHSDQuery = InputXMLGenerationClient.getInputXMLString(HDSConstants.GET_ALL_HOST_INFO_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
        log.info("Query to get All Host: {}", 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.HOST_INFO_SMOOKS_CONFIG_FILE);
            hdsApiClient.verifyErrorPayload(javaResult);
            hostList = (List<HDSHost>) javaResult.getBean(HDSConstants.HOST_LIST_BEAN_NAME);
        } 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 hostList;
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) HDSHost(com.emc.storageos.hds.model.HDSHost) HashMap(java.util.HashMap) InputStream(java.io.InputStream) Get(com.emc.storageos.hds.model.Get) IOException(java.io.IOException) URI(java.net.URI) JavaResult(org.milyn.payload.JavaResult)

Example 9 with Get

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

the class HDSApiVolumeManager method getStoragePoolInfo.

/**
 * Return the storagepool information.
 *
 * @param systemObjectId
 * @param poolObjectId
 * @return
 * @throws Exception
 */
public Pool getStoragePoolInfo(String systemObjectId, String poolObjectId) throws Exception {
    InputStream responseStream = null;
    Pool storagePool = null;
    String poolMethodType = 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);
    Pool pool = new Pool(poolObjectId);
    if (poolObjectId.contains(HDSConstants.ARRAYGROUP)) {
        attributeMap.put(HDSConstants.ARRAY_GROUP, pool);
        poolMethodType = HDSConstants.GET_ARRAYGROUP_INFO_OP;
    } else if (poolObjectId.contains(HDSConstants.JOURNALPOOL)) {
        attributeMap.put(HDSConstants.JOURNAL_POOL, pool);
        poolMethodType = HDSConstants.GET_JOURNAL_POOL_INFO_OP;
    }
    String getStoragePoolInputXML = InputXMLGenerationClient.getInputXMLString(poolMethodType, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
    URI endpointURI = hdsApiClient.getBaseURI();
    log.info("Storagepool info query payload :{}", getStoragePoolInputXML);
    ClientResponse response = hdsApiClient.post(endpointURI, getStoragePoolInputXML);
    if (HttpStatus.SC_OK == response.getStatus()) {
        responseStream = response.getEntityInputStream();
        JavaResult result = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.SMOOKS_CONFIG_FILE);
        verifyErrorPayload(result);
        storagePool = result.getBean(Pool.class);
    } else {
        log.error("Get StoragePool info failed with invalid response code {}", response.getStatus());
        throw HDSException.exceptions.invalidResponseFromHDS(String.format("Not able to query StoragePool info due to invalid response %1$s from server for system %2$s", response.getStatus(), systemObjectId));
    }
    return storagePool;
}
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 10 with Get

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

the class HDSApiVolumeManager method getLogicalUnitInfo.

/**
 * Return the LogicalUnit info for the given logicalUnitObjectId.
 *
 * @param systemObjectId
 * @param logicalUnitObjectId
 * @return
 * @throws Exception
 */
public LogicalUnit getLogicalUnitInfo(String systemObjectId, String logicalUnitObjectId) throws Exception {
    InputStream responseStream = null;
    LogicalUnit logicalUnit = null;
    Map<String, Object> attributeMap = new HashMap<String, Object>();
    StorageArray storageArray = new StorageArray(systemObjectId);
    Get getOp = new Get(HDSConstants.STORAGEARRAY);
    attributeMap.put(HDSConstants.STORAGEARRAY, storageArray);
    attributeMap.put(HDSConstants.GET, getOp);
    LogicalUnit lu = new LogicalUnit(logicalUnitObjectId, null);
    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("Volume info 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);
        logicalUnit = (LogicalUnit) result.getBean(HDSConstants.LOGICALUNIT_BEAN_NAME);
    } else {
        log.error("Get LogicalUnit info failed with invalid response code {}", response.getStatus());
        throw HDSException.exceptions.invalidResponseFromHDS(String.format("Not able to query LogicalUnit info due to invalid response %1$s from server for system %2$s", response.getStatus(), systemObjectId));
    }
    return logicalUnit;
}
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)

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