use of com.emc.storageos.recoverpoint.objectmodel.RPSite 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.objectmodel.RPSite 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.objectmodel.RPSite 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.objectmodel.RPSite in project coprhd-controller by CoprHD.
the class RecoverPointClient method deleteJournalFromCopy.
/**
* Delete a journal volume (WWN) from the consistency group copy specified by the input volume info.
*
* @param RecoverPointVolumeProtectionInfo copyToModify - Volume info for the CG to add a journal volume to
*
* @param String journalWWNToDelete - WWN of the journal volume to delete
*
* @return void
*
* @throws RecoverPointException
*/
public void deleteJournalFromCopy(RecoverPointVolumeProtectionInfo copyToModify, String journalWWNToDelete) throws RecoverPointException {
ConsistencyGroupCopyUID cgCopyUID = RecoverPointUtils.mapRPVolumeProtectionInfoToCGCopyUID(copyToModify);
String copyName = null;
String cgName = null;
try {
copyName = functionalAPI.getGroupCopyName(cgCopyUID);
cgName = functionalAPI.getGroupName(cgCopyUID.getGroupUID());
logger.info("Request to delete journal " + journalWWNToDelete + " from copy " + copyName + " for consistency group " + cgName);
Set<RPSite> allSites = getAssociatedRPSites();
DeviceUID journalDeviceUIDToDelete = RecoverPointUtils.getDeviceID(allSites, journalWWNToDelete);
if (journalDeviceUIDToDelete == null) {
throw RecoverPointException.exceptions.cannotFindJournal(journalWWNToDelete);
}
functionalAPI.removeJournalVolume(cgCopyUID, journalDeviceUIDToDelete);
} catch (FunctionalAPIActionFailedException_Exception e) {
throw RecoverPointException.exceptions.failedToDeleteJournal(journalWWNToDelete, copyName, cgName, e);
} catch (FunctionalAPIInternalError_Exception e) {
throw RecoverPointException.exceptions.failedToDeleteJournal(journalWWNToDelete, copyName, cgName, e);
}
}
use of com.emc.storageos.recoverpoint.objectmodel.RPSite in project coprhd-controller by CoprHD.
the class RecoverPointClient method getAssociatedRPSites.
/**
* Returns a list of sites associated with any given site (or RPA). The user can/should enter a site mgmt IP addr, but they can also
* support the mgmt IP addr of an RPA. This method will return sites, not RPAs
*
* @return set of discovered RP sites
*
* @throws RecoverPointException
*/
public Set<RPSite> getAssociatedRPSites() throws RecoverPointException {
String mgmtIPAddress = _endpoint.toASCIIString();
if (null == mgmtIPAddress) {
throw RecoverPointException.exceptions.noRecoverPointEndpoint();
}
try {
logger.info("RecoverPoint service: Returning all RP Sites associated with endpoint: " + _endpoint);
Set<RPSite> returnSiteSet = new HashSet<RPSite>();
RPSite discoveredSite = null;
ClusterUID localClusterUID = functionalAPI.getLocalCluster();
String localSiteName = "unknown";
FullRecoverPointSettings fullRecoverPointSettings = functionalAPI.getFullRecoverPointSettings();
SortedSet<String> siteNames = new TreeSet<String>();
for (ClusterSettings siteSettings : fullRecoverPointSettings.getSystemSettings().getClustersSettings()) {
String siteName = siteSettings.getClusterName();
siteNames.add(siteName);
}
Iterator<String> iter = siteNames.iterator();
String installationId = "";
while (iter.hasNext()) {
installationId += iter.next();
if (iter.hasNext()) {
installationId += "_";
}
}
for (ClusterConfiguration siteSettings : fullRecoverPointSettings.getSystemSettings().getGlobalSystemConfiguration().getClustersConfigurations()) {
try {
// TODO: Support multiple management IPs per site
String siteIP = siteSettings.getManagementIPs().get(0).getIp();
String siteName = siteSettings.getClusterName();
if (siteIP == null) {
throw RecoverPointException.exceptions.cannotDetermineMgmtIPSite(siteName);
}
List<RpaConfiguration> rpaList = siteSettings.getRpasConfigurations();
discoveredSite = new RPSite();
discoveredSite.setSiteName(siteName);
discoveredSite.setSiteManagementIPv4(siteIP);
discoveredSite.setSiteVersion(functionalAPI.getRecoverPointVersion().getVersion());
discoveredSite.setSiteVolumes(functionalAPI.getClusterSANVolumes(siteSettings.getCluster(), true));
discoveredSite.setInternalSiteName(siteSettings.getInternalClusterName());
discoveredSite.setSiteUID(siteSettings.getCluster().getId());
if (localClusterUID.getId() == siteSettings.getCluster().getId()) {
localSiteName = siteName;
}
discoveredSite.setNumRPAs(rpaList.size());
String siteGUID = installationId + ":" + siteSettings.getCluster().getId();
logger.info("SITE GUID: " + siteGUID);
discoveredSite.setSiteGUID(siteGUID);
if (localClusterUID.getId() == siteSettings.getCluster().getId()) {
logger.info("Discovered local site name: " + siteName + ", site IP: " + siteIP + ", RP version: " + discoveredSite.getSiteVersion() + ", num RPAs: " + discoveredSite.getNumRPAs());
} else {
logger.info("Discovered non-local site name: " + siteName + ", site IP: " + siteIP + ", RP version: " + discoveredSite.getSiteVersion() + ", num RPAs: " + discoveredSite.getNumRPAs());
}
returnSiteSet.add(discoveredSite);
} catch (FunctionalAPIInternalError_Exception | FunctionalAPIActionFailedException_Exception fe) {
StringBuffer buf = new StringBuffer();
buf.append(String.format("Internal Error during discover of RP Cluster %s, Skipping discovery of this site.", localSiteName));
if (fe != null) {
buf.append('\n');
buf.append(String.format("Exception returned : %s", fe.getMessage()));
}
logger.warn(buf.toString());
}
}
// 99% of unlicensed RP system errors will be caught here
if (!RecoverPointUtils.isSiteLicensed(functionalAPI)) {
throw RecoverPointException.exceptions.siteNotLicensed(localSiteName);
}
return returnSiteSet;
} catch (RecoverPointException e) {
throw e;
} catch (Exception e) {
logger.error(e.getMessage());
throw RecoverPointException.exceptions.failedToPingMgmtIP(mgmtIPAddress, getCause(e));
}
}
Aggregations