use of com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception in project coprhd-controller by CoprHD.
the class RecoverPointClient method updateConsistencyGroupPolicy.
/**
* Updates the entire consistency group policy. Meaning the link policy for each link
* will be changed to the same policy.
*
* @param policyParam the update policy param
*/
public void updateConsistencyGroupPolicy(UpdateCGPolicyParams policyParam) {
if (policyParam == null) {
logger.warn("Unable to update policy for CG. The update paramaters are invalid.");
return;
}
if (policyParam.getPolicyParams() == null) {
logger.warn("Unable to update policy for CG. The update paramaters are missing.");
return;
}
if (policyParam.getPolicyParams().getCopyMode() == null) {
logger.warn("Unable to update CG policy copy mode. The copy mode paramaters is missing.");
return;
}
try {
String copyMode = policyParam.getPolicyParams().getCopyMode();
ConsistencyGroupUID cgUID = getConsistencyGroupUID(policyParam.getCgName());
FullConsistencyGroupPolicy cgPolicy = functionalAPI.getFullConsistencyGroupPolicy(cgUID);
List<FullConsistencyGroupLinkPolicy> linkPolicies = cgPolicy.getLinksPolicies();
for (FullConsistencyGroupLinkPolicy linkPolicy : linkPolicies) {
ConsistencyGroupLinkPolicy cgLinkPolicy = linkPolicy.getLinkPolicy();
LinkProtectionPolicy linkProtectionPolicy = cgLinkPolicy.getProtectionPolicy();
if (copyMode != null) {
ProtectionMode protectionMode = ProtectionMode.valueOf(copyMode);
if (protectionMode != null) {
linkProtectionPolicy.setProtectionType(protectionMode);
cgLinkPolicy.setProtectionPolicy(linkProtectionPolicy);
}
}
}
logger.info(String.format("Setting protection mode for CG links to %s, for CG %s", copyMode, policyParam.getCgName()));
functionalAPI.setFullConsistencyGroupPolicy(cgPolicy);
} catch (FunctionalAPIActionFailedException_Exception e) {
throw RecoverPointException.exceptions.failedToUpdateCgLinkPolicy(policyParam.getCgName(), e);
} catch (FunctionalAPIInternalError_Exception e) {
throw RecoverPointException.exceptions.failedToUpdateCgLinkPolicy(policyParam.getCgName(), e);
} catch (Exception e) {
throw RecoverPointException.exceptions.failedToUpdateCgLinkPolicy(policyParam.getCgName(), e);
}
}
use of com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception in project coprhd-controller by CoprHD.
the class RecoverPointClient method recreateReplicationSets.
/**
* Perform Step 2 of expanding a volume, Recreate a replication set that was previously removed.
*
* @param volume volume base of replication set
* @param rsetSettings replication set information used to create replication set
* @throws RecoverPointException
*/
public void recreateReplicationSets(Map<String, RecreateReplicationSetRequestParams> rsetParams) throws RecoverPointException {
if (rsetParams != null && !rsetParams.isEmpty()) {
// Used to capture the volume WWNs associated with each replication set to recreate.
List<String> volumeWWNs = new ArrayList<String>();
try {
// Get the CG ID from the first element in the list. All elements will share
// the same CG ID.
RecreateReplicationSetRequestParams param = rsetParams.values().iterator().next();
ConsistencyGroupUID cgID = param.getConsistencyGroupUID();
// Rescan the SAN
functionalAPI.rescanSANVolumesInAllClusters(true);
ConsistencyGroupSettingsChangesParam cgSettingsParam = new ConsistencyGroupSettingsChangesParam();
ActivationSettingsChangesParams cgActivationSettings = new ActivationSettingsChangesParams();
cgActivationSettings.setEnable(true);
cgActivationSettings.setStartTransfer(true);
cgSettingsParam.setActivationParams(cgActivationSettings);
cgSettingsParam.setGroupUID(cgID);
for (Entry<String, RecreateReplicationSetRequestParams> entry : rsetParams.entrySet()) {
RecreateReplicationSetRequestParams rsetParam = entry.getValue();
// Create replication set
logger.info("Adding replication set: " + rsetParam.getName());
ReplicationSetSettingsChangesParam repSetSettings = new ReplicationSetSettingsChangesParam();
repSetSettings.setName(rsetParam.getName());
repSetSettings.setShouldAttachAsClean(false);
for (CreateRSetVolumeParams volume : rsetParam.getVolumes()) {
UserVolumeSettingsChangesParam volSettings = new UserVolumeSettingsChangesParam();
volSettings.setNewVolumeID(volume.getDeviceUID());
volSettings.setCopyUID(volume.getConsistencyGroupCopyUID());
volSettings.getCopyUID().setGroupUID(cgID);
repSetSettings.getVolumesChanges().add(volSettings);
}
cgSettingsParam.getReplicationSetsChanges().add(repSetSettings);
volumeWWNs.add(entry.getKey());
}
// Add the replication set
functionalAPI.setConsistencyGroupSettings(cgSettingsParam);
logger.info("Checking for volumes unattached to splitters");
RecoverPointUtils.verifyCGVolumesAttachedToSplitter(functionalAPI, cgID);
RecoverPointImageManagementUtils rpiMgmt = new RecoverPointImageManagementUtils();
logger.info("Waiting for links to become active for CG ");
// Wait for the active state or paused state. If a copy is in direct access mode, the link
// will be paused but it's still a valid state.
rpiMgmt.waitForCGLinkState(functionalAPI, cgID, RecoverPointImageManagementUtils.getPipeActiveState(functionalAPI, cgID), PipeState.PAUSED);
} catch (FunctionalAPIActionFailedException_Exception e) {
throw RecoverPointException.exceptions.failedToRecreateReplicationSet(volumeWWNs.toString(), e);
} catch (FunctionalAPIInternalError_Exception e) {
throw RecoverPointException.exceptions.failedToRecreateReplicationSet(volumeWWNs.toString(), e);
}
}
}
use of com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception 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.FunctionalAPIInternalError_Exception in project coprhd-controller by CoprHD.
the class RecoverPointClient method swapCopy.
/**
* Perform a swap to the consistency group copy specified by the input request params.
*
* @param copyParams the volume info for the CG to perform a swap to.
*
* @return void
*
* @throws RecoverPointException
* @throws FunctionalAPIInternalError_Exception
* @throws FunctionalAPIActionFailedException_Exception
*/
public void swapCopy(RPCopyRequestParams copyParams) throws RecoverPointException {
try {
logger.info("Swap copy to current or most recent image");
// Make sure the copy is already enabled or RP will fail the operation. If it isn't enabled, enable it.
RecoverPointImageManagementUtils imageManager = new RecoverPointImageManagementUtils();
ConsistencyGroupCopyUID cgCopyUID = RecoverPointUtils.mapRPVolumeProtectionInfoToCGCopyUID(copyParams.getCopyVolumeInfo());
ConsistencyGroupCopyState copyState = imageManager.getCopyState(functionalAPI, cgCopyUID);
if (copyState != null && copyState.getAccessedImage() == null && !StorageAccessState.DIRECT_ACCESS.equals(copyState.getStorageAccessState())) {
// Enable image access to the latest snapshot if copy image access isn't already enabled.
failoverCopy(copyParams);
}
ConsistencyGroupCopySettings cgCopySettings = RecoverPointUtils.getCopySettings(functionalAPI, cgCopyUID);
List<ConsistencyGroupCopyUID> productionCopiesUIDs = functionalAPI.getGroupSettings(cgCopyUID.getGroupUID()).getProductionCopiesUIDs();
// data replication. Otherwise, we need to perform a failover.
if (RecoverPointUtils.isProductionCopy(cgCopyUID, productionCopiesUIDs) && cgCopySettings.getRoleInfo() != null && ConsistencyGroupCopyRole.REPLICA == cgCopySettings.getRoleInfo().getRole()) {
logger.info("Swap copy is a production copy with role 'Target at Production'. Resuming production to complete the swap.");
functionalAPI.resumeProduction(cgCopyUID.getGroupUID(), true);
} else {
// Perform the failover
imageManager.failoverCGCopy(functionalAPI, cgCopyUID);
}
} catch (FunctionalAPIActionFailedException_Exception | FunctionalAPIInternalError_Exception e) {
String copyName = copyParams.getCopyVolumeInfo() != null ? copyParams.getCopyVolumeInfo().getRpCopyName() : "N/A";
throw RecoverPointException.exceptions.failedToSwapCopy(copyName, e);
}
}
use of com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception in project coprhd-controller by CoprHD.
the class RecoverPointClient method doesStandbyProdCopyExist.
/**
* Determines if the consistency group associated with the volume protection info contains
* a standby production copy.
*
* @param volume the volume protection information
* @return true if the standby production copy exists, false otherwise
*/
public boolean doesStandbyProdCopyExist(RecoverPointVolumeProtectionInfo volume) {
try {
ConsistencyGroupUID cgID = new ConsistencyGroupUID();
cgID.setId(volume.getRpVolumeGroupID());
ConsistencyGroupState state = functionalAPI.getGroupState(cgID);
ConsistencyGroupSettings cgSettings = functionalAPI.getGroupSettings(cgID);
ConsistencyGroupCopyUID standbyProdCopy = RecoverPointUtils.getStandbyProductionCopy(cgSettings, state);
if (standbyProdCopy != null) {
String standbyProdCopyName = functionalAPI.getGroupCopyName(standbyProdCopy);
logger.info(String.format("Determined that standby production copy %s exists in CG %s.", standbyProdCopyName, volume.getRpProtectionName()));
return true;
}
logger.info(String.format("Determined that no standby production copy exists in CG %s.", volume.getRpProtectionName()));
return false;
} catch (FunctionalAPIActionFailedException_Exception e) {
throw RecoverPointException.exceptions.failedStandbyProdCopyLookup(volume.getRpProtectionName(), e);
} catch (FunctionalAPIInternalError_Exception e) {
throw RecoverPointException.exceptions.failedStandbyProdCopyLookup(volume.getRpProtectionName(), e);
}
}
Aggregations