use of com.emc.storageos.recoverpoint.exceptions.RecoverPointException 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.storageos.recoverpoint.exceptions.RecoverPointException 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.storageos.recoverpoint.exceptions.RecoverPointException in project coprhd-controller by CoprHD.
the class RecoverPointClient method deleteReplicationSets.
/**
* Deletes one-to-many replication sets based on the volume information passed in.
*
* @param volumeInfoList the volume information that relates to one or more replication sets.
* @throws RecoverPointException
*/
public void deleteReplicationSets(List<RecoverPointVolumeProtectionInfo> volumeInfoList) throws RecoverPointException {
// Used to capture the volume WWNs associated with each replication set to remove.
List<String> volumeWWNs = new ArrayList<String>();
Map<Long, String> rsetNames = new HashMap<Long, String>();
List<Long> rsetIDsToValidate = new ArrayList<Long>();
try {
ConsistencyGroupUID cgID = new ConsistencyGroupUID();
cgID.setId(volumeInfoList.get(0).getRpVolumeGroupID());
ConsistencyGroupSettingsChangesParam cgSettingsParam = new ConsistencyGroupSettingsChangesParam();
cgSettingsParam.setGroupUID(cgID);
ConsistencyGroupSettings groupSettings = functionalAPI.getGroupSettings(cgID);
List<ReplicationSetSettings> replicationSetSettings = groupSettings.getReplicationSetsSettings();
for (RecoverPointVolumeProtectionInfo volumeInfo : volumeInfoList) {
boolean found = false;
// Validate that the requested replication sets to delete actually exist.
for (ReplicationSetSettings replicationSet : replicationSetSettings) {
if (replicationSet.getReplicationSetUID().getId() == volumeInfo.getRpVolumeRSetID()) {
rsetNames.put(volumeInfo.getRpVolumeRSetID(), replicationSet.getReplicationSetName());
found = true;
break;
}
}
if (!found) {
logger.warn(String.format("No matching replication set for volume [%s] with replication set ID [%s] found." + " This will need to be checked on the RP System.", volumeInfo.getRpVolumeWWN(), volumeInfo.getRpVolumeRSetID()));
continue;
}
ReplicationSetUID repSetUID = new ReplicationSetUID();
repSetUID.setId(volumeInfo.getRpVolumeRSetID());
repSetUID.setGroupUID(cgID);
if (!containsRepSetUID(cgSettingsParam.getRemovedReplicationSets(), repSetUID)) {
cgSettingsParam.getRemovedReplicationSets().add(repSetUID);
rsetIDsToValidate.add(repSetUID.getId());
}
volumeWWNs.add(volumeInfo.getRpVolumeWWN());
logger.info(String.format("Adding replication set [%s] (%d) to be removed from RP CG [%s] (%d)", rsetNames.get(volumeInfo.getRpVolumeRSetID()), volumeInfo.getRpVolumeRSetID(), groupSettings.getName(), cgID.getId()));
}
// to remove.
if (cgSettingsParam.getRemovedReplicationSets() != null && !cgSettingsParam.getRemovedReplicationSets().isEmpty()) {
if (replicationSetSettings.size() == cgSettingsParam.getRemovedReplicationSets().size()) {
// We are removing all the replication sets in the CG so we need to disable
// the entire CG.
disableConsistencyGroup(cgID);
}
// Remove the replication sets
functionalAPI.setConsistencyGroupSettings(cgSettingsParam);
// Validate that the RSets have been removed
validateRSetsRemoved(rsetIDsToValidate, cgID, volumeWWNs);
logger.info("Request to delete replication sets " + rsetNames.toString() + " from RP CG " + groupSettings.getName() + " completed.");
} else {
logger.warn(String.format("No replication sets found to be deleted from RP CG [%s] (%d)", groupSettings.getName(), cgID.getId()));
}
} catch (Exception e) {
throw RecoverPointException.exceptions.failedToDeleteReplicationSet(volumeWWNs.toString(), e);
}
}
use of com.emc.storageos.recoverpoint.exceptions.RecoverPointException in project coprhd-controller by CoprHD.
the class RecoverPointClient method validateCGRemoved.
/**
* Validate that the CG has been removed from the RP system by calling out
* to get all CGs and ensuring the one we are trying to delete is gone.
*
* If we still see the CG being returned, wait and try again until max attempts is
* reached.
*
* @param cgToValidate The CG UID to check
* @param cgName The CG name to check
* @throws RecoverPointException RP Exception to throw if we hit it
*/
private void validateCGRemoved(ConsistencyGroupUID cgToValidate, String cgName) throws RecoverPointException {
try {
logger.info(String.format("Validating that RP CG [%s] (%d) has been removed.", cgName, cgToValidate.getId()));
int cgDeleteAttempt = 0;
while (cgDeleteAttempt < MAX_WAIT_FOR_RP_DELETE_ATTEMPTS) {
boolean cgDeleted = true;
logger.info(String.format("Validation attempt %d of %d", cgDeleteAttempt + 1, MAX_WAIT_FOR_RP_DELETE_ATTEMPTS));
// Get all the CGs from RecoverPoint
List<ConsistencyGroupUID> allCGs = functionalAPI.getAllConsistencyGroups();
// If not, wait and check again.
for (ConsistencyGroupUID cgUID : allCGs) {
if (cgToValidate.getId() == cgUID.getId()) {
logger.info(String.format("RP CG [%s] (%d) has not been removed yet. Will wait and check again...", cgName, cgToValidate.getId()));
waitForRpOperation();
cgDeleteAttempt++;
cgDeleted = false;
// to RecoverPoint to ensure we do not have a stale connection.
if (cgDeleteAttempt == (MAX_WAIT_FOR_RP_DELETE_ATTEMPTS / 2)) {
this.reconnect();
}
break;
}
}
if (cgDeleted) {
// RP CG appears to have been removed from RP
logger.info(String.format("RP CG [%s] (%d) has been removed.", cgName, cgToValidate.getId()));
break;
}
}
// If we reached max attempts alert the user and continue on with delete operation.
if (cgDeleteAttempt >= MAX_WAIT_FOR_RP_DELETE_ATTEMPTS) {
// Allow the cleanup to continue in ViPR but warn the user
logger.error(String.format("Max attempts reached waiting for RP CG [%s] (%d) to be removed from RP. " + "Please check RP System. Delete operation will continue...", cgName, cgToValidate.getId()));
throw RecoverPointException.exceptions.failedToDeleteConsistencyGroup(cgName, new Exception("Max attempts reached waiting for RP CG to be removed from RP."));
}
} catch (Exception e) {
logger.error(String.format("Exception hit while waiting for RP CG [%s] to be removed.", cgName));
throw RecoverPointException.exceptions.failedToDeleteConsistencyGroup(cgName, e);
}
}
use of com.emc.storageos.recoverpoint.exceptions.RecoverPointException in project coprhd-controller by CoprHD.
the class RecoverPointClient method getClusterTopology.
public Set<String> getClusterTopology() throws RecoverPointException {
Set<String> clusterTopology = new HashSet<String>();
String mgmtIPAddress = _endpoint.toASCIIString();
if (null == mgmtIPAddress) {
throw RecoverPointException.exceptions.noRecoverPointEndpoint();
}
try {
Map<Long, String> clusterSiteNameMap = new HashMap<Long, String>();
for (ClusterConfiguration clusterInfo : functionalAPI.getFullRecoverPointSettings().getSystemSettings().getGlobalSystemConfiguration().getClustersConfigurations()) {
clusterSiteNameMap.put(clusterInfo.getCluster().getId(), clusterInfo.getInternalClusterName());
}
logger.info("RecoverPoint service: Returning all RP Sites associated with endpoint: " + _endpoint);
for (ClusterConfiguration clusterInfo : functionalAPI.getFullRecoverPointSettings().getSystemSettings().getGlobalSystemConfiguration().getClustersConfigurations()) {
for (RemoteClusterConnectionInformation connectionInfo : clusterInfo.getRemoteClustersConnectionInformations()) {
// Find the internal site name associated with the cluster name
clusterTopology.add(clusterInfo.getInternalClusterName() + " " + clusterSiteNameMap.get(connectionInfo.getCluster().getId()) + " " + connectionInfo.getConnectionType().toString());
}
}
return clusterTopology;
} catch (RecoverPointException e) {
throw e;
} catch (Exception e) {
throw RecoverPointException.exceptions.failedToPingMgmtIP(mgmtIPAddress, getCause(e));
}
}
Aggregations