Search in sources :

Example 1 with CGPolicyParams

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

the class RPDeviceController method getCGRequestParams.

/**
 * Create the RP Client consistency group request object based on the incoming prepared volumes.
 *
 * @param volumeDescriptors
 *            volume descriptor objects
 * @param rpSystem
 * @return RP request to create CG
 * @throws DatabaseException
 */
private CGRequestParams getCGRequestParams(List<VolumeDescriptor> volumeDescriptors, ProtectionSystem rpSystem) throws DatabaseException {
    _log.info("Creating CG Request param...");
    // Maps of replication set request objects, where the key is the rset name itself
    Map<String, CreateRSetParams> rsetParamsMap = new HashMap<String, CreateRSetParams>();
    // Maps of the copy request objects, where the key is the copy name itself
    Map<String, CreateCopyParams> copyParamsMap = new HashMap<String, CreateCopyParams>();
    // The parameters we need at the CG Level that we can only get from looking at the Volumes
    Project project = null;
    String cgName = null;
    Set<String> productionCopies = new HashSet<String>();
    BlockConsistencyGroup cg = null;
    String copyMode = null;
    String rpoType = null;
    Long rpoValue = null;
    int maxNumberOfSnapShots = 0;
    Map<URI, Volume> volumeMap = new HashMap<URI, Volume>();
    // Sort the volume descriptors using the natural order of the enum.
    // In this case sort as:
    // SOURCE, TARGET, JOURNAL
    // We want SOURCE volumes to be processed first below to populate the
    // productionCopies in order.
    VolumeDescriptor.sortByType(volumeDescriptors);
    // Next create all of the request objects we need
    for (VolumeDescriptor volumeDescriptor : volumeDescriptors) {
        Volume volume = null;
        if (volumeMap.containsKey(volumeDescriptor.getVolumeURI())) {
            volume = volumeMap.get(volumeDescriptor.getVolumeURI());
        } else {
            volume = _dbClient.queryObject(Volume.class, volumeDescriptor.getVolumeURI());
            volumeMap.put(volume.getId(), volume);
        }
        boolean isMetroPoint = RPHelper.isMetroPointVolume(_dbClient, volume);
        boolean isRPSource = RPHelper.isRPSource(volumeDescriptor);
        boolean isRPTarget = RPHelper.isRPTarget(volumeDescriptor);
        boolean extraParamsGathered = false;
        if (volumeDescriptor.getCapabilitiesValues() != null) {
            maxNumberOfSnapShots = volumeDescriptor.getCapabilitiesValues().getRPMaxSnaps();
        }
        // Set up the source and target volumes in their respective replication sets
        if (isRPSource || isRPTarget) {
            // Gather the extra params we need (once is sufficient)
            if (isRPSource && !extraParamsGathered) {
                project = _dbClient.queryObject(Project.class, volume.getProject());
                cg = _dbClient.queryObject(BlockConsistencyGroup.class, volumeDescriptor.getCapabilitiesValues().getBlockConsistencyGroup());
                cgName = cg.getCgNameOnStorageSystem(rpSystem.getId());
                if (cgName == null) {
                    cgName = CG_NAME_PREFIX + cg.getLabel();
                }
                copyMode = volumeDescriptor.getCapabilitiesValues().getRpCopyMode();
                rpoType = volumeDescriptor.getCapabilitiesValues().getRpRpoType();
                rpoValue = volumeDescriptor.getCapabilitiesValues().getRpRpoValue();
                // Flag so we only grab this information once
                extraParamsGathered = true;
            }
            if (isMetroPoint && isRPSource) {
                // we need to handle metropoint request a bit differently.
                // since the same metro volume will be part of 2 (production) copies in the replication set,
                // we need to fetch the correct internal site names and other site related parameters from the
                // backing volume.
                StringSet backingVolumes = volume.getAssociatedVolumes();
                if (null == backingVolumes || backingVolumes.isEmpty()) {
                    _log.error("VPLEX volume {} has no backend volumes.", volume.forDisplay());
                    throw InternalServerErrorException.internalServerErrors.noAssociatedVolumesForVPLEXVolume(volume.forDisplay());
                }
                for (String backingVolumeStr : backingVolumes) {
                    Volume backingVolume = _dbClient.queryObject(Volume.class, URI.create(backingVolumeStr));
                    CreateVolumeParams volumeParams = populateVolumeParams(volume.getId(), volume.getStorageController(), backingVolume.getVirtualArray(), backingVolume.getInternalSiteName(), true, backingVolume.getRpCopyName(), RPHelper.getRPWWn(volume.getId(), _dbClient), maxNumberOfSnapShots);
                    _log.info(String.format("Creating RSet Param for MetroPoint RP PROD - VOLUME: [%s] Name: [%s]", backingVolume.getLabel(), volume.getRSetName()));
                    populateRsetsMap(rsetParamsMap, volumeParams, volume);
                    productionCopies.add(backingVolume.getRpCopyName());
                }
            } else {
                CreateVolumeParams volumeParams = populateVolumeParams(volume.getId(), volume.getStorageController(), volume.getVirtualArray(), volume.getInternalSiteName(), isRPSource, volume.getRpCopyName(), RPHelper.getRPWWn(volume.getId(), _dbClient), maxNumberOfSnapShots);
                String type = isRPSource ? "PROD" : "TARGET";
                _log.info(String.format("Creating RSet Param for RP %s - VOLUME: [%s] Name: [%s]", type, volume.getLabel(), volume.getRSetName()));
                populateRsetsMap(rsetParamsMap, volumeParams, volume);
                if (isRPSource) {
                    productionCopies.add(volume.getRpCopyName());
                }
            }
        }
        // Set up the journal volumes in the copy objects
        if (volumeDescriptor.getType().equals(VolumeDescriptor.Type.RP_JOURNAL) || volumeDescriptor.getType().equals(VolumeDescriptor.Type.RP_VPLEX_VIRT_JOURNAL)) {
            if (cgName == null) {
                project = _dbClient.queryObject(Project.class, volume.getProject());
                cg = _dbClient.queryObject(BlockConsistencyGroup.class, volumeDescriptor.getCapabilitiesValues().getBlockConsistencyGroup());
                cgName = cg.getCgNameOnStorageSystem(rpSystem.getId());
                if (cgName == null) {
                    cgName = CG_NAME_PREFIX + cg.getLabel();
                }
            }
            CreateVolumeParams volumeParams = populateVolumeParams(volume.getId(), volume.getStorageController(), volume.getVirtualArray(), volume.getInternalSiteName(), RPHelper.isProductionJournal(productionCopies, volume), volume.getRpCopyName(), RPHelper.getRPWWn(volume.getId(), _dbClient), maxNumberOfSnapShots);
            String key = volume.getRpCopyName();
            _log.info(String.format("Creating Copy Param for RP JOURNAL: VOLUME - [%s] Name: [%s]", volume.getLabel(), key));
            if (copyParamsMap.containsKey(key)) {
                copyParamsMap.get(key).getJournals().add(volumeParams);
            } else {
                CreateCopyParams copyParams = new CreateCopyParams();
                copyParams.setName(key);
                copyParams.setJournals(new ArrayList<CreateVolumeParams>());
                copyParams.getJournals().add(volumeParams);
                copyParamsMap.put(key, copyParams);
            }
        }
    }
    // Set up the CG Request
    CGRequestParams cgParams = new CGRequestParams();
    cgParams.setCopies(new ArrayList<CreateCopyParams>());
    cgParams.getCopies().addAll(copyParamsMap.values());
    cgParams.setRsets(new ArrayList<CreateRSetParams>());
    cgParams.getRsets().addAll(rsetParamsMap.values());
    cgParams.setCgName(cgName);
    cgParams.setCgUri(cg.getId());
    cgParams.setProject(project.getId());
    cgParams.setTenant(project.getTenantOrg().getURI());
    CGPolicyParams policyParams = new CGPolicyParams();
    policyParams.setCopyMode(copyMode);
    policyParams.setRpoType(rpoType);
    policyParams.setRpoValue(rpoValue);
    cgParams.setCgPolicy(policyParams);
    _log.info(String.format("CG Request param complete:%n %s", cgParams));
    return cgParams;
}
Also used : VolumeDescriptor(com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor) CreateRSetParams(com.emc.storageos.recoverpoint.requests.CreateRSetParams) HashMap(java.util.HashMap) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) Constraint(com.emc.storageos.db.client.constraint.Constraint) CreateVolumeParams(com.emc.storageos.recoverpoint.requests.CreateVolumeParams) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup) UpdateCGPolicyParams(com.emc.storageos.recoverpoint.requests.UpdateCGPolicyParams) CGPolicyParams(com.emc.storageos.recoverpoint.requests.CGPolicyParams) Project(com.emc.storageos.db.client.model.Project) Volume(com.emc.storageos.db.client.model.Volume) StringSet(com.emc.storageos.db.client.model.StringSet) CGRequestParams(com.emc.storageos.recoverpoint.requests.CGRequestParams) CreateCopyParams(com.emc.storageos.recoverpoint.requests.CreateCopyParams) HashSet(java.util.HashSet)

Example 2 with CGPolicyParams

use of com.emc.storageos.recoverpoint.requests.CGPolicyParams 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

BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)2 CGPolicyParams (com.emc.storageos.recoverpoint.requests.CGPolicyParams)2 UpdateCGPolicyParams (com.emc.storageos.recoverpoint.requests.UpdateCGPolicyParams)2 FunctionalAPIActionFailedException_Exception (com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception)1 FunctionalAPIInternalError_Exception (com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception)1 VolumeDescriptor (com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor)1 CoordinatorException (com.emc.storageos.coordinator.exceptions.CoordinatorException)1 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)1 Constraint (com.emc.storageos.db.client.constraint.Constraint)1 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)1 NamedURI (com.emc.storageos.db.client.model.NamedURI)1 Project (com.emc.storageos.db.client.model.Project)1 StringSet (com.emc.storageos.db.client.model.StringSet)1 Volume (com.emc.storageos.db.client.model.Volume)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 CGRequestParams (com.emc.storageos.recoverpoint.requests.CGRequestParams)1