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