use of com.emc.fapiclient.ws.ClusterUID 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.fapiclient.ws.ClusterUID 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));
}
}
use of com.emc.fapiclient.ws.ClusterUID in project coprhd-controller by CoprHD.
the class RecoverPointClient method restoreImageCopies.
/**
* Restore copy images for one or more consistency group copies
*
* @param MultiCopyRestoreImageRequestParams request - contains the information about which CG copies to restore
*
* @return MultiCopyRestoreImageResponse - response as to success or fail of restoring the image copies
*
* @throws RecoverPointException
*/
public MultiCopyRestoreImageResponse restoreImageCopies(MultiCopyRestoreImageRequestParams request) throws RecoverPointException {
MultiCopyRestoreImageResponse response = new MultiCopyRestoreImageResponse();
RecoverPointImageManagementUtils imageManager = new RecoverPointImageManagementUtils();
RecoverPointBookmarkManagementUtils bookmarkManager = new RecoverPointBookmarkManagementUtils();
String mgmtIPAddress = _endpoint.toASCIIString();
if (null == mgmtIPAddress) {
throw RecoverPointException.exceptions.noRecoverPointEndpoint();
}
Set<String> wwnSet = request.getVolumeWWNSet();
if (wwnSet == null) {
throw RecoverPointException.exceptions.noWWNsFoundInRequest();
}
Set<String> unmappedWWNs = new HashSet<String>();
CreateBookmarkRequestParams mapRequest = new CreateBookmarkRequestParams();
mapRequest.setBookmark(request.getBookmark());
mapRequest.setVolumeWWNSet(wwnSet);
Map<String, RPConsistencyGroup> rpCGMap = bookmarkManager.mapCGsForWWNs(functionalAPI, mapRequest, unmappedWWNs);
if (!unmappedWWNs.isEmpty()) {
throw RecoverPointException.exceptions.couldNotMapWWNsToAGroup(unmappedWWNs);
}
if (rpCGMap == null) {
throw RecoverPointException.exceptions.couldNotMapWWNsToAGroup(wwnSet);
}
Set<RPConsistencyGroup> cgSetToEnable = new HashSet<RPConsistencyGroup>();
for (String volume : rpCGMap.keySet()) {
// logger.info("Get RPCG for volume: " + volume);
cgSetToEnable.add(rpCGMap.get(volume));
}
ClusterUID siteToRestore = null;
// Verify that we are not restoring from different sites
for (RPConsistencyGroup rpcg : cgSetToEnable) {
Set<RPCopy> copies = rpcg.getCopies();
for (RPCopy copy : copies) {
if (siteToRestore == null) {
siteToRestore = copy.getCGGroupCopyUID().getGlobalCopyUID().getClusterUID();
} else if (siteToRestore.getId() != copy.getCGGroupCopyUID().getGlobalCopyUID().getClusterUID().getId()) {
throw RecoverPointException.exceptions.cannotRestoreVolumesFromDifferentSites(wwnSet);
}
try {
List<ConsistencyGroupCopyUID> productionCopiesUIDs = functionalAPI.getGroupSettings(copy.getCGGroupCopyUID().getGroupUID()).getProductionCopiesUIDs();
for (ConsistencyGroupCopyUID productionCopyUID : productionCopiesUIDs) {
if (RecoverPointUtils.copiesEqual(productionCopyUID, copy.getCGGroupCopyUID())) {
throw RecoverPointException.exceptions.cannotRestoreVolumesInConsistencyGroup(wwnSet);
}
}
} catch (FunctionalAPIActionFailedException_Exception e) {
logger.error(e.getMessage());
logger.error("Received FunctionalAPIActionFailedException_Exception. Get production copy");
throw RecoverPointException.exceptions.failureRestoringVolumes();
} catch (FunctionalAPIInternalError_Exception e) {
logger.error(e.getMessage());
logger.error("Received FunctionalAPIActionFailedException_Exception. Get production copy");
throw RecoverPointException.exceptions.failureRestoringVolumes();
}
}
}
try {
for (RPConsistencyGroup rpcg : cgSetToEnable) {
Set<RPCopy> copies = rpcg.getCopies();
for (RPCopy copy : copies) {
boolean waitForLinkState = false;
imageManager.enableCGCopy(functionalAPI, copy.getCGGroupCopyUID(), waitForLinkState, ImageAccessMode.LOGGED_ACCESS, request.getBookmark(), request.getAPITTime());
}
}
} catch (RecoverPointException e) {
logger.error("Caught exception while enabling CG copies for restore. Return copies to previous state");
for (RPConsistencyGroup rpcg : cgSetToEnable) {
Set<RPCopy> copies = rpcg.getCopies();
for (RPCopy copy : copies) {
imageManager.disableCGCopy(functionalAPI, copy.getCGGroupCopyUID());
}
}
throw e;
}
for (RPConsistencyGroup rpcg : cgSetToEnable) {
Set<RPCopy> copies = rpcg.getCopies();
for (RPCopy copy : copies) {
imageManager.restoreEnabledCGCopy(functionalAPI, copy.getCGGroupCopyUID());
}
}
response.setReturnCode(RecoverPointReturnCode.SUCCESS);
return response;
}
use of com.emc.fapiclient.ws.ClusterUID in project coprhd-controller by CoprHD.
the class RecoverPointClient method getStandbyCopyLinkSettings.
/**
* in a Metropoint environment, fetches link(s) between the primary copy(s) and the remote/DR copy
*
* @param activeProdCopy the CG copy uid of the active production copy
* @param standbyProdCopy the CG copy uid of the standby production copy
* @throws FunctionalAPIInternalError_Exception
* @throws FunctionalAPIActionFailedException_Exception
* @throws FunctionalAPIValidationException_Exception
* @throws RecoverPointException
*/
private List<ConsistencyGroupLinkSettings> getStandbyCopyLinkSettings(ConsistencyGroupCopyUID activeProdCopy, ConsistencyGroupCopyUID standbyProdCopy) throws FunctionalAPIActionFailedException_Exception, FunctionalAPIInternalError_Exception, FunctionalAPIValidationException_Exception {
logger.info("Preparing link settings between standby production copy and remote copy after Metropoint swap production copies.");
ConsistencyGroupLinkSettings standByCopyLinkSettings = new ConsistencyGroupLinkSettings();
List<ConsistencyGroupLinkSettings> cgLinkSettings = new ArrayList<ConsistencyGroupLinkSettings>();
String activeCgCopyName = functionalAPI.getGroupCopyName(activeProdCopy);
String standbyCgCopyName = functionalAPI.getGroupCopyName(standbyProdCopy);
String cgName = functionalAPI.getGroupName(activeProdCopy.getGroupUID());
ConsistencyGroupSettings groupSettings = functionalAPI.getGroupSettings(activeProdCopy.getGroupUID());
// find the remote copy; with metropoint, you're only allowed one remote copy
// so it must be the one with cluster id not equal to the active or standby cluster ids
ClusterUID activeClusterId = activeProdCopy.getGlobalCopyUID().getClusterUID();
ClusterUID standbyClusterId = standbyProdCopy.getGlobalCopyUID().getClusterUID();
for (ConsistencyGroupCopySettings copySetting : groupSettings.getGroupCopiesSettings()) {
// see if this is the remote copy; that is it's not the active and not the standby
ClusterUID copyClusterId = copySetting.getCopyUID().getGlobalCopyUID().getClusterUID();
if (copyClusterId.getId() != activeClusterId.getId() && copyClusterId.getId() != standbyClusterId.getId()) {
String targetCopyName = functionalAPI.getGroupCopyName(copySetting.getCopyUID());
// get the link settings for the active production copy and remote copy
ConsistencyGroupLinkSettings linkSettings = findLinkSettings(groupSettings.getActiveLinksSettings(), activeProdCopy.getGlobalCopyUID(), copySetting.getCopyUID().getGlobalCopyUID(), activeCgCopyName, targetCopyName);
if (linkSettings != null) {
logger.info(String.format("Generate new link settings between %s and %s based on existing link settings between the current production copy %s and %s.", standbyCgCopyName, targetCopyName, activeCgCopyName, targetCopyName));
cgLinkSettings.add(linkSettings);
ConsistencyGroupLinkUID cgLinkUID = linkSettings.getGroupLinkUID();
// Set the link copies appropriately
GlobalCopyUID standbyCopyUid = standbyProdCopy.getGlobalCopyUID();
GlobalCopyUID remoteTargetCopyUid = copySetting.getCopyUID().getGlobalCopyUID();
cgLinkUID.setFirstCopy(standbyCopyUid);
cgLinkUID.setSecondCopy(remoteTargetCopyUid);
ConsistencyGroupLinkPolicy linkPolicy = linkSettings.getLinkPolicy();
// Build the link between the standby production copy and the remote copy
// this has to be a remote copy
logger.info(String.format("Build new remote copy link settings between %s and %s, for consistency group %s.", standbyCgCopyName, targetCopyName, cgName));
linkPolicy.getProtectionPolicy().setReplicatingOverWAN(true);
standByCopyLinkSettings.setGroupLinkUID(cgLinkUID);
standByCopyLinkSettings.setLinkPolicy(linkPolicy);
standByCopyLinkSettings.setLocalLink(false);
standByCopyLinkSettings.setTransferEnabled(true);
cgLinkSettings.add(standByCopyLinkSettings);
break;
}
}
}
return cgLinkSettings;
}
use of com.emc.fapiclient.ws.ClusterUID in project coprhd-controller by CoprHD.
the class RecoverPointClient method createCG.
/**
* Creates a consistency group
*
* @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 CreateCGResponse - response as to success or fail of creating the consistency group
*
* @throws RecoverPointException
*/
public RecoverPointCGResponse createCG(CGRequestParams request, boolean metropoint, boolean attachAsClean) throws RecoverPointException {
if (null == _endpoint.toASCIIString()) {
throw RecoverPointException.exceptions.noRecoverPointEndpoint();
}
RecoverPointCGResponse response = new RecoverPointCGResponse();
ConsistencyGroupUID cgUID = null;
try {
// Make sure the CG name is unique.
int cgSuffix = 0;
String cgName = request.getCgName();
while (doesCgExist(request.getCgName())) {
request.setCgName(String.format("%s-%d", cgName, ++cgSuffix));
}
// 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 = getProdSites(request, clusterIdCache);
StringBuffer sb = new StringBuffer();
for (ClusterUID prodSite : prodSites) {
sb.append(prodSite.getId());
sb.append(" ");
}
logger.info("RecoverPointClient: Creating recoverPoint consistency group " + request.getCgName() + " for endpoint: " + _endpoint.toASCIIString() + " and production sites: " + sb.toString());
// 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>();
Map<ConsistencyGroupCopyUID, String> cgCopyNames = new HashMap<ConsistencyGroupCopyUID, String>();
FullConsistencyGroupPolicy fullConsistencyGroupPolicy = configureCGPolicy(request, prodSites, clusterIdCache, productionCopiesUID, nonProductionCopiesUID, cgCopyNames);
// create the CG with copies
logger.info("Adding cg, copies and links for CG: " + request.getCgName());
functionalAPI.validateAddConsistencyGroupAndCopies(fullConsistencyGroupPolicy);
cgUID = functionalAPI.addConsistencyGroupAndCopies(fullConsistencyGroupPolicy);
response.setCgId(cgUID.getId());
ConsistencyGroupSettingsChangesParam cgSettingsParam = configureCGSettingsChangeParams(request, cgUID, prodSites, clusterIdCache, productionCopiesUID, nonProductionCopiesUID, attachAsClean);
logger.info("Adding journals and rsets for CG " + request.getCgName());
functionalAPI.setConsistencyGroupSettings(cgSettingsParam);
RecoverPointImageManagementUtils rpiMgmt = new RecoverPointImageManagementUtils();
logger.info("Waiting for links to become active for CG " + request.getCgName());
rpiMgmt.waitForCGLinkState(functionalAPI, cgUID, RecoverPointImageManagementUtils.getPipeActiveState(functionalAPI, cgUID));
logger.info(String.format("Consistency group %s has been created.", request.getCgName()));
response.setReturnCode(RecoverPointReturnCode.SUCCESS);
return response;
} catch (Exception e) {
if (cgUID != null) {
try {
RecoverPointUtils.cleanupCG(functionalAPI, cgUID);
} catch (Exception e1) {
logger.error("Error removing CG " + request.getCgName() + " after create CG failure");
logger.error(e1.getMessage(), e1);
}
}
throw RecoverPointException.exceptions.failedToCreateConsistencyGroup(request.getCgName(), getCause(e));
}
}
Aggregations