use of com.emc.fapiclient.ws.ConsistencyGroupCopyUID in project coprhd-controller by CoprHD.
the class RecoverPointClient method addStandbyProductionCopy.
/**
* In a metropoint environment, adds the standby production and CDP copies to the CG after failover
* and set as production back to the original vplex metro
*
* @param standbyProdCopy has info about the standby production copy to be added
* @param standbyLocalCopyParams local standby copies
* @param rSet contains volume info for standby local copies
* @param activeProdCopy has info about the active production copy
*/
public void addStandbyProductionCopy(CreateCopyParams standbyProdCopy, CreateCopyParams standbyLocalCopyParams, List<CreateRSetParams> rSets, RPCopyRequestParams activeProdCopy) {
String cgName = "";
String activeCgCopyName = "";
ConsistencyGroupCopyUID standbyLocalCopyUID = null;
try {
ConsistencyGroupCopyUID activeProdCopyUID = RecoverPointUtils.mapRPVolumeProtectionInfoToCGCopyUID(activeProdCopy.getCopyVolumeInfo());
ConsistencyGroupUID cgUID = activeProdCopyUID.getGroupUID();
cgName = functionalAPI.getGroupName(cgUID);
logger.info(String.format("Adding Standby production and local volumes to Metropoint CG %s", cgName));
activeCgCopyName = functionalAPI.getGroupCopyName(activeProdCopyUID);
List<CreateCopyParams> copies = new ArrayList<CreateCopyParams>();
copies.add(standbyProdCopy);
if (standbyLocalCopyParams != null) {
copies.add(standbyLocalCopyParams);
}
Set<RPSite> allSites = scan(copies, rSets);
CreateVolumeParams volume = standbyProdCopy.getJournals().get(0);
ClusterUID clusterUid = RecoverPointUtils.getRPSiteID(functionalAPI, volume.getInternalSiteName());
// fetch the ConsistencyGroupCopyUID for standby production copy
ConsistencyGroupCopyUID standbyProdCopyUID = createCgCopyUid(cgUID, clusterUid, RecoverPointCGCopyType.PRODUCTION);
// fetch the link Settings between to be added standby prod copy and the remote copy
List<ConsistencyGroupLinkSettings> standbyProductionlinkSettings = new ArrayList<ConsistencyGroupLinkSettings>();
standbyProductionlinkSettings = getStandbyCopyLinkSettings(activeProdCopyUID, standbyProdCopyUID);
// add the standby production copy
addCopyToCG(cgUID, allSites, standbyProdCopy, null, RecoverPointCGCopyType.PRODUCTION, standbyProductionlinkSettings, standbyProdCopyUID);
// add the standby local copies if we have any
if (standbyLocalCopyParams != null) {
// fetch the ConsistencyGroupCopyUID for standby local Copy
standbyLocalCopyUID = createCgCopyUid(cgUID, clusterUid, RecoverPointCGCopyType.LOCAL);
// fetch the link Settings between to be added standby local copy and the standby Production copy
List<ConsistencyGroupLinkSettings> standbyLocallinkSettings = new ArrayList<ConsistencyGroupLinkSettings>();
standbyLocallinkSettings = getStandbyCopyLinkSettings(standbyProdCopyUID, standbyLocalCopyUID);
addCopyToCG(cgUID, allSites, standbyLocalCopyParams, rSets, RecoverPointCGCopyType.LOCAL, standbyLocallinkSettings, standbyLocalCopyUID);
logger.info("Setting link policy between production copy and local copy on standby cluster(id) : " + standbyLocalCopyUID.getGlobalCopyUID().getClusterUID().getId());
setLinkPolicy(false, standbyProdCopyUID, standbyLocalCopyUID, cgUID);
}
// enable the local copy
if (standbyLocalCopyUID != null) {
logger.info("enable standby local copy for CG ", cgName);
functionalAPI.enableConsistencyGroupCopy(standbyLocalCopyUID, true);
}
// enable the production copy
logger.info("enable production standby copy for CG ", cgName);
functionalAPI.enableConsistencyGroupCopy(standbyProdCopyUID, true);
// enable the CG
logger.info("enable CG " + cgName + " after standby copies added");
functionalAPI.startGroupTransfer(cgUID);
RecoverPointImageManagementUtils rpiMgmt = new RecoverPointImageManagementUtils();
rpiMgmt.waitForCGLinkState(functionalAPI, cgUID, RecoverPointImageManagementUtils.getPipeActiveState(functionalAPI, cgUID));
} catch (Exception e) {
throw RecoverPointException.exceptions.failedToFailoverCopy(activeCgCopyName, cgName, e);
}
}
use of com.emc.fapiclient.ws.ConsistencyGroupCopyUID in project coprhd-controller by CoprHD.
the class RecoverPointClient method getProtectionInfoForVolume.
/**
* The getProtectionInfoForVolume method takes the WWN, and looks for it in the RP site protection environment.
* If it finds the WWN as a member of a consistency group, it fills in the information, and returns it to the caller.
* If it does not find the WWN as a member of a consistency group, it returns null
*
* @param String volumeWWN - The WWN being checked for RecoverPoint protection
*
* @return RecoverPointVolumeProtectionInfo - description of protection information about the WWN, or null if not protected in CG
*
* @throws RecoverPointException
*/
public RecoverPointVolumeProtectionInfo getProtectionInfoForVolume(String volumeWWN) throws RecoverPointException {
RecoverPointVolumeProtectionInfo protectionInfo = null;
try {
// logger.info("getProtectionInfoForVolume called for: " + volumeWWN);
protectionInfo = new RecoverPointVolumeProtectionInfo();
List<ConsistencyGroupSettings> cgsSettings = functionalAPI.getAllGroupsSettings();
for (ConsistencyGroupSettings cgSettings : cgsSettings) {
// See if it is a production source, or an RP target
for (ReplicationSetSettings rsSettings : cgSettings.getReplicationSetsSettings()) {
for (UserVolumeSettings uvSettings : rsSettings.getVolumes()) {
if (matchesVolumeWWN(uvSettings.getVolumeInfo(), volumeWWN)) {
ConsistencyGroupUID cgID = uvSettings.getGroupCopyUID().getGroupUID();
ConsistencyGroupState state = functionalAPI.getGroupState(cgID);
List<ConsistencyGroupCopyUID> productionCopiesUIDs = functionalAPI.getGroupSettings(cgID).getProductionCopiesUIDs();
String cgName = cgSettings.getName();
String cgCopyName = functionalAPI.getGroupCopyName(uvSettings.getGroupCopyUID());
protectionInfo.setRpProtectionName(cgName);
protectionInfo.setRpVolumeGroupCopyID(uvSettings.getGroupCopyUID().getGlobalCopyUID().getCopyUID());
protectionInfo.setRpCopyName(cgCopyName);
protectionInfo.setRpSiteName(getRecoverPointClusterName(uvSettings.getClusterUID()));
protectionInfo.setRpVolumeGroupID(cgID.getId());
protectionInfo.setRpVolumeSiteID(uvSettings.getClusterUID().getId());
protectionInfo.setRpVolumeRSetID(rsSettings.getReplicationSetUID().getId());
protectionInfo.setRpVolumeWWN(volumeWWN);
if (RecoverPointUtils.isProductionCopy(uvSettings.getGroupCopyUID(), productionCopiesUIDs)) {
if (RecoverPointUtils.isStandbyProductionCopy(uvSettings.getGroupCopyUID(), state, productionCopiesUIDs)) {
// In the case of MetroPoint, we will have 2 production copies for the same volume (active and standby).
// We want to always match on the active production copy. If this is a MetroPoint CG, skip over the
// standby production copy.
logger.info(String.format("Found production volume %s on copy %s. Skipping because it is not the active production copy.", volumeWWN, cgCopyName));
continue;
}
logger.info("Production volume: " + volumeWWN + " is on copy " + cgCopyName + " of CG " + cgName);
protectionInfo.setRpVolumeCurrentProtectionStatus(RecoverPointVolumeProtectionInfo.volumeProtectionStatus.PROTECTED_SOURCE);
} else {
logger.info("Target volume: " + volumeWWN + " is on copy " + cgCopyName + " of CG " + cgName);
protectionInfo.setRpVolumeCurrentProtectionStatus(RecoverPointVolumeProtectionInfo.volumeProtectionStatus.PROTECTED_TARGET);
}
return protectionInfo;
}
}
}
// See if it is a journal volume
for (ConsistencyGroupCopySettings cgCopySettings : cgSettings.getGroupCopiesSettings()) {
ConsistencyGroupCopyJournal cgJournal = cgCopySettings.getJournal();
List<JournalVolumeSettings> journalVolumeSettingsList = cgJournal.getJournalVolumes();
for (JournalVolumeSettings journalVolumeSettings : journalVolumeSettingsList) {
if (matchesVolumeWWN(journalVolumeSettings.getVolumeInfo(), volumeWWN)) {
ConsistencyGroupUID cgID = journalVolumeSettings.getGroupCopyUID().getGroupUID();
List<ConsistencyGroupCopyUID> productionCopiesUIDs = functionalAPI.getGroupSettings(cgID).getProductionCopiesUIDs();
String cgName = cgSettings.getName();
String cgCopyName = functionalAPI.getGroupCopyName(journalVolumeSettings.getGroupCopyUID());
protectionInfo.setRpProtectionName(cgName);
protectionInfo.setRpVolumeGroupCopyID(journalVolumeSettings.getGroupCopyUID().getGlobalCopyUID().getCopyUID());
protectionInfo.setRpVolumeGroupID(cgID.getId());
protectionInfo.setRpVolumeSiteID(journalVolumeSettings.getClusterUID().getId());
protectionInfo.setRpVolumeWWN(volumeWWN);
if (RecoverPointUtils.isProductionCopy(journalVolumeSettings.getGroupCopyUID(), productionCopiesUIDs)) {
logger.info("Production journal: " + volumeWWN + " is on copy " + cgCopyName + " of CG " + cgName);
protectionInfo.setRpVolumeCurrentProtectionStatus(RecoverPointVolumeProtectionInfo.volumeProtectionStatus.SOURCE_JOURNAL);
} else {
logger.info("Target journal: " + volumeWWN + " is on copy " + cgCopyName + " of CG " + cgName);
protectionInfo.setRpVolumeCurrentProtectionStatus(RecoverPointVolumeProtectionInfo.volumeProtectionStatus.TARGET_JOURNAL);
}
return protectionInfo;
}
}
}
}
} catch (FunctionalAPIActionFailedException_Exception e) {
throw RecoverPointException.exceptions.failureGettingProtectionInfoForVolume(volumeWWN, e);
} catch (FunctionalAPIInternalError_Exception e) {
throw RecoverPointException.exceptions.failureGettingProtectionInfoForVolume(volumeWWN, e);
}
throw RecoverPointException.exceptions.failureGettingProtectionInfoForVolume(volumeWWN);
}
use of com.emc.fapiclient.ws.ConsistencyGroupCopyUID in project coprhd-controller by CoprHD.
the class RecoverPointClient method configureCGSettingsChangeParams.
/**
* Configures the consistency group settings change param.
*
* @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 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 the consistency group settings change param
* @throws FunctionalAPIInternalError_Exception
* @throws FunctionalAPIActionFailedException_Exception
*/
private ConsistencyGroupSettingsChangesParam configureCGSettingsChangeParams(CGRequestParams request, ConsistencyGroupUID cgUID, List<ClusterUID> prodSites, Map<String, ClusterUID> clusterIdCache, Map<Long, ConsistencyGroupCopyUID> productionCopiesUID, Map<Long, ConsistencyGroupCopyUID> nonProductionCopiesUID, boolean attachAsClean) throws FunctionalAPIActionFailedException_Exception, FunctionalAPIInternalError_Exception {
Set<RPSite> allSites = getAssociatedRPSites();
// used to set journal volumes and RSets after the CG is created
ConsistencyGroupSettingsChangesParam cgSettingsParam = new ConsistencyGroupSettingsChangesParam();
ActivationSettingsChangesParams cgActivationSettings = new ActivationSettingsChangesParams();
cgActivationSettings.setEnable(true);
cgActivationSettings.setStartTransfer(true);
cgSettingsParam.setActivationParams(cgActivationSettings);
cgSettingsParam.setGroupUID(cgUID);
for (CreateCopyParams copyParam : request.getCopies()) {
ClusterUID clusterUID = getClusterUid(copyParam, clusterIdCache);
if (clusterUID != null) {
RecoverPointCGCopyType copyType = getCopyType(copyParam, prodSites, clusterUID);
if (copyType != null) {
ConsistencyGroupCopyUID cgCopyUID = getCGCopyUid(clusterUID, copyType, cgUID);
// set up journal params
ConsistencyGroupCopySettingsChangesParam copySettingsParam = new ConsistencyGroupCopySettingsChangesParam();
copySettingsParam.setCopyUID(cgCopyUID);
ActivationSettingsChangesParams copyActivationSettings = new ActivationSettingsChangesParams();
copyActivationSettings.setEnable(true);
copyActivationSettings.setStartTransfer(true);
copySettingsParam.setActivationParams(copyActivationSettings);
for (CreateVolumeParams journalVolume : copyParam.getJournals()) {
logger.info("Configuring Journal : \n" + journalVolume.toString() + "\n for copy: " + copyParam.getName() + "; CG " + request.getCgName());
copySettingsParam.getNewJournalVolumes().add(RecoverPointUtils.getDeviceID(allSites, journalVolume.getInternalSiteName(), journalVolume.getWwn()));
}
cgSettingsParam.getCopiesChanges().add(copySettingsParam);
} else {
logger.warn("No journal volumes specified for CG: " + copyParam.getName());
}
} else {
logger.warn("No journal volumes specified for CG: " + copyParam.getName());
}
}
String previousProdCopyName = null;
// configure replication sets
for (CreateRSetParams rsetParam : request.getRsets()) {
logger.info("Configuring replication set: " + rsetParam.toString() + " for cg " + request.getCgName());
ReplicationSetSettingsChangesParam repSetSettings = new ReplicationSetSettingsChangesParam();
repSetSettings.setName(rsetParam.getName());
repSetSettings.setShouldAttachAsClean(attachAsClean);
Set<String> sourceWWNsInRset = new HashSet<String>();
for (CreateVolumeParams volume : rsetParam.getVolumes()) {
UserVolumeSettingsChangesParam volSettings = new UserVolumeSettingsChangesParam();
volSettings.setNewVolumeID(RecoverPointUtils.getDeviceID(allSites, volume.getInternalSiteName(), volume.getWwn()));
ClusterUID volSiteId = getRPSiteID(volume.getInternalSiteName(), clusterIdCache);
if (volume.isProduction()) {
// for metropoint, the same production volume will appear twice; we only want to add it once
if (sourceWWNsInRset.contains(volume.getWwn())) {
continue;
}
if (previousProdCopyName == null) {
previousProdCopyName = volume.getRpCopyName();
} else if (!previousProdCopyName.equals(volume.getRpCopyName())) {
logger.info(String.format("will not add rset for volume %s to prod copy %s because another rset has already been added to prod copy %s", rsetParam.getName(), volume.getRpCopyName(), previousProdCopyName));
continue;
}
sourceWWNsInRset.add(volume.getWwn());
logger.info("Configuring production copy volume : \n" + volume.toString());
ConsistencyGroupCopyUID copyUID = productionCopiesUID.get(Long.valueOf(volSiteId.getId()));
copyUID.setGroupUID(cgUID);
volSettings.setCopyUID(copyUID);
} else {
logger.info("Configuring non-production copy volume : \n" + volume.toString());
ConsistencyGroupCopyUID copyUID = nonProductionCopiesUID.get(Long.valueOf(volSiteId.getId()));
copyUID.setGroupUID(cgUID);
volSettings.setCopyUID(copyUID);
}
repSetSettings.getVolumesChanges().add(volSettings);
}
cgSettingsParam.getReplicationSetsChanges().add(repSetSettings);
}
return cgSettingsParam;
}
use of com.emc.fapiclient.ws.ConsistencyGroupCopyUID in project coprhd-controller by CoprHD.
the class RecoverPointClient method addReplicationSetsToCG.
/**
* Updates an existing CG by adding new replication sets.
*
* @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 RecoverPointCGResponse - response as to success or fail of creating the consistency group
*
* @throws RecoverPointException
*/
public RecoverPointCGResponse addReplicationSetsToCG(CGRequestParams request, boolean metropoint, boolean attachAsClean) throws RecoverPointException {
if (null == _endpoint.toASCIIString()) {
throw RecoverPointException.exceptions.noRecoverPointEndpoint();
}
RecoverPointCGResponse response = new RecoverPointCGResponse();
List<ConsistencyGroupCopySettings> groupCopySettings = null;
ConsistencyGroupUID cgUID = null;
try {
// Make sure the CG name is unique.
List<ConsistencyGroupUID> allCgs = functionalAPI.getAllConsistencyGroups();
for (ConsistencyGroupUID cg : allCgs) {
ConsistencyGroupSettings settings = functionalAPI.getGroupSettings(cg);
if (settings.getName().toString().equalsIgnoreCase(request.getCgName())) {
cgUID = settings.getGroupUID();
groupCopySettings = settings.getGroupCopiesSettings();
break;
}
}
if (cgUID == null) {
// The CG does not exist so we cannot add replication sets
throw RecoverPointException.exceptions.failedToAddReplicationSetCgDoesNotExist(request.getCgName());
}
response.setCgId(cgUID.getId());
// 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 = new ArrayList<ClusterUID>();
// 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>();
// get a list of CG production copies so we can determine which copies are production and which
// are not.
List<ConsistencyGroupCopyUID> productionCopiesUIDs = functionalAPI.getGroupSettings(cgUID).getProductionCopiesUIDs();
for (ConsistencyGroupCopySettings copySettings : groupCopySettings) {
GlobalCopyUID globalCopyUID = copySettings.getCopyUID().getGlobalCopyUID();
ConsistencyGroupCopyUID copyUID = copySettings.getCopyUID();
if (RecoverPointUtils.isProductionCopy(copyUID, productionCopiesUIDs)) {
productionCopiesUID.put(Long.valueOf(globalCopyUID.getClusterUID().getId()), copySettings.getCopyUID());
prodSites.add(globalCopyUID.getClusterUID());
} else {
nonProductionCopiesUID.put(Long.valueOf(globalCopyUID.getClusterUID().getId()), copySettings.getCopyUID());
}
}
StringBuffer sb = new StringBuffer();
for (ClusterUID prodSite : prodSites) {
sb.append(prodSite.getId());
sb.append(" ");
}
logger.info("RecoverPointClient: Adding replication set(s) to consistency group " + request.getCgName() + " for endpoint: " + _endpoint.toASCIIString() + " and production sites: " + sb.toString());
ConsistencyGroupSettingsChangesParam cgSettingsParam = configureCGSettingsChangeParams(request, cgUID, prodSites, clusterIdCache, productionCopiesUID, nonProductionCopiesUID, attachAsClean);
logger.info("Adding journals and rsets for CG " + request.getCgName());
functionalAPI.setConsistencyGroupSettings(cgSettingsParam);
// Sometimes the CG is still active when we start polling for link state and then
// starts initializing some time afterwards. Adding this sleep to make sure the CG
// starts initializing before we check the link states
waitForRpOperation();
RecoverPointImageManagementUtils rpiMgmt = new RecoverPointImageManagementUtils();
logger.info("Waiting for links to become active for CG " + request.getCgName());
// Wait for the CG link state to be active or paused. We can add replication sets to a CG that has a target
// copy in DIRECT_ACCESS mode. In this image access mode, the link state is PAUSED and is therefore a valid
// link state.
rpiMgmt.waitForCGLinkState(functionalAPI, cgUID, RecoverPointImageManagementUtils.getPipeActiveState(functionalAPI, cgUID), PipeState.PAUSED);
logger.info(String.format("Replication sets have been added to consistency group %s.", request.getCgName()));
response.setReturnCode(RecoverPointReturnCode.SUCCESS);
return response;
} catch (Exception e) {
logger.info("Failed to add replication set(s) to CG");
throw RecoverPointException.exceptions.failedToAddReplicationSetToConsistencyGroup(request.getCgName(), getCause(e));
}
}
use of com.emc.fapiclient.ws.ConsistencyGroupCopyUID in project coprhd-controller by CoprHD.
the class RecoverPointClient method swapCopy.
/**
* Perform a swap to the consistency group copy specified by the input request params.
*
* @param copyParams the volume info for the CG to perform a swap to.
*
* @return void
*
* @throws RecoverPointException
* @throws FunctionalAPIInternalError_Exception
* @throws FunctionalAPIActionFailedException_Exception
*/
public void swapCopy(RPCopyRequestParams copyParams) throws RecoverPointException {
try {
logger.info("Swap copy to current or most recent image");
// Make sure the copy is already enabled or RP will fail the operation. If it isn't enabled, enable it.
RecoverPointImageManagementUtils imageManager = new RecoverPointImageManagementUtils();
ConsistencyGroupCopyUID cgCopyUID = RecoverPointUtils.mapRPVolumeProtectionInfoToCGCopyUID(copyParams.getCopyVolumeInfo());
ConsistencyGroupCopyState copyState = imageManager.getCopyState(functionalAPI, cgCopyUID);
if (copyState != null && copyState.getAccessedImage() == null && !StorageAccessState.DIRECT_ACCESS.equals(copyState.getStorageAccessState())) {
// Enable image access to the latest snapshot if copy image access isn't already enabled.
failoverCopy(copyParams);
}
ConsistencyGroupCopySettings cgCopySettings = RecoverPointUtils.getCopySettings(functionalAPI, cgCopyUID);
List<ConsistencyGroupCopyUID> productionCopiesUIDs = functionalAPI.getGroupSettings(cgCopyUID.getGroupUID()).getProductionCopiesUIDs();
// data replication. Otherwise, we need to perform a failover.
if (RecoverPointUtils.isProductionCopy(cgCopyUID, productionCopiesUIDs) && cgCopySettings.getRoleInfo() != null && ConsistencyGroupCopyRole.REPLICA == cgCopySettings.getRoleInfo().getRole()) {
logger.info("Swap copy is a production copy with role 'Target at Production'. Resuming production to complete the swap.");
functionalAPI.resumeProduction(cgCopyUID.getGroupUID(), true);
} else {
// Perform the failover
imageManager.failoverCGCopy(functionalAPI, cgCopyUID);
}
} catch (FunctionalAPIActionFailedException_Exception | FunctionalAPIInternalError_Exception e) {
String copyName = copyParams.getCopyVolumeInfo() != null ? copyParams.getCopyVolumeInfo().getRpCopyName() : "N/A";
throw RecoverPointException.exceptions.failedToSwapCopy(copyName, e);
}
}
Aggregations