Search in sources :

Example 26 with FunctionalAPIActionFailedException_Exception

use of com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception in project coprhd-controller by CoprHD.

the class RecoverPointClient method setCopyAsProduction.

/**
 * Prepares the copy link settings and sets copy as production. This would typically be
 * called following a call to swapCopy.
 *
 * @param copyParams the volume info for preparing the CG links and setting copy as production.
 * @throws RecoverPointException
 */
public void setCopyAsProduction(RPCopyRequestParams copyParams) throws RecoverPointException {
    logger.info(String.format("Setting copy %s as production copy.", (copyParams.getCopyVolumeInfo() != null) ? copyParams.getCopyVolumeInfo().getRpCopyName() : "N/A"));
    // 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());
    // Prepare the link settings for new links
    prepareLinkSettings(cgCopyUID);
    // Set the failover copy as production to resume data flow
    imageManager.setCopyAsProduction(functionalAPI, cgCopyUID);
    // wait for links to become active
    ConsistencyGroupUID cgUID = cgCopyUID.getGroupUID();
    String cgName = null;
    try {
        cgName = functionalAPI.getGroupName(cgUID);
    } catch (FunctionalAPIActionFailedException_Exception | FunctionalAPIInternalError_Exception e) {
        // benign error -- cgName is only used for logging
        logger.error(e.getMessage(), e);
    }
    boolean waitForLinkStates = false;
    // In a true DR scenario, we cant expect links to become active and that should not fail the swap/failover operation.
    if (waitForLinkStates) {
        logger.info("Waiting for links to become active for CG " + (cgName == null ? "unknown CG name" : cgName));
        (new RecoverPointImageManagementUtils()).waitForCGLinkState(functionalAPI, cgUID, PipeState.ACTIVE);
    } else {
        logger.info("Not waiting for links to become active for CG" + (cgName == null ? "unknown CG name" : cgName));
    }
    logger.info(String.format("Replication sets have been added to consistency group %s.", (cgName == null ? "unknown CG name" : cgName)));
}
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 27 with FunctionalAPIActionFailedException_Exception

use of com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception 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)

Example 28 with FunctionalAPIActionFailedException_Exception

use of com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception in project coprhd-controller by CoprHD.

the class RecoverPointClient method deleteCG.

/**
 * Delete the consistency group specified by the input volume info.
 *
 * @param RecoverPointVolumeProtectionInfo volumeInfo - Volume info for the CG to delete
 *
 * @return void
 *
 * @throws RecoverPointException
 */
public void deleteCG(RecoverPointVolumeProtectionInfo cgToDelete) throws RecoverPointException {
    ConsistencyGroupCopyUID cgCopyUID = RecoverPointUtils.mapRPVolumeProtectionInfoToCGCopyUID(cgToDelete);
    String cgName = null;
    try {
        cgName = functionalAPI.getGroupName(cgCopyUID.getGroupUID());
        ConsistencyGroupSettings groupSettings = functionalAPI.getGroupSettings(cgCopyUID.getGroupUID());
        List<ConsistencyGroupCopyUID> productionCopiesUIDs = groupSettings.getProductionCopiesUIDs();
        for (ConsistencyGroupCopyUID productionCopyUID : productionCopiesUIDs) {
            if (!cgToDelete.isMetroPoint() && !RecoverPointUtils.copiesEqual(productionCopyUID, cgCopyUID)) {
                // Can't call delete CG using anything but the production CG copy
                throw RecoverPointException.exceptions.cantCallDeleteCGUsingProductionCGCopy(cgName);
            }
        }
        // First disable the CG before removing it, this buys RP a bit of time
        // to clean it up.
        disableConsistencyGroup(cgCopyUID.getGroupUID());
        // Delete the CG, async call to RP
        functionalAPI.removeConsistencyGroup(cgCopyUID.getGroupUID());
        // Verify the CG has been removed
        validateCGRemoved(cgCopyUID.getGroupUID(), cgName);
        logger.info("Deleted consistency group " + cgName);
    } catch (FunctionalAPIActionFailedException_Exception e) {
        throw RecoverPointException.exceptions.failedToDeleteConsistencyGroup(cgName, e);
    } catch (FunctionalAPIInternalError_Exception e) {
        throw RecoverPointException.exceptions.failedToDeleteConsistencyGroup(cgName, e);
    } catch (Exception e) {
        throw RecoverPointException.exceptions.failedToDeleteConsistencyGroup(cgName, e);
    }
}
Also used : FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) ConsistencyGroupSettings(com.emc.fapiclient.ws.ConsistencyGroupSettings) 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)

Example 29 with FunctionalAPIActionFailedException_Exception

use of com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception in project coprhd-controller by CoprHD.

the class RecoverPointClient method disableProtection.

/**
 * Disable (stop) the consistency group protection specified by the input volume info.
 * If a target volume is specified, disable the copy associated with the target.
 * Disable requires a full sweep when enabled.
 *
 * @param RecoverPointVolumeProtectionInfo volumeInfo - Volume info for the CG to disable
 *
 * @return void
 *
 * @throws RecoverPointException
 */
public void disableProtection(RecoverPointVolumeProtectionInfo volumeInfo) throws RecoverPointException {
    try {
        ConsistencyGroupUID cgUID = new ConsistencyGroupUID();
        cgUID.setId(volumeInfo.getRpVolumeGroupID());
        if (volumeInfo.getRpVolumeCurrentProtectionStatus() == RecoverPointVolumeProtectionInfo.volumeProtectionStatus.PROTECTED_SOURCE) {
            // Disable the whole CG
            disableConsistencyGroup(cgUID);
        } else {
            // Disable the CG copy associated with the target.
            ConsistencyGroupCopyUID cgCopyUID = RecoverPointUtils.mapRPVolumeProtectionInfoToCGCopyUID(volumeInfo);
            functionalAPI.disableConsistencyGroupCopy(cgCopyUID);
            String cgCopyName = functionalAPI.getGroupCopyName(cgCopyUID);
            String cgName = functionalAPI.getGroupName(cgCopyUID.getGroupUID());
            logger.info("Protection disabled on CG copy " + cgCopyName + " on CG " + cgName);
            // Make sure the CG copy is stopped
            RecoverPointImageManagementUtils imageManager = new RecoverPointImageManagementUtils();
            imageManager.waitForCGCopyLinkState(functionalAPI, cgCopyUID, PipeState.UNKNOWN);
            logger.info("Protection disabled on CG copy " + cgCopyName + " on CG " + cgName);
        }
    } catch (FunctionalAPIActionFailedException_Exception e) {
        throw RecoverPointException.exceptions.failedToDisableProtection(volumeInfo.getRpVolumeGroupID(), e);
    } catch (FunctionalAPIInternalError_Exception e) {
        throw RecoverPointException.exceptions.failedToDisableProtection(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 30 with FunctionalAPIActionFailedException_Exception

use of com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception in project coprhd-controller by CoprHD.

the class RecoverPointClient method pauseTransfer.

/**
 * Pause (suspend) the consistency group protection specified by the input volume info.
 *
 * @param RecoverPointVolumeProtectionInfo volumeInfo - Volume info for the CG to pause
 *
 * @return void
 *
 * @throws RecoverPointException
 */
public void pauseTransfer(RecoverPointVolumeProtectionInfo volumeInfo) throws RecoverPointException {
    try {
        ConsistencyGroupUID cgUID = new ConsistencyGroupUID();
        cgUID.setId(volumeInfo.getRpVolumeGroupID());
        if (volumeInfo.getRpVolumeCurrentProtectionStatus() == RecoverPointVolumeProtectionInfo.volumeProtectionStatus.PROTECTED_SOURCE) {
            // Pause the whole CG
            functionalAPI.pauseGroupTransfer(cgUID);
            String cgName = functionalAPI.getGroupName(cgUID);
            logger.info("Protection paused on CG " + cgName);
        } else {
            // Pause the CG copy associated with the target
            ConsistencyGroupCopyUID cgCopyUID = RecoverPointUtils.mapRPVolumeProtectionInfoToCGCopyUID(volumeInfo);
            functionalAPI.pauseGroupCopyTransfer(cgCopyUID);
            String cgCopyName = functionalAPI.getGroupCopyName(cgCopyUID);
            String cgName = functionalAPI.getGroupName(cgCopyUID.getGroupUID());
            logger.info("Protection paused on CG copy " + cgCopyName + " on CG " + cgName);
        }
    } catch (FunctionalAPIActionFailedException_Exception e) {
        throw RecoverPointException.exceptions.failedToPauseProtection(volumeInfo.getRpVolumeGroupID(), e);
    } catch (FunctionalAPIInternalError_Exception e) {
        throw RecoverPointException.exceptions.failedToPauseProtection(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) ConsistencyGroupCopyUID(com.emc.fapiclient.ws.ConsistencyGroupCopyUID)

Aggregations

FunctionalAPIActionFailedException_Exception (com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception)42 FunctionalAPIInternalError_Exception (com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception)42 ConsistencyGroupCopyUID (com.emc.fapiclient.ws.ConsistencyGroupCopyUID)21 ConsistencyGroupUID (com.emc.fapiclient.ws.ConsistencyGroupUID)15 ConsistencyGroupSettings (com.emc.fapiclient.ws.ConsistencyGroupSettings)11 HashSet (java.util.HashSet)10 ConsistencyGroupState (com.emc.fapiclient.ws.ConsistencyGroupState)8 RecoverPointException (com.emc.storageos.recoverpoint.exceptions.RecoverPointException)8 FunctionalAPIValidationException_Exception (com.emc.fapiclient.ws.FunctionalAPIValidationException_Exception)7 RecoverPointImageManagementUtils (com.emc.storageos.recoverpoint.utils.RecoverPointImageManagementUtils)7 ConsistencyGroupCopySettings (com.emc.fapiclient.ws.ConsistencyGroupCopySettings)5 ConsistencyGroupCopyState (com.emc.fapiclient.ws.ConsistencyGroupCopyState)5 ConsistencyGroupLinkState (com.emc.fapiclient.ws.ConsistencyGroupLinkState)5 HashMap (java.util.HashMap)5 ClusterUID (com.emc.fapiclient.ws.ClusterUID)4 ReplicationSetSettings (com.emc.fapiclient.ws.ReplicationSetSettings)4 RPSite (com.emc.storageos.recoverpoint.objectmodel.RPSite)4 ClusterConfiguration (com.emc.fapiclient.ws.ClusterConfiguration)3 ConsistencyGroupCopySnapshots (com.emc.fapiclient.ws.ConsistencyGroupCopySnapshots)3 DeviceUID (com.emc.fapiclient.ws.DeviceUID)3