use of com.emc.storageos.hds.model.ReplicationInfo 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.ReplicationInfo in project coprhd-controller by CoprHD.
the class HDSMirrorOperations method createSingleVolumeMirror.
/**
* 1. Find ReplicationGroup objId from Device Manager
* 2. Check dummy Host Group available on Storage System. if not available create a dummy Host Group name.
* 3. Create a secondary volume and add dummy host group on it.
* 4. create a SI pair.
*
* @param storageSystem {@link StorageSystem}
* @param mirrorVolumeURI {@link URI}
* @param createInactive {@link Boolean}
* @param taskCompleter {@link TaskCompleter}
*/
@Override
public void createSingleVolumeMirror(StorageSystem storageSystem, URI mirrorVolumeURI, Boolean createInactive, TaskCompleter taskCompleter) throws DeviceControllerException {
log.info("START createSingleVolumeMirror operation");
try {
HDSApiClient hdsApiClient = hdsApiFactory.getClient(HDSUtils.getHDSServerManagementServerInfo(storageSystem), storageSystem.getSmisUserName(), storageSystem.getSmisPassword());
HDSApiProtectionManager hdsApiProtectionManager = hdsApiClient.getHdsApiProtectionManager();
String replicationGroupObjectID = hdsApiClient.getHdsApiProtectionManager().getReplicationGroupObjectId();
if (replicationGroupObjectID == null) {
log.error("Unable to find replication group information/pair management server for pair configuration");
throw HDSException.exceptions.replicationGroupNotAvailable();
}
BlockMirror mirrorObj = dbClient.queryObject(BlockMirror.class, mirrorVolumeURI);
Volume source = dbClient.queryObject(Volume.class, mirrorObj.getSource());
hdsProtectionOperations.createSecondaryVolumeForMirror(storageSystem, source.getId(), mirrorObj);
mirrorObj = dbClient.queryObject(BlockMirror.class, mirrorVolumeURI);
hdsProtectionOperations.addDummyLunPath(hdsApiClient, mirrorObj);
String pairName = hdsProtectionOperations.generatePairName(source, mirrorObj);
log.info("Pair Name :{}", pairName);
ReplicationInfo replicationInfo = hdsApiProtectionManager.createShadowImagePair(replicationGroupObjectID, pairName, HDSUtils.getSystemArrayType(storageSystem), HDSUtils.getSystemSerialNumber(storageSystem), source.getNativeId(), mirrorObj.getNativeId(), storageSystem.getModel());
mirrorObj.setSyncState(SynchronizationState.SYNCHRONIZED.name());
dbClient.persistObject(mirrorObj);
log.info("Replication Info object :{}", replicationInfo.toXMLString());
taskCompleter.ready(dbClient);
} catch (Exception e) {
String errorMsg = String.format(CREATE_ERROR_MSG_FORMAT, mirrorVolumeURI);
log.error(errorMsg, e);
ServiceError serviceError = DeviceControllerErrors.hds.methodFailed("createSingleVolumeMirror", e.getMessage());
taskCompleter.error(dbClient, serviceError);
}
log.info("FINISHED createSingleVolumeMirror operation");
}
use of com.emc.storageos.hds.model.ReplicationInfo 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);
}
}
use of com.emc.storageos.hds.model.ReplicationInfo in project coprhd-controller by CoprHD.
the class HDSSnapshotOperations method getReplicationInfo.
/**
* Get replicationInfo object for the given pvol and svol from SnapshotGroup instance.
*/
private ReplicationInfo getReplicationInfo(SnapshotGroup snapShotGrp, String pvoldevnum, String svoldevnum) {
ReplicationInfo repInfo = null;
if (snapShotGrp != null && snapShotGrp.getReplicationInfoList() != null) {
log.info("rep list size :{}", snapShotGrp.getReplicationInfoList().size());
for (ReplicationInfo replicationInfo : snapShotGrp.getReplicationInfoList()) {
if (null != replicationInfo) {
log.debug("Rep Info :{}", replicationInfo.toXMLString());
if (pvoldevnum.equals(replicationInfo.getPvolDevNum()) && svoldevnum.equals(replicationInfo.getSvolDevNum())) {
log.info("Found replication info object :{}", replicationInfo.getObjectID());
repInfo = replicationInfo;
break;
}
}
}
}
return repInfo;
}
use of com.emc.storageos.hds.model.ReplicationInfo in project coprhd-controller by CoprHD.
the class HDSStorageDevice method doWaitForSynchronized.
/*
* (non-Javadoc)
*
* @see
* com.emc.storageos.volumecontroller.BlockStorageDevice#doWaitForSynchronized
* (java.lang.Class, com.emc.storageos.db.client.model.StorageSystem,
* java.net.URI, com.emc.storageos.volumecontroller.TaskCompleter)
*/
@Override
public void doWaitForSynchronized(Class<? extends BlockObject> clazz, StorageSystem storageObj, URI target, TaskCompleter completer) {
log.info("START waitForSynchronized for {}", target);
try {
Volume targetObj = dbClient.queryObject(Volume.class, target);
// Source could be either Volume or BlockSnapshot
BlockObject sourceObj = BlockObject.fetch(dbClient, targetObj.getAssociatedSourceVolume());
// We split the pair which causes the data to be synchronized.
// When the split is complete that data is synchronized.
HDSApiClient hdsApiClient = hdsApiFactory.getClient(HDSUtils.getHDSServerManagementServerInfo(storageObj), storageObj.getSmisUserName(), storageObj.getSmisPassword());
HDSApiProtectionManager hdsApiProtectionManager = hdsApiClient.getHdsApiProtectionManager();
String replicationGroupObjectID = hdsApiProtectionManager.getReplicationGroupObjectId();
ReplicationInfo replicationInfo = hdsApiProtectionManager.getReplicationInfoFromSystem(sourceObj.getNativeId(), targetObj.getNativeId()).first;
hdsApiProtectionManager.modifyShadowImagePair(replicationGroupObjectID, replicationInfo.getObjectID(), HDSApiProtectionManager.ShadowImageOperationType.split, storageObj.getModel());
// Update state in case we are waiting for synchronization
// after creation of a new full copy that was not created
// inactive.
String state = targetObj.getReplicaState();
if (!ReplicationState.SYNCHRONIZED.name().equals(state)) {
targetObj.setSyncActive(true);
targetObj.setReplicaState(ReplicationState.SYNCHRONIZED.name());
dbClient.persistObject(targetObj);
}
// Queue job to wait for replication status to move to split.
ControllerServiceImpl.enqueueJob(new QueueJob(new HDSReplicationSyncJob(storageObj.getId(), sourceObj.getNativeId(), targetObj.getNativeId(), ReplicationStatus.SPLIT, completer)));
} catch (Exception e) {
log.error("Exception occurred while waiting for synchronization", e);
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
completer.error(dbClient, serviceError);
}
log.info("completed doWaitForSynchronized");
}
Aggregations