use of org.milyn.payload.JavaResult in project coprhd-controller by CoprHD.
the class HDSApiVolumeManager method modifyVirtualVolume.
/**
* Modify the Virtual Volumes with the passed information.
*
* @param systemId : represents SystemObjectID.
* @param newLUCapacityInBytes: new VirtualVolume Capacity in bytes.
* @return : asyncMessageId
* @throws Exception
*/
public String modifyVirtualVolume(String systemId, String luObjectId, Long newLUCapacityInBytes, String model) throws Exception {
Long luCapacityInKB = newLUCapacityInBytes / 1024;
InputStream responseStream = null;
String asyncTaskMessageId = null;
try {
Map<String, Object> attributeMap = new HashMap<String, Object>();
StorageArray storageArray = new StorageArray(systemId);
Modify modifyOp = new Modify(HDSConstants.VIRTUALVOLUME, false);
LogicalUnit logicalUnit = new LogicalUnit(luObjectId, String.valueOf(luCapacityInKB));
attributeMap.put(HDSConstants.STORAGEARRAY, storageArray);
attributeMap.put(HDSConstants.MODEL, model);
attributeMap.put(HDSConstants.MODIFY, modifyOp);
attributeMap.put(HDSConstants.LOGICALUNIT, logicalUnit);
String modifyVolumeInputXML = InputXMLGenerationClient.getInputXMLString(HDSConstants.MODIFY_THIN_VOLUME_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
log.info("Query to modify Thin Volume: {}", modifyVolumeInputXML);
URI endpointURI = hdsApiClient.getBaseURI();
ClientResponse response = hdsApiClient.post(endpointURI, modifyVolumeInputXML);
if (HttpStatus.SC_OK == response.getStatus()) {
responseStream = response.getEntityInputStream();
JavaResult result = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.SMOOKS_CONFIG_FILE);
EchoCommand command = result.getBean(EchoCommand.class);
log.info("command Status :{} MessageId :{}", command.getStatus(), command.getMessageID());
if (HDSConstants.PROCESSING_STR.equalsIgnoreCase(command.getStatus()) || HDSConstants.COMPLETED_STR.equalsIgnoreCase(command.getStatus())) {
asyncTaskMessageId = command.getMessageID();
} else if (HDSConstants.FAILED_STR.equalsIgnoreCase(command.getStatus())) {
Error error = result.getBean(Error.class);
log.error("Thin Volume modification failed status messageID: {}", command.getMessageID());
log.error("Thin Volume modification failed with error code: {} with message: {}", error.getCode(), error.getDescription());
throw HDSException.exceptions.notAbleToCreateVolume(error.getCode(), error.getDescription());
}
} else {
log.error("Thin Volume modification failed with invalid response code {}", response.getStatus());
throw HDSException.exceptions.invalidResponseFromHDS(String.format("Thin Volume modification failed due to invalid response %1$s from server for system %2$s", response.getStatus(), systemId));
}
} finally {
if (null != responseStream) {
try {
responseStream.close();
} catch (IOException e) {
log.warn("Exception occurred while closing Thin volume modification response stream");
}
}
}
return asyncTaskMessageId;
}
use of org.milyn.payload.JavaResult in project coprhd-controller by CoprHD.
the class HDSApiVolumeManager method createSnapshotVolume.
public String createSnapshotVolume(String systemObjectId, Long luCapacityInBytes, String model) throws Exception {
Long luCapacityInKB = luCapacityInBytes / 1024;
InputStream responseStream = null;
String asyncTaskMessageId = null;
try {
log.info("Creating snapshot with {}KB size on Storage System {}", luCapacityInKB, systemObjectId);
Map<String, Object> attributeMap = new HashMap<String, Object>();
Add addOp = new Add(HDSConstants.VIRTUALVOLUME);
StorageArray storageArray = new StorageArray(systemObjectId);
ArrayGroup arrayGroup = new ArrayGroup();
arrayGroup.setType("2");
LogicalUnit logicalUnit = new LogicalUnit();
logicalUnit.setCapacityInKB(String.valueOf(luCapacityInKB));
logicalUnit.setEmulation(HDSConstants.EMULATION_OPENV);
attributeMap.put(HDSConstants.STORAGEARRAY, storageArray);
attributeMap.put(HDSConstants.MODEL, model);
attributeMap.put(HDSConstants.ARRAY_GROUP, arrayGroup);
attributeMap.put(HDSConstants.ADD, addOp);
attributeMap.put(HDSConstants.LOGICALUNIT, logicalUnit);
String createSnapshotInputXML = InputXMLGenerationClient.getInputXMLString(HDSConstants.CREATE_SNAPSHOT_VOLUME_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
log.info("Query to create snapshot Volume: {}", createSnapshotInputXML);
URI endpointURI = hdsApiClient.getBaseURI();
ClientResponse response = hdsApiClient.post(endpointURI, createSnapshotInputXML);
if (HttpStatus.SC_OK == response.getStatus()) {
responseStream = response.getEntityInputStream();
JavaResult result = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.SMOOKS_CONFIG_FILE);
EchoCommand command = result.getBean(EchoCommand.class);
log.info("command Status :{} MessageId :{}", command.getStatus(), command.getMessageID());
if (HDSConstants.PROCESSING_STR.equalsIgnoreCase(command.getStatus()) || HDSConstants.COMPLETED_STR.equalsIgnoreCase(command.getStatus())) {
asyncTaskMessageId = command.getMessageID();
} else if (HDSConstants.FAILED_STR.equalsIgnoreCase(command.getStatus())) {
Error error = result.getBean(Error.class);
log.error("Thin snapshot creation failed status messageID: {}", command.getMessageID());
log.error("Thin snapshot creation failed with error code: {} with message: {}", error.getCode(), error.getDescription());
throw HDSException.exceptions.notAbleToCreateSnapshot(error.getCode(), error.getDescription());
}
} else {
log.error("Thin snapshot creation failed with invalid response code {}", response.getStatus());
throw HDSException.exceptions.invalidResponseFromHDS(String.format("Thin snapshot creation failed due to invalid response %1$s from server for system %2$s", response.getStatus(), systemObjectId));
}
log.info("Snapshot creation initiated on Storage System {}", systemObjectId);
} finally {
if (null != responseStream) {
try {
responseStream.close();
} catch (IOException e) {
log.warn("Exception occurred while closing snapshot creation response stream");
}
}
}
return asyncTaskMessageId;
}
use of org.milyn.payload.JavaResult in project coprhd-controller by CoprHD.
the class HDSBatchApiExportManager method addISCSINamesToHostStorageDomain.
/**
* This method makes a HTTP POST call to HiCommand with a payload of muliple
* HSD's and each with a set of ISCSINames. This method can only be used for
* ISCSI HSD's.
*
* @param systemId
* - represents Storage System ObjectID.
* @param hsdList
* - List of HostStorageDomain objects.
* @return - List of HostStorageDomain objects with ISCSINames's added.
* @throws Exception
* - In case of processing error.
*/
public List<HostStorageDomain> addISCSINamesToHostStorageDomain(String systemId, List<HostStorageDomain> hsdList, String model) throws Exception {
InputStream responseStream = null;
List<HostStorageDomain> hsdResponseList = null;
try {
String addISCSINamesToHSDsQuery = constructISCSINamesQuery(systemId, hsdList, model);
log.info("batch query to add ISCSI initiators to HostStorageDomains: {}", addISCSINamesToHSDsQuery);
URI endpointURI = hdsApiClient.getBaseURI();
ClientResponse response = hdsApiClient.post(endpointURI, addISCSINamesToHSDsQuery);
if (HttpStatus.SC_OK == response.getStatus()) {
responseStream = response.getEntityInputStream();
JavaResult javaResult = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.SMOOKS_CONFIG_FILE);
verifyErrorPayload(javaResult);
hsdResponseList = (List<HostStorageDomain>) javaResult.getBean(HDSConstants.HSD_RESPONSE_BEAN_ID);
if (null == hsdResponseList || hsdResponseList.isEmpty()) {
throw HDSException.exceptions.notAbleToAddInitiatorsToHostStorageDomain(systemId);
}
} else {
throw HDSException.exceptions.invalidResponseFromHDS(String.format("Batch query to add ISCSI initiators to HSDs 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 hsdResponseList;
}
use of org.milyn.payload.JavaResult in project coprhd-controller by CoprHD.
the class HDSBatchApiExportManager method addWWNsToHostStorageDomain.
/**
* This method makes a HTTP POST call to HiCommand with a payload of muliple
* HSD's and each with a set of WWNs. This method can only be used for FC
* HSD's.
*
* @param systemId
* - represents Storage System ObjectID.
* @param hsdList
* - List of HostStorageDomain objects.
* @return - List of HostStorageDomain objects with WWN's added.
* @throws Exception
* - In case of processing error.
*/
public List<HostStorageDomain> addWWNsToHostStorageDomain(String systemId, List<HostStorageDomain> hsdList, String model) throws Exception {
InputStream responseStream = null;
List<HostStorageDomain> hsdResponseList = null;
try {
String addWWNToHSDsQuery = constructWWNQuery(systemId, hsdList, model);
log.info("batch query to add FC initiators to HostStorageDomains: {}", addWWNToHSDsQuery);
URI endpointURI = hdsApiClient.getBaseURI();
ClientResponse response = hdsApiClient.post(endpointURI, addWWNToHSDsQuery);
if (HttpStatus.SC_OK == response.getStatus()) {
responseStream = response.getEntityInputStream();
JavaResult javaResult = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.SMOOKS_CONFIG_FILE);
verifyErrorPayload(javaResult);
hsdResponseList = (List<HostStorageDomain>) javaResult.getBean(HDSConstants.HSD_RESPONSE_BEAN_ID);
if (null == hsdResponseList || hsdResponseList.isEmpty()) {
throw HDSException.exceptions.notAbleToAddInitiatorsToHostStorageDomain(systemId);
}
} else {
throw HDSException.exceptions.invalidResponseFromHDS(String.format("Batch query to add FC initiators to HSDs 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 hsdResponseList;
}
use of org.milyn.payload.JavaResult in project coprhd-controller by CoprHD.
the class HDSBatchApiExportManager method addLUNPathsToHSDs.
/**
* This method makes a HTTP POST call to add multiple LUN Paths using a
* batch query.
*
* @param systemId
* - Represents the storage system objectID.
* @param pathList
* - List of Path objects.
* @param model - model of the system
* @return - List of Path objects after successful creation.
* @throws Exception
* - Incase of processing Error.
*/
public List<Path> addLUNPathsToHSDs(String systemId, List<Path> pathList, String model) throws Exception {
InputStream responseStream = null;
List<Path> pathResponseList = null;
try {
String addLUNQuery = constructAddLUNQuery(systemId, 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);
pathResponseList = (List<Path>) javaResult.getBean(HDSConstants.PATHLIST_RESPONSE_BEANID);
if (null == pathResponseList || pathResponseList.isEmpty()) {
throw HDSException.exceptions.notAbleToAddVolumeToHSD(null, 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 pathResponseList;
}
Aggregations