Search in sources :

Example 6 with RecoverPointImageManagementUtils

use of com.emc.storageos.recoverpoint.utils.RecoverPointImageManagementUtils 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 7 with RecoverPointImageManagementUtils

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

the class RecoverPointClient method failoverCopyTest.

/**
 * Perform a failover test to the consistency group copy specified by the input request params.
 *
 * @param RPCopyRequestParams copyToFailoverTo - Volume info for the CG to perform a failover test to. Also contains bookmark and APIT
 *            info. If no bookmark or APIT specified, failover test to most recent image.
 *
 * @return void
 *
 * @throws RecoverPointException
 */
public void failoverCopyTest(RPCopyRequestParams copyToFailoverTo) throws RecoverPointException {
    // Check the params
    // If bookmark != null, enable the bookmark on the copy, and failover to that copy
    // If APITTime != null, enable the specified APIT on the copy, and failover to that copy
    // If both are null, enable the most recent imagem, and failover to that copy
    String bookmarkName = copyToFailoverTo.getBookmarkName();
    Date apitTime = copyToFailoverTo.getApitTime();
    if (bookmarkName != null) {
        logger.info("Failver copy to bookmark : " + bookmarkName);
    } else if (apitTime != null) {
        logger.info("Failover copy to APIT : " + apitTime.toString());
    } else {
        logger.info("Failover copy to most recent image");
    }
    RecoverPointImageManagementUtils imageManager = new RecoverPointImageManagementUtils();
    imageManager.enableCopyImage(functionalAPI, copyToFailoverTo, false);
    // RecoverPointUtils.mapRPVolumeProtectionInfoToCGCopyUID(copyToFailoverTo.getCopyVolumeInfo());
    RecoverPointVolumeProtectionInfo failoverCopyInfo = copyToFailoverTo.getCopyVolumeInfo();
    pauseTransfer(failoverCopyInfo);
}
Also used : RecoverPointVolumeProtectionInfo(com.emc.storageos.recoverpoint.responses.RecoverPointVolumeProtectionInfo) Date(java.util.Date) RecoverPointImageManagementUtils(com.emc.storageos.recoverpoint.utils.RecoverPointImageManagementUtils)

Example 8 with RecoverPointImageManagementUtils

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

the class RecoverPointClient method enableProtection.

/**
 * Enable (start) the consistency group protection specified by the input volume info
 * Requires a full sweep.
 *
 * @param RecoverPointVolumeProtectionInfo volumeInfo - Volume info for the CG to enable
 *
 * @return void
 *
 * @throws RecoverPointException
 */
public void enableProtection(RecoverPointVolumeProtectionInfo volumeInfo) throws RecoverPointException {
    try {
        ConsistencyGroupUID cgUID = new ConsistencyGroupUID();
        cgUID.setId(volumeInfo.getRpVolumeGroupID());
        ConsistencyGroupCopyUID cgCopyUID = null;
        cgCopyUID = RecoverPointUtils.mapRPVolumeProtectionInfoToCGCopyUID(volumeInfo);
        String cgCopyName = functionalAPI.getGroupCopyName(cgCopyUID);
        String cgName = functionalAPI.getGroupName(cgUID);
        if (volumeInfo.getRpVolumeCurrentProtectionStatus() == RecoverPointVolumeProtectionInfo.volumeProtectionStatus.PROTECTED_SOURCE) {
            // Enable the whole CG.
            logger.info("Enabling consistency group " + cgName);
            functionalAPI.enableConsistencyGroup(cgUID, true);
            // Make sure the CG is ready
            RecoverPointImageManagementUtils imageManager = new RecoverPointImageManagementUtils();
            imageManager.waitForCGLinkState(functionalAPI, cgUID, RecoverPointImageManagementUtils.getPipeActiveState(functionalAPI, cgUID));
            logger.info("Protection enabled on CG " + cgName);
        } else {
            // Enable the CG copy associated with the target
            logger.info("Enabling CG copy " + cgCopyName + " on CG " + cgName);
            functionalAPI.enableConsistencyGroupCopy(cgCopyUID, true);
            // Make sure the CG copy is stopped
            RecoverPointImageManagementUtils imageManager = new RecoverPointImageManagementUtils();
            imageManager.waitForCGCopyLinkState(functionalAPI, cgCopyUID, PipeState.ACTIVE);
            logger.info("Protection enabled on CG copy " + cgCopyName + " on CG " + cgName);
        }
    } catch (FunctionalAPIActionFailedException_Exception e) {
        throw RecoverPointException.exceptions.failedToEnableProtection(volumeInfo.getRpVolumeGroupID(), e);
    } catch (FunctionalAPIInternalError_Exception e) {
        throw RecoverPointException.exceptions.failedToEnableProtection(volumeInfo.getRpVolumeGroupID(), e);
    }
}
Also used : FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) ConsistencyGroupUID(com.emc.fapiclient.ws.ConsistencyGroupUID) RecoverPointImageManagementUtils(com.emc.storageos.recoverpoint.utils.RecoverPointImageManagementUtils) ConsistencyGroupCopyUID(com.emc.fapiclient.ws.ConsistencyGroupCopyUID)

Example 9 with RecoverPointImageManagementUtils

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

the class RecoverPointClient method disableConsistencyGroup.

/**
 * Disables the whole consistency group.
 *
 * @param cgUID the consistency group UID.
 * @throws FunctionalAPIActionFailedException_Exception
 * @throws FunctionalAPIInternalError_Exception
 */
private void disableConsistencyGroup(ConsistencyGroupUID cgUID) throws FunctionalAPIActionFailedException_Exception, FunctionalAPIInternalError_Exception {
    functionalAPI.disableConsistencyGroup(cgUID);
    String cgName = functionalAPI.getGroupName(cgUID);
    logger.info("Protection disabled on CG: " + cgName);
    // Make sure the CG is stopped
    RecoverPointImageManagementUtils imageManager = new RecoverPointImageManagementUtils();
    imageManager.waitForCGLinkState(functionalAPI, cgUID, PipeState.UNKNOWN);
}
Also used : RecoverPointImageManagementUtils(com.emc.storageos.recoverpoint.utils.RecoverPointImageManagementUtils)

Example 10 with RecoverPointImageManagementUtils

use of com.emc.storageos.recoverpoint.utils.RecoverPointImageManagementUtils 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)

Aggregations

RecoverPointImageManagementUtils (com.emc.storageos.recoverpoint.utils.RecoverPointImageManagementUtils)17 FunctionalAPIActionFailedException_Exception (com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception)10 FunctionalAPIInternalError_Exception (com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception)10 ConsistencyGroupCopyUID (com.emc.fapiclient.ws.ConsistencyGroupCopyUID)9 ConsistencyGroupUID (com.emc.fapiclient.ws.ConsistencyGroupUID)7 ClusterUID (com.emc.fapiclient.ws.ClusterUID)4 RecoverPointException (com.emc.storageos.recoverpoint.exceptions.RecoverPointException)4 ConsistencyGroupCopyState (com.emc.fapiclient.ws.ConsistencyGroupCopyState)3 ConsistencyGroupSettingsChangesParam (com.emc.fapiclient.ws.ConsistencyGroupSettingsChangesParam)3 FunctionalAPIValidationException_Exception (com.emc.fapiclient.ws.FunctionalAPIValidationException_Exception)3 RPConsistencyGroup (com.emc.storageos.recoverpoint.objectmodel.RPConsistencyGroup)3 RPCopy (com.emc.storageos.recoverpoint.objectmodel.RPCopy)3 CreateBookmarkRequestParams (com.emc.storageos.recoverpoint.requests.CreateBookmarkRequestParams)3 RecoverPointVolumeProtectionInfo (com.emc.storageos.recoverpoint.responses.RecoverPointVolumeProtectionInfo)3 RecoverPointBookmarkManagementUtils (com.emc.storageos.recoverpoint.utils.RecoverPointBookmarkManagementUtils)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 ConsistencyGroupCopySettings (com.emc.fapiclient.ws.ConsistencyGroupCopySettings)2 RecoverPointCGResponse (com.emc.storageos.recoverpoint.responses.RecoverPointCGResponse)2