use of com.emc.fapiclient.ws.ReplicationSetUID 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.fapiclient.ws.ReplicationSetUID 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.ReplicationSetUID 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);
}
}
Aggregations