use of com.emc.fapiclient.ws.ConsistencyGroupCopyUID in project coprhd-controller by CoprHD.
the class RecoverPointClient method doesStandbyProdCopyExist.
/**
* Determines if the consistency group associated with the volume protection info contains
* a standby production copy.
*
* @param volume the volume protection information
* @return true if the standby production copy exists, false otherwise
*/
public boolean doesStandbyProdCopyExist(RecoverPointVolumeProtectionInfo volume) {
try {
ConsistencyGroupUID cgID = new ConsistencyGroupUID();
cgID.setId(volume.getRpVolumeGroupID());
ConsistencyGroupState state = functionalAPI.getGroupState(cgID);
ConsistencyGroupSettings cgSettings = functionalAPI.getGroupSettings(cgID);
ConsistencyGroupCopyUID standbyProdCopy = RecoverPointUtils.getStandbyProductionCopy(cgSettings, state);
if (standbyProdCopy != null) {
String standbyProdCopyName = functionalAPI.getGroupCopyName(standbyProdCopy);
logger.info(String.format("Determined that standby production copy %s exists in CG %s.", standbyProdCopyName, volume.getRpProtectionName()));
return true;
}
logger.info(String.format("Determined that no standby production copy exists in CG %s.", volume.getRpProtectionName()));
return false;
} catch (FunctionalAPIActionFailedException_Exception e) {
throw RecoverPointException.exceptions.failedStandbyProdCopyLookup(volume.getRpProtectionName(), e);
} catch (FunctionalAPIInternalError_Exception e) {
throw RecoverPointException.exceptions.failedStandbyProdCopyLookup(volume.getRpProtectionName(), e);
}
}
use of com.emc.fapiclient.ws.ConsistencyGroupCopyUID in project coprhd-controller by CoprHD.
the class RecoverPointClient method addJournalVolumesToCG.
/**
* Operation to add journal volumes to an existing recoverpoint consistency group
*
* @param request - contains both the consistency group
* and the journals to add to the consistency group
* @param copyType - indicates whether the copy is production, local or remote
* @return boolean indicating the result of the operation
*/
public boolean addJournalVolumesToCG(CGRequestParams request, int copyType) {
// Make sure the CG name is unique.
ConsistencyGroupUID cgUID = null;
List<ConsistencyGroupUID> allCgs;
String copyName = "not determined";
Map<ConsistencyGroupCopyUID, DeviceUID> addedJournalVolumes = new HashMap<ConsistencyGroupCopyUID, DeviceUID>();
try {
allCgs = functionalAPI.getAllConsistencyGroups();
for (ConsistencyGroupUID cg : allCgs) {
ConsistencyGroupSettings settings = functionalAPI.getGroupSettings(cg);
if (settings.getName().toString().equalsIgnoreCase(request.getCgName())) {
cgUID = settings.getGroupUID();
break;
}
}
if (cgUID == null) {
// The CG does not exist so we cannot add replication sets
throw RecoverPointException.exceptions.failedToAddReplicationSetCgDoesNotExist(request.getCgName());
}
List<CreateCopyParams> copyParams = request.getCopies();
// determine if the volumes are visible to the recoverpoint appliance
Set<RPSite> allSites = scan(copyParams, null);
for (CreateCopyParams copyParam : copyParams) {
for (CreateVolumeParams journalVolume : copyParam.getJournals()) {
copyName = journalVolume.getRpCopyName();
ClusterUID clusterId = RecoverPointUtils.getRPSiteID(functionalAPI, journalVolume.getInternalSiteName());
ConsistencyGroupCopyUID copyUID = getCGCopyUid(clusterId, getCopyType(copyType), cgUID);
DeviceUID journalDevice = RecoverPointUtils.getDeviceID(allSites, journalVolume.getInternalSiteName(), journalVolume.getWwn());
addedJournalVolumes.put(copyUID, journalDevice);
functionalAPI.addJournalVolume(copyUID, journalDevice);
}
}
} catch (FunctionalAPIActionFailedException_Exception e) {
if (!addedJournalVolumes.isEmpty()) {
try {
for (Map.Entry<ConsistencyGroupCopyUID, DeviceUID> journalVolume : addedJournalVolumes.entrySet()) {
functionalAPI.removeJournalVolume(journalVolume.getKey(), journalVolume.getValue());
}
} catch (Exception e1) {
logger.error("Error removing journal volume from consistency group");
logger.error(e1.getMessage(), e1);
}
}
logger.error("Error in attempting to add a journal volume to the recoverpoint consistency group");
logger.error(e.getMessage(), e);
throw RecoverPointException.exceptions.failedToAddJournalVolumeToConsistencyGroup(copyName, getCause(e));
} catch (FunctionalAPIInternalError_Exception e) {
if (!addedJournalVolumes.isEmpty()) {
try {
for (Map.Entry<ConsistencyGroupCopyUID, DeviceUID> journalVolume : addedJournalVolumes.entrySet()) {
functionalAPI.removeJournalVolume(journalVolume.getKey(), journalVolume.getValue());
}
} catch (Exception e1) {
logger.error("Error removing journal volume from consistency group");
logger.error(e1.getMessage(), e1);
}
}
logger.error("Error in attempting to add a journal volume to the recoverpoint consistency group");
logger.error(e.getMessage(), e);
throw RecoverPointException.exceptions.failedToCreateConsistencyGroup(copyName, getCause(e));
}
return true;
}
use of com.emc.fapiclient.ws.ConsistencyGroupCopyUID in project coprhd-controller by CoprHD.
the class RecoverPointClient method prepareLinkSettings.
/**
* Prepares the link settings between the new production copy and all other copies.
*
* @param newProductionCopyUID the failover/new production copy
* @throws RecoverPointException
*/
private void prepareLinkSettings(ConsistencyGroupCopyUID newProductionCopyUID) throws RecoverPointException {
logger.info("Preparing link settings between new production copy and local/remote copies after failover.");
String cgName = null;
String newProductionCopyName = null;
try {
ConsistencyGroupSettings groupSettings = functionalAPI.getGroupSettings(newProductionCopyUID.getGroupUID());
List<ConsistencyGroupLinkSettings> cgLinkSettings = groupSettings.getActiveLinksSettings();
List<ConsistencyGroupCopyUID> productionCopiesUIDs = groupSettings.getProductionCopiesUIDs();
newProductionCopyName = functionalAPI.getGroupCopyName(newProductionCopyUID);
cgName = functionalAPI.getGroupName(newProductionCopyUID.getGroupUID());
// Go through the existing production copies
for (ConsistencyGroupCopyUID existingProductionCopyUID : productionCopiesUIDs) {
List<ConsistencyGroupCopySettings> copySettings = groupSettings.getGroupCopiesSettings();
ConsistencyGroupLinkSettings linkSettings = null;
for (ConsistencyGroupCopySettings copySetting : copySettings) {
// are identified by not being the existing production copy or the new production copy.
if (!RecoverPointUtils.copiesEqual(copySetting.getCopyUID(), existingProductionCopyUID) && !RecoverPointUtils.copiesEqual(copySetting.getCopyUID(), newProductionCopyUID)) {
String copyName = functionalAPI.getGroupCopyName(copySetting.getCopyUID());
logger.info(String.format("Checking to see if there is an active link between %s and %s.", newProductionCopyName, copyName));
// Check to see if a link setting already exists for the link between the 2 copies
linkSettings = findLinkSettings(cgLinkSettings, newProductionCopyUID.getGlobalCopyUID(), copySetting.getCopyUID().getGlobalCopyUID(), newProductionCopyName, copyName);
if (linkSettings == null) {
// Link settings for the source/target copies does not exist so we need to create one. Just grab the
// first link settings that's available and base the new link off of that.
linkSettings = cgLinkSettings.get(0);
if (linkSettings != null) {
ConsistencyGroupCopyUID firstCopyUID = new ConsistencyGroupCopyUID();
firstCopyUID.setGlobalCopyUID(linkSettings.getGroupLinkUID().getFirstCopy());
firstCopyUID.setGroupUID(linkSettings.getGroupLinkUID().getGroupUID());
ConsistencyGroupCopyUID secondCopyUID = new ConsistencyGroupCopyUID();
secondCopyUID.setGlobalCopyUID(linkSettings.getGroupLinkUID().getSecondCopy());
secondCopyUID.setGroupUID(linkSettings.getGroupLinkUID().getGroupUID());
String firstCopyName = functionalAPI.getGroupCopyName(firstCopyUID);
String secondCopyName = functionalAPI.getGroupCopyName(secondCopyUID);
logger.info(String.format("Generating new link settings between [%s] and [%s] based on existing link settings between copy [%s] and [%s].", newProductionCopyName, copyName, firstCopyName, secondCopyName));
ConsistencyGroupLinkUID cgLinkUID = linkSettings.getGroupLinkUID();
// Set the link copies appropriately
GlobalCopyUID sourceCopy = newProductionCopyUID.getGlobalCopyUID();
GlobalCopyUID targetCopy = copySetting.getCopyUID().getGlobalCopyUID();
cgLinkUID.setFirstCopy(sourceCopy);
cgLinkUID.setSecondCopy(targetCopy);
ConsistencyGroupLinkPolicy linkPolicy = linkSettings.getLinkPolicy();
// Check the copy cluster information to determine if this is a local or remote copy
if (sourceCopy.getClusterUID().getId() == targetCopy.getClusterUID().getId()) {
// local copy
logger.info(String.format("Creating new local copy link settings between %s and %s, for consistency group %s.", newProductionCopyName, copyName, cgName));
linkPolicy.getProtectionPolicy().setReplicatingOverWAN(false);
} else {
// remote copy
logger.info(String.format("Creating new remote copy link settings between %s and %s, for consistency group %s.", newProductionCopyName, copyName, cgName));
linkPolicy.getProtectionPolicy().setReplicatingOverWAN(true);
}
functionalAPI.addConsistencyGroupLink(cgLinkUID, linkPolicy);
}
}
}
}
}
} catch (FunctionalAPIActionFailedException_Exception e) {
throw RecoverPointException.exceptions.failedToFailoverCopy(newProductionCopyName, cgName, e);
} catch (FunctionalAPIInternalError_Exception e) {
throw RecoverPointException.exceptions.failedToFailoverCopy(newProductionCopyName, cgName, e);
}
}
use of com.emc.fapiclient.ws.ConsistencyGroupCopyUID in project coprhd-controller by CoprHD.
the class RecoverPointClient method configureCGPolicy.
/**
* Configure the entire consistency group policy.
*
* @param request the CG create request information
* @param prodSites the list of production clusters
* @param clusterIdCache the cached map of internal site names to clusters
* @param productionCopiesUID mapping of production clusters IDs to consistency group copy IDs
* @param nonProductionCopiesUID mapping of non-production clusters IDs to consistency group copy IDs
* @param cgCopyNames mapping of consistency group copy IDs to consistency group copy names
* @return the full consistency group policy
* @throws FunctionalAPIActionFailedException_Exception
* @throws FunctionalAPIInternalError_Exception
*/
private FullConsistencyGroupPolicy configureCGPolicy(CGRequestParams request, List<ClusterUID> prodSites, Map<String, ClusterUID> clusterIdCache, Map<Long, ConsistencyGroupCopyUID> productionCopiesUID, Map<Long, ConsistencyGroupCopyUID> nonProductionCopiesUID, Map<ConsistencyGroupCopyUID, String> cgCopyNames) throws FunctionalAPIActionFailedException_Exception, FunctionalAPIInternalError_Exception {
logger.info("Requesting preferred RPA for cluster " + prodSites.get(0).getId());
RpaUID preferredRPA = RecoverPointUtils.getPreferredRPAForNewCG(functionalAPI, prodSites.get(0));
logger.info("Preferred RPA for cluster " + preferredRPA.getClusterUID().getId() + " is RPA " + preferredRPA.getRpaNumber());
// used to create the CG; contains CG settings, copies and links
FullConsistencyGroupPolicy fullConsistencyGroupPolicy = new FullConsistencyGroupPolicy();
fullConsistencyGroupPolicy.setGroupName(request.getCgName());
fullConsistencyGroupPolicy.setGroupPolicy(functionalAPI.getDefaultConsistencyGroupPolicy());
fullConsistencyGroupPolicy.getGroupPolicy().setPrimaryRPANumber(preferredRPA.getRpaNumber());
for (CreateCopyParams copyParam : request.getCopies()) {
ClusterUID clusterUID = getClusterUid(copyParam, clusterIdCache);
if (clusterUID != null) {
RecoverPointCGCopyType copyType = getCopyType(copyParam, prodSites, clusterUID);
if (copyType != null) {
logger.info(String.format("Configuring %s copy %s for CG %s", copyType.toString(), copyParam.getName(), request.getCgName()));
ConsistencyGroupCopyUID cgCopyUID = getCGCopyUid(clusterUID, copyType, null);
FullConsistencyGroupCopyPolicy copyPolicy = new FullConsistencyGroupCopyPolicy();
copyPolicy.setCopyName(copyParam.getName());
copyPolicy.setCopyPolicy(functionalAPI.getDefaultConsistencyGroupCopyPolicy());
copyPolicy.setCopyUID(cgCopyUID);
cgCopyNames.put(cgCopyUID, copyParam.getName());
if (getMaxNumberOfSnapShots(copyParam) > 0) {
copyPolicy.getCopyPolicy().getSnapshotsPolicy().setNumOfDesiredSnapshots(getMaxNumberOfSnapShots(copyParam));
}
fullConsistencyGroupPolicy.getCopiesPolicies().add(copyPolicy);
if (copyType.isProduction()) {
fullConsistencyGroupPolicy.getProductionCopies().add(copyPolicy.getCopyUID());
productionCopiesUID.put(Long.valueOf(clusterUID.getId()), copyPolicy.getCopyUID());
} else {
nonProductionCopiesUID.put(Long.valueOf(clusterUID.getId()), copyPolicy.getCopyUID());
}
} else {
logger.error("No journal volumes specified for create CG: " + copyParam.getName());
}
} else {
logger.error("No journal volumes specified for create CG: " + copyParam.getName());
}
}
// set links between production and remote/local copies
configureLinkPolicies(fullConsistencyGroupPolicy, request, productionCopiesUID, nonProductionCopiesUID, cgCopyNames);
return fullConsistencyGroupPolicy;
}
use of com.emc.fapiclient.ws.ConsistencyGroupCopyUID in project coprhd-controller by CoprHD.
the class RecoverPointClient method configureLinkPolicies.
/**
* Configure the valid links between each production and each local and/or remote copy in a new CG
* configured links are added to fullConsistencyGroupPolicy
*
* @param fullConsistencyGroupPolicy CG policy with copies populated
* @param request request create cg request used for copy mode and rpo
* @param productionCopiesUID the map of production copies
* @param targetCopiesUID the map of non-production copies
* @param cgCopyNames the map of CG copy UIDs to their actual names
* @throws FunctionalAPIInternalError_Exception
* @throws FunctionalAPIActionFailedException_Exception
*/
private void configureLinkPolicies(FullConsistencyGroupPolicy fullConsistencyGroupPolicy, CGRequestParams request, Map<Long, ConsistencyGroupCopyUID> productionCopiesUID, Map<Long, ConsistencyGroupCopyUID> targetCopiesUID, Map<ConsistencyGroupCopyUID, String> cgCopyNames) throws FunctionalAPIActionFailedException_Exception, FunctionalAPIInternalError_Exception {
for (Map.Entry<Long, ConsistencyGroupCopyUID> productionCopyEntry : productionCopiesUID.entrySet()) {
Long productionCopyClusterUID = productionCopyEntry.getKey();
ConsistencyGroupCopyUID productionCopyUID = productionCopyEntry.getValue();
String prodCopyName = cgCopyNames.get(productionCopyUID);
for (Map.Entry<Long, ConsistencyGroupCopyUID> nonProductionCopyEntry : targetCopiesUID.entrySet()) {
// Determine what links need to be configured based on known production and non-production copies.
// The production/non-production copy maps are keyed on ClusterUID. If a ClusterUID from the non-production
// copy map matches one from the production copy map, that is considered a local copy - so a single link will be configured
// between that production copy and the non-production copy matching the ClusterUID. If a ClusterUID
// from the non-production map doesn't match any ClusterUIDs from the production copy map, that copy is
// considered a remote copy - so links will be configured between all production copies and this remote copy. Based on that
// information we will configure the valid links between the production copies and the local/remote copies.
Long nonProductionCopyClusterUID = nonProductionCopyEntry.getKey();
ConsistencyGroupCopyUID nonProductionCopyUID = nonProductionCopyEntry.getValue();
String nonProdCopyName = cgCopyNames.get(nonProductionCopyUID);
// local copy. Or, the non-production ClusterUID doesn't match any production ClusterUIDs - this is a remote copy.
if (nonProductionCopyClusterUID.equals(productionCopyClusterUID) || !productionCopiesUID.containsKey(nonProductionCopyClusterUID)) {
ConsistencyGroupLinkUID linkUid = new ConsistencyGroupLinkUID();
linkUid.setFirstCopy(productionCopyUID.getGlobalCopyUID());
linkUid.setSecondCopy(nonProductionCopyUID.getGlobalCopyUID());
logger.info(String.format("Configuring a copy link between copies %s and %s", prodCopyName, nonProdCopyName));
RecoverPointCGCopyType copyType = (productionCopyClusterUID == nonProductionCopyClusterUID) ? RecoverPointCGCopyType.LOCAL : RecoverPointCGCopyType.REMOTE;
ConsistencyGroupLinkPolicy linkPolicy = createLinkPolicy(copyType, request.getCgPolicy().getCopyMode(), request.getCgPolicy().getRpoType(), request.getCgPolicy().getRpoValue());
FullConsistencyGroupCopyPolicy copyPolicy = getCopyPolicy(fullConsistencyGroupPolicy, nonProductionCopyUID);
// Set the snapshot policy on the link based off the existing non-production copy policy
if (copyPolicy != null && copyPolicy.getCopyPolicy() != null && copyPolicy.getCopyPolicy().getSnapshotsPolicy() != null && copyPolicy.getCopyPolicy().getSnapshotsPolicy().getNumOfDesiredSnapshots() != null && copyPolicy.getCopyPolicy().getSnapshotsPolicy().getNumOfDesiredSnapshots() > 0) {
SnapshotShippingPolicy snapPolicy = new SnapshotShippingPolicy();
snapPolicy.setIntervaInMinutes(1L);
snapPolicy.setMode(SnapshotShippingMode.PERIODICALLY);
linkPolicy.setSnapshotShippingPolicy(snapPolicy);
} else {
logger.warn("Not setting the snapshot policy on link because there is no existing copy snapshot policy to base this off of.");
}
FullConsistencyGroupLinkPolicy fullLinkPolicy = new FullConsistencyGroupLinkPolicy();
fullLinkPolicy.setLinkPolicy(linkPolicy);
fullLinkPolicy.setLinkUID(linkUid);
fullConsistencyGroupPolicy.getLinksPolicies().add(fullLinkPolicy);
}
}
}
}
Aggregations