Search in sources :

Example 1 with DeviceUID

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;
}
Also used : HashMap(java.util.HashMap) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) DeviceUID(com.emc.fapiclient.ws.DeviceUID) CreateVolumeParams(com.emc.storageos.recoverpoint.requests.CreateVolumeParams) FunctionalAPIValidationException_Exception(com.emc.fapiclient.ws.FunctionalAPIValidationException_Exception) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) RecoverPointException(com.emc.storageos.recoverpoint.exceptions.RecoverPointException) ConsistencyGroupCopyUID(com.emc.fapiclient.ws.ConsistencyGroupCopyUID) ClusterUID(com.emc.fapiclient.ws.ClusterUID) Entry(java.util.Map.Entry) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) ConsistencyGroupUID(com.emc.fapiclient.ws.ConsistencyGroupUID) RPSite(com.emc.storageos.recoverpoint.objectmodel.RPSite) CreateCopyParams(com.emc.storageos.recoverpoint.requests.CreateCopyParams) ConsistencyGroupSettings(com.emc.fapiclient.ws.ConsistencyGroupSettings)

Example 2 with DeviceUID

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);
    }
}
Also used : FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) DeviceUID(com.emc.fapiclient.ws.DeviceUID) RPSite(com.emc.storageos.recoverpoint.objectmodel.RPSite) ConsistencyGroupCopyUID(com.emc.fapiclient.ws.ConsistencyGroupCopyUID)

Example 3 with DeviceUID

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);
    }
}
Also used : SplitterUID(com.emc.fapiclient.ws.SplitterUID) SplitterSettings(com.emc.fapiclient.ws.SplitterSettings) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) DeviceUID(com.emc.fapiclient.ws.DeviceUID) HashSet(java.util.HashSet)

Aggregations

DeviceUID (com.emc.fapiclient.ws.DeviceUID)3 FunctionalAPIActionFailedException_Exception (com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception)3 FunctionalAPIInternalError_Exception (com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception)3 ConsistencyGroupCopyUID (com.emc.fapiclient.ws.ConsistencyGroupCopyUID)2 RPSite (com.emc.storageos.recoverpoint.objectmodel.RPSite)2 ClusterUID (com.emc.fapiclient.ws.ClusterUID)1 ConsistencyGroupSettings (com.emc.fapiclient.ws.ConsistencyGroupSettings)1 ConsistencyGroupUID (com.emc.fapiclient.ws.ConsistencyGroupUID)1 FunctionalAPIValidationException_Exception (com.emc.fapiclient.ws.FunctionalAPIValidationException_Exception)1 SplitterSettings (com.emc.fapiclient.ws.SplitterSettings)1 SplitterUID (com.emc.fapiclient.ws.SplitterUID)1 RecoverPointException (com.emc.storageos.recoverpoint.exceptions.RecoverPointException)1 CreateCopyParams (com.emc.storageos.recoverpoint.requests.CreateCopyParams)1 CreateVolumeParams (com.emc.storageos.recoverpoint.requests.CreateVolumeParams)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Entry (java.util.Map.Entry)1