use of com.emc.fapiclient.ws.ConsistencyGroupCopySettingsChangesParam 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;
}
Aggregations