Search in sources :

Example 1 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 2 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 3 with RecoverPointImageManagementUtils

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

the class RecoverPointClient method failoverCopy.

/**
 * Perform a failover to the consistency group copy specified by the input request params.
 *
 * @param RPCopyRequestParams copyToFailoverTo - Volume info for the CG to perform a failover to. Also contains bookmark and APIT info.
 *            If no bookmark or APIT specified, failover to most recent image.
 *
 * @return void
 *
 * @throws RecoverPointException
 */
public void failoverCopy(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("Failover 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, true);
// Stop the replication link to this copy
// ConsistencyGroupCopyUID cgCopyUID = RecoverPointUtils.mapRPVolumeProtectionInfoToCGCopyUID(copyToFailoverTo.getCopyVolumeInfo());
// imageManager.disableCGCopy(functionalAPI, cgCopyUID);
}
Also used : Date(java.util.Date) RecoverPointImageManagementUtils(com.emc.storageos.recoverpoint.utils.RecoverPointImageManagementUtils)

Example 4 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 5 with RecoverPointImageManagementUtils

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

the class RecoverPointClient method swapCopy.

/**
 * Perform a swap to the consistency group copy specified by the input request params.
 *
 * @param copyParams the volume info for the CG to perform a swap to.
 *
 * @return void
 *
 * @throws RecoverPointException
 * @throws FunctionalAPIInternalError_Exception
 * @throws FunctionalAPIActionFailedException_Exception
 */
public void swapCopy(RPCopyRequestParams copyParams) throws RecoverPointException {
    try {
        logger.info("Swap copy to current or most recent image");
        // Make sure the copy is already enabled or RP will fail the operation. If it isn't enabled, enable it.
        RecoverPointImageManagementUtils imageManager = new RecoverPointImageManagementUtils();
        ConsistencyGroupCopyUID cgCopyUID = RecoverPointUtils.mapRPVolumeProtectionInfoToCGCopyUID(copyParams.getCopyVolumeInfo());
        ConsistencyGroupCopyState copyState = imageManager.getCopyState(functionalAPI, cgCopyUID);
        if (copyState != null && copyState.getAccessedImage() == null && !StorageAccessState.DIRECT_ACCESS.equals(copyState.getStorageAccessState())) {
            // Enable image access to the latest snapshot if copy image access isn't already enabled.
            failoverCopy(copyParams);
        }
        ConsistencyGroupCopySettings cgCopySettings = RecoverPointUtils.getCopySettings(functionalAPI, cgCopyUID);
        List<ConsistencyGroupCopyUID> productionCopiesUIDs = functionalAPI.getGroupSettings(cgCopyUID.getGroupUID()).getProductionCopiesUIDs();
        // data replication. Otherwise, we need to perform a failover.
        if (RecoverPointUtils.isProductionCopy(cgCopyUID, productionCopiesUIDs) && cgCopySettings.getRoleInfo() != null && ConsistencyGroupCopyRole.REPLICA == cgCopySettings.getRoleInfo().getRole()) {
            logger.info("Swap copy is a production copy with role 'Target at Production'.  Resuming production to complete the swap.");
            functionalAPI.resumeProduction(cgCopyUID.getGroupUID(), true);
        } else {
            // Perform the failover
            imageManager.failoverCGCopy(functionalAPI, cgCopyUID);
        }
    } catch (FunctionalAPIActionFailedException_Exception | FunctionalAPIInternalError_Exception e) {
        String copyName = copyParams.getCopyVolumeInfo() != null ? copyParams.getCopyVolumeInfo().getRpCopyName() : "N/A";
        throw RecoverPointException.exceptions.failedToSwapCopy(copyName, e);
    }
}
Also used : FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) ConsistencyGroupCopyState(com.emc.fapiclient.ws.ConsistencyGroupCopyState) RecoverPointImageManagementUtils(com.emc.storageos.recoverpoint.utils.RecoverPointImageManagementUtils) ConsistencyGroupCopySettings(com.emc.fapiclient.ws.ConsistencyGroupCopySettings) ConsistencyGroupCopyUID(com.emc.fapiclient.ws.ConsistencyGroupCopyUID)

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