use of com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception in project coprhd-controller by CoprHD.
the class RecoverPointClient method getArraysForClusters.
/**
* Returns the array serial numbers associated with each RP Cluster.
* That is, all arrays that have "visibility" according to the RP Cluster.
*
* @return a Map of RP Cluster ID -> a Set of array serial numbers
* @throws RecoverPointException
*/
public Map<String, Set<String>> getArraysForClusters() throws RecoverPointException {
String mgmtIPAddress = _endpoint.toASCIIString();
if (null == mgmtIPAddress) {
throw RecoverPointException.exceptions.noRecoverPointEndpoint();
}
try {
logger.info("RecoverPoint service: Returning all RP Clusters associated with endpoint: " + _endpoint);
FullRecoverPointSettings fullRecoverPointSettings = functionalAPI.getFullRecoverPointSettings();
Map<String, Set<String>> clusterStorageSystems = new HashMap<String, Set<String>>();
for (ClusterConfiguration siteSettings : fullRecoverPointSettings.getSystemSettings().getGlobalSystemConfiguration().getClustersConfigurations()) {
String siteName = siteSettings.getInternalClusterName();
clusterStorageSystems.put(siteName, RecoverPointUtils.getArraysForCluster(functionalAPI, siteSettings.getCluster()));
}
return clusterStorageSystems;
} catch (FunctionalAPIActionFailedException_Exception e) {
logger.error(e.getMessage(), e);
throw RecoverPointException.exceptions.exceptionGettingArrays(e);
} catch (FunctionalAPIInternalError_Exception e) {
logger.error(e.getMessage(), e);
throw RecoverPointException.exceptions.exceptionGettingArrays(e);
}
}
use of com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception in project coprhd-controller by CoprHD.
the class RecoverPointClient method scan.
/**
* Walk through the journals and source/target volumes to see where the WWNS lie.
*
* @param copies
* @param rSets
* @return set of discovered RP sites
*/
private Set<RPSite> scan(List<CreateCopyParams> copies, List<CreateRSetParams> rSets) {
// Setting the MAX_SCAN_WAIT_TOTAL_TRIES = 240
// so that we loop for a max of 1 hour (240 * 15000 = 1 hour)
final int MAX_SCAN_WAIT_TOTAL_TRIES = 240;
final int MAX_SCAN_WAIT_RETRY_MILLISECONDS = 15000;
int rescanTries = MAX_SCAN_WAIT_TOTAL_TRIES;
// set to true to stay in the loop
boolean needsScan = true;
Set<RPSite> allSites = null;
while (needsScan && rescanTries-- > 0) {
// Reset scan flag. If something goes wrong, it'll get set to true.
needsScan = false;
if ((MAX_SCAN_WAIT_TOTAL_TRIES - rescanTries) != 1) {
logger.info("RecoverPointClient: Briefly sleeping to accommodate export group latencies (Attempt #{} / {})", MAX_SCAN_WAIT_TOTAL_TRIES - rescanTries, MAX_SCAN_WAIT_TOTAL_TRIES);
try {
Thread.sleep(MAX_SCAN_WAIT_RETRY_MILLISECONDS);
} catch (InterruptedException e1) {
Thread.currentThread().interrupt();
}
}
// Rescan the san
logger.info("RecoverPointClient: Rescanning san volumes for endpoint: " + _endpoint.toASCIIString());
try {
functionalAPI.rescanSANVolumesInAllClusters(true);
} catch (FunctionalAPIActionFailedException_Exception e) {
logger.warn("Exception in call to rescanSANVolumesInAllSites");
} catch (FunctionalAPIInternalError_Exception e) {
logger.warn("Exception in call to rescanSANVolumesInAllSites");
}
// Get all of the volumes
allSites = getAssociatedRPSites();
//
for (CreateCopyParams copy : copies) {
for (CreateVolumeParams volumeParam : copy.getJournals()) {
boolean found = false;
for (RPSite rpSite : allSites) {
ClusterSANVolumes siteSANVolumes = rpSite.getSiteVolumes();
for (VolumeInformation volume : siteSANVolumes.getVolumesInformations()) {
if (matchesVolumeWWN(volume, volumeParam.getWwn())) {
logger.info("Found site and volume ID for journal: " + volumeParam.getWwn() + " for copy: " + copy.getName());
found = true;
break;
}
}
if (found) {
break;
}
}
if (!found) {
logger.warn(String.format("Could not find volume %s for copy %s and internal site %s on any RP site. We will likely retry.", volumeParam.getWwn(), copy.getName(), volumeParam.getInternalSiteName()));
// set that we still need to scan.
needsScan = true;
if (rescanTries <= 0) {
for (RPSite rpSite : allSites) {
logger.error(String.format("Could not find volume %s on any RP site. Retries exhausted.", volumeParam.getWwn()));
ClusterSANVolumes siteSANVolumes = rpSite.getSiteVolumes();
for (VolumeInformation volume : siteSANVolumes.getVolumesInformations()) {
logger.info(String.format("RP Site: %s; volume from RP: %s", rpSite.getSiteName(), RecoverPointUtils.getGuidBufferAsString(volume.getNaaUids(), false)));
}
}
throw RecoverPointException.exceptions.couldNotFindSiteAndVolumeIDForJournal(volumeParam.getWwn(), copy.getName(), volumeParam.getInternalSiteName());
}
}
}
}
// When adding new journal volumes only no need to look at source and target volumes
if (rSets == null || rSets.isEmpty()) {
continue;
}
//
for (CreateRSetParams rset : rSets) {
for (CreateVolumeParams volumeParam : rset.getVolumes()) {
boolean found = false;
for (RPSite rpSite : allSites) {
ClusterSANVolumes siteSANVolumes = rpSite.getSiteVolumes();
for (VolumeInformation volume : siteSANVolumes.getVolumesInformations()) {
if (matchesVolumeWWN(volume, volumeParam.getWwn())) {
logger.info(String.format("Found site and volume ID for volume: %s for replication set: %s on site: %s (%s)", volumeParam.getWwn(), rset.getName(), rpSite.getSiteName(), volumeParam.getInternalSiteName()));
found = true;
break;
}
}
if (found) {
break;
}
}
if (!found) {
logger.warn(String.format("Could not find volume %s for internal site %s on any RP site. We will likely retry.", volumeParam.getWwn(), volumeParam.getInternalSiteName()));
// set that we still need to scan
needsScan = true;
if (rescanTries <= 0) {
for (RPSite rpSite : allSites) {
logger.error(String.format("Could not find volume %s on any RP site. Retries exhausted.", volumeParam.getWwn()));
ClusterSANVolumes siteSANVolumes = rpSite.getSiteVolumes();
for (VolumeInformation volume : siteSANVolumes.getVolumesInformations()) {
logger.info(String.format("RP Site: %s; volume from RP: %s", rpSite.getSiteName(), RecoverPointUtils.getGuidBufferAsString(volume.getNaaUids(), false)));
}
}
throw RecoverPointException.exceptions.couldNotFindSiteAndVolumeIDForVolume(volumeParam.getWwn(), rset.getName(), volumeParam.getInternalSiteName());
}
}
}
}
}
return allSites;
}
use of com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception in project coprhd-controller by CoprHD.
the class RecoverPointClient method getCGState.
/**
* Return the state of a consistency group.
*
* @param cgUID - CG identifier
*
* @return the state of the CG
*
* @throws RecoverPointException
*/
private RecoverPointCGState getCGState(ConsistencyGroupUID cgUID) throws RecoverPointException {
ConsistencyGroupSettings cgSettings = null;
ConsistencyGroupState cgState = null;
try {
cgSettings = functionalAPI.getGroupSettings(cgUID);
cgState = functionalAPI.getGroupState(cgUID);
} catch (FunctionalAPIActionFailedException_Exception e) {
// No longer exists
return RecoverPointCGState.DELETED;
} catch (FunctionalAPIInternalError_Exception e) {
// No longer exists
return RecoverPointCGState.DELETED;
}
if (!cgSettings.isEnabled()) {
return RecoverPointCGState.STOPPED;
}
// First check for disabled copies
boolean someCopiesEnabled = false;
boolean someCopiesDisabled = false;
for (ConsistencyGroupCopyState cgCopyState : cgState.getGroupCopiesStates()) {
if (cgCopyState.isEnabled()) {
someCopiesEnabled = true;
} else {
someCopiesDisabled = true;
}
}
if (someCopiesDisabled && !someCopiesEnabled) {
// All copies are disabled
return RecoverPointCGState.STOPPED;
}
// Now check to see if all the copies are paused
boolean someCopiesPaused = false;
boolean someCopiesNotPaused = false;
List<ConsistencyGroupLinkState> cgLinkStateList;
try {
cgLinkStateList = functionalAPI.getGroupState(cgUID).getLinksStates();
} catch (FunctionalAPIActionFailedException_Exception e) {
// No longer exists
return RecoverPointCGState.DELETED;
} catch (FunctionalAPIInternalError_Exception e) {
// No longer exists
return RecoverPointCGState.DELETED;
}
for (ConsistencyGroupLinkState cgLinkState : cgLinkStateList) {
// OK, this is our link that we just restored. Check the link state to see if it is active
if (PipeState.ACTIVE.equals(cgLinkState.getPipeState()) || PipeState.SNAP_IDLE.equals(cgLinkState.getPipeState()) || PipeState.SNAP_SHIPPING.equals(cgLinkState.getPipeState()) || PipeState.STAND_BY.equals(cgLinkState.getPipeState())) {
someCopiesNotPaused = true;
} else {
someCopiesPaused = true;
}
}
if (someCopiesPaused && !someCopiesNotPaused) {
// All copies are paused
return RecoverPointCGState.PAUSED;
}
if (someCopiesPaused || someCopiesDisabled) {
return RecoverPointCGState.MIXED;
}
return RecoverPointCGState.READY;
}
use of com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception in project coprhd-controller by CoprHD.
the class RecoverPointClient method getReplicationSet.
/**
* Get the replication set information associated with this volume. This is important when assembling a workflow to
* recreate the replication set for the purpose of expanding volumes.
*
* Steps are as follows:
* This method: Get the state information associated with the replication set
* Delete method below: Delete the replication set
* RP Controller: Expand volumes
* Recreate method below: Perform a rescan_san
* Recreate method below: Create the replication set
*
* @param RecoverPointVolumeProtectionInfo volume - Volume info for the CG to remove the replication set from
* @return void
*
* @throws RecoverPointException
*/
public RecreateReplicationSetRequestParams getReplicationSet(RecoverPointVolumeProtectionInfo volume) throws RecoverPointException {
ReplicationSetSettings rsetSettings = null;
try {
ConsistencyGroupUID cgID = new ConsistencyGroupUID();
cgID.setId(volume.getRpVolumeGroupID());
ReplicationSetUID repSetUID = new ReplicationSetUID();
repSetUID.setId(volume.getRpVolumeRSetID());
rsetSettings = getReplicationSetSettings(functionalAPI, rsetSettings, cgID, repSetUID);
if (rsetSettings == null) {
throw RecoverPointException.exceptions.cannotFindReplicationSet(volume.getRpVolumeWWN());
}
RecreateReplicationSetRequestParams response = new RecreateReplicationSetRequestParams();
response.setCgName(volume.getRpProtectionName());
response.setName(rsetSettings.getReplicationSetName());
response.setConsistencyGroupUID(cgID);
response.setVolumes(new ArrayList<CreateRSetVolumeParams>());
ConsistencyGroupState state = functionalAPI.getGroupState(cgID);
ConsistencyGroupSettings cgSettings = functionalAPI.getGroupSettings(cgID);
// Get the standby production copy (if one exists). In the case of MetroPoint,
// we must ignore the standby copy device when getting the replication set. Including
// the standby copy during replication set re-creation will throw an exception
// because it has the same device ID as the active copy device.
ConsistencyGroupCopyUID standbyProdCopy = RecoverPointUtils.getStandbyProductionCopy(cgSettings, state);
for (UserVolumeSettings volumeSettings : rsetSettings.getVolumes()) {
if (standbyProdCopy != null && RecoverPointUtils.copiesEqual(volumeSettings.getGroupCopyUID(), standbyProdCopy)) {
// This is the standby production copy so ignore it.
String standyCopyName = functionalAPI.getGroupCopyName(volumeSettings.getGroupCopyUID());
logger.info(String.format("Ignoring volume %s at standby copy %s to avoid duplicate device IDs in replication set reconstruction for MetroPoint.", volumeSettings.getVolumeInfo().getVolumeName(), standyCopyName));
continue;
}
CreateRSetVolumeParams volumeParams = new CreateRSetVolumeParams();
volumeParams.setDeviceUID(volumeSettings.getVolumeInfo().getVolumeID());
volumeParams.setConsistencyGroupCopyUID(volumeSettings.getGroupCopyUID());
response.getVolumes().add(volumeParams);
}
return response;
} catch (FunctionalAPIActionFailedException_Exception e) {
throw RecoverPointException.exceptions.cannotFindReplicationSet(volume.getRpVolumeWWN(), e);
} catch (FunctionalAPIInternalError_Exception e) {
throw RecoverPointException.exceptions.cannotFindReplicationSet(volume.getRpVolumeWWN(), e);
}
}
use of com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception in project coprhd-controller by CoprHD.
the class RecoverPointBookmarkManagementUtils method createCGBookmarks.
/**
* Create bookmarks for a CG
*
* @param impl - RP handle to use for RP operations
* @param rpCGMap - The mapping of RP CGs to WWNs. Used to create a list of CGs to bookmark
* @param request - Information about the bookmark to request
*
* @return CreateBookmarkResponse - Results of the create bookmark.
* TODO: Return bookmark information (date/time)
*
* @throws RecoverPointException
*/
public CreateBookmarkResponse createCGBookmarks(FunctionalAPIImpl impl, Map<String, RPConsistencyGroup> rpCGMap, CreateBookmarkRequestParams request) throws RecoverPointException {
Set<ConsistencyGroupUID> uniqueCGUIDSet = new HashSet<ConsistencyGroupUID>();
List<ConsistencyGroupUID> uniqueCGUIDlist = new LinkedList<ConsistencyGroupUID>();
Set<RPConsistencyGroup> rpCGSet = new HashSet<RPConsistencyGroup>();
CreateBookmarkResponse response = new CreateBookmarkResponse();
for (String volume : rpCGMap.keySet()) {
RPConsistencyGroup rpCG = rpCGMap.get(volume);
if (rpCG.getCGUID() != null) {
boolean foundCGUID = false;
ConsistencyGroupUID cguid = rpCG.getCGUID();
for (ConsistencyGroupUID cguidunique : uniqueCGUIDSet) {
if (cguidunique.getId() == cguid.getId()) {
foundCGUID = true;
break;
}
}
if (!foundCGUID) {
logger.info("Adding CG: " + rpCG.getName() + " with ID " + rpCG.getCGUID().getId() + " to unique CGUID list");
uniqueCGUIDSet.add(cguid);
uniqueCGUIDlist.add(cguid);
rpCGSet.add(rpCG);
}
}
}
// Make sure the CG is in a good state before we make bookmarks
RecoverPointImageManagementUtils imageManager = new RecoverPointImageManagementUtils();
for (ConsistencyGroupUID cgID : uniqueCGUIDlist) {
// Make sure the CG is ready for enable
imageManager.waitForCGLinkState(impl, cgID, RecoverPointImageManagementUtils.getPipeActiveState(impl, cgID), PipeState.PAUSED);
}
try {
impl.createBookmark(uniqueCGUIDlist, request.getBookmark(), BookmarkConsolidationPolicy.NEVER_CONSOLIDATE, SnapshotConsistencyType.APPLICATION_CONSISTENT);
logger.info(String.format("Created RP Bookmark successfully: %s", request.getBookmark()));
response.setCgBookmarkMap(findRPBookmarks(impl, rpCGSet, request));
response.setReturnCode(RecoverPointReturnCode.SUCCESS);
} catch (FunctionalAPIActionFailedException_Exception | FunctionalAPIInternalError_Exception e) {
throw RecoverPointException.exceptions.failedToCreateBookmarkOnRecoverPoint(e);
}
return response;
}
Aggregations