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;
}
Aggregations