Search in sources :

Example 1 with RecoverPointBookmarkManagementUtils

use of com.emc.storageos.recoverpoint.utils.RecoverPointBookmarkManagementUtils in project coprhd-controller by CoprHD.

the class RecoverPointClient method getRPBookmarks.

/**
 * Get all RP bookmarks for all CGs specified
 *
 * @param request - set of CG integer IDs
 * @return GetBookmarkResponse - a map of CGs to bookmarks for that CG
 * @throws RecoverPointException
 */
public GetBookmarksResponse getRPBookmarks(Set<Integer> request) throws RecoverPointException {
    String mgmtIPAddress = _endpoint.toASCIIString();
    if (null == mgmtIPAddress) {
        throw RecoverPointException.exceptions.noRecoverPointEndpoint();
    }
    RecoverPointBookmarkManagementUtils bookmarkManager = new RecoverPointBookmarkManagementUtils();
    GetBookmarksResponse response = new GetBookmarksResponse();
    response.setCgBookmarkMap(new HashMap<Integer, List<RPBookmark>>());
    for (Integer cgID : request) {
        ConsistencyGroupUID cgUID = new ConsistencyGroupUID();
        cgUID.setId(cgID);
        response.getCgBookmarkMap().put(cgID, bookmarkManager.getRPBookmarksForCG(functionalAPI, cgUID));
    }
    response.setReturnCode(RecoverPointReturnCode.SUCCESS);
    return response;
}
Also used : GetBookmarksResponse(com.emc.storageos.recoverpoint.responses.GetBookmarksResponse) RecoverPointBookmarkManagementUtils(com.emc.storageos.recoverpoint.utils.RecoverPointBookmarkManagementUtils) ConsistencyGroupUID(com.emc.fapiclient.ws.ConsistencyGroupUID) ArrayList(java.util.ArrayList) List(java.util.List) LinkedList(java.util.LinkedList)

Example 2 with RecoverPointBookmarkManagementUtils

use of com.emc.storageos.recoverpoint.utils.RecoverPointBookmarkManagementUtils in project coprhd-controller by CoprHD.

the class RecoverPointClient method createBookmarks.

/**
 * Creates a bookmark against one or more consistency group
 *
 * @param CreateBookmarkRequestParams request - contains the information about which CGs to create bookmarks on
 *
 * @return CreateBookmarkResponse - response as to success or fail of creating the bookmarks
 *
 * @throws RecoverPointException
 */
public CreateBookmarkResponse createBookmarks(CreateBookmarkRequestParams request) throws RecoverPointException {
    String mgmtIPAddress = _endpoint.toASCIIString();
    if (null == mgmtIPAddress) {
        throw RecoverPointException.exceptions.noRecoverPointEndpoint();
    }
    Set<String> wwnSet = request.getVolumeWWNSet();
    if (wwnSet == null) {
        throw RecoverPointException.exceptions.noWWNsFoundInRequest();
    }
    Set<String> unmappedWWNs = new HashSet<String>();
    RecoverPointBookmarkManagementUtils bookmarkManager = new RecoverPointBookmarkManagementUtils();
    Map<String, RPConsistencyGroup> rpCGMap = bookmarkManager.mapCGsForWWNs(functionalAPI, request, unmappedWWNs);
    if (!unmappedWWNs.isEmpty()) {
        throw RecoverPointException.exceptions.couldNotMapWWNsToAGroup(unmappedWWNs);
    }
    if (rpCGMap == null) {
        throw RecoverPointException.exceptions.couldNotMapWWNsToAGroup(wwnSet);
    }
    return bookmarkManager.createCGBookmarks(functionalAPI, rpCGMap, request);
}
Also used : RecoverPointBookmarkManagementUtils(com.emc.storageos.recoverpoint.utils.RecoverPointBookmarkManagementUtils) RPConsistencyGroup(com.emc.storageos.recoverpoint.objectmodel.RPConsistencyGroup) HashSet(java.util.HashSet)

Example 3 with RecoverPointBookmarkManagementUtils

use of com.emc.storageos.recoverpoint.utils.RecoverPointBookmarkManagementUtils in project coprhd-controller by CoprHD.

the class RecoverPointClient method disableImageCopies.

/**
 * Disables copy images for one or more consistency group copies
 *
 * @param MultiCopyDisableImageRequestParams request - contains the information about which CG copies to disable
 *
 * @return MultiCopyDisableImageResponse - response as to success or fail of disabling the image copies
 *
 * @throws RecoverPointException
 */
public MultiCopyDisableImageResponse disableImageCopies(MultiCopyDisableImageRequestParams request) throws RecoverPointException {
    MultiCopyDisableImageResponse response = new MultiCopyDisableImageResponse();
    RecoverPointImageManagementUtils imageManager = new RecoverPointImageManagementUtils();
    RecoverPointBookmarkManagementUtils bookmarkManager = new RecoverPointBookmarkManagementUtils();
    String mgmtIPAddress = _endpoint.toASCIIString();
    if (null == mgmtIPAddress) {
        throw RecoverPointException.exceptions.noRecoverPointEndpoint();
    }
    Set<String> wwnSet = request.getVolumeWWNSet();
    if (wwnSet == null) {
        throw RecoverPointException.exceptions.noWWNsFoundInRequest();
    }
    Set<String> unmappedWWNs = new HashSet<String>();
    CreateBookmarkRequestParams mapRequest = new CreateBookmarkRequestParams();
    mapRequest.setVolumeWWNSet(wwnSet);
    Map<String, RPConsistencyGroup> rpCGMap = bookmarkManager.mapCGsForWWNs(functionalAPI, mapRequest, unmappedWWNs);
    if (!unmappedWWNs.isEmpty()) {
        throw RecoverPointException.exceptions.couldNotMapWWNsToAGroup(unmappedWWNs);
    }
    if (rpCGMap == null) {
        throw RecoverPointException.exceptions.couldNotMapWWNsToAGroup(wwnSet);
    }
    Set<RPConsistencyGroup> cgSetToDisable = new HashSet<RPConsistencyGroup>();
    for (String volume : rpCGMap.keySet()) {
        cgSetToDisable.add(rpCGMap.get(volume));
    }
    for (RPConsistencyGroup rpcg : cgSetToDisable) {
        Set<RPCopy> copies = rpcg.getCopies();
        for (RPCopy copy : copies) {
            ConsistencyGroupCopyState copyState = imageManager.getCopyState(functionalAPI, copy.getCGGroupCopyUID());
            if (request.getEmName() == null || request.getEmName().isEmpty() || (copyState != null && copyState.getAccessedImage() != null && copyState.getAccessedImage().getDescription() != null && copyState.getAccessedImage().getDescription().equals(request.getEmName()))) {
                imageManager.disableCGCopy(functionalAPI, copy.getCGGroupCopyUID());
            }
        }
    }
    response.setReturnCode(RecoverPointReturnCode.SUCCESS);
    return response;
}
Also used : ConsistencyGroupCopyState(com.emc.fapiclient.ws.ConsistencyGroupCopyState) RecoverPointBookmarkManagementUtils(com.emc.storageos.recoverpoint.utils.RecoverPointBookmarkManagementUtils) RPCopy(com.emc.storageos.recoverpoint.objectmodel.RPCopy) RecoverPointImageManagementUtils(com.emc.storageos.recoverpoint.utils.RecoverPointImageManagementUtils) RPConsistencyGroup(com.emc.storageos.recoverpoint.objectmodel.RPConsistencyGroup) CreateBookmarkRequestParams(com.emc.storageos.recoverpoint.requests.CreateBookmarkRequestParams) MultiCopyDisableImageResponse(com.emc.storageos.recoverpoint.responses.MultiCopyDisableImageResponse) HashSet(java.util.HashSet)

Example 4 with RecoverPointBookmarkManagementUtils

use of com.emc.storageos.recoverpoint.utils.RecoverPointBookmarkManagementUtils in project coprhd-controller by CoprHD.

the class RecoverPointClient method enableImageCopies.

/**
 * Enables copy images for one or more consistency group copies
 *
 * @param MultiCopyEnableImageRequestParams request - contains the information about which CG copies to enable
 *
 * @return MultiCopyEnableImageResponse - response as to success or fail of enabling the image copies
 *
 * @throws RecoverPointException
 */
public MultiCopyEnableImageResponse enableImageCopies(MultiCopyEnableImageRequestParams request) throws RecoverPointException {
    MultiCopyEnableImageResponse response = new MultiCopyEnableImageResponse();
    RecoverPointImageManagementUtils imageManager = new RecoverPointImageManagementUtils();
    RecoverPointBookmarkManagementUtils bookmarkManager = new RecoverPointBookmarkManagementUtils();
    String mgmtIPAddress = _endpoint.toASCIIString();
    if (null == mgmtIPAddress) {
        throw RecoverPointException.exceptions.noRecoverPointEndpoint();
    }
    Set<String> wwnSet = request.getVolumeWWNSet();
    if (wwnSet == null) {
        throw RecoverPointException.exceptions.noWWNsFoundInRequest();
    }
    Set<String> unmappedWWNs = new HashSet<String>();
    CreateBookmarkRequestParams mapRequest = new CreateBookmarkRequestParams();
    mapRequest.setBookmark(request.getBookmark());
    mapRequest.setVolumeWWNSet(wwnSet);
    Map<String, RPConsistencyGroup> rpCGMap = bookmarkManager.mapCGsForWWNs(functionalAPI, mapRequest, unmappedWWNs);
    if (!unmappedWWNs.isEmpty()) {
        throw RecoverPointException.exceptions.couldNotMapWWNsToAGroup(unmappedWWNs);
    }
    if (rpCGMap == null) {
        throw RecoverPointException.exceptions.couldNotMapWWNsToAGroup(wwnSet);
    }
    Set<RPConsistencyGroup> cgSetToEnable = new HashSet<RPConsistencyGroup>();
    for (String volume : rpCGMap.keySet()) {
        // logger.info("Get RPCG for volume: " + volume);
        cgSetToEnable.add(rpCGMap.get(volume));
    }
    // Make sure your copies are OK to enable.
    for (RPConsistencyGroup rpcg : cgSetToEnable) {
        Set<RPCopy> copies = rpcg.getCopies();
        for (RPCopy copy : copies) {
            try {
                String cgCopyName = functionalAPI.getGroupCopyName(copy.getCGGroupCopyUID());
                String cgName = functionalAPI.getGroupName(copy.getCGGroupCopyUID().getGroupUID());
                if (!imageManager.verifyCopyCapableOfEnableImageAccess(functionalAPI, copy.getCGGroupCopyUID(), request.getBookmark(), false)) {
                    logger.info("Copy " + cgCopyName + " of group " + cgName + " is in a mode that disallows enabling the CG copy.");
                    throw RecoverPointException.exceptions.notAllowedToEnableImageAccessToCG(cgName, cgCopyName);
                }
            } catch (FunctionalAPIActionFailedException_Exception e) {
                throw RecoverPointException.exceptions.notAllowedToEnableImageAccessToCGException(e);
            } catch (FunctionalAPIInternalError_Exception e) {
                throw RecoverPointException.exceptions.notAllowedToEnableImageAccessToCGException(e);
            }
        }
    }
    for (RPConsistencyGroup rpcg : cgSetToEnable) {
        Set<RPCopy> copies = rpcg.getCopies();
        for (RPCopy copy : copies) {
            boolean waitForLinkState = true;
            imageManager.enableCGCopy(functionalAPI, copy.getCGGroupCopyUID(), waitForLinkState, ImageAccessMode.LOGGED_ACCESS, request.getBookmark(), request.getAPITTime());
        }
    }
    response.setReturnCode(RecoverPointReturnCode.SUCCESS);
    return response;
}
Also used : MultiCopyEnableImageResponse(com.emc.storageos.recoverpoint.responses.MultiCopyEnableImageResponse) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) RecoverPointBookmarkManagementUtils(com.emc.storageos.recoverpoint.utils.RecoverPointBookmarkManagementUtils) RPCopy(com.emc.storageos.recoverpoint.objectmodel.RPCopy) RecoverPointImageManagementUtils(com.emc.storageos.recoverpoint.utils.RecoverPointImageManagementUtils) RPConsistencyGroup(com.emc.storageos.recoverpoint.objectmodel.RPConsistencyGroup) CreateBookmarkRequestParams(com.emc.storageos.recoverpoint.requests.CreateBookmarkRequestParams) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) HashSet(java.util.HashSet)

Example 5 with RecoverPointBookmarkManagementUtils

use of com.emc.storageos.recoverpoint.utils.RecoverPointBookmarkManagementUtils in project coprhd-controller by CoprHD.

the class RecoverPointClient method restoreImageCopies.

/**
 * Restore copy images for one or more consistency group copies
 *
 * @param MultiCopyRestoreImageRequestParams request - contains the information about which CG copies to restore
 *
 * @return MultiCopyRestoreImageResponse - response as to success or fail of restoring the image copies
 *
 * @throws RecoverPointException
 */
public MultiCopyRestoreImageResponse restoreImageCopies(MultiCopyRestoreImageRequestParams request) throws RecoverPointException {
    MultiCopyRestoreImageResponse response = new MultiCopyRestoreImageResponse();
    RecoverPointImageManagementUtils imageManager = new RecoverPointImageManagementUtils();
    RecoverPointBookmarkManagementUtils bookmarkManager = new RecoverPointBookmarkManagementUtils();
    String mgmtIPAddress = _endpoint.toASCIIString();
    if (null == mgmtIPAddress) {
        throw RecoverPointException.exceptions.noRecoverPointEndpoint();
    }
    Set<String> wwnSet = request.getVolumeWWNSet();
    if (wwnSet == null) {
        throw RecoverPointException.exceptions.noWWNsFoundInRequest();
    }
    Set<String> unmappedWWNs = new HashSet<String>();
    CreateBookmarkRequestParams mapRequest = new CreateBookmarkRequestParams();
    mapRequest.setBookmark(request.getBookmark());
    mapRequest.setVolumeWWNSet(wwnSet);
    Map<String, RPConsistencyGroup> rpCGMap = bookmarkManager.mapCGsForWWNs(functionalAPI, mapRequest, unmappedWWNs);
    if (!unmappedWWNs.isEmpty()) {
        throw RecoverPointException.exceptions.couldNotMapWWNsToAGroup(unmappedWWNs);
    }
    if (rpCGMap == null) {
        throw RecoverPointException.exceptions.couldNotMapWWNsToAGroup(wwnSet);
    }
    Set<RPConsistencyGroup> cgSetToEnable = new HashSet<RPConsistencyGroup>();
    for (String volume : rpCGMap.keySet()) {
        // logger.info("Get RPCG for volume: " + volume);
        cgSetToEnable.add(rpCGMap.get(volume));
    }
    ClusterUID siteToRestore = null;
    // Verify that we are not restoring from different sites
    for (RPConsistencyGroup rpcg : cgSetToEnable) {
        Set<RPCopy> copies = rpcg.getCopies();
        for (RPCopy copy : copies) {
            if (siteToRestore == null) {
                siteToRestore = copy.getCGGroupCopyUID().getGlobalCopyUID().getClusterUID();
            } else if (siteToRestore.getId() != copy.getCGGroupCopyUID().getGlobalCopyUID().getClusterUID().getId()) {
                throw RecoverPointException.exceptions.cannotRestoreVolumesFromDifferentSites(wwnSet);
            }
            try {
                List<ConsistencyGroupCopyUID> productionCopiesUIDs = functionalAPI.getGroupSettings(copy.getCGGroupCopyUID().getGroupUID()).getProductionCopiesUIDs();
                for (ConsistencyGroupCopyUID productionCopyUID : productionCopiesUIDs) {
                    if (RecoverPointUtils.copiesEqual(productionCopyUID, copy.getCGGroupCopyUID())) {
                        throw RecoverPointException.exceptions.cannotRestoreVolumesInConsistencyGroup(wwnSet);
                    }
                }
            } catch (FunctionalAPIActionFailedException_Exception e) {
                logger.error(e.getMessage());
                logger.error("Received FunctionalAPIActionFailedException_Exception. Get production copy");
                throw RecoverPointException.exceptions.failureRestoringVolumes();
            } catch (FunctionalAPIInternalError_Exception e) {
                logger.error(e.getMessage());
                logger.error("Received FunctionalAPIActionFailedException_Exception. Get production copy");
                throw RecoverPointException.exceptions.failureRestoringVolumes();
            }
        }
    }
    try {
        for (RPConsistencyGroup rpcg : cgSetToEnable) {
            Set<RPCopy> copies = rpcg.getCopies();
            for (RPCopy copy : copies) {
                boolean waitForLinkState = false;
                imageManager.enableCGCopy(functionalAPI, copy.getCGGroupCopyUID(), waitForLinkState, ImageAccessMode.LOGGED_ACCESS, request.getBookmark(), request.getAPITTime());
            }
        }
    } catch (RecoverPointException e) {
        logger.error("Caught exception while enabling CG copies for restore.  Return copies to previous state");
        for (RPConsistencyGroup rpcg : cgSetToEnable) {
            Set<RPCopy> copies = rpcg.getCopies();
            for (RPCopy copy : copies) {
                imageManager.disableCGCopy(functionalAPI, copy.getCGGroupCopyUID());
            }
        }
        throw e;
    }
    for (RPConsistencyGroup rpcg : cgSetToEnable) {
        Set<RPCopy> copies = rpcg.getCopies();
        for (RPCopy copy : copies) {
            imageManager.restoreEnabledCGCopy(functionalAPI, copy.getCGGroupCopyUID());
        }
    }
    response.setReturnCode(RecoverPointReturnCode.SUCCESS);
    return response;
}
Also used : Set(java.util.Set) TreeSet(java.util.TreeSet) SortedSet(java.util.SortedSet) HashSet(java.util.HashSet) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) RecoverPointBookmarkManagementUtils(com.emc.storageos.recoverpoint.utils.RecoverPointBookmarkManagementUtils) RPCopy(com.emc.storageos.recoverpoint.objectmodel.RPCopy) RecoverPointImageManagementUtils(com.emc.storageos.recoverpoint.utils.RecoverPointImageManagementUtils) RPConsistencyGroup(com.emc.storageos.recoverpoint.objectmodel.RPConsistencyGroup) ConsistencyGroupCopyUID(com.emc.fapiclient.ws.ConsistencyGroupCopyUID) CreateBookmarkRequestParams(com.emc.storageos.recoverpoint.requests.CreateBookmarkRequestParams) ClusterUID(com.emc.fapiclient.ws.ClusterUID) MultiCopyRestoreImageResponse(com.emc.storageos.recoverpoint.responses.MultiCopyRestoreImageResponse) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) RecoverPointException(com.emc.storageos.recoverpoint.exceptions.RecoverPointException) HashSet(java.util.HashSet)

Aggregations

RecoverPointBookmarkManagementUtils (com.emc.storageos.recoverpoint.utils.RecoverPointBookmarkManagementUtils)5 RPConsistencyGroup (com.emc.storageos.recoverpoint.objectmodel.RPConsistencyGroup)4 HashSet (java.util.HashSet)4 RPCopy (com.emc.storageos.recoverpoint.objectmodel.RPCopy)3 CreateBookmarkRequestParams (com.emc.storageos.recoverpoint.requests.CreateBookmarkRequestParams)3 RecoverPointImageManagementUtils (com.emc.storageos.recoverpoint.utils.RecoverPointImageManagementUtils)3 FunctionalAPIActionFailedException_Exception (com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception)2 FunctionalAPIInternalError_Exception (com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception)2 ClusterUID (com.emc.fapiclient.ws.ClusterUID)1 ConsistencyGroupCopyState (com.emc.fapiclient.ws.ConsistencyGroupCopyState)1 ConsistencyGroupCopyUID (com.emc.fapiclient.ws.ConsistencyGroupCopyUID)1 ConsistencyGroupUID (com.emc.fapiclient.ws.ConsistencyGroupUID)1 RecoverPointException (com.emc.storageos.recoverpoint.exceptions.RecoverPointException)1 GetBookmarksResponse (com.emc.storageos.recoverpoint.responses.GetBookmarksResponse)1 MultiCopyDisableImageResponse (com.emc.storageos.recoverpoint.responses.MultiCopyDisableImageResponse)1 MultiCopyEnableImageResponse (com.emc.storageos.recoverpoint.responses.MultiCopyEnableImageResponse)1 MultiCopyRestoreImageResponse (com.emc.storageos.recoverpoint.responses.MultiCopyRestoreImageResponse)1 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1