use of com.emc.fapiclient.ws.ReplicationSetSettings in project coprhd-controller by CoprHD.
the class RecoverPointClient method addCopyToCG.
/**
* adds one copy to an existing CG
*
* @param cgUID CG uid where new copy should be added
* @param allSites list of sites that see journal and copy file WWN's
* @param copyParams the copy to be added
* @param rSets replication set to which the user volumes have to be added
* @param copyType either production, local or remote
* @param linkSettings for the copy being added
* @param copyUid of the copy being added
* @throws FunctionalAPIActionFailedException_Exception
* @throws FunctionalAPIInternalError_Exception
* @throws FunctionalAPIValidationException_Exception
*/
private void addCopyToCG(ConsistencyGroupUID cgUID, Set<RPSite> allSites, CreateCopyParams copyParams, List<CreateRSetParams> rSets, RecoverPointCGCopyType copyType, List<ConsistencyGroupLinkSettings> linkSettings, ConsistencyGroupCopyUID copyUid) throws FunctionalAPIActionFailedException_Exception, FunctionalAPIInternalError_Exception, FunctionalAPIValidationException_Exception {
boolean isProduction = copyType == RecoverPointCGCopyType.PRODUCTION;
String copyTypeStr = copyType.toString();
logger.info(String.format("Adding new copy %s to cg", copyParams.getName()));
ConsistencyGroupCopySettingsParam copySettingsParam = new ConsistencyGroupCopySettingsParam();
copySettingsParam.setCopyName(copyParams.getName());
copySettingsParam.setCopyPolicy(null);
copySettingsParam.setEnabled(false);
copySettingsParam.setGroupCopy(copyUid);
copySettingsParam.setProductionCopy(isProduction);
copySettingsParam.setTransferEnabled(false);
copySettingsParam.getGroupLinksSettings().addAll(linkSettings);
// we can't call validateAddConsistencyGroupCopy here because during a swap operation, it throws an exception
// which is just a warning that a full sweep will be required. There didn't seem to be a way to catch
// just the warning and let other errors propagate as errors.
logger.info(String.format("Add Production copy %s (no validation): ", copyParams.getName(), copyParams.toString()));
functionalAPI.addConsistencyGroupCopy(copySettingsParam);
// add journals
for (CreateVolumeParams journalVolume : copyParams.getJournals()) {
logger.info(String.format("Adding Journal for Production copy %s : %s", copyParams.getName(), journalVolume.toString()));
functionalAPI.addJournalVolume(copyUid, RecoverPointUtils.getDeviceID(allSites, journalVolume.getInternalSiteName(), journalVolume.getWwn()));
}
if (rSets != null) {
ConsistencyGroupSettings groupSettings = functionalAPI.getGroupSettings(cgUID);
// Keep track of volumes added so we don't add the same one again. Prevents an exception from being thrown.
List<String> volumesAdded = new ArrayList<String>();
for (CreateRSetParams rSet : rSets) {
ReplicationSetUID rSetUid = null;
if (rSet != null && rSet.getName() != null && !rSet.getName().isEmpty()) {
for (ReplicationSetSettings rSetSetting : groupSettings.getReplicationSetsSettings()) {
if (rSetSetting.getReplicationSetName().equalsIgnoreCase(rSet.getName())) {
rSetUid = rSetSetting.getReplicationSetUID();
break;
}
}
}
if (rSetUid != null) {
for (CreateVolumeParams volume : rSet.getVolumes()) {
if ((isProduction && volume.isProduction()) || (!isProduction && !volume.isProduction()) && !volumesAdded.contains(volume.getWwn())) {
logger.info(String.format("Adding %s copy volume : %s", copyTypeStr, volume.toString()));
functionalAPI.addUserVolume(copyUid, rSetUid, RecoverPointUtils.getDeviceID(allSites, volume.getInternalSiteName(), volume.getWwn()));
volumesAdded.add(volume.getWwn());
}
}
}
}
}
}
use of com.emc.fapiclient.ws.ReplicationSetSettings in project coprhd-controller by CoprHD.
the class RecoverPointClient method getAllCGs.
/**
* Returns all CGs, policies, and volumes within the CG.
*
* @return a set of RP consistency group objects
* @throws RecoverPointException
*/
public Set<GetCGsResponse> getAllCGs() throws RecoverPointException {
String mgmtIPAddress = _endpoint.toASCIIString();
if (null == mgmtIPAddress) {
throw RecoverPointException.exceptions.noRecoverPointEndpoint();
}
// TODO: Refactor to break down into smaller pieces
Set<GetCGsResponse> cgs = new HashSet<GetCGsResponse>();
try {
// Quickly get a map of cluster/sitenames
Map<Long, String> clusterIdToInternalSiteNameMap = new HashMap<Long, String>();
FullRecoverPointSettings fullRecoverPointSettings = functionalAPI.getFullRecoverPointSettings();
for (ClusterConfiguration siteSettings : fullRecoverPointSettings.getSystemSettings().getGlobalSystemConfiguration().getClustersConfigurations()) {
clusterIdToInternalSiteNameMap.put(siteSettings.getCluster().getId(), siteSettings.getInternalClusterName());
}
// Go through all of the CGs and retrieve important pieces of information
List<ConsistencyGroupUID> allCgs = functionalAPI.getAllConsistencyGroups();
for (ConsistencyGroupUID cg : allCgs) {
ConsistencyGroupSettings settings = functionalAPI.getGroupSettings(cg);
ConsistencyGroupState state = functionalAPI.getGroupState(cg);
logger.info("Processing CG found on RecoverPoint system: " + settings.getName());
// First storage attributes about the top-level CG
GetCGsResponse cgResp = new GetCGsResponse();
cgResp.setCgName(settings.getName());
cgResp.setCgId(cg.getId());
cgResp.setCgPolicy(new GetCGsResponse.GetPolicyResponse());
// Find and store the policy information
if (settings.getActiveLinksSettings() != null) {
for (ConsistencyGroupLinkSettings cgls : settings.getActiveLinksSettings()) {
if (cgls.getLinkPolicy() != null && cgls.getLinkPolicy().getProtectionPolicy() != null) {
if (cgls.getLinkPolicy().getProtectionPolicy().getProtectionType() != null) {
if (cgls.getLinkPolicy().getProtectionPolicy().getProtectionType().toString().equalsIgnoreCase(ProtectionMode.SYNCHRONOUS.toString())) {
cgResp.getCgPolicy().synchronous = true;
} else {
cgResp.getCgPolicy().synchronous = false;
}
}
if (cgls.getLinkPolicy().getProtectionPolicy().getRpoPolicy() != null && cgls.getLinkPolicy().getProtectionPolicy().getRpoPolicy().getMaximumAllowedLag() != null) {
cgResp.getCgPolicy().rpoType = cgls.getLinkPolicy().getProtectionPolicy().getRpoPolicy().getMaximumAllowedLag().getType().name();
cgResp.getCgPolicy().rpoValue = cgls.getLinkPolicy().getProtectionPolicy().getRpoPolicy().getMaximumAllowedLag().getValue();
}
}
}
}
// We assume CG health until we see something that indicates otherwise.
cgResp.setCgState(GetCGsResponse.GetCGStateResponse.HEALTHY);
RecoverPointCGState cgState = this.getCGState(cg);
if (cgState.equals(RecoverPointCGState.DELETED)) {
cgResp.setCgState(GetCGStateResponse.UNHEALTHY_ERROR);
} else if (cgState.equals(RecoverPointCGState.MIXED)) {
cgResp.setCgState(GetCGStateResponse.UNHEALTHY_PAUSED_OR_DISABLED);
} else if (cgState.equals(RecoverPointCGState.PAUSED)) {
cgResp.setCgState(GetCGStateResponse.UNHEALTHY_PAUSED_OR_DISABLED);
} else if (cgState.equals(RecoverPointCGState.STOPPED)) {
cgResp.setCgState(GetCGStateResponse.UNHEALTHY_PAUSED_OR_DISABLED);
}
// Fill in the Copy information
if (settings.getGroupCopiesSettings() == null) {
continue;
}
Map<String, String> copyUIDToNameMap = new HashMap<String, String>();
Map<String, String> copyNameToRoleMap = new HashMap<String, String>();
// used to set the copy uid on the rset volume when adding rsets
Set<String> productionCopiesUID = new HashSet<String>();
// Retrieve all RP copies for this CG
for (ConsistencyGroupCopySettings copySettings : settings.getGroupCopiesSettings()) {
GetCopyResponse copy = new GetCopyResponse();
copy.setName(copySettings.getName());
String copyID = copySettings.getCopyUID().getGlobalCopyUID().getClusterUID().getId() + "-" + copySettings.getCopyUID().getGlobalCopyUID().getCopyUID();
copyUIDToNameMap.put(copyID, copySettings.getName());
for (ConsistencyGroupCopyState copyState : state.getGroupCopiesStates()) {
if (!RecoverPointUtils.copiesEqual(copySettings.getCopyUID(), copyState.getCopyUID())) {
continue;
}
// Get the access image and enabled information
copy.setAccessState(copyState.getStorageAccessState().toString());
copy.setAccessedImage(copyState.getAccessedImage() != null ? copyState.getAccessedImage().getDescription() : null);
copy.setEnabled(copyState.isEnabled());
copy.setActive(copyState.isActive());
}
// Set ID fields (these are immutable no matter if things are renamed)
copy.setCgId(copySettings.getCopyUID().getGroupUID().getId());
copy.setClusterId(copySettings.getCopyUID().getGlobalCopyUID().getClusterUID().getId());
copy.setCopyId(copySettings.getCopyUID().getGlobalCopyUID().getCopyUID());
if (ConsistencyGroupCopyRole.ACTIVE.equals(copySettings.getRoleInfo().getRole()) || ConsistencyGroupCopyRole.TEMPORARY_ACTIVE.equals(copySettings.getRoleInfo().getRole())) {
productionCopiesUID.add(copyID);
copy.setProduction(true);
// Standby Production role is defined as: copy is production and copy is NOT active.
if (copy.isActive()) {
copy.setRole(GetCopyResponse.GetCopyRole.ACTIVE_PRODUCTION);
} else {
copy.setRole(GetCopyResponse.GetCopyRole.STANDBY_PRODUCTION);
}
} else if (ConsistencyGroupCopyRole.REPLICA.equals(copySettings.getRoleInfo().getRole())) {
copy.setProduction(false);
copy.setRole(GetCopyResponse.GetCopyRole.TARGET);
} else {
copy.setProduction(false);
copy.setRole(GetCopyResponse.GetCopyRole.UNKNOWN);
}
// Add an entry for this copy name and its defined role
copyNameToRoleMap.put(copy.getName(), copy.getRole().toString());
if (copySettings.getJournal() == null || copySettings.getJournal().getJournalVolumes() == null) {
continue;
}
for (JournalVolumeSettings journal : copySettings.getJournal().getJournalVolumes()) {
GetVolumeResponse volume = new GetVolumeResponse();
volume.setRpCopyName(copySettings.getName());
volume.setInternalSiteName(clusterIdToInternalSiteNameMap.get(journal.getClusterUID().getId()));
// Need to extract the naaUids to format: 600601608D20370089260942815CE511
volume.setWwn(RecoverPointUtils.getGuidBufferAsString(journal.getVolumeInfo().getNaaUids(), false).toUpperCase(Locale.ENGLISH));
if (copy.getJournals() == null) {
copy.setJournals(new ArrayList<GetVolumeResponse>());
}
copy.getJournals().add(volume);
}
if (cgResp.getCopies() == null) {
cgResp.setCopies(new ArrayList<GetCopyResponse>());
}
cgResp.getCopies().add(copy);
}
// Retrieve all replication sets for this CG
for (ReplicationSetSettings rsetSettings : settings.getReplicationSetsSettings()) {
GetRSetResponse rset = new GetRSetResponse();
rset.setName(rsetSettings.getReplicationSetName());
if (rsetSettings.getVolumes() == null) {
continue;
}
for (UserVolumeSettings volume : rsetSettings.getVolumes()) {
GetVolumeResponse volResp = new GetVolumeResponse();
// Get the RP copy name, needed to match up sources to targets
String copyID = volume.getGroupCopyUID().getGlobalCopyUID().getClusterUID().getId() + "-" + volume.getGroupCopyUID().getGlobalCopyUID().getCopyUID();
volResp.setRpCopyName(copyUIDToNameMap.get(copyID));
volResp.setInternalSiteName(clusterIdToInternalSiteNameMap.get(volume.getClusterUID().getId()));
if (productionCopiesUID.contains(copyID)) {
volResp.setProduction(true);
// volumes copy name to role mapping that was populated earlier.
if (GetCopyResponse.GetCopyRole.STANDBY_PRODUCTION.toString().equalsIgnoreCase(copyNameToRoleMap.get(volResp.getRpCopyName()))) {
volResp.setProductionStandby(true);
}
} else {
volResp.setProduction(false);
}
// Need to extract the naaUids to format: 600601608D20370089260942815CE511
volResp.setWwn(RecoverPointUtils.getGuidBufferAsString(volume.getVolumeInfo().getNaaUids(), false).toUpperCase(Locale.ENGLISH));
if (rset.getVolumes() == null) {
rset.setVolumes(new ArrayList<GetVolumeResponse>());
}
rset.getVolumes().add(volResp);
}
if (cgResp.getRsets() == null) {
cgResp.setRsets(new ArrayList<GetRSetResponse>());
}
cgResp.getRsets().add(rset);
}
cgs.add(cgResp);
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw RecoverPointException.exceptions.failedToLookupConsistencyGroups(getCause(e));
}
return cgs;
}
use of com.emc.fapiclient.ws.ReplicationSetSettings 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.ReplicationSetSettings in project coprhd-controller by CoprHD.
the class RecoverPointBookmarkManagementUtils method mapCGToStorageArraysNoConnection.
/**
* Find the arrays for a CG
*
* @param groupSettings - A groupSettings object which contains, among other things, the array information for the CG
*
* @return The site to array mappings for the CG
*
* @throws RecoverPointException
*/
public Map<ClusterUID, Set<String>> mapCGToStorageArraysNoConnection(ConsistencyGroupSettings groupSettings) throws RecoverPointException {
Set<String> siteArraySet = null;
Map<ClusterUID, Set<String>> returnMap = new HashMap<ClusterUID, Set<String>>();
Set<ClusterUID> siteSet = new HashSet<ClusterUID>();
// First find out the sites involved in the CG
ClusterUID ClusterUID = null;
boolean foundSite = false;
for (ReplicationSetSettings replicationSet : groupSettings.getReplicationSetsSettings()) {
for (UserVolumeSettings userVolume : replicationSet.getVolumes()) {
ClusterUID = userVolume.getClusterUID();
foundSite = false;
for (ClusterUID mappedSite : siteSet) {
if (ClusterUID.getId() == mappedSite.getId()) {
foundSite = true;
break;
}
}
if (!foundSite) {
siteSet.add(ClusterUID);
}
}
}
for (ClusterUID mappedSite : siteSet) {
siteArraySet = new HashSet<String>();
for (ReplicationSetSettings replicationSet1 : groupSettings.getReplicationSetsSettings()) {
for (UserVolumeSettings userVolume : replicationSet1.getVolumes()) {
ClusterUID = userVolume.getClusterUID();
if (ClusterUID.getId() == mappedSite.getId()) {
if (userVolume.getVolumeInfo().getVendorName().equalsIgnoreCase("DGC")) {
siteArraySet.add(userVolume.getVolumeInfo().getArraySerialNumber());
}
}
}
}
if (!siteArraySet.isEmpty()) {
returnMap.put(mappedSite, siteArraySet);
}
}
if (!returnMap.isEmpty()) {
return returnMap;
} else {
return null;
}
}
Aggregations