Search in sources :

Example 1 with CreateBookmarkResponse

use of com.emc.storageos.recoverpoint.responses.CreateBookmarkResponse in project coprhd-controller by CoprHD.

the class RecoverPointBookmarkManagementUtils method createCGBookmarks.

/**
 * Create bookmarks for a CG
 *
 * @param impl - RP handle to use for RP operations
 * @param rpCGMap - The mapping of RP CGs to WWNs. Used to create a list of CGs to bookmark
 * @param request - Information about the bookmark to request
 *
 * @return CreateBookmarkResponse - Results of the create bookmark.
 *         TODO: Return bookmark information (date/time)
 *
 * @throws RecoverPointException
 */
public CreateBookmarkResponse createCGBookmarks(FunctionalAPIImpl impl, Map<String, RPConsistencyGroup> rpCGMap, CreateBookmarkRequestParams request) throws RecoverPointException {
    Set<ConsistencyGroupUID> uniqueCGUIDSet = new HashSet<ConsistencyGroupUID>();
    List<ConsistencyGroupUID> uniqueCGUIDlist = new LinkedList<ConsistencyGroupUID>();
    Set<RPConsistencyGroup> rpCGSet = new HashSet<RPConsistencyGroup>();
    CreateBookmarkResponse response = new CreateBookmarkResponse();
    for (String volume : rpCGMap.keySet()) {
        RPConsistencyGroup rpCG = rpCGMap.get(volume);
        if (rpCG.getCGUID() != null) {
            boolean foundCGUID = false;
            ConsistencyGroupUID cguid = rpCG.getCGUID();
            for (ConsistencyGroupUID cguidunique : uniqueCGUIDSet) {
                if (cguidunique.getId() == cguid.getId()) {
                    foundCGUID = true;
                    break;
                }
            }
            if (!foundCGUID) {
                logger.info("Adding CG: " + rpCG.getName() + " with ID " + rpCG.getCGUID().getId() + " to unique CGUID list");
                uniqueCGUIDSet.add(cguid);
                uniqueCGUIDlist.add(cguid);
                rpCGSet.add(rpCG);
            }
        }
    }
    // Make sure the CG is in a good state before we make bookmarks
    RecoverPointImageManagementUtils imageManager = new RecoverPointImageManagementUtils();
    for (ConsistencyGroupUID cgID : uniqueCGUIDlist) {
        // Make sure the CG is ready for enable
        imageManager.waitForCGLinkState(impl, cgID, RecoverPointImageManagementUtils.getPipeActiveState(impl, cgID), PipeState.PAUSED);
    }
    try {
        impl.createBookmark(uniqueCGUIDlist, request.getBookmark(), BookmarkConsolidationPolicy.NEVER_CONSOLIDATE, SnapshotConsistencyType.APPLICATION_CONSISTENT);
        logger.info(String.format("Created RP Bookmark successfully: %s", request.getBookmark()));
        response.setCgBookmarkMap(findRPBookmarks(impl, rpCGSet, request));
        response.setReturnCode(RecoverPointReturnCode.SUCCESS);
    } catch (FunctionalAPIActionFailedException_Exception | FunctionalAPIInternalError_Exception e) {
        throw RecoverPointException.exceptions.failedToCreateBookmarkOnRecoverPoint(e);
    }
    return response;
}
Also used : FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) LinkedList(java.util.LinkedList) RPConsistencyGroup(com.emc.storageos.recoverpoint.objectmodel.RPConsistencyGroup) CreateBookmarkResponse(com.emc.storageos.recoverpoint.responses.CreateBookmarkResponse) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) ConsistencyGroupUID(com.emc.fapiclient.ws.ConsistencyGroupUID) HashSet(java.util.HashSet)

Example 2 with CreateBookmarkResponse

use of com.emc.storageos.recoverpoint.responses.CreateBookmarkResponse in project coprhd-controller by CoprHD.

the class RPDeviceController method createBookmarkStep.

/**
 * This method creates a RP bookmark
 *
 * @param snapshotList
 *            List of snapshot
 * @param system
 *            Protection Sytem
 * @param snapshotName
 *            snapshot name
 * @param volumeWWNs
 *            WWNs of the volumes whose snap is requested
 * @param rpBookmarkOnly
 *            if true, an RP bookmark is taken or a local array snap is performed.
 * @param token
 *            step Id corresponding to this step.
 * @return true if successful, false otherwise.
 */
public boolean createBookmarkStep(List<URI> snapshotList, ProtectionSystem system, String snapshotName, Set<String> volumeWWNs, boolean rpBookmarkOnly, String token) {
    RecoverPointClient rp = RPHelper.getRecoverPointClient(system);
    CreateBookmarkRequestParams request = new CreateBookmarkRequestParams();
    request.setVolumeWWNSet(volumeWWNs);
    request.setBookmark(snapshotName);
    try {
        // Create the bookmark on the RP System
        CreateBookmarkResponse response = rp.createBookmarks(request);
        if (response == null) {
            throw DeviceControllerExceptions.recoverpoint.failedToCreateBookmark();
        }
        if (snapshotList != null && !snapshotList.isEmpty()) {
            // RP Bookmark-only flow.
            if (rpBookmarkOnly) {
                // This will update the blocksnapshot object based on the return of the EM call
                // The construct method will set the task completer on each snapshot
                constructSnapshotObjectFromBookmark(response, system, snapshotList, snapshotName, token);
            } else {
                // image access later on.
                for (URI snapshotURI : snapshotList) {
                    BlockSnapshot snapshot = _dbClient.queryObject(BlockSnapshot.class, snapshotURI);
                    snapshot.setEmName(snapshotName);
                    _dbClient.updateObject(snapshot);
                }
            }
        }
        WorkflowStepCompleter.stepSucceded(token);
    } catch (RecoverPointException e) {
        _log.error("create bookmark step failed with a RecoverPoint exception: ", e);
        WorkflowStepCompleter.stepFailed(token, e);
        return false;
    } catch (Exception e) {
        _log.error("create bookmark step failed with an unchecked exception: ", e);
        WorkflowStepCompleter.stepFailed(token, DeviceControllerException.errors.jobFailed(e));
        return false;
    }
    return true;
}
Also used : CreateBookmarkRequestParams(com.emc.storageos.recoverpoint.requests.CreateBookmarkRequestParams) RecoverPointClient(com.emc.storageos.recoverpoint.impl.RecoverPointClient) RecoverPointException(com.emc.storageos.recoverpoint.exceptions.RecoverPointException) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) InternalServerErrorException(com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) LockRetryException(com.emc.storageos.locking.LockRetryException) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) URISyntaxException(java.net.URISyntaxException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) RecoverPointException(com.emc.storageos.recoverpoint.exceptions.RecoverPointException) CreateBookmarkResponse(com.emc.storageos.recoverpoint.responses.CreateBookmarkResponse)

Aggregations

FunctionalAPIActionFailedException_Exception (com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception)2 FunctionalAPIInternalError_Exception (com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception)2 CreateBookmarkResponse (com.emc.storageos.recoverpoint.responses.CreateBookmarkResponse)2 ConsistencyGroupUID (com.emc.fapiclient.ws.ConsistencyGroupUID)1 CoordinatorException (com.emc.storageos.coordinator.exceptions.CoordinatorException)1 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)1 NamedURI (com.emc.storageos.db.client.model.NamedURI)1 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)1 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)1 LockRetryException (com.emc.storageos.locking.LockRetryException)1 RecoverPointException (com.emc.storageos.recoverpoint.exceptions.RecoverPointException)1 RecoverPointClient (com.emc.storageos.recoverpoint.impl.RecoverPointClient)1 RPConsistencyGroup (com.emc.storageos.recoverpoint.objectmodel.RPConsistencyGroup)1 CreateBookmarkRequestParams (com.emc.storageos.recoverpoint.requests.CreateBookmarkRequestParams)1 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)1 InternalServerErrorException (com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException)1 ControllerException (com.emc.storageos.volumecontroller.ControllerException)1 WorkflowException (com.emc.storageos.workflow.WorkflowException)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1