Search in sources :

Example 36 with JavaResult

use of org.milyn.payload.JavaResult 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 37 with JavaResult

use of org.milyn.payload.JavaResult in project coprhd-controller by CoprHD.

the class HDSApiExportManager method deleteWWNsFromHostStorageDomain.

/**
 * Remove given WWN's from HostStorageDomain means disable LUN security by removing these WWN's.
 *
 * @param systemId
 * @param hsdId
 * @param wwnList
 * @param model
 * @return
 * @throws Exception
 */
public void deleteWWNsFromHostStorageDomain(String systemId, String hsdId, List<String> wwnList, String model) throws Exception {
    InputStream responseStream = null;
    try {
        String removeWWNFromHSDQuery = constructDeleteWWNQuery(systemId, hsdId, wwnList, model);
        log.info("Query to delete FC initiators to HostStorageDomain: {}", removeWWNFromHSDQuery);
        URI endpointURI = hdsApiClient.getBaseURI();
        ClientResponse response = hdsApiClient.post(endpointURI, removeWWNFromHSDQuery);
        if (HttpStatus.SC_OK == response.getStatus()) {
            responseStream = response.getEntityInputStream();
            JavaResult javaResult = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.SMOOKS_CONFIG_FILE);
            verifyErrorPayload(javaResult);
            log.info("Remove fc initiators: {} from HSD: {}", wwnList, hsdId);
        } else {
            throw HDSException.exceptions.invalidResponseFromHDS(String.format("Deleting initiator from HostStorageDomain failed due to 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");
            }
        }
    }
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) InputStream(java.io.InputStream) IOException(java.io.IOException) URI(java.net.URI) JavaResult(org.milyn.payload.JavaResult)

Example 38 with JavaResult

use of org.milyn.payload.JavaResult in project coprhd-controller by CoprHD.

the class HDSApiExportManager method addWWNToHostStorageDomain.

/**
 * Add WWN to the HostStorageDomain means enable LUN security by adding WWN.
 *
 * @param systemId
 * @param hsdId
 * @param wwnList
 * @param model
 * @return
 * @throws Exception
 */
public HostStorageDomain addWWNToHostStorageDomain(String systemId, String hsdId, List<String> wwnList, String model) throws Exception {
    InputStream responseStream = null;
    HostStorageDomain hsd = null;
    try {
        String addWWNToHSDQuery = constructWWNQuery(systemId, hsdId, wwnList, model);
        log.info("Query to add FC initiators to HostStorageDomain: {}", addWWNToHSDQuery);
        URI endpointURI = hdsApiClient.getBaseURI();
        ClientResponse response = hdsApiClient.post(endpointURI, addWWNToHSDQuery);
        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);
            if (null == hsd) {
                throw HDSException.exceptions.notAbleToAddInitiatorToHostStorageDomain("FC", hsdId, systemId);
            }
        } else {
            throw HDSException.exceptions.invalidResponseFromHDS(String.format("Add initiator to HostStorageDomain failed 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) InputStream(java.io.InputStream) IOException(java.io.IOException) URI(java.net.URI) JavaResult(org.milyn.payload.JavaResult)

Example 39 with JavaResult

use of org.milyn.payload.JavaResult 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)

Example 40 with JavaResult

use of org.milyn.payload.JavaResult in project coprhd-controller by CoprHD.

the class HDSApiExportManager method addISCSIInitatorsToHostStorageDomain.

/**
 * Add WWN to the HostStorageDomain means enable LUN security by adding WWN.
 *
 * @param systemId
 * @param hsdId
 * @param scsiNameList
 * @param model
 * @return
 * @throws Exception
 */
public HostStorageDomain addISCSIInitatorsToHostStorageDomain(String systemId, String hsdId, List<String> scsiNameList, String model) throws Exception {
    InputStream responseStream = null;
    HostStorageDomain hsd = null;
    try {
        String addISCSINamesToHSDQuery = constructISCSIQuery(systemId, hsdId, scsiNameList, model);
        log.info("Query to add SCSI Initiators to HostStorageDomain: {}", addISCSINamesToHSDQuery);
        URI endpointURI = hdsApiClient.getBaseURI();
        ClientResponse response = hdsApiClient.post(endpointURI, addISCSINamesToHSDQuery);
        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);
            if (null == hsd) {
                throw HDSException.exceptions.notAbleToAddInitiatorToHostStorageDomain("iSCSI", hsdId, systemId);
            }
        } else {
            throw HDSException.exceptions.invalidResponseFromHDS(String.format("Add iSCSI initiator to HostStorageDomain failed 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) InputStream(java.io.InputStream) IOException(java.io.IOException) URI(java.net.URI) JavaResult(org.milyn.payload.JavaResult)

Aggregations

JavaResult (org.milyn.payload.JavaResult)57 InputStream (java.io.InputStream)53 ClientResponse (com.sun.jersey.api.client.ClientResponse)52 URI (java.net.URI)50 IOException (java.io.IOException)42 HashMap (java.util.HashMap)38 StorageArray (com.emc.storageos.hds.model.StorageArray)26 Error (com.emc.storageos.hds.model.Error)17 Get (com.emc.storageos.hds.model.Get)16 EchoCommand (com.emc.storageos.hds.model.EchoCommand)15 LogicalUnit (com.emc.storageos.hds.model.LogicalUnit)13 Add (com.emc.storageos.hds.model.Add)11 HostStorageDomain (com.emc.storageos.hds.model.HostStorageDomain)11 HDSHost (com.emc.storageos.hds.model.HDSHost)8 Delete (com.emc.storageos.hds.model.Delete)7 HDSException (com.emc.storageos.hds.HDSException)6 ReplicationInfo (com.emc.storageos.hds.model.ReplicationInfo)6 Modify (com.emc.storageos.hds.model.Modify)5 Pool (com.emc.storageos.hds.model.Pool)5 ArrayList (java.util.ArrayList)5