use of com.emc.storageos.recoverpoint.requests.CreateVolumeParams 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.storageos.recoverpoint.requests.CreateVolumeParams 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.storageos.recoverpoint.requests.CreateVolumeParams 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.storageos.recoverpoint.requests.CreateVolumeParams in project coprhd-controller by CoprHD.
the class RecoverPointClient method getProdSites.
/**
* @param request
* @param clusterIdCache
* @return
* @throws FunctionalAPIActionFailedException_Exception
* @throws FunctionalAPIInternalError_Exception
*/
private List<ClusterUID> getProdSites(CGRequestParams request, Map<String, ClusterUID> clusterIdCache) throws FunctionalAPIActionFailedException_Exception, FunctionalAPIInternalError_Exception {
List<ClusterUID> prodSites = new ArrayList<ClusterUID>();
for (CreateVolumeParams volume : request.getRsets().get(0).getVolumes()) {
if (volume.isProduction()) {
ClusterUID prodSite = getRPSiteID(volume.getInternalSiteName(), clusterIdCache);
prodSites.add(prodSite);
}
}
return prodSites;
}
use of com.emc.storageos.recoverpoint.requests.CreateVolumeParams in project coprhd-controller by CoprHD.
the class RecoverPointClient method addCopyToCG.
/**
* adds one copy to an existing CG
*
* @param cgUID CG uid where new copy should be added
* @param allSites list of sites that see journal and copy file WWN's
* @param copyParams the copy to be added
* @param rSets replication set to which the user volumes have to be added
* @param copyType either production, local or remote
* @param linkSettings for the copy being added
* @param copyUid of the copy being added
* @throws FunctionalAPIActionFailedException_Exception
* @throws FunctionalAPIInternalError_Exception
* @throws FunctionalAPIValidationException_Exception
*/
private void addCopyToCG(ConsistencyGroupUID cgUID, Set<RPSite> allSites, CreateCopyParams copyParams, List<CreateRSetParams> rSets, RecoverPointCGCopyType copyType, List<ConsistencyGroupLinkSettings> linkSettings, ConsistencyGroupCopyUID copyUid) throws FunctionalAPIActionFailedException_Exception, FunctionalAPIInternalError_Exception, FunctionalAPIValidationException_Exception {
boolean isProduction = copyType == RecoverPointCGCopyType.PRODUCTION;
String copyTypeStr = copyType.toString();
logger.info(String.format("Adding new copy %s to cg", copyParams.getName()));
ConsistencyGroupCopySettingsParam copySettingsParam = new ConsistencyGroupCopySettingsParam();
copySettingsParam.setCopyName(copyParams.getName());
copySettingsParam.setCopyPolicy(null);
copySettingsParam.setEnabled(false);
copySettingsParam.setGroupCopy(copyUid);
copySettingsParam.setProductionCopy(isProduction);
copySettingsParam.setTransferEnabled(false);
copySettingsParam.getGroupLinksSettings().addAll(linkSettings);
// we can't call validateAddConsistencyGroupCopy here because during a swap operation, it throws an exception
// which is just a warning that a full sweep will be required. There didn't seem to be a way to catch
// just the warning and let other errors propagate as errors.
logger.info(String.format("Add Production copy %s (no validation): ", copyParams.getName(), copyParams.toString()));
functionalAPI.addConsistencyGroupCopy(copySettingsParam);
// add journals
for (CreateVolumeParams journalVolume : copyParams.getJournals()) {
logger.info(String.format("Adding Journal for Production copy %s : %s", copyParams.getName(), journalVolume.toString()));
functionalAPI.addJournalVolume(copyUid, RecoverPointUtils.getDeviceID(allSites, journalVolume.getInternalSiteName(), journalVolume.getWwn()));
}
if (rSets != null) {
ConsistencyGroupSettings groupSettings = functionalAPI.getGroupSettings(cgUID);
// Keep track of volumes added so we don't add the same one again. Prevents an exception from being thrown.
List<String> volumesAdded = new ArrayList<String>();
for (CreateRSetParams rSet : rSets) {
ReplicationSetUID rSetUid = null;
if (rSet != null && rSet.getName() != null && !rSet.getName().isEmpty()) {
for (ReplicationSetSettings rSetSetting : groupSettings.getReplicationSetsSettings()) {
if (rSetSetting.getReplicationSetName().equalsIgnoreCase(rSet.getName())) {
rSetUid = rSetSetting.getReplicationSetUID();
break;
}
}
}
if (rSetUid != null) {
for (CreateVolumeParams volume : rSet.getVolumes()) {
if ((isProduction && volume.isProduction()) || (!isProduction && !volume.isProduction()) && !volumesAdded.contains(volume.getWwn())) {
logger.info(String.format("Adding %s copy volume : %s", copyTypeStr, volume.toString()));
functionalAPI.addUserVolume(copyUid, rSetUid, RecoverPointUtils.getDeviceID(allSites, volume.getInternalSiteName(), volume.getWwn()));
volumesAdded.add(volume.getWwn());
}
}
}
}
}
}
Aggregations