use of com.emc.storageos.hds.model.Modify in project coprhd-controller by CoprHD.
the class HDSApiProtectionManager method modifyShadowImagePair.
/**
* Modify ShadowImage pair operation .
*
* @param replicationGroupId
* @param replicationInfoId
* @param operationType
* @return {@link ReplicationInfo}
* @throws Exception
*/
public ReplicationInfo modifyShadowImagePair(String replicationGroupId, String replicationInfoId, ShadowImageOperationType operationType, String model) throws Exception {
InputStream responseStream = null;
ReplicationInfo replicationInfo = null;
try {
if (replicationGroupId != null && replicationInfoId != null) {
Map<String, Object> attributeMap = new HashMap<String, Object>();
Modify modifyOp = new Modify();
modifyOp.setTarget(HDSConstants.REPLICATION);
modifyOp.setOption(operationType.name());
ReplicationGroup replicationGroup = new ReplicationGroup();
replicationGroup.setObjectID(replicationGroupId);
replicationInfo = new ReplicationInfo();
replicationInfo.setObjectID(replicationInfoId);
attributeMap.put(HDSConstants.MODIFY, modifyOp);
attributeMap.put(HDSConstants.MODEL, model);
attributeMap.put(HDSConstants.REPLICATION_GROUP, replicationGroup);
attributeMap.put(HDSConstants.REPLICATION_INFO, replicationInfo);
String modifyPairQuery = InputXMLGenerationClient.getInputXMLString(HDSConstants.MODIFY_SHADOW_IMAGE_PAIR_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
log.info("Query to {} shadow image pair Query: {}", operationType.name(), modifyPairQuery);
URI endpointURI = hdsApiClient.getBaseURI();
ClientResponse response = hdsApiClient.post(endpointURI, modifyPairQuery);
if (HttpStatus.SC_OK == response.getStatus()) {
responseStream = response.getEntityInputStream();
JavaResult javaResult = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.HITACHI_SMOOKS_REPLICATION_CONFIG_FILE);
verifyErrorPayload(javaResult);
log.info("Successfully {}ed pair", operationType.name());
replicationInfo = javaResult.getBean(ReplicationInfo.class);
log.info("replicationInfo :{}", replicationInfo);
/*
* if (null == replicationInfo) {
* throw HDSException.exceptions.notAbleToCreateShadowImagePair();
* }
*/
} else {
throw HDSException.exceptions.invalidResponseFromHDS(String.format("Not able to modify replication info 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 replicationInfo;
}
use of com.emc.storageos.hds.model.Modify in project coprhd-controller by CoprHD.
the class HDSApiVolumeManager method formatLogicalUnit.
/**
* Formats the LogicalUnit.
*
* @param systemObjectId
* @param luObjectId
* @return
*/
public String formatLogicalUnit(String systemObjectId, String luObjectId) {
InputStream responseStream = null;
String asyncTaskMessageId = null;
try {
Map<String, Object> attributeMap = new HashMap<String, Object>();
StorageArray storageArray = new StorageArray(systemObjectId);
Modify modifyOp = new Modify(HDSConstants.LU_FORMAT_TARGET, true);
LogicalUnit logicalUnit = new LogicalUnit(luObjectId, null);
attributeMap.put(HDSConstants.STORAGEARRAY, storageArray);
attributeMap.put(HDSConstants.MODIFY, modifyOp);
attributeMap.put(HDSConstants.LOGICALUNIT, logicalUnit);
String fromatVolumeInputXML = InputXMLGenerationClient.getInputXMLString(HDSConstants.FORMAT_VOLUME_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
log.info("Query to format LogicalUnit: {}", fromatVolumeInputXML);
URI endpointURI = hdsApiClient.getBaseURI();
ClientResponse response = hdsApiClient.post(endpointURI, fromatVolumeInputXML);
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("Query to format LogicalUnit: failed status messageID: {}", command.getMessageID());
log.error("LogicalUnit formatting failed with error code: {} with message: {}", error.getCode(), error.getDescription());
throw HDSException.exceptions.notAbleToCreateVolume(error.getCode(), error.getDescription());
}
} else {
log.error("LogicalUnit format failed with invalid response code {}", response.getStatus());
throw HDSException.exceptions.invalidResponseFromHDS(String.format("LogicalUnit format 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.warn("Exception occurred while closing Formatting LogicalUnit response stream");
}
}
}
return asyncTaskMessageId;
}
use of com.emc.storageos.hds.model.Modify in project coprhd-controller by CoprHD.
the class HDSApiProtectionManager method restoreThinImagePair.
/**
* Restore's snapshot to source volume.
*
* @param pairMgmtServerHostObjId
* @param snapshotGroupObjId
* @param replicationInfoObjId
* @return
* @throws Exception
*/
public boolean restoreThinImagePair(String pairMgmtServerHostObjId, String snapshotGroupObjId, String replicationInfoObjId, String model) throws Exception {
InputStream responseStream = null;
ReplicationInfo replicationInfo = null;
boolean status = false;
try {
if (pairMgmtServerHostObjId != null && snapshotGroupObjId != null && replicationInfoObjId != null) {
log.info("Restore thin image pair started");
Map<String, Object> attributeMap = new HashMap<String, Object>();
Modify modifyOp = new Modify(HDSConstants.REPLICATION);
modifyOp.setOption(HDSConstants.RESTORE_INBAND2);
HDSHost host = new HDSHost();
host.setObjectID(pairMgmtServerHostObjId);
SnapshotGroup snapshotGroup = new SnapshotGroup();
snapshotGroup.setObjectID(snapshotGroupObjId);
replicationInfo = new ReplicationInfo();
replicationInfo.setObjectID(replicationInfoObjId);
attributeMap.put(HDSConstants.MODIFY, modifyOp);
attributeMap.put(HDSConstants.MODEL, model);
attributeMap.put(HDSConstants.HOST, host);
attributeMap.put(HDSConstants.SNAPSHOTGROUP, snapshotGroup);
attributeMap.put(HDSConstants.REPLICATION_INFO, replicationInfo);
String restoreThinImagePairQuery = InputXMLGenerationClient.getInputXMLString(HDSConstants.RESTORE_THIN_IMAGE_PAIR_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
log.info("Query to restore thin image pair Query: {}", restoreThinImagePairQuery);
URI endpointURI = hdsApiClient.getBaseURI();
ClientResponse response = hdsApiClient.post(endpointURI, restoreThinImagePairQuery);
if (HttpStatus.SC_OK == response.getStatus()) {
responseStream = response.getEntityInputStream();
JavaResult javaResult = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.HITACHI_SMOOKS_THINIMAGE_CONFIG_FILE);
verifyErrorPayload(javaResult);
log.info("Successfully restored thin image pair");
status = true;
replicationInfo = javaResult.getBean(ReplicationInfo.class);
log.info("replicationInfo :{}", replicationInfo);
/*
* if (null == replicationInfo) {
* throw HDSException.exceptions.notAbleToCreateShadowImagePair();
* }
*/
} else {
throw HDSException.exceptions.invalidResponseFromHDS(String.format("Not able to delete shadow image pair due to invalid response %1$s from server", response.getStatus()));
}
} else {
log.info("Replication info is not available on pair management server");
}
} finally {
if (null != responseStream) {
try {
responseStream.close();
} catch (IOException e) {
log.warn("IOException occurred while closing the response stream");
}
}
}
return status;
}
use of com.emc.storageos.hds.model.Modify 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 com.emc.storageos.hds.model.Modify 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;
}
Aggregations