use of com.emc.fapiclient.ws.ConsistencyGroupCopyUID in project coprhd-controller by CoprHD.
the class RecoverPointClient method deleteCG.
/**
* Delete the consistency group specified by the input volume info.
*
* @param RecoverPointVolumeProtectionInfo volumeInfo - Volume info for the CG to delete
*
* @return void
*
* @throws RecoverPointException
*/
public void deleteCG(RecoverPointVolumeProtectionInfo cgToDelete) throws RecoverPointException {
ConsistencyGroupCopyUID cgCopyUID = RecoverPointUtils.mapRPVolumeProtectionInfoToCGCopyUID(cgToDelete);
String cgName = null;
try {
cgName = functionalAPI.getGroupName(cgCopyUID.getGroupUID());
ConsistencyGroupSettings groupSettings = functionalAPI.getGroupSettings(cgCopyUID.getGroupUID());
List<ConsistencyGroupCopyUID> productionCopiesUIDs = groupSettings.getProductionCopiesUIDs();
for (ConsistencyGroupCopyUID productionCopyUID : productionCopiesUIDs) {
if (!cgToDelete.isMetroPoint() && !RecoverPointUtils.copiesEqual(productionCopyUID, cgCopyUID)) {
// Can't call delete CG using anything but the production CG copy
throw RecoverPointException.exceptions.cantCallDeleteCGUsingProductionCGCopy(cgName);
}
}
// First disable the CG before removing it, this buys RP a bit of time
// to clean it up.
disableConsistencyGroup(cgCopyUID.getGroupUID());
// Delete the CG, async call to RP
functionalAPI.removeConsistencyGroup(cgCopyUID.getGroupUID());
// Verify the CG has been removed
validateCGRemoved(cgCopyUID.getGroupUID(), cgName);
logger.info("Deleted consistency group " + cgName);
} catch (FunctionalAPIActionFailedException_Exception e) {
throw RecoverPointException.exceptions.failedToDeleteConsistencyGroup(cgName, e);
} catch (FunctionalAPIInternalError_Exception e) {
throw RecoverPointException.exceptions.failedToDeleteConsistencyGroup(cgName, e);
} catch (Exception e) {
throw RecoverPointException.exceptions.failedToDeleteConsistencyGroup(cgName, e);
}
}
use of com.emc.fapiclient.ws.ConsistencyGroupCopyUID in project coprhd-controller by CoprHD.
the class RecoverPointClient method disableProtection.
/**
* Disable (stop) the consistency group protection specified by the input volume info.
* If a target volume is specified, disable the copy associated with the target.
* Disable requires a full sweep when enabled.
*
* @param RecoverPointVolumeProtectionInfo volumeInfo - Volume info for the CG to disable
*
* @return void
*
* @throws RecoverPointException
*/
public void disableProtection(RecoverPointVolumeProtectionInfo volumeInfo) throws RecoverPointException {
try {
ConsistencyGroupUID cgUID = new ConsistencyGroupUID();
cgUID.setId(volumeInfo.getRpVolumeGroupID());
if (volumeInfo.getRpVolumeCurrentProtectionStatus() == RecoverPointVolumeProtectionInfo.volumeProtectionStatus.PROTECTED_SOURCE) {
// Disable the whole CG
disableConsistencyGroup(cgUID);
} else {
// Disable the CG copy associated with the target.
ConsistencyGroupCopyUID cgCopyUID = RecoverPointUtils.mapRPVolumeProtectionInfoToCGCopyUID(volumeInfo);
functionalAPI.disableConsistencyGroupCopy(cgCopyUID);
String cgCopyName = functionalAPI.getGroupCopyName(cgCopyUID);
String cgName = functionalAPI.getGroupName(cgCopyUID.getGroupUID());
logger.info("Protection disabled on CG copy " + cgCopyName + " on CG " + cgName);
// Make sure the CG copy is stopped
RecoverPointImageManagementUtils imageManager = new RecoverPointImageManagementUtils();
imageManager.waitForCGCopyLinkState(functionalAPI, cgCopyUID, PipeState.UNKNOWN);
logger.info("Protection disabled on CG copy " + cgCopyName + " on CG " + cgName);
}
} catch (FunctionalAPIActionFailedException_Exception e) {
throw RecoverPointException.exceptions.failedToDisableProtection(volumeInfo.getRpVolumeGroupID(), e);
} catch (FunctionalAPIInternalError_Exception e) {
throw RecoverPointException.exceptions.failedToDisableProtection(volumeInfo.getRpVolumeGroupID(), e);
}
}
use of com.emc.fapiclient.ws.ConsistencyGroupCopyUID in project coprhd-controller by CoprHD.
the class RecoverPointClient method createCG.
/**
* Creates a consistency group
*
* @param request - contains all the information required to create the consistency group
*
* @param attachAsClean attach as clean can be true if source and target are guaranteed to be the same (as in create
* new volume). for change vpool, attach as clean should be false
*
* @return CreateCGResponse - response as to success or fail of creating the consistency group
*
* @throws RecoverPointException
*/
public RecoverPointCGResponse createCG(CGRequestParams request, boolean metropoint, boolean attachAsClean) throws RecoverPointException {
if (null == _endpoint.toASCIIString()) {
throw RecoverPointException.exceptions.noRecoverPointEndpoint();
}
RecoverPointCGResponse response = new RecoverPointCGResponse();
ConsistencyGroupUID cgUID = null;
try {
// Make sure the CG name is unique.
int cgSuffix = 0;
String cgName = request.getCgName();
while (doesCgExist(request.getCgName())) {
request.setCgName(String.format("%s-%d", cgName, ++cgSuffix));
}
// caches site names to cluster id's to reduce calls to fapi for the same information
Map<String, ClusterUID> clusterIdCache = new HashMap<String, ClusterUID>();
// prodSites is used for logging and to determine if a non-production copy is local or remote
List<ClusterUID> prodSites = getProdSites(request, clusterIdCache);
StringBuffer sb = new StringBuffer();
for (ClusterUID prodSite : prodSites) {
sb.append(prodSite.getId());
sb.append(" ");
}
logger.info("RecoverPointClient: Creating recoverPoint consistency group " + request.getCgName() + " for endpoint: " + _endpoint.toASCIIString() + " and production sites: " + sb.toString());
// used to set the copy uid on the rset volume when adding rsets
Map<Long, ConsistencyGroupCopyUID> productionCopiesUID = new HashMap<Long, ConsistencyGroupCopyUID>();
Map<Long, ConsistencyGroupCopyUID> nonProductionCopiesUID = new HashMap<Long, ConsistencyGroupCopyUID>();
Map<ConsistencyGroupCopyUID, String> cgCopyNames = new HashMap<ConsistencyGroupCopyUID, String>();
FullConsistencyGroupPolicy fullConsistencyGroupPolicy = configureCGPolicy(request, prodSites, clusterIdCache, productionCopiesUID, nonProductionCopiesUID, cgCopyNames);
// create the CG with copies
logger.info("Adding cg, copies and links for CG: " + request.getCgName());
functionalAPI.validateAddConsistencyGroupAndCopies(fullConsistencyGroupPolicy);
cgUID = functionalAPI.addConsistencyGroupAndCopies(fullConsistencyGroupPolicy);
response.setCgId(cgUID.getId());
ConsistencyGroupSettingsChangesParam cgSettingsParam = configureCGSettingsChangeParams(request, cgUID, prodSites, clusterIdCache, productionCopiesUID, nonProductionCopiesUID, attachAsClean);
logger.info("Adding journals and rsets for CG " + request.getCgName());
functionalAPI.setConsistencyGroupSettings(cgSettingsParam);
RecoverPointImageManagementUtils rpiMgmt = new RecoverPointImageManagementUtils();
logger.info("Waiting for links to become active for CG " + request.getCgName());
rpiMgmt.waitForCGLinkState(functionalAPI, cgUID, RecoverPointImageManagementUtils.getPipeActiveState(functionalAPI, cgUID));
logger.info(String.format("Consistency group %s has been created.", request.getCgName()));
response.setReturnCode(RecoverPointReturnCode.SUCCESS);
return response;
} catch (Exception e) {
if (cgUID != null) {
try {
RecoverPointUtils.cleanupCG(functionalAPI, cgUID);
} catch (Exception e1) {
logger.error("Error removing CG " + request.getCgName() + " after create CG failure");
logger.error(e1.getMessage(), e1);
}
}
throw RecoverPointException.exceptions.failedToCreateConsistencyGroup(request.getCgName(), getCause(e));
}
}
use of com.emc.fapiclient.ws.ConsistencyGroupCopyUID in project coprhd-controller by CoprHD.
the class RecoverPointClient method pauseTransfer.
/**
* Pause (suspend) the consistency group protection specified by the input volume info.
*
* @param RecoverPointVolumeProtectionInfo volumeInfo - Volume info for the CG to pause
*
* @return void
*
* @throws RecoverPointException
*/
public void pauseTransfer(RecoverPointVolumeProtectionInfo volumeInfo) throws RecoverPointException {
try {
ConsistencyGroupUID cgUID = new ConsistencyGroupUID();
cgUID.setId(volumeInfo.getRpVolumeGroupID());
if (volumeInfo.getRpVolumeCurrentProtectionStatus() == RecoverPointVolumeProtectionInfo.volumeProtectionStatus.PROTECTED_SOURCE) {
// Pause the whole CG
functionalAPI.pauseGroupTransfer(cgUID);
String cgName = functionalAPI.getGroupName(cgUID);
logger.info("Protection paused on CG " + cgName);
} else {
// Pause the CG copy associated with the target
ConsistencyGroupCopyUID cgCopyUID = RecoverPointUtils.mapRPVolumeProtectionInfoToCGCopyUID(volumeInfo);
functionalAPI.pauseGroupCopyTransfer(cgCopyUID);
String cgCopyName = functionalAPI.getGroupCopyName(cgCopyUID);
String cgName = functionalAPI.getGroupName(cgCopyUID.getGroupUID());
logger.info("Protection paused on CG copy " + cgCopyName + " on CG " + cgName);
}
} catch (FunctionalAPIActionFailedException_Exception e) {
throw RecoverPointException.exceptions.failedToPauseProtection(volumeInfo.getRpVolumeGroupID(), e);
} catch (FunctionalAPIInternalError_Exception e) {
throw RecoverPointException.exceptions.failedToPauseProtection(volumeInfo.getRpVolumeGroupID(), e);
}
}
use of com.emc.fapiclient.ws.ConsistencyGroupCopyUID in project coprhd-controller by CoprHD.
the class RecoverPointClient method getReplicationSet.
/**
* Get the replication set information associated with this volume. This is important when assembling a workflow to
* recreate the replication set for the purpose of expanding volumes.
*
* Steps are as follows:
* This method: Get the state information associated with the replication set
* Delete method below: Delete the replication set
* RP Controller: Expand volumes
* Recreate method below: Perform a rescan_san
* Recreate method below: Create the replication set
*
* @param RecoverPointVolumeProtectionInfo volume - Volume info for the CG to remove the replication set from
* @return void
*
* @throws RecoverPointException
*/
public RecreateReplicationSetRequestParams getReplicationSet(RecoverPointVolumeProtectionInfo volume) throws RecoverPointException {
ReplicationSetSettings rsetSettings = null;
try {
ConsistencyGroupUID cgID = new ConsistencyGroupUID();
cgID.setId(volume.getRpVolumeGroupID());
ReplicationSetUID repSetUID = new ReplicationSetUID();
repSetUID.setId(volume.getRpVolumeRSetID());
rsetSettings = getReplicationSetSettings(functionalAPI, rsetSettings, cgID, repSetUID);
if (rsetSettings == null) {
throw RecoverPointException.exceptions.cannotFindReplicationSet(volume.getRpVolumeWWN());
}
RecreateReplicationSetRequestParams response = new RecreateReplicationSetRequestParams();
response.setCgName(volume.getRpProtectionName());
response.setName(rsetSettings.getReplicationSetName());
response.setConsistencyGroupUID(cgID);
response.setVolumes(new ArrayList<CreateRSetVolumeParams>());
ConsistencyGroupState state = functionalAPI.getGroupState(cgID);
ConsistencyGroupSettings cgSettings = functionalAPI.getGroupSettings(cgID);
// Get the standby production copy (if one exists). In the case of MetroPoint,
// we must ignore the standby copy device when getting the replication set. Including
// the standby copy during replication set re-creation will throw an exception
// because it has the same device ID as the active copy device.
ConsistencyGroupCopyUID standbyProdCopy = RecoverPointUtils.getStandbyProductionCopy(cgSettings, state);
for (UserVolumeSettings volumeSettings : rsetSettings.getVolumes()) {
if (standbyProdCopy != null && RecoverPointUtils.copiesEqual(volumeSettings.getGroupCopyUID(), standbyProdCopy)) {
// This is the standby production copy so ignore it.
String standyCopyName = functionalAPI.getGroupCopyName(volumeSettings.getGroupCopyUID());
logger.info(String.format("Ignoring volume %s at standby copy %s to avoid duplicate device IDs in replication set reconstruction for MetroPoint.", volumeSettings.getVolumeInfo().getVolumeName(), standyCopyName));
continue;
}
CreateRSetVolumeParams volumeParams = new CreateRSetVolumeParams();
volumeParams.setDeviceUID(volumeSettings.getVolumeInfo().getVolumeID());
volumeParams.setConsistencyGroupCopyUID(volumeSettings.getGroupCopyUID());
response.getVolumes().add(volumeParams);
}
return response;
} catch (FunctionalAPIActionFailedException_Exception e) {
throw RecoverPointException.exceptions.cannotFindReplicationSet(volume.getRpVolumeWWN(), e);
} catch (FunctionalAPIInternalError_Exception e) {
throw RecoverPointException.exceptions.cannotFindReplicationSet(volume.getRpVolumeWWN(), e);
}
}
Aggregations