Search in sources :

Example 1 with CGRequestParams

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

the class RPDeviceController method cgCreateStep.

/**
 * Workflow step method for creating/updating a consistency group.
 *
 * @param rpSystemId
 *            RP system Id
 * @param recommendation
 *            parameters needed to create the CG
 * @param token
 *            the task
 * @return
 * @throws InternalException
 */
public boolean cgCreateStep(URI rpSystemId, List<VolumeDescriptor> volumeDescriptors, String token) throws InternalException {
    RecoverPointClient rp;
    CGRequestParams cgParams = null;
    boolean metropoint = false;
    boolean lockException = false;
    RPHelper.setLinkStateWaitTimeOut(_coordinator);
    try {
        // Get only the RP volumes from the descriptors.
        List<VolumeDescriptor> sourceVolumeDescriptors = VolumeDescriptor.filterByType(volumeDescriptors, new VolumeDescriptor.Type[] { VolumeDescriptor.Type.RP_SOURCE, VolumeDescriptor.Type.RP_EXISTING_SOURCE, VolumeDescriptor.Type.RP_VPLEX_VIRT_SOURCE }, new VolumeDescriptor.Type[] {});
        WorkflowStepCompleter.stepExecuting(token);
        ProtectionSystem rpSystem = _dbClient.queryObject(ProtectionSystem.class, rpSystemId);
        URI cgId = volumeDescriptors.iterator().next().getCapabilitiesValues().getBlockConsistencyGroup();
        boolean attachAsClean = true;
        for (VolumeDescriptor sourceVolumedescriptor : sourceVolumeDescriptors) {
            Volume sourceVolume = _dbClient.queryObject(Volume.class, sourceVolumedescriptor.getVolumeURI());
            metropoint = RPHelper.isMetroPointVolume(_dbClient, sourceVolume);
            // if this is a change vpool, attachAsClean should be false so that source and target are synchronized
            if (VolumeDescriptor.Type.RP_EXISTING_SOURCE.equals(sourceVolumedescriptor.getType())) {
                attachAsClean = false;
            }
        }
        // Build the CG Request params
        cgParams = getCGRequestParams(volumeDescriptors, rpSystem);
        updateCGParams(cgParams);
        // Validate the source/target volumes before creating a CG.
        validateCGVolumes(volumeDescriptors);
        rp = RPHelper.getRecoverPointClient(rpSystem);
        // Scan the rp sites for volume visibility
        rp.waitForVolumesToBeVisible(cgParams);
        // Before acquiring a lock on the CG we need to ensure that the
        // CG is created. If it hasn't, then the first CGRequestParams
        // to be allowed to pass through needs to have the journals
        // defined.
        // 
        // NOTE: The CG may not yet be created on the RP protection system and
        // that's OK since this might be the first request going in.
        waitForCGToBeCreated(cgId, cgParams);
        // lock around create and delete operations on the same CG
        List<String> lockKeys = new ArrayList<String>();
        lockKeys.add(ControllerLockingUtil.getConsistencyGroupStorageKey(_dbClient, cgId, rpSystem.getId()));
        boolean lockAcquired = _workflowService.acquireWorkflowStepLocks(token, lockKeys, LockTimeoutValue.get(LockType.RP_CG));
        if (!lockAcquired) {
            lockException = true;
            throw DeviceControllerException.exceptions.failedToAcquireLock(lockKeys.toString(), String.format("Create or add volumes to RP consistency group id: %s", cgId.toString()));
        }
        RecoverPointCGResponse response = null;
        // The CG already exists if it contains volumes and is of type RP
        _log.info("Submitting RP Request: " + cgParams);
        BlockConsistencyGroup cg = _dbClient.queryObject(BlockConsistencyGroup.class, cgId);
        // Check to see if the CG has been created in ViPR and on the RP protection system
        boolean cgAlreadyExists = rpCGExists(cg, rp, cgParams.getCgName(), rpSystem.getId());
        if (cgAlreadyExists) {
            // cg exists in both the ViPR db and on the RP system
            _log.info(String.format("RP CG [%s] already exists, adding replication set(s) to it...", cgParams.getCgName()));
            response = rp.addReplicationSetsToCG(cgParams, metropoint, attachAsClean);
        } else {
            _log.info(String.format("RP CG [%s] does not already exist, creating it now and adding replication set(s) to it...", cgParams.getCgName()));
            response = rp.createCG(cgParams, metropoint, attachAsClean);
            // "Turn-on" the consistency group
            cg = _dbClient.queryObject(BlockConsistencyGroup.class, cgParams.getCgUri());
            cg.addSystemConsistencyGroup(rpSystemId.toString(), cgParams.getCgName());
            cg.addConsistencyGroupTypes(Types.RP.name());
        }
        // At this point, always clear the journal provisioning lock on the
        // CG for any concurrent orders that may come in.
        cg.setJournalProvisioningLock(0L);
        _dbClient.updateObject(cg);
        setVolumeConsistencyGroup(volumeDescriptors, cgParams.getCgUri());
        // If this was a vpool Update, now is a good time to update the vpool and Volume information
        if (VolumeDescriptor.getVirtualPoolChangeVolume(volumeDescriptors) != null) {
            Volume volume = _dbClient.queryObject(Volume.class, VolumeDescriptor.getVirtualPoolChangeVolume(volumeDescriptors));
            URI newVpoolURI = getVirtualPoolChangeNewVirtualPool(volumeDescriptors);
            volume.setVirtualPool(newVpoolURI);
            volume.setPersonality(Volume.PersonalityTypes.SOURCE.toString());
            volume.setAccessState(Volume.VolumeAccessState.READWRITE.name());
            volume.setLinkStatus(Volume.LinkStatus.IN_SYNC.name());
            volume.setProtectionController(rpSystemId);
            _dbClient.updateObject(volume);
            // We might need to update the vpools of the backing volumes if this is an RP+VPLEX
            // or MetroPoint change vpool.
            VPlexUtil.updateVPlexBackingVolumeVpools(volume, newVpoolURI, _dbClient);
            // Record Audit operation. (virtualpool change only)
            AuditBlockUtil.auditBlock(_dbClient, OperationTypeEnum.CHANGE_VOLUME_VPOOL, true, AuditLogManager.AUDITOP_END, token);
        }
        // Create the ProtectionSet to contain the CG UID (which is truly unique to the protection system)
        if (response.getCgId() != null) {
            List<ProtectionSet> protectionSets = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, ProtectionSet.class, AlternateIdConstraint.Factory.getConstraint(ProtectionSet.class, "protectionId", response.getCgId().toString()));
            ProtectionSet protectionSet = null;
            if (protectionSets.isEmpty()) {
                // A protection set corresponding to the CG does not exist so we need to create one
                protectionSet = createProtectionSet(rpSystem, cgParams, response.getCgId());
            } else {
                // Update the existing protection set. We will only have 1 protection set
                // get the first one.
                protectionSet = protectionSets.get(0);
                protectionSet = updateProtectionSet(protectionSet, cgParams);
            }
            _dbClient.updateObject(protectionSet);
        }
        // Set the CG last created time to now.
        rpSystem.setCgLastCreatedTime(Calendar.getInstance());
        _dbClient.updateObject(rpSystem);
        // Update the workflow state.
        WorkflowStepCompleter.stepSucceded(token);
        // collect and update the protection system statistics to account for
        // the newly created CG.
        _log.info("Collecting RP statistics post CG create.");
        collectRPStatistics(rpSystem);
    } catch (Exception e) {
        if (lockException) {
            List<URI> volUris = VolumeDescriptor.getVolumeURIs(volumeDescriptors);
            ServiceError serviceError = DeviceControllerException.errors.createVolumesAborted(volUris.toString(), e);
            doFailCgCreateStep(volumeDescriptors, cgParams, rpSystemId, token);
            stepFailed(token, serviceError, "cgCreateStep");
        } else {
            doFailCgCreateStep(volumeDescriptors, cgParams, rpSystemId, token);
            stepFailed(token, e, "cgCreateStep");
        }
        return false;
    }
    return true;
}
Also used : RecoverPointCGResponse(com.emc.storageos.recoverpoint.responses.RecoverPointCGResponse) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) VolumeDescriptor(com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor) ArrayList(java.util.ArrayList) ProtectionSet(com.emc.storageos.db.client.model.ProtectionSet) ProtectionSystem(com.emc.storageos.db.client.model.ProtectionSystem) 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) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup) Volume(com.emc.storageos.db.client.model.Volume) RecoverPointClient(com.emc.storageos.recoverpoint.impl.RecoverPointClient) CGRequestParams(com.emc.storageos.recoverpoint.requests.CGRequestParams) ApplicationAddVolumeList(com.emc.storageos.volumecontroller.ApplicationAddVolumeList) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) List(java.util.List)

Example 2 with CGRequestParams

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

the class RPDeviceController method exportOrchestrationSteps.

/**
 * @param volumeDescriptors
 *            - Volume descriptors
 * @param rpSystemId
 *            - RP system
 * @param taskId
 *            - task ID
 * @return - True on success, false otherwise
 * @throws InternalException
 */
public boolean exportOrchestrationSteps(List<VolumeDescriptor> volumeDescriptors, URI rpSystemId, String taskId) throws InternalException {
    List<URI> volUris = VolumeDescriptor.getVolumeURIs(volumeDescriptors);
    RPCGExportOrchestrationCompleter completer = new RPCGExportOrchestrationCompleter(volUris, taskId);
    Workflow workflow = null;
    boolean lockException = false;
    Map<URI, Set<URI>> exportGroupVolumesAdded = new HashMap<URI, Set<URI>>();
    exportGroupsCreated = new ArrayList<URI>();
    final String COMPUTE_RESOURCE_CLUSTER = "cluster";
    try {
        final String workflowKey = "rpExportOrchestration";
        if (!WorkflowService.getInstance().hasWorkflowBeenCreated(taskId, workflowKey)) {
            // Generate the Workflow.
            workflow = _workflowService.getNewWorkflow(this, EXPORT_ORCHESTRATOR_WF_NAME, true, taskId);
            // the wait for key returned by previous call
            String waitFor = null;
            ProtectionSystem rpSystem = _dbClient.queryObject(ProtectionSystem.class, rpSystemId);
            // Get the CG Params based on the volume descriptors
            CGRequestParams params = this.getCGRequestParams(volumeDescriptors, rpSystem);
            updateCGParams(params);
            _log.info("Start adding RP Export Volumes steps....");
            // Get the RP Exports from the CGRequestParams object
            Collection<RPExport> rpExports = generateStorageSystemExportMaps(params, volumeDescriptors);
            Map<String, Set<URI>> rpSiteInitiatorsMap = getRPSiteInitiators(rpSystem, rpExports);
            // Acquire all the RP lock keys needed for export before we start assembling the export groups.
            acquireRPLockKeysForExport(taskId, rpExports, rpSiteInitiatorsMap);
            // or create a new one.
            for (RPExport rpExport : rpExports) {
                URI storageSystemURI = rpExport.getStorageSystem();
                String internalSiteName = rpExport.getRpSite();
                URI varrayURI = rpExport.getVarray();
                List<URI> volumes = rpExport.getVolumes();
                List<URI> initiatorSet = new ArrayList<URI>();
                String rpSiteName = (rpSystem.getRpSiteNames() != null) ? rpSystem.getRpSiteNames().get(internalSiteName) : internalSiteName;
                StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, storageSystemURI);
                VirtualArray varray = _dbClient.queryObject(VirtualArray.class, varrayURI);
                _log.info("--------------------");
                _log.info(String.format("RP Export: StorageSystem = [%s] RPSite = [%s] VirtualArray = [%s]", storageSystem.getLabel(), rpSiteName, varray.getLabel()));
                boolean isJournalExport = rpExport.getIsJournalExport();
                String exportGroupGeneratedName = RPHelper.generateExportGroupName(rpSystem, storageSystem, internalSiteName, varray, isJournalExport);
                // Setup the export group - we may or may not need to create it, but we need to have everything ready in case we do
                ExportGroup exportGroup = RPHelper.createRPExportGroup(exportGroupGeneratedName, varray, _dbClient.queryObject(Project.class, params.getProject()), 0, isJournalExport);
                // Get the initiators of the RP Cluster (all of the RPAs on one side of a configuration)
                Map<String, Map<String, String>> rpaWWNs = RPHelper.getRecoverPointClient(rpSystem).getInitiatorWWNs(internalSiteName);
                if (rpaWWNs == null || rpaWWNs.isEmpty()) {
                    throw DeviceControllerExceptions.recoverpoint.noInitiatorsFoundOnRPAs();
                }
                // Convert to initiator object
                List<Initiator> initiators = new ArrayList<Initiator>();
                for (String rpaId : rpaWWNs.keySet()) {
                    for (Map.Entry<String, String> rpaWWN : rpaWWNs.get(rpaId).entrySet()) {
                        Initiator initiator = ExportUtils.getInitiator(rpaWWN.getKey(), _dbClient);
                        initiators.add(initiator);
                    }
                }
                // We need to find and distill only those RP initiators that correspond to the network of the
                // storage
                // system and
                // that network has front end port from the storage system.
                // In certain lab environments, its quite possible that there are 2 networks one for the storage
                // system
                // FE ports and one for
                // the BE ports.
                // In such configs, RP initiators will be spread across those 2 networks. RP controller does not
                // care
                // about storage system
                // back-end ports, so
                // we will ignore those initiators that are connected to a network that has only storage system back
                // end
                // port connectivity.
                Map<URI, Set<Initiator>> rpNetworkToInitiatorsMap = new HashMap<URI, Set<Initiator>>();
                Set<URI> rpSiteInitiatorUris = rpSiteInitiatorsMap.get(internalSiteName);
                if (rpSiteInitiatorUris != null) {
                    for (URI rpSiteInitiatorUri : rpSiteInitiatorUris) {
                        Initiator rpSiteInitiator = _dbClient.queryObject(Initiator.class, rpSiteInitiatorUri);
                        URI rpInitiatorNetworkURI = getInitiatorNetwork(exportGroup, rpSiteInitiator);
                        if (rpInitiatorNetworkURI != null) {
                            if (rpNetworkToInitiatorsMap.get(rpInitiatorNetworkURI) == null) {
                                rpNetworkToInitiatorsMap.put(rpInitiatorNetworkURI, new HashSet<Initiator>());
                            }
                            rpNetworkToInitiatorsMap.get(rpInitiatorNetworkURI).add(rpSiteInitiator);
                            _log.info(String.format("RP Initiator [%s] found on network: [%s]", rpSiteInitiator.getInitiatorPort(), rpInitiatorNetworkURI.toASCIIString()));
                        } else {
                            _log.info(String.format("RP Initiator [%s] was not found on any network. Excluding from automated exports", rpSiteInitiator.getInitiatorPort()));
                        }
                    }
                }
                // Compute numPaths. This is how its done:
                // We know the RP site and the Network/TransportZone it is on.
                // Determine all the storage ports for the storage array for all the networks they are on.
                // Next, if we find the network for the RP site in the above list, return all the storage ports
                // corresponding to that.
                // For RP we will try and use as many Storage ports as possible.
                Map<URI, List<StoragePort>> initiatorPortMap = getInitiatorPortsForArray(rpNetworkToInitiatorsMap, storageSystemURI, varrayURI, rpSiteName);
                for (URI networkURI : initiatorPortMap.keySet()) {
                    for (StoragePort storagePort : initiatorPortMap.get(networkURI)) {
                        _log.info(String.format("Network : [%s] - Port : [%s]", networkURI.toString(), storagePort.getLabel()));
                    }
                }
                int numPaths = computeNumPaths(initiatorPortMap, varrayURI, storageSystem);
                _log.info("Total paths = " + numPaths);
                // Stems from above comment where we distill the RP network and the initiators in that network.
                List<Initiator> initiatorList = new ArrayList<Initiator>();
                for (URI rpNetworkURI : rpNetworkToInitiatorsMap.keySet()) {
                    if (initiatorPortMap.containsKey(rpNetworkURI)) {
                        initiatorList.addAll(rpNetworkToInitiatorsMap.get(rpNetworkURI));
                    }
                }
                for (Initiator initiator : initiatorList) {
                    initiatorSet.add(initiator.getId());
                }
                // See if the export group already exists
                ExportGroup exportGroupInDB = exportGroupExistsInDB(exportGroup);
                boolean addExportGroupToDB = false;
                if (exportGroupInDB != null) {
                    exportGroup = exportGroupInDB;
                    // If the export already exists, check to see if any of the volumes have already been exported.
                    // No
                    // need to
                    // re-export volumes.
                    List<URI> volumesToRemove = new ArrayList<URI>();
                    for (URI volumeURI : volumes) {
                        if (exportGroup.getVolumes() != null && !exportGroup.getVolumes().isEmpty() && exportGroup.getVolumes().containsKey(volumeURI.toString())) {
                            _log.info(String.format("Volume [%s] already exported to export group [%s], " + "it will be not be re-exported", volumeURI.toString(), exportGroup.getGeneratedName()));
                            volumesToRemove.add(volumeURI);
                        }
                    }
                    // Remove volumes if they have already been exported
                    if (!volumesToRemove.isEmpty()) {
                        volumes.removeAll(volumesToRemove);
                    }
                    // nothing else needs to be done here.
                    if (volumes.isEmpty()) {
                        _log.info(String.format("No volumes needed to be exported to export group [%s], continue", exportGroup.getGeneratedName()));
                        continue;
                    }
                } else {
                    addExportGroupToDB = true;
                }
                // Add volumes to the export group
                Map<URI, Integer> volumesToAdd = new HashMap<URI, Integer>();
                for (URI volumeID : volumes) {
                    exportGroup.addVolume(volumeID, ExportGroup.LUN_UNASSIGNED);
                    volumesToAdd.put(volumeID, ExportGroup.LUN_UNASSIGNED);
                }
                // Keep track of volumes added to export group
                if (!volumesToAdd.isEmpty()) {
                    exportGroupVolumesAdded.put(exportGroup.getId(), volumesToAdd.keySet());
                }
                // volume
                if (rpExport.getComputeResource() != null) {
                    URI computeResource = rpExport.getComputeResource();
                    _log.info(String.format("RP Export: ComputeResource : %s", computeResource.toString()));
                    if (computeResource.toString().toLowerCase().contains(COMPUTE_RESOURCE_CLUSTER)) {
                        Cluster cluster = _dbClient.queryObject(Cluster.class, computeResource);
                        exportGroup.addCluster(cluster);
                    } else {
                        Host host = _dbClient.queryObject(Host.class, rpExport.getComputeResource());
                        exportGroup.addHost(host);
                    }
                }
                // Persist the export group
                if (addExportGroupToDB) {
                    exportGroup.addInitiators(initiatorSet);
                    exportGroup.setNumPaths(numPaths);
                    _dbClient.createObject(exportGroup);
                    // Keep track of newly created EGs in case of rollback
                    exportGroupsCreated.add(exportGroup.getId());
                } else {
                    _dbClient.updateObject(exportGroup);
                }
                // If the export group already exists, add the volumes to it, otherwise create a brand new
                // export group.
                StringBuilder buffer = new StringBuilder();
                buffer.append(String.format(DASHED_NEWLINE));
                if (!addExportGroupToDB) {
                    buffer.append(String.format("Adding volumes to existing Export Group for Storage System [%s], RP Site [%s], Virtual Array [%s]%n", storageSystem.getLabel(), rpSiteName, varray.getLabel()));
                    buffer.append(String.format("Export Group name is : [%s]%n", exportGroup.getGeneratedName()));
                    buffer.append(String.format("Export Group will have these volumes added: [%s]%n", Joiner.on(',').join(volumes)));
                    buffer.append(String.format(DASHED_NEWLINE));
                    _log.info(buffer.toString());
                    waitFor = _exportWfUtils.generateExportGroupAddVolumes(workflow, STEP_EXPORT_GROUP, waitFor, storageSystemURI, exportGroup.getId(), volumesToAdd);
                    _log.info("Added Export Group add volumes step in workflow");
                } else {
                    buffer.append(String.format("Creating new Export Group for Storage System [%s], RP Site [%s], Virtual Array [%s]%n", storageSystem.getLabel(), rpSiteName, varray.getLabel()));
                    buffer.append(String.format("Export Group name is: [%s]%n", exportGroup.getGeneratedName()));
                    buffer.append(String.format("Export Group will have these initiators: [%s]%n", Joiner.on(',').join(initiatorSet)));
                    buffer.append(String.format("Export Group will have these volumes added: [%s]%n", Joiner.on(',').join(volumes)));
                    buffer.append(String.format(DASHED_NEWLINE));
                    _log.info(buffer.toString());
                    String exportStep = workflow.createStepId();
                    initTaskStatus(exportGroup, exportStep, Operation.Status.pending, "create export");
                    waitFor = _exportWfUtils.generateExportGroupCreateWorkflow(workflow, STEP_EXPORT_GROUP, waitFor, storageSystemURI, exportGroup.getId(), volumesToAdd, initiatorSet);
                    _log.info("Added Export Group create step in workflow. New Export Group Id: " + exportGroup.getId());
                }
            }
            String successMessage = "Export orchestration completed successfully";
            // Finish up and execute the plan.
            // The Workflow will handle the TaskCompleter
            Object[] callbackArgs = new Object[] { volUris };
            workflow.executePlan(completer, successMessage, new WorkflowCallback(), callbackArgs, null, null);
            // Mark this workflow as created/executed so we don't do it again on retry/resume
            WorkflowService.getInstance().markWorkflowBeenCreated(taskId, workflowKey);
        }
    } catch (LockRetryException ex) {
        /**
         * Added this catch block to mark the current workflow as completed so that lock retry will not get exception while creating new
         * workflow using the same taskid.
         */
        _log.warn(String.format("Lock retry exception key: %s remaining time %d", ex.getLockIdentifier(), ex.getRemainingWaitTimeSeconds()));
        if (workflow != null && !NullColumnValueGetter.isNullURI(workflow.getWorkflowURI()) && workflow.getWorkflowState() == WorkflowState.CREATED) {
            com.emc.storageos.db.client.model.Workflow wf = _dbClient.queryObject(com.emc.storageos.db.client.model.Workflow.class, workflow.getWorkflowURI());
            if (!wf.getCompleted()) {
                _log.error("Marking the status to completed for the newly created workflow {}", wf.getId());
                wf.setCompleted(true);
                _dbClient.updateObject(wf);
            }
        }
        throw ex;
    } catch (Exception ex) {
        _log.error("Could not create volumes: " + volUris, ex);
        // Rollback ViPR level RP export group changes
        rpExportGroupRollback();
        if (workflow != null) {
            _workflowService.releaseAllWorkflowLocks(workflow);
        }
        String opName = ResourceOperationTypeEnum.CREATE_BLOCK_VOLUME.getName();
        ServiceError serviceError = null;
        if (lockException) {
            serviceError = DeviceControllerException.errors.createVolumesAborted(volUris.toString(), ex);
        } else {
            serviceError = DeviceControllerException.errors.createVolumesFailed(volUris.toString(), opName, ex);
        }
        completer.error(_dbClient, _locker, serviceError);
        return false;
    }
    _log.info("End adding RP Export Volumes steps.");
    return true;
}
Also used : VirtualArray(com.emc.storageos.db.client.model.VirtualArray) ProtectionSet(com.emc.storageos.db.client.model.ProtectionSet) Set(java.util.Set) HashSet(java.util.HashSet) StringSet(com.emc.storageos.db.client.model.StringSet) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) ProtectionSystem(com.emc.storageos.db.client.model.ProtectionSystem) RPCGExportOrchestrationCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.RPCGExportOrchestrationCompleter) Initiator(com.emc.storageos.db.client.model.Initiator) ApplicationAddVolumeList(com.emc.storageos.volumecontroller.ApplicationAddVolumeList) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) List(java.util.List) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) StoragePort(com.emc.storageos.db.client.model.StoragePort) Workflow(com.emc.storageos.workflow.Workflow) Cluster(com.emc.storageos.db.client.model.Cluster) Host(com.emc.storageos.db.client.model.Host) LockRetryException(com.emc.storageos.locking.LockRetryException) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) Constraint(com.emc.storageos.db.client.constraint.Constraint) 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) ExportGroup(com.emc.storageos.db.client.model.ExportGroup) Project(com.emc.storageos.db.client.model.Project) CGRequestParams(com.emc.storageos.recoverpoint.requests.CGRequestParams) BlockObject(com.emc.storageos.db.client.model.BlockObject) DataObject(com.emc.storageos.db.client.model.DataObject) Map(java.util.Map) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) OpStatusMap(com.emc.storageos.db.client.model.OpStatusMap) HashMap(java.util.HashMap)

Example 3 with CGRequestParams

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

the class RPDeviceController method addJournalStep.

/**
 * This operation will add additional journal volumes to a recoverpoint consistency group
 *
 * @param rpSystemId
 *            - recoverpoint system
 * @param volumeDescriptors
 *            - journal volumes to add
 * @param taskId
 *            - task tracking the operation
 * @return boolean indicating the result of the operation
 */
public boolean addJournalStep(URI rpSystemId, List<VolumeDescriptor> volumeDescriptors, String taskId) {
    WorkflowStepCompleter.stepExecuting(taskId);
    if (volumeDescriptors.isEmpty()) {
        stepFailed(taskId, "addJournalStep");
    }
    ProtectionSystem rpSystem = _dbClient.queryObject(ProtectionSystem.class, rpSystemId);
    RecoverPointClient rp = RPHelper.getRecoverPointClient(rpSystem);
    CGRequestParams cgParams = this.getCGRequestParams(volumeDescriptors, rpSystem);
    updateCGParams(cgParams);
    try {
        rp.addJournalVolumesToCG(cgParams, volumeDescriptors.get(0).getCapabilitiesValues().getRPCopyType());
        WorkflowStepCompleter.stepSucceded(taskId);
    } catch (Exception e) {
        stepFailed(taskId, "addJournalStep");
    }
    return true;
}
Also used : RecoverPointClient(com.emc.storageos.recoverpoint.impl.RecoverPointClient) CGRequestParams(com.emc.storageos.recoverpoint.requests.CGRequestParams) ProtectionSystem(com.emc.storageos.db.client.model.ProtectionSystem) 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)

Example 4 with CGRequestParams

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

the class RecoverPointClientIntegrationTest method recreateCG.

public void recreateCG() throws RecoverPointException {
    RecoverPointVolumeProtectionInfo protectionInfo = null;
    try {
        protectionInfo = rpClient.getProtectionInfoForVolume(BourneRPTestProdLUN1WWN);
    } catch (RecoverPointException e) {
        logger.info("Ignore getProtectionInfoForVolume error");
    }
    if (protectionInfo != null) {
        logger.info("Delete previous CG (if it exists)");
        rpClient.deleteCG(protectionInfo);
    }
    logger.info("Create the CG with two replication sets");
    CGRequestParams createCGParams = createCGParamsHelper(true, true, 2);
    rpClient.createCG(createCGParams, false, false);
}
Also used : RecoverPointVolumeProtectionInfo(com.emc.storageos.recoverpoint.responses.RecoverPointVolumeProtectionInfo) RecoverPointException(com.emc.storageos.recoverpoint.exceptions.RecoverPointException) CGRequestParams(com.emc.storageos.recoverpoint.requests.CGRequestParams)

Example 5 with CGRequestParams

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

the class RecoverPointClientIntegrationTest method createCGParamsHelper.

public CGRequestParams createCGParamsHelper(boolean createCDP, boolean createCRR, int numRSets) {
    CGRequestParams params = new CGRequestParams();
    params.setJunitTest(true);
    if (createCDP && createCRR) {
        params.setCgName("BourneRPTestCDPAndCRR");
        logger.info("Create CG for CDP and CRR: BourneRPTestCDPAndCRR");
    } else if (createCDP) {
        params.setCgName("BourneRPTestCDPOnly");
        logger.info("Create CG for CDP: BourneRPTestCDPOnly");
    } else {
        params.setCgName("BourneRPTestCRROnly");
        logger.info("Create CG for CRR: BourneRPTestCRROnly");
    }
    List<CreateRSetParams> rsetParamList = new LinkedList<CreateRSetParams>();
    // Production copy (VNX: 10.247.160.30)
    CreateVolumeParams copyprodVolumeParams = new CreateVolumeParams();
    copyprodVolumeParams.setWwn(BourneRPTestProdLUN1WWN);
    copyprodVolumeParams.setInternalSiteName(site1InternalSiteName);
    copyprodVolumeParams.setProduction(true);
    List<CreateVolumeParams> rsetVolumeList = new ArrayList<CreateVolumeParams>();
    rsetVolumeList.add(copyprodVolumeParams);
    if (createCDP) {
        CreateVolumeParams copylocalVolumeParams = new CreateVolumeParams();
        copylocalVolumeParams.setWwn(BourneRPTestCDPLUN1WWN);
        copylocalVolumeParams.setInternalSiteName(site1InternalSiteName);
        copylocalVolumeParams.setProduction(false);
        rsetVolumeList.add(copylocalVolumeParams);
    }
    if (createCRR) {
        CreateVolumeParams copyremoteVolumeParams = new CreateVolumeParams();
        copyremoteVolumeParams.setWwn(BourneRPTestCRRLUN1WWN);
        copyremoteVolumeParams.setInternalSiteName(site2InternalSiteName);
        copyremoteVolumeParams.setProduction(false);
        rsetVolumeList.add(copyremoteVolumeParams);
    }
    CreateRSetParams rset = new CreateRSetParams();
    rset.setName("RSet1");
    rset.setVolumes(rsetVolumeList);
    rsetParamList.add(rset);
    // Replication set 2
    if (numRSets > 1) {
        CreateVolumeParams r2copyprodVolumeParams = new CreateVolumeParams();
        r2copyprodVolumeParams.setWwn(BourneRPTestProdLUN2WWN);
        r2copyprodVolumeParams.setInternalSiteName(site1InternalSiteName);
        r2copyprodVolumeParams.setProduction(true);
        rsetVolumeList = new ArrayList<CreateVolumeParams>();
        rsetVolumeList.add(r2copyprodVolumeParams);
        if (createCDP) {
            CreateVolumeParams r2copylocalVolumeParams = new CreateVolumeParams();
            r2copylocalVolumeParams = new CreateVolumeParams();
            r2copylocalVolumeParams.setWwn(BourneRPTestCDPLUN2WWN);
            r2copylocalVolumeParams.setInternalSiteName(site1InternalSiteName);
            r2copylocalVolumeParams.setProduction(false);
            rsetVolumeList.add(r2copylocalVolumeParams);
        }
        if (createCRR) {
            CreateVolumeParams r2copyremoteVolumeParams = new CreateVolumeParams();
            r2copyremoteVolumeParams = new CreateVolumeParams();
            r2copyremoteVolumeParams.setWwn(BourneRPTestCRRLUN2WWN);
            r2copyremoteVolumeParams.setInternalSiteName(site2InternalSiteName);
            r2copyremoteVolumeParams.setProduction(false);
            rsetVolumeList.add(r2copyremoteVolumeParams);
        }
        rset = new CreateRSetParams();
        rset.setName("RSet2");
        rset.setVolumes(rsetVolumeList);
        rsetParamList.add(rset);
    }
    params.setRsets(rsetParamList);
    CreateCopyParams prodCopyParams = new CreateCopyParams();
    CreateCopyParams localCopyParams = new CreateCopyParams();
    CreateCopyParams remoteCopyParams = new CreateCopyParams();
    CreateVolumeParams prodJournalParams = new CreateVolumeParams();
    prodJournalParams.setWwn(BourneRPTestJrnlLUN1WWN);
    prodJournalParams.setInternalSiteName(site1InternalSiteName);
    // necessary for now
    prodJournalParams.setProduction(true);
    List<CreateVolumeParams> prodJournalVolumeList = new ArrayList<CreateVolumeParams>();
    prodJournalVolumeList.add(prodJournalParams);
    if (isSymmDevices) {
        // extra jrnl for symm
        CreateVolumeParams prodJournalParams2 = new CreateVolumeParams();
        prodJournalParams2.setWwn(BourneRPTestJrnlLUN3WWN);
        prodJournalParams2.setInternalSiteName(site1InternalSiteName);
        prodJournalParams2.setProduction(true);
        prodJournalVolumeList.add(prodJournalParams2);
    }
    prodCopyParams.setName("production");
    prodCopyParams.setJournals(prodJournalVolumeList);
    List<CreateCopyParams> copyList = new ArrayList<CreateCopyParams>();
    copyList.add(prodCopyParams);
    if (createCDP) {
        CreateVolumeParams localJournalParams = new CreateVolumeParams();
        localJournalParams.setWwn(BourneRPTestJrnlLUN2WWN);
        localJournalParams.setInternalSiteName(site1InternalSiteName);
        localJournalParams.setProduction(false);
        List<CreateVolumeParams> localJournalVolumeList = new ArrayList<CreateVolumeParams>();
        localJournalVolumeList.add(localJournalParams);
        if (isSymmDevices) {
            // extra jrnl for symm
            CreateVolumeParams localJournalParams2 = new CreateVolumeParams();
            localJournalParams2.setWwn(BourneRPTestJrnlLUN4WWN);
            localJournalParams2.setInternalSiteName(site1InternalSiteName);
            localJournalParams2.setProduction(false);
            localJournalVolumeList.add(localJournalParams2);
        }
        // 
        localCopyParams.setName("local");
        localCopyParams.setJournals(localJournalVolumeList);
        copyList.add(localCopyParams);
    }
    if (createCRR) {
        CreateVolumeParams remoteJournalParams = new CreateVolumeParams();
        remoteJournalParams.setWwn(BourneRPTestJrnlLUN5WWN);
        remoteJournalParams.setInternalSiteName(site2InternalSiteName);
        remoteJournalParams.setProduction(false);
        List<CreateVolumeParams> remoteJournalVolumeList = new ArrayList<CreateVolumeParams>();
        remoteJournalVolumeList.add(remoteJournalParams);
        if (isSymmDevices) {
            // extra jrnl for symm
            CreateVolumeParams remoteJournalParams2 = new CreateVolumeParams();
            remoteJournalParams2.setWwn(BourneRPTestJrnlLUN6WWN);
            remoteJournalParams2.setInternalSiteName(site2InternalSiteName);
            remoteJournalParams2.setProduction(false);
            remoteJournalVolumeList.add(remoteJournalParams2);
        }
        remoteCopyParams.setName("remote");
        remoteCopyParams.setJournals(remoteJournalVolumeList);
        copyList.add(remoteCopyParams);
    }
    params.setCopies(copyList);
    logger.info(params.toString());
    return params;
}
Also used : CreateRSetParams(com.emc.storageos.recoverpoint.requests.CreateRSetParams) ArrayList(java.util.ArrayList) CGRequestParams(com.emc.storageos.recoverpoint.requests.CGRequestParams) CreateCopyParams(com.emc.storageos.recoverpoint.requests.CreateCopyParams) LinkedList(java.util.LinkedList) CreateVolumeParams(com.emc.storageos.recoverpoint.requests.CreateVolumeParams)

Aggregations

CGRequestParams (com.emc.storageos.recoverpoint.requests.CGRequestParams)8 RecoverPointException (com.emc.storageos.recoverpoint.exceptions.RecoverPointException)6 FunctionalAPIActionFailedException_Exception (com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception)4 FunctionalAPIInternalError_Exception (com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception)4 CoordinatorException (com.emc.storageos.coordinator.exceptions.CoordinatorException)4 ProtectionSystem (com.emc.storageos.db.client.model.ProtectionSystem)4 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)4 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)4 LockRetryException (com.emc.storageos.locking.LockRetryException)4 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)4 InternalServerErrorException (com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException)4 ControllerException (com.emc.storageos.volumecontroller.ControllerException)4 WorkflowException (com.emc.storageos.workflow.WorkflowException)4 URISyntaxException (java.net.URISyntaxException)4 VolumeDescriptor (com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor)3 NamedURI (com.emc.storageos.db.client.model.NamedURI)3 URI (java.net.URI)3 ArrayList (java.util.ArrayList)3 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)2 Constraint (com.emc.storageos.db.client.constraint.Constraint)2