Search in sources :

Example 1 with UpdateCGPolicyParams

use of com.emc.storageos.recoverpoint.requests.UpdateCGPolicyParams in project coprhd-controller by CoprHD.

the class RPDeviceController method updateConsistencyGroupPolicyStep.

/**
 * Updates the consistency group policy (replication mode).
 *
 * @param protectionSystem
 *            the RP protection system
 * @param cgUri
 *            the consistency group ID
 * @param copyMode
 *            the copy/replication mode (sync or async)
 * @param stepId
 *            the step ID
 * @return true if the step executes successfully, false otherwise.
 */
public boolean updateConsistencyGroupPolicyStep(ProtectionSystem protectionSystem, URI cgUri, String copyMode, String stepId) {
    try {
        _log.info(String.format("Updating consistency group policy for CG %s.", cgUri));
        WorkflowStepCompleter.stepExecuting(stepId);
        RecoverPointClient rp = RPHelper.getRecoverPointClient(protectionSystem);
        BlockConsistencyGroup cg = _dbClient.queryObject(BlockConsistencyGroup.class, cgUri);
        // lock around update policy operations on the same CG
        List<String> lockKeys = new ArrayList<String>();
        lockKeys.add(ControllerLockingUtil.getConsistencyGroupStorageKey(_dbClient, cgUri, protectionSystem.getId()));
        boolean lockAcquired = _workflowService.acquireWorkflowStepLocks(stepId, lockKeys, LockTimeoutValue.get(LockType.RP_CG));
        if (!lockAcquired) {
            throw DeviceControllerException.exceptions.failedToAcquireLock(lockKeys.toString(), String.format("Upgrade policy for RP consistency group %s; id: %s", cg.getLabel(), cgUri.toString()));
        }
        CGPolicyParams policyParams = new CGPolicyParams(copyMode);
        UpdateCGPolicyParams updateParams = new UpdateCGPolicyParams(cg.getCgNameOnStorageSystem(protectionSystem.getId()), policyParams);
        rp.updateConsistencyGroupPolicy(updateParams);
        // Update the workflow state.
        WorkflowStepCompleter.stepSucceded(stepId);
    } catch (InternalException e) {
        _log.error("Operation failed with Exception: ", e);
        return stepFailed(stepId, (ServiceCoded) e, "updateConsistencyGroupPolicyStep");
    } catch (Exception e) {
        _log.error("Operation failed with Exception: ", e);
        return stepFailed(stepId, e, "updateConsistencyGroupPolicyStep");
    }
    return true;
}
Also used : ServiceCoded(com.emc.storageos.svcs.errorhandling.model.ServiceCoded) RecoverPointClient(com.emc.storageos.recoverpoint.impl.RecoverPointClient) ArrayList(java.util.ArrayList) UpdateCGPolicyParams(com.emc.storageos.recoverpoint.requests.UpdateCGPolicyParams) 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) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup) UpdateCGPolicyParams(com.emc.storageos.recoverpoint.requests.UpdateCGPolicyParams) CGPolicyParams(com.emc.storageos.recoverpoint.requests.CGPolicyParams) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException)

Aggregations

FunctionalAPIActionFailedException_Exception (com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception)1 FunctionalAPIInternalError_Exception (com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception)1 CoordinatorException (com.emc.storageos.coordinator.exceptions.CoordinatorException)1 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)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 CGPolicyParams (com.emc.storageos.recoverpoint.requests.CGPolicyParams)1 UpdateCGPolicyParams (com.emc.storageos.recoverpoint.requests.UpdateCGPolicyParams)1 ServiceCoded (com.emc.storageos.svcs.errorhandling.model.ServiceCoded)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 URISyntaxException (java.net.URISyntaxException)1 ArrayList (java.util.ArrayList)1