use of org.milyn.payload.JavaResult in project coprhd-controller by CoprHD.
the class HDSApiDiscoveryManager method getStorageSystemTieringPolicyDetails.
/**
* Returns all storage system information.
*
* @return
* @throws Exception
*/
public StorageArray getStorageSystemTieringPolicyDetails(String systemObjectID) throws Exception {
InputStream responseStream = null;
StorageArray storageArray = null;
URI endpointURI = hdsApiClient.getBaseURI();
Map<String, Object> attributeMap = new HashMap<String, Object>();
StorageArray inputStorageArray = new StorageArray(systemObjectID);
Get getOp = new Get(HDSConstants.STORAGEARRAY);
attributeMap.put(HDSConstants.STORAGEARRAY, inputStorageArray);
attributeMap.put(HDSConstants.GET, getOp);
String getSystemDetailsInputXML = InputXMLGenerationClient.getInputXMLString(HDSConstants.GET_SYSTEM_TIERING_DETAILS_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
log.info("Get system Tiering details query payload :{}", getSystemDetailsInputXML);
ClientResponse response = hdsApiClient.post(endpointURI, getSystemDetailsInputXML);
if (HttpStatus.SC_OK == response.getStatus()) {
responseStream = response.getEntityInputStream();
JavaResult result = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.SMOOKS_CONFIG_FILE);
verifyErrorPayload(result);
storageArray = result.getBean(StorageArray.class);
} else {
log.error("Get system details failed with invalid response code {}", response.getStatus());
throw HDSException.exceptions.invalidResponseFromHDS(String.format("Not able to query system details due to invalid response %1$s from server", response.getStatus()));
}
return storageArray;
}
use of org.milyn.payload.JavaResult in project coprhd-controller by CoprHD.
the class HDSApiDiscoveryManager method getStorageSystemsInfo.
/**
* Returns all storage system information.
*
* @return
* @throws Exception
*/
public List<StorageArray> getStorageSystemsInfo() throws Exception {
InputStream responseStream = null;
List<StorageArray> arrayList = null;
try {
URI endpointURI = hdsApiClient.getBaseURI();
Map<String, Object> attributeMap = new HashMap<String, Object>();
StorageArray storageArray = new StorageArray(HDSConstants.STAR);
Get getOp = new Get(HDSConstants.STORAGEARRAY);
attributeMap.put(HDSConstants.STORAGEARRAY, storageArray);
attributeMap.put(HDSConstants.GET, getOp);
String getSystemsInputXML = InputXMLGenerationClient.getInputXMLString(HDSConstants.GET_SYSTEMS_INFO_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
log.info("Get all systems query payload :{}", getSystemsInputXML);
ClientResponse response = hdsApiClient.post(endpointURI, getSystemsInputXML);
if (HttpStatus.SC_OK == response.getStatus()) {
responseStream = response.getEntityInputStream();
JavaResult result = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.SMOOKS_CONFIG_FILE);
verifyErrorPayload(result);
arrayList = (List<StorageArray>) result.getBean(HDSConstants.SYSTEMLIST_BEAN_ID);
} else {
log.error("Get all systems query failed with invalid response code {}", response.getStatus());
throw HDSException.exceptions.invalidResponseFromHDS(String.format("Not able to query all systems 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 arrayList;
}
use of org.milyn.payload.JavaResult in project coprhd-controller by CoprHD.
the class HDSApiExportManager method registerHost.
/**
* Register the given host with HiCommand Device Manager.
*
* @param hostName
* @param ipAddress
* @param portWWN
* @return
* @throws Exception
*/
public HDSHost registerHost(HDSHost hdshost, List<String> portWWNList, String initiatorType) throws Exception {
String addHostQueryWithParams = null;
InputStream responseStream = null;
HDSHost registeredhost = null;
try {
if (initiatorType.equalsIgnoreCase(HDSConstants.FC)) {
addHostQueryWithParams = constructAddFCInitiatorHostQuery(hdshost, portWWNList);
} else if (initiatorType.equalsIgnoreCase(HDSConstants.ISCSI)) {
addHostQueryWithParams = constructAddiSCSIInitiatorHostQuery(hdshost, portWWNList);
}
log.info("Query to Add host: {}", addHostQueryWithParams);
URI endpointURI = hdsApiClient.getBaseURI();
ClientResponse response = hdsApiClient.post(endpointURI, addHostQueryWithParams);
if (HttpStatus.SC_OK == response.getStatus()) {
responseStream = response.getEntityInputStream();
JavaResult javaResult = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.HOST_INFO_SMOOKS_CONFIG_FILE);
EchoCommand command = javaResult.getBean(EchoCommand.class);
if (null == command || null == command.getStatus() || HDSConstants.FAILED_STR.equalsIgnoreCase(command.getStatus())) {
Error error = javaResult.getBean(Error.class);
if (error.getCode() == HDSConstants.HOST_ALREADY_EXISTS) {
log.info("The host {} already exists on DeviceManager", hdshost.getName());
return registeredhost;
} else if (error.getCode() == HDSConstants.HOST_PORT_WWN_ALREADY_EXISTS) {
log.info("The WWN is already in use by another host");
return registeredhost;
} else {
log.error("Error response received for messageID", command.getMessageID());
log.error("command failed with error code: {} with message {}", error.getCode(), error.getDescription());
throw HDSException.exceptions.notAbleToAddHostToDeviceManager(hdshost.getName());
}
}
registeredhost = javaResult.getBean(HDSHost.class);
if (null == registeredhost) {
throw HDSException.exceptions.notAbleToAddHostToDeviceManager(String.format("Not able to add host:%1$s to Device manager", hdshost.getName()));
}
} else {
throw HDSException.exceptions.invalidResponseFromHDS(String.format("Add Host to Device Manager 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 registeredhost;
}
use of org.milyn.payload.JavaResult in project coprhd-controller by CoprHD.
the class HDSApiExportManager method addLUN.
/**
* API call to addLun to the storage array.
* Once the client makes the call, the luns should be visible to the host.
*
* @param systemId
* @param targetPortId
* @param domainId
* @param deviceLunList
* @param model
* @throws Exception
*/
public List<Path> addLUN(String systemId, String targetPortId, String domainId, Map<String, String> deviceLunList, String model) throws Exception {
InputStream responseStream = null;
List<Path> pathList = new ArrayList<Path>();
try {
String addLUNQuery = constructAddLUNQuery(systemId, targetPortId, domainId, deviceLunList, pathList, model);
log.info("Query to addLUN Query: {}", addLUNQuery);
URI endpointURI = hdsApiClient.getBaseURI();
ClientResponse response = hdsApiClient.post(endpointURI, addLUNQuery);
if (HttpStatus.SC_OK == response.getStatus()) {
responseStream = response.getEntityInputStream();
JavaResult javaResult = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.SMOOKS_CONFIG_FILE);
verifyErrorPayload(javaResult);
pathList = (List<Path>) javaResult.getBean(HDSConstants.PATHLIST_RESPONSE_BEANID);
if (pathList.isEmpty()) {
throw HDSException.exceptions.notAbleToAddVolumeToHSD(domainId, systemId);
}
} else {
throw HDSException.exceptions.invalidResponseFromHDS(String.format("Not able to add Volume to 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 pathList;
}
use of org.milyn.payload.JavaResult in project coprhd-controller by CoprHD.
the class HDSApiExportManager method deleteISCSIsFromHostStorageDomain.
/**
* Remove ISCSIName from the HostStorageDomain means disable LUN security by to the given iSCSIName.
*
* @param systemId
* @param hsdId
* @param scsiNameList
* @param model
* @return
* @throws Exception
*/
public void deleteISCSIsFromHostStorageDomain(String systemId, String hsdId, List<String> scsiNameList, String model) throws Exception {
InputStream responseStream = null;
try {
String addISCSINamesToHSDQuery = constructRemoveISCSIQuery(systemId, hsdId, scsiNameList, model);
log.info("Query to remove SCSI Initiators from 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);
log.info("Remove iscsi initiators: {} from HSD: {}", scsiNameList, hsdId);
} else {
throw HDSException.exceptions.invalidResponseFromHDS(String.format("Remove iSCSI initiator From 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");
}
}
}
}
Aggregations