use of org.milyn.payload.JavaResult in project coprhd-controller by CoprHD.
the class HDSApiVolumeManager method addLUSE.
/**
* Form a single meta volume by concatenating multiple volumes.
*
* @param systemObjectId
* @param ldevIds
* @return
* @throws Exception
*/
public LogicalUnit addLUSE(String systemObjectId, String metaHead, List<String> ldevIds) throws Exception {
String addLUSEQuery = constructAddLUSEQuery(systemObjectId, metaHead, ldevIds);
URI endpointURI = hdsApiClient.getBaseURI();
InputStream responseStream = null;
LogicalUnit logicalUnit = null;
try {
log.info("Add LUSE Query payload :{}", addLUSEQuery);
ClientResponse response = hdsApiClient.post(endpointURI, addLUSEQuery);
if (HttpStatus.SC_OK == response.getStatus()) {
responseStream = response.getEntityInputStream();
JavaResult result = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.SMOOKS_CONFIG_FILE);
verifyErrorPayload(result);
logicalUnit = (LogicalUnit) result.getBean(HDSConstants.LOGICALUNIT_BEAN_NAME);
} else {
log.error("AddLUSE failed with invalid response code {}", response.getStatus());
throw HDSException.exceptions.invalidResponseFromHDS(String.format("Not able to Add LUSE due to invalid response %1$s from server for system %2$s", response.getStatus(), systemObjectId));
}
} finally {
if (null != responseStream) {
try {
responseStream.close();
} catch (IOException e) {
log.warn("IOException occurred while closing the response stream");
}
}
}
return logicalUnit;
}
use of org.milyn.payload.JavaResult in project coprhd-controller by CoprHD.
the class HDSApiVolumeManager method addLabelToObject.
/**
* Adds the label to an Object in DeviceManager.
* Currently this is supported for labeling LDEV.
* So, targetID must be a LDEV ID of a LU.
*
* @param targetID
* @param label
* @return
* @throws Exception
*/
public ObjectLabel addLabelToObject(String targetID, String label) throws Exception {
InputStream responseStream = null;
ObjectLabel objectLabel = null;
Map<String, Object> attributeMap = new HashMap<String, Object>();
Add addOp = new Add(HDSConstants.OBJECTLABEL);
addOp.setOverwrite(Boolean.TRUE);
attributeMap.put(HDSConstants.ADD, addOp);
ObjectLabel objectLabelReq = new ObjectLabel(targetID, label);
attributeMap.put(HDSConstants.OBJECTLABEL, objectLabelReq);
String addLabelToObject = InputXMLGenerationClient.getInputXMLString(HDSConstants.ADD_LABEL_TO_OBJECT_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
URI endpointURI = hdsApiClient.getBaseURI();
log.info("Add Label to Object payload :{}", addLabelToObject);
ClientResponse response = hdsApiClient.post(endpointURI, addLabelToObject);
if (HttpStatus.SC_OK == response.getStatus()) {
responseStream = response.getEntityInputStream();
JavaResult result = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.SMOOKS_CONFIG_FILE);
verifyErrorPayload(result);
objectLabel = result.getBean(ObjectLabel.class);
} else {
log.error("Add label to Object failed with invalid response code {}", response.getStatus());
throw HDSException.exceptions.invalidResponseFromHDS(String.format("Not able to Add Label to object due to invalid response %1$s from server", response.getStatus()));
}
return objectLabel;
}
use of org.milyn.payload.JavaResult in project coprhd-controller by CoprHD.
the class HDSApiVolumeManager method deleteThinLogicalUnits.
public String deleteThinLogicalUnits(String systemObjectID, Set<String> logicalUnitIdList, String model) throws Exception {
InputStream responseStream = null;
String asyncTaskMessageId = null;
try {
Map<String, Object> attributeMap = new HashMap<String, Object>();
StorageArray storageArray = new StorageArray(systemObjectID);
Delete deleteOp = new Delete(HDSConstants.VIRTUALVOLUME, true);
List<LogicalUnit> luList = new ArrayList<LogicalUnit>();
for (String logicalUnitId : logicalUnitIdList) {
LogicalUnit logicalUnit = new LogicalUnit(logicalUnitId, null);
luList.add(logicalUnit);
}
attributeMap.put(HDSConstants.STORAGEARRAY, storageArray);
attributeMap.put(HDSConstants.DELETE, deleteOp);
attributeMap.put(HDSConstants.MODEL, model);
attributeMap.put(HDSConstants.LOGICALUNIT_LIST, luList);
String deleteVolumesInputXML = InputXMLGenerationClient.getInputXMLString(HDSConstants.DELETE_VOLUMES_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
log.info("volume delete payload :{}", deleteVolumesInputXML);
URI endpointURI = hdsApiClient.getBaseURI();
ClientResponse response = hdsApiClient.post(endpointURI, deleteVolumesInputXML);
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();
log.info("Async task id : {}", asyncTaskMessageId);
} else if (HDSConstants.FAILED_STR.equalsIgnoreCase(command.getStatus())) {
Error error = result.getBean(Error.class);
log.info("command failed error code: {}", error.getCode());
log.info("Command failed: messageID: {} {}", command.getMessageID(), error.getDescription());
throw HDSException.exceptions.notAbleToDeleteVolume(error.getCode(), error.getDescription());
}
} else {
log.error("LogicalUnit deletion failed with invalid response code {}", response.getStatus());
throw HDSException.exceptions.invalidResponseFromHDS(String.format("LogicalUnit creation failed due to invalid response %1$s from server for system %2$s", response.getStatus(), systemObjectID));
}
} finally {
if (null != responseStream) {
try {
responseStream.close();
} catch (IOException e) {
log.error(e.getMessage(), e);
}
}
}
return asyncTaskMessageId;
}
use of org.milyn.payload.JavaResult in project coprhd-controller by CoprHD.
the class HDSApiVolumeManager method modifyThinVolumeTieringPolicy.
public String modifyThinVolumeTieringPolicy(String systemObjectID, String luObjectID, String ldevObjectID, String tieringPolicyName, String model) {
InputStream responseStream = null;
String asyncTaskMessageId = null;
Map<String, Object> attributeMap = new HashMap<String, Object>();
Modify modifyOp = new Modify(HDSConstants.VIRTUALVOLUME);
StorageArray array = new StorageArray(systemObjectID);
LogicalUnit logicalUnit = new LogicalUnit();
logicalUnit.setObjectID(luObjectID);
LDEV ldev = new LDEV(ldevObjectID);
ldev.setTierLevel(Integer.parseInt(tieringPolicyName));
attributeMap.put(HDSConstants.STORAGEARRAY, array);
attributeMap.put(HDSConstants.MODIFY, modifyOp);
attributeMap.put(HDSConstants.MODEL, model);
attributeMap.put(HDSConstants.LOGICALUNIT, logicalUnit);
attributeMap.put(HDSConstants.LDEV, ldev);
String modifyThinVolumeTieringPolicyPayload = InputXMLGenerationClient.getInputXMLString(HDSConstants.MODIFY_THIN_VOLUME_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
URI endpointURI = hdsApiClient.getBaseURI();
log.info("Modify Volume TieringPolicy payload:{}", modifyThinVolumeTieringPolicyPayload);
ClientResponse response = hdsApiClient.post(endpointURI, modifyThinVolumeTieringPolicyPayload);
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("Modify Volume TieringPolicy failed status messageID: {}", command.getMessageID());
log.error("Modify Volume TieringPolicy failed with error code: {} with message: {}", error.getCode(), error.getDescription());
throw HDSException.exceptions.notAbleToCreateVolume(error.getCode(), error.getDescription());
}
} else {
log.error("Modify Volume TieringPolicy failed with invalid response code {}", response.getStatus());
throw HDSException.exceptions.invalidResponseFromHDS(String.format("Modify Volume TieringPolicy failed due to invalid response %1$s from server for system %2$s", response.getStatus(), systemObjectID));
}
return asyncTaskMessageId;
}
use of org.milyn.payload.JavaResult in project coprhd-controller by CoprHD.
the class HDSApiVolumeManager method releaseLUSE.
/**
* This client method is responsible to release all the volumes in LUSE volume.
*
* @param systemObjectId
* @param logicalUnitId
* @return
* @throws Exception
*/
public LogicalUnit releaseLUSE(String systemObjectId, String logicalUnitId) throws Exception {
Map<String, Object> attributeMap = new HashMap<String, Object>();
StorageArray storageArray = new StorageArray(systemObjectId);
attributeMap.put(HDSConstants.STORAGEARRAY, storageArray);
Add addOp = new Add(HDSConstants.LUSE_TARGET);
attributeMap.put(HDSConstants.GET, addOp);
attributeMap.put(HDSConstants.LOGICALUNIT, logicalUnitId);
String releaseLUSEVolumeInputXML = InputXMLGenerationClient.getInputXMLString(HDSConstants.RELEASE_LUSE_VOLUME_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
URI endpointURI = hdsApiClient.getBaseURI();
InputStream responseStream = null;
LogicalUnit logicalUnit = null;
try {
log.info("release LUSE Query payload :{}", releaseLUSEVolumeInputXML);
ClientResponse response = hdsApiClient.post(endpointURI, releaseLUSEVolumeInputXML);
if (HttpStatus.SC_OK == response.getStatus()) {
responseStream = response.getEntityInputStream();
JavaResult result = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.SMOOKS_CONFIG_FILE);
verifyErrorPayload(result);
logicalUnit = (LogicalUnit) result.getBean(HDSConstants.LOGICALUNIT_BEAN_NAME);
} else {
log.error("deleteLUSE failed with invalid response code {}", response.getStatus());
throw HDSException.exceptions.invalidResponseFromHDS(String.format("Not able to delete LUSE due to invalid response %1$s from server for system %2$s", response.getStatus(), systemObjectId));
}
} finally {
if (null != responseStream) {
try {
responseStream.close();
} catch (IOException e) {
log.warn("IOException occurred while closing the response stream");
}
}
}
return logicalUnit;
}
Aggregations