use of com.emc.fapiclient.ws.DeviceUID in project coprhd-controller by CoprHD.
the class RecoverPointClient method addJournalVolumesToCG.
/**
* Operation to add journal volumes to an existing recoverpoint consistency group
*
* @param request - contains both the consistency group
* and the journals to add to the consistency group
* @param copyType - indicates whether the copy is production, local or remote
* @return boolean indicating the result of the operation
*/
public boolean addJournalVolumesToCG(CGRequestParams request, int copyType) {
// Make sure the CG name is unique.
ConsistencyGroupUID cgUID = null;
List<ConsistencyGroupUID> allCgs;
String copyName = "not determined";
Map<ConsistencyGroupCopyUID, DeviceUID> addedJournalVolumes = new HashMap<ConsistencyGroupCopyUID, DeviceUID>();
try {
allCgs = functionalAPI.getAllConsistencyGroups();
for (ConsistencyGroupUID cg : allCgs) {
ConsistencyGroupSettings settings = functionalAPI.getGroupSettings(cg);
if (settings.getName().toString().equalsIgnoreCase(request.getCgName())) {
cgUID = settings.getGroupUID();
break;
}
}
if (cgUID == null) {
// The CG does not exist so we cannot add replication sets
throw RecoverPointException.exceptions.failedToAddReplicationSetCgDoesNotExist(request.getCgName());
}
List<CreateCopyParams> copyParams = request.getCopies();
// determine if the volumes are visible to the recoverpoint appliance
Set<RPSite> allSites = scan(copyParams, null);
for (CreateCopyParams copyParam : copyParams) {
for (CreateVolumeParams journalVolume : copyParam.getJournals()) {
copyName = journalVolume.getRpCopyName();
ClusterUID clusterId = RecoverPointUtils.getRPSiteID(functionalAPI, journalVolume.getInternalSiteName());
ConsistencyGroupCopyUID copyUID = getCGCopyUid(clusterId, getCopyType(copyType), cgUID);
DeviceUID journalDevice = RecoverPointUtils.getDeviceID(allSites, journalVolume.getInternalSiteName(), journalVolume.getWwn());
addedJournalVolumes.put(copyUID, journalDevice);
functionalAPI.addJournalVolume(copyUID, journalDevice);
}
}
} catch (FunctionalAPIActionFailedException_Exception e) {
if (!addedJournalVolumes.isEmpty()) {
try {
for (Map.Entry<ConsistencyGroupCopyUID, DeviceUID> journalVolume : addedJournalVolumes.entrySet()) {
functionalAPI.removeJournalVolume(journalVolume.getKey(), journalVolume.getValue());
}
} catch (Exception e1) {
logger.error("Error removing journal volume from consistency group");
logger.error(e1.getMessage(), e1);
}
}
logger.error("Error in attempting to add a journal volume to the recoverpoint consistency group");
logger.error(e.getMessage(), e);
throw RecoverPointException.exceptions.failedToAddJournalVolumeToConsistencyGroup(copyName, getCause(e));
} catch (FunctionalAPIInternalError_Exception e) {
if (!addedJournalVolumes.isEmpty()) {
try {
for (Map.Entry<ConsistencyGroupCopyUID, DeviceUID> journalVolume : addedJournalVolumes.entrySet()) {
functionalAPI.removeJournalVolume(journalVolume.getKey(), journalVolume.getValue());
}
} catch (Exception e1) {
logger.error("Error removing journal volume from consistency group");
logger.error(e1.getMessage(), e1);
}
}
logger.error("Error in attempting to add a journal volume to the recoverpoint consistency group");
logger.error(e.getMessage(), e);
throw RecoverPointException.exceptions.failedToCreateConsistencyGroup(copyName, getCause(e));
}
return true;
}
use of com.emc.fapiclient.ws.DeviceUID in project coprhd-controller by CoprHD.
the class RecoverPointClient method deleteJournalFromCopy.
/**
* Delete a journal volume (WWN) from the consistency group copy specified by the input volume info.
*
* @param RecoverPointVolumeProtectionInfo copyToModify - Volume info for the CG to add a journal volume to
*
* @param String journalWWNToDelete - WWN of the journal volume to delete
*
* @return void
*
* @throws RecoverPointException
*/
public void deleteJournalFromCopy(RecoverPointVolumeProtectionInfo copyToModify, String journalWWNToDelete) throws RecoverPointException {
ConsistencyGroupCopyUID cgCopyUID = RecoverPointUtils.mapRPVolumeProtectionInfoToCGCopyUID(copyToModify);
String copyName = null;
String cgName = null;
try {
copyName = functionalAPI.getGroupCopyName(cgCopyUID);
cgName = functionalAPI.getGroupName(cgCopyUID.getGroupUID());
logger.info("Request to delete journal " + journalWWNToDelete + " from copy " + copyName + " for consistency group " + cgName);
Set<RPSite> allSites = getAssociatedRPSites();
DeviceUID journalDeviceUIDToDelete = RecoverPointUtils.getDeviceID(allSites, journalWWNToDelete);
if (journalDeviceUIDToDelete == null) {
throw RecoverPointException.exceptions.cannotFindJournal(journalWWNToDelete);
}
functionalAPI.removeJournalVolume(cgCopyUID, journalDeviceUIDToDelete);
} catch (FunctionalAPIActionFailedException_Exception e) {
throw RecoverPointException.exceptions.failedToDeleteJournal(journalWWNToDelete, copyName, cgName, e);
} catch (FunctionalAPIInternalError_Exception e) {
throw RecoverPointException.exceptions.failedToDeleteJournal(journalWWNToDelete, copyName, cgName, e);
}
}
use of com.emc.fapiclient.ws.DeviceUID in project coprhd-controller by CoprHD.
the class RecoverPointUtils method getSplittersToAttachToForVolume.
/**
* Finds the splitter(s) to attach a volume to (if any need to be attached).
*
* @param impl - handle for FAPI
* @param ClusterUID - site for the volume
* @param volume - volume ID we are looking for
* @return - Set<SplitterUID>
*/
private static Set<SplitterUID> getSplittersToAttachToForVolume(FunctionalAPIImpl impl, ClusterUID ClusterUID, DeviceUID volume) throws RecoverPointException {
Set<SplitterUID> returnSplitters = new HashSet<SplitterUID>();
try {
logger.info("Finding splitters with unattached volumes");
List<SplitterUID> splittersWithUnattachedVols = impl.getAvailableSplittersToAttachToVolume(ClusterUID, volume);
for (SplitterUID splitterUID : splittersWithUnattachedVols) {
SplitterSettings splitterSettings = impl.getSplitterSettings(splitterUID);
List<DeviceUID> unattachedVolumes = impl.getAvailableVolumesToAttachToSplitter(splitterUID, true);
if (!unattachedVolumes.isEmpty()) {
for (DeviceUID unattachedVolume : unattachedVolumes) {
if (unattachedVolume.getId() == volume.getId()) {
returnSplitters.add(splitterSettings.getSplitterUID());
}
}
}
}
return returnSplitters;
} catch (FunctionalAPIActionFailedException_Exception e) {
logger.error(e.getMessage(), e);
throw RecoverPointException.exceptions.exceptionGettingSplittersVolume(e);
} catch (FunctionalAPIInternalError_Exception e) {
logger.error(e.getMessage(), e);
throw RecoverPointException.exceptions.exceptionGettingSplittersVolume(e);
}
}
Aggregations