use of com.emc.fapiclient.ws.ReplicationSetSettings in project coprhd-controller by CoprHD.
the class RecoverPointClient method getProtectionInfoForVolume.
/**
* The getProtectionInfoForVolume method takes the WWN, and looks for it in the RP site protection environment.
* If it finds the WWN as a member of a consistency group, it fills in the information, and returns it to the caller.
* If it does not find the WWN as a member of a consistency group, it returns null
*
* @param String volumeWWN - The WWN being checked for RecoverPoint protection
*
* @return RecoverPointVolumeProtectionInfo - description of protection information about the WWN, or null if not protected in CG
*
* @throws RecoverPointException
*/
public RecoverPointVolumeProtectionInfo getProtectionInfoForVolume(String volumeWWN) throws RecoverPointException {
RecoverPointVolumeProtectionInfo protectionInfo = null;
try {
// logger.info("getProtectionInfoForVolume called for: " + volumeWWN);
protectionInfo = new RecoverPointVolumeProtectionInfo();
List<ConsistencyGroupSettings> cgsSettings = functionalAPI.getAllGroupsSettings();
for (ConsistencyGroupSettings cgSettings : cgsSettings) {
// See if it is a production source, or an RP target
for (ReplicationSetSettings rsSettings : cgSettings.getReplicationSetsSettings()) {
for (UserVolumeSettings uvSettings : rsSettings.getVolumes()) {
if (matchesVolumeWWN(uvSettings.getVolumeInfo(), volumeWWN)) {
ConsistencyGroupUID cgID = uvSettings.getGroupCopyUID().getGroupUID();
ConsistencyGroupState state = functionalAPI.getGroupState(cgID);
List<ConsistencyGroupCopyUID> productionCopiesUIDs = functionalAPI.getGroupSettings(cgID).getProductionCopiesUIDs();
String cgName = cgSettings.getName();
String cgCopyName = functionalAPI.getGroupCopyName(uvSettings.getGroupCopyUID());
protectionInfo.setRpProtectionName(cgName);
protectionInfo.setRpVolumeGroupCopyID(uvSettings.getGroupCopyUID().getGlobalCopyUID().getCopyUID());
protectionInfo.setRpCopyName(cgCopyName);
protectionInfo.setRpSiteName(getRecoverPointClusterName(uvSettings.getClusterUID()));
protectionInfo.setRpVolumeGroupID(cgID.getId());
protectionInfo.setRpVolumeSiteID(uvSettings.getClusterUID().getId());
protectionInfo.setRpVolumeRSetID(rsSettings.getReplicationSetUID().getId());
protectionInfo.setRpVolumeWWN(volumeWWN);
if (RecoverPointUtils.isProductionCopy(uvSettings.getGroupCopyUID(), productionCopiesUIDs)) {
if (RecoverPointUtils.isStandbyProductionCopy(uvSettings.getGroupCopyUID(), state, productionCopiesUIDs)) {
// In the case of MetroPoint, we will have 2 production copies for the same volume (active and standby).
// We want to always match on the active production copy. If this is a MetroPoint CG, skip over the
// standby production copy.
logger.info(String.format("Found production volume %s on copy %s. Skipping because it is not the active production copy.", volumeWWN, cgCopyName));
continue;
}
logger.info("Production volume: " + volumeWWN + " is on copy " + cgCopyName + " of CG " + cgName);
protectionInfo.setRpVolumeCurrentProtectionStatus(RecoverPointVolumeProtectionInfo.volumeProtectionStatus.PROTECTED_SOURCE);
} else {
logger.info("Target volume: " + volumeWWN + " is on copy " + cgCopyName + " of CG " + cgName);
protectionInfo.setRpVolumeCurrentProtectionStatus(RecoverPointVolumeProtectionInfo.volumeProtectionStatus.PROTECTED_TARGET);
}
return protectionInfo;
}
}
}
// See if it is a journal volume
for (ConsistencyGroupCopySettings cgCopySettings : cgSettings.getGroupCopiesSettings()) {
ConsistencyGroupCopyJournal cgJournal = cgCopySettings.getJournal();
List<JournalVolumeSettings> journalVolumeSettingsList = cgJournal.getJournalVolumes();
for (JournalVolumeSettings journalVolumeSettings : journalVolumeSettingsList) {
if (matchesVolumeWWN(journalVolumeSettings.getVolumeInfo(), volumeWWN)) {
ConsistencyGroupUID cgID = journalVolumeSettings.getGroupCopyUID().getGroupUID();
List<ConsistencyGroupCopyUID> productionCopiesUIDs = functionalAPI.getGroupSettings(cgID).getProductionCopiesUIDs();
String cgName = cgSettings.getName();
String cgCopyName = functionalAPI.getGroupCopyName(journalVolumeSettings.getGroupCopyUID());
protectionInfo.setRpProtectionName(cgName);
protectionInfo.setRpVolumeGroupCopyID(journalVolumeSettings.getGroupCopyUID().getGlobalCopyUID().getCopyUID());
protectionInfo.setRpVolumeGroupID(cgID.getId());
protectionInfo.setRpVolumeSiteID(journalVolumeSettings.getClusterUID().getId());
protectionInfo.setRpVolumeWWN(volumeWWN);
if (RecoverPointUtils.isProductionCopy(journalVolumeSettings.getGroupCopyUID(), productionCopiesUIDs)) {
logger.info("Production journal: " + volumeWWN + " is on copy " + cgCopyName + " of CG " + cgName);
protectionInfo.setRpVolumeCurrentProtectionStatus(RecoverPointVolumeProtectionInfo.volumeProtectionStatus.SOURCE_JOURNAL);
} else {
logger.info("Target journal: " + volumeWWN + " is on copy " + cgCopyName + " of CG " + cgName);
protectionInfo.setRpVolumeCurrentProtectionStatus(RecoverPointVolumeProtectionInfo.volumeProtectionStatus.TARGET_JOURNAL);
}
return protectionInfo;
}
}
}
}
} catch (FunctionalAPIActionFailedException_Exception e) {
throw RecoverPointException.exceptions.failureGettingProtectionInfoForVolume(volumeWWN, e);
} catch (FunctionalAPIInternalError_Exception e) {
throw RecoverPointException.exceptions.failureGettingProtectionInfoForVolume(volumeWWN, e);
}
throw RecoverPointException.exceptions.failureGettingProtectionInfoForVolume(volumeWWN);
}
use of com.emc.fapiclient.ws.ReplicationSetSettings in project coprhd-controller by CoprHD.
the class RecoverPointClient method validateRSetsRemoved.
/**
* Validate that the RSet(s) has been removed from the RP system by calling out
* to get all RSets for the CG and ensuring the one(s) we are trying to delete is gone.
*
* If we still see the RSet(s) being returned, wait and try again until max attempts is
* reached.
*
* @param resetIDsToValidate The RSet IDs to check that they have been removed from RP
* @param cgToValidate The CG UID to check
* @param volumeWWNs The WWNs of the source volumes to delete, used for exceptions
* @throws RecoverPointException RP Exception to throw if we hit it
*/
private void validateRSetsRemoved(List<Long> resetIDsToValidate, ConsistencyGroupUID cgToValidate, List<String> volumeWWNs) throws RecoverPointException {
try {
String cgName = functionalAPI.getGroupName(cgToValidate);
logger.info(String.format("Validating that all requested RSets have been removed from RP CG [%s] (%d)", cgName, cgToValidate.getId()));
int rsetDeleteAttempt = 0;
while (rsetDeleteAttempt < MAX_WAIT_FOR_RP_DELETE_ATTEMPTS) {
boolean allRSetsDeleted = true;
logger.info(String.format("Validation attempt %d of %d", rsetDeleteAttempt + 1, MAX_WAIT_FOR_RP_DELETE_ATTEMPTS));
// Get the current RSets from the CG
ConsistencyGroupSettings groupSettings = functionalAPI.getGroupSettings(cgToValidate);
List<ReplicationSetSettings> replicationSetSettings = groupSettings.getReplicationSetsSettings();
// If any are still present, wait and check again.
for (ReplicationSetSettings rset : replicationSetSettings) {
if (resetIDsToValidate.contains(rset.getReplicationSetUID().getId())) {
logger.info(String.format("RSet [%s] (%d) has not been removed yet. Will wait and check again...", rset.getReplicationSetName(), rset.getReplicationSetUID().getId()));
waitForRpOperation();
rsetDeleteAttempt++;
allRSetsDeleted = false;
// to RecoverPoint to ensure we do not have a stale connection.
if (rsetDeleteAttempt == (MAX_WAIT_FOR_RP_DELETE_ATTEMPTS / 2)) {
this.reconnect();
}
break;
}
}
if (allRSetsDeleted) {
// RSets appear to have been removed from RP
logger.info(String.format("All requested RSets have been removed from RP CG [%s] (%d).", cgName, cgToValidate.getId()));
break;
}
}
// If we reached max attempts alert the user and continue on with delete operation.
if (rsetDeleteAttempt >= 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 requested RSets to be removed from RP CG. " + "Please check RP System."));
throw RecoverPointException.exceptions.failedToDeleteReplicationSet(volumeWWNs.toString(), new Exception("Max attempts reached waiting for requested RSets to be removed from RP CG. " + "Please check RP System."));
}
} catch (Exception e) {
logger.error(String.format("Exception hit while waiting for all requested RSets to be removed from RP CG."));
throw RecoverPointException.exceptions.failedToDeleteReplicationSet(volumeWWNs.toString(), e);
}
}
use of com.emc.fapiclient.ws.ReplicationSetSettings in project coprhd-controller by CoprHD.
the class RecoverPointBookmarkManagementUtils method mapCGsForWWNs.
/**
* Take a list of WWNs for a RecoverPoint appliance and return consistency group information for the WWNs
*
* @param impl - RP handle to perform RP operations
* @param request - Input request of WWNs
* @param unmappedWWNs - WWNs that could not be mapped to a consistency group
*
* @return WWN to consistency group mappings
*
* @throws RecoverPointException
*/
public Map<String, RPConsistencyGroup> mapCGsForWWNs(FunctionalAPIImpl impl, CreateBookmarkRequestParams request, Set<String> unmappedWWNs) throws RecoverPointException {
try {
Set<String> wwnList = request.getVolumeWWNSet();
if (wwnList.isEmpty()) {
logger.error("Input WWN list size is 0");
return null;
}
Map<String, RPConsistencyGroup> returnMap = new HashMap<String, RPConsistencyGroup>();
Set<String> wwnListCopy = new HashSet<String>();
for (String wwn : wwnList) {
wwnListCopy.add(wwn.toLowerCase(Locale.ENGLISH));
logger.info("Mapping source WWN " + wwn.toLowerCase(Locale.ENGLISH) + " to RecoverPoint CG");
}
List<ConsistencyGroupSettings> cgSettings = impl.getAllGroupsSettings();
RPConsistencyGroup rpCG = null;
for (ConsistencyGroupSettings cgSetting : cgSettings) {
for (ReplicationSetSettings rsSetting : cgSetting.getReplicationSetsSettings()) {
// Only get the unique volumes from a replication set. In MetroPoint, a replication set will list the source volume
// twice. This is because in MetroPoint each VPLEX leg is considered a copy but the WWN/volume is the same.
Set<UserVolumeSettings> uvSettings = new HashSet<UserVolumeSettings>();
uvSettings.addAll(rsSetting.getVolumes());
for (UserVolumeSettings uvSetting : uvSettings) {
String volUID = RecoverPointUtils.getGuidBufferAsString(uvSetting.getVolumeInfo().getRawUids(), false);
if (wwnListCopy.contains(volUID.toLowerCase(Locale.ENGLISH))) {
// Remove the volUID from the list
wwnListCopy.remove(volUID.toLowerCase(Locale.ENGLISH));
// We are getting the index of the first production copy because we only need to
// get the cluster ID of the source. All source copies in a CG, across different Rsets, are on the same cluster.
// Hence we are ok fetching the first one and getting its cluster id and using it.
ConsistencyGroupCopyUID productionCopyUID = cgSetting.getProductionCopiesUIDs().get(0);
// Get the RecoverPoint CG name and ID
String cgName = cgSetting.getName();
ConsistencyGroupUID cgUID = cgSetting.getGroupUID();
// Get the Copy information
RPCopy rpCopy = new RPCopy();
rpCopy.setCGGroupCopyUID(uvSetting.getGroupCopyUID());
Set<RPCopy> copies = new HashSet<RPCopy>();
copies.add(rpCopy);
logger.info("Source WWN: " + volUID + " is on RecoverPoint CG " + cgName + " with RecoverPoint CGID " + cgUID.getId());
rpCG = new RPConsistencyGroup();
rpCG.setName(cgName);
rpCG.setCGUID(cgUID);
rpCG.setClusterUID(productionCopyUID.getGlobalCopyUID().getClusterUID());
rpCG.setSiteToArrayIDsMap(mapCGToStorageArraysNoConnection(cgSetting));
rpCG.setCopies(copies);
returnMap.put(volUID, rpCG);
break;
}
}
}
if (wwnListCopy.isEmpty()) {
break;
}
}
for (String wwnMissing : wwnListCopy) {
logger.error("Could not map WWN: " + wwnMissing);
unmappedWWNs.add(wwnMissing);
}
return returnMap;
} catch (FunctionalAPIActionFailedException_Exception e) {
logger.error(e.getMessage());
return null;
} catch (FunctionalAPIInternalError_Exception e) {
logger.error(e.getMessage());
return null;
}
}
use of com.emc.fapiclient.ws.ReplicationSetSettings in project coprhd-controller by CoprHD.
the class RecoverPointUtils method verifyCGVolumesAttachedToSplitter.
/**
* verify that the volumes in a consistency group are connected to a splitter
*
* @param impl - handle for FAPI
* @param groupUID - consistency group to examine volumes on
* @throws - RecoverPointException
*/
public static void verifyCGVolumesAttachedToSplitter(FunctionalAPIImpl impl, ConsistencyGroupUID groupUID) throws RecoverPointException {
ConsistencyGroupSettings groupSettings;
try {
groupSettings = impl.getGroupSettings(groupUID);
// Get the consistency group settings
for (ReplicationSetSettings replicationSet : groupSettings.getReplicationSetsSettings()) {
// Run over all replication sets
for (UserVolumeSettings userVolume : replicationSet.getVolumes()) {
logger.info("Volume : " + RecoverPointUtils.getGuidBufferAsString(userVolume.getVolumeInfo().getRawUids(), false) + " is of type " + userVolume.getVolumeType());
if (userVolume.getAttachedSplitters().isEmpty()) {
String volumeWWN = RecoverPointUtils.getGuidBufferAsString(userVolume.getVolumeInfo().getRawUids(), false);
logger.warn("Volume " + volumeWWN + " is not attached to any splitters");
Set<SplitterUID> splittersToAttachTo = getSplittersToAttachToForVolume(impl, userVolume.getClusterUID(), userVolume.getVolumeInfo().getVolumeID());
for (SplitterUID splitterUID : splittersToAttachTo) {
SetVolumeParam volumeParam = new SetVolumeParam();
volumeParam.setShouldAttachAsClean(false);
volumeParam.setVolumeID(userVolume.getVolumeInfo().getVolumeID());
logger.info("Attaching volume " + volumeWWN + " to splitter" + impl.getSplitterName(splitterUID));
impl.attachVolumeToSplitter(splitterUID, volumeParam);
}
} else {
for (SplitterUID splitterUID : userVolume.getAttachedSplitters()) {
logger.info("Volume " + RecoverPointUtils.getGuidBufferAsString(userVolume.getVolumeInfo().getRawUids(), false) + " is attached to splitter " + impl.getSplitterName(splitterUID));
}
}
}
}
} catch (FunctionalAPIActionFailedException_Exception e) {
logger.error(e.getMessage(), e);
throw RecoverPointException.exceptions.exceptionGettingSettingsCG(e);
} catch (FunctionalAPIInternalError_Exception e) {
logger.error(e.getMessage(), e);
throw RecoverPointException.exceptions.exceptionGettingSettingsCG(e);
}
}
use of com.emc.fapiclient.ws.ReplicationSetSettings 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);
}
}
Aggregations