use of com.emc.storageos.hds.model.SnapshotGroup in project coprhd-controller by CoprHD.
the class HDSApiProtectionManager method deleteThinImagePair.
/**
* Deletes ReplicationInfo instance from SnapshotGroup
*
* @param snapshotGroupObjId
* @param replicationInfoObjId
* @throws Exception
*/
public void deleteThinImagePair(String hostObjId, String snapshotGroupObjId, String replicationInfoObjId, String model) throws Exception {
InputStream responseStream = null;
ReplicationInfo replicationInfo = null;
try {
if (hostObjId != null && snapshotGroupObjId != null && replicationInfoObjId != null) {
Map<String, Object> attributeMap = new HashMap<String, Object>();
Delete deleteOp = new Delete(HDSConstants.REPLICATION, HDSConstants.INBAND2);
HDSHost host = new HDSHost();
host.setObjectID(hostObjId);
SnapshotGroup snapshotGroup = new SnapshotGroup();
snapshotGroup.setObjectID(snapshotGroupObjId);
replicationInfo = new ReplicationInfo();
replicationInfo.setObjectID(replicationInfoObjId);
attributeMap.put(HDSConstants.DELETE, deleteOp);
attributeMap.put(HDSConstants.HOST, host);
attributeMap.put(HDSConstants.MODEL, model);
attributeMap.put(HDSConstants.SNAPSHOTGROUP, snapshotGroup);
attributeMap.put(HDSConstants.REPLICATION_INFO, replicationInfo);
String deleteThinImagePairInputXML = InputXMLGenerationClient.getInputXMLString(HDSConstants.DELETE_THIN_IMAGE_PAIR_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
log.info("Query to delete thin image pair : {}", deleteThinImagePairInputXML);
URI endpointURI = hdsApiClient.getBaseURI();
ClientResponse response = hdsApiClient.post(endpointURI, deleteThinImagePairInputXML);
if (HttpStatus.SC_OK == response.getStatus()) {
responseStream = response.getEntityInputStream();
JavaResult result = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.HITACHI_SMOOKS_THINIMAGE_CONFIG_FILE);
verifyErrorPayload(result);
log.info("Thin Image pair deleted successfully.");
} else {
log.error("Thin Image pair deletion failed with invalid response code {}", response.getStatus());
throw HDSException.exceptions.invalidResponseFromHDS(String.format("Thin Image pair deletion 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");
}
}
}
}
use of com.emc.storageos.hds.model.SnapshotGroup in project coprhd-controller by CoprHD.
the class HDSSnapshotOperations method deleteSingleVolumeSnapshot.
/**
* 1. Delete ThinImage Pair
* 2. Delete Dummy lun path from snap volume
* 3. Delete Snapshot
*/
@Override
public void deleteSingleVolumeSnapshot(StorageSystem storage, URI snapshot, TaskCompleter taskCompleter) throws DeviceControllerException {
log.info("Delete Single Volume Snapshot Started");
try {
BlockSnapshot snapshotObj = dbClient.queryObject(BlockSnapshot.class, snapshot);
log.info("deleteSingleVolumeSnapshot operation START");
HDSApiClient hdsApiClient = hdsApiFactory.getClient(HDSUtils.getHDSServerManagementServerInfo(storage), storage.getSmisUserName(), storage.getSmisPassword());
// Get pair management server
HDSHost pairMgmtServer = hdsApiClient.getSnapshotGroupPairManagementServer(storage.getSerialNumber());
if (null == pairMgmtServer) {
log.error("Unable to find snapshot group information/pair management server for Thin Image");
throw HDSException.exceptions.snapshotGroupNotAvailable(storage.getNativeGuid());
}
// Get snapshot group id
SnapshotGroup snapshotGroup = getViPRSnapshotGroup(pairMgmtServer, storage.getSerialNumber());
String snapShotGrpId = snapshotGroup.getObjectID();
// Get replication object ids
Volume volume = dbClient.queryObject(Volume.class, snapshotObj.getParent());
ReplicationInfo replicationInfo = getReplicationInfo(snapshotGroup, volume.getNativeId(), snapshotObj.getNativeId());
if (replicationInfo != null) {
String replicationInfoObjId = replicationInfo.getObjectID();
// Delete ThinImage pair between volume and snapshot
hdsApiClient.deleteThinImagePair(pairMgmtServer.getObjectID(), snapShotGrpId, replicationInfoObjId, storage.getModel());
} else {
log.info("Pair has been deleted already on storage system");
}
// Remove dummy lun path
hdsProtectionOperations.removeDummyLunPath(storage, snapshot);
// Delete snapshot vollume
hdsProtectionOperations.deleteSecondaryVolumeSnapshot(storage, snapshotObj, taskCompleter);
log.info("Delete Single Volume Snapshot Completed");
} catch (Exception e) {
String errorMsg = String.format(DELETE_ERROR_MSG_FORMAT, snapshot);
log.error(errorMsg, e);
ServiceError serviceError = DeviceControllerErrors.hds.methodFailed("deleteSingleVolumeSnapshot", e.getMessage());
taskCompleter.error(dbClient, serviceError);
}
}
Aggregations