Search in sources :

Example 16 with Get

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

the class HDSApiProtectionManager method getSnapshotGroupPairManagementServer.

/**
 * Get PairManagement Server for SnapshotGroup
 *
 * @param serialNumber
 * @return
 * @throws Exception
 */
public HDSHost getSnapshotGroupPairManagementServer(String serialNumber) throws Exception {
    InputStream responseStream = null;
    try {
        log.info("Started to collect Pair Mgmt Server details");
        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);
        SnapshotGroup snapshotGroup = new SnapshotGroup();
        // snapshotGroup.setArrayType(arrayType);
        snapshotGroup.setSerialNumber(serialNumber);
        snapshotGroup.setGroupName(HDSConstants.VIPR_SNAPSHOT_GROUP_NAME);
        attributeMap.put(HDSConstants.SNAPSHOTGROUP, snapshotGroup);
        String getSnapshotGroupQuery = InputXMLGenerationClient.getInputXMLString(HDSConstants.GET_SNAPSHOT_GROUP_INFO_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
        log.info("Query to pair management server Host: {}", getSnapshotGroupQuery);
        URI endpointURI = hdsApiClient.getBaseURI();
        ClientResponse response = hdsApiClient.post(endpointURI, getSnapshotGroupQuery);
        if (HttpStatus.SC_OK == response.getStatus()) {
            responseStream = response.getEntityInputStream();
            JavaResult javaResult = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.HITACHI_SMOOKS_THINIMAGE_CONFIG_FILE);
            hdsApiClient.verifyErrorPayload(javaResult);
            List<HDSHost> hostList = (List<HDSHost>) javaResult.getBean(HDSConstants.HOST_LIST_BEAN_NAME);
            log.info("Host List size :{}", hostList.size());
            for (HDSHost hdsHost : hostList) {
                if (hdsHost != null && hdsHost.getSnapshotGroupList() != null) {
                    log.info("Host Name :{}", hdsHost.getName());
                    for (SnapshotGroup snapGroup : hdsHost.getSnapshotGroupList()) {
                        log.info("SnapshotGroup groupName :{}", snapGroup.getGroupName());
                        if (snapGroup != null && HDSConstants.VIPR_SNAPSHOT_GROUP_NAME.equalsIgnoreCase(snapGroup.getGroupName()) && serialNumber.equalsIgnoreCase(snapGroup.getSerialNumber())) {
                            log.info("Found ViPR snaphot group on pair mgmt server {}", hdsHost.getName());
                            return hdsHost;
                        }
                    }
                }
            }
        } 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");
            }
        }
    }
    // If we are here there is no pair mgmt server available on storage system.
    return null;
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) HDSHost(com.emc.storageos.hds.model.HDSHost) HashMap(java.util.HashMap) InputStream(java.io.InputStream) IOException(java.io.IOException) URI(java.net.URI) SnapshotGroup(com.emc.storageos.hds.model.SnapshotGroup) Get(com.emc.storageos.hds.model.Get) List(java.util.List) JavaResult(org.milyn.payload.JavaResult)

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