Search in sources :

Example 1 with CreateRSetParams

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

the class RPDeviceController method upgradeRPVPlexToMetroPoint.

/**
 * Upgrades a RP+VPLEX CG to MetroPoint by adding a standby journal to the HA side.
 *
 * Prerequisite: All RSets(volumes) in the CG must have had their HA sides already exported to RP in VPLEX.
 *
 * @param sourceVolume
 *            A single source volume from the CG, we only need one.
 * @param rpSystem
 *            The rpSystem we're using
 */
private void upgradeRPVPlexToMetroPoint(Volume sourceVolume, VirtualPool newVpool, VirtualPool oldVpool, ProtectionSystem rpSystem) {
    // Grab the new standby journal from the CG
    String standbyCopyName = RPHelper.getStandbyProductionCopyName(_dbClient, sourceVolume);
    List<Volume> existingStandbyJournals = RPHelper.findExistingJournalsForCopy(_dbClient, sourceVolume.getConsistencyGroup(), standbyCopyName);
    if (existingStandbyJournals.isEmpty()) {
        _log.error(String.format("Could not find standby journal during upgrade to MetroPoint operation. " + "Expected to find a new standby journal for RP copy [%s]", standbyCopyName));
        throw RecoverPointException.exceptions.cannotFindJournal(String.format("for RP copy [%s]", standbyCopyName));
    }
    Volume standbyProdJournal = existingStandbyJournals.get(0);
    // Add new standby journal
    if (standbyProdJournal != null) {
        _log.info(String.format("Upgrade RP+VPLEX CG to MetroPoint by adding new standby journal [%s] to the CG", standbyProdJournal.getLabel()));
        RecoverPointClient rp = RPHelper.getRecoverPointClient(rpSystem);
        RecoverPointVolumeProtectionInfo protectionInfo = rp.getProtectionInfoForVolume(RPHelper.getRPWWn(sourceVolume.getId(), _dbClient));
        _log.info(String.format("RecoverPointVolumeProtectionInfo [%s] retrieved", protectionInfo.getRpProtectionName()));
        RPCopyRequestParams copyParams = new RPCopyRequestParams();
        copyParams.setCopyVolumeInfo(protectionInfo);
        List<CreateVolumeParams> journaVols = new ArrayList<CreateVolumeParams>();
        CreateVolumeParams journalVolParams = new CreateVolumeParams();
        journalVolParams.setWwn(RPHelper.getRPWWn(standbyProdJournal.getId(), _dbClient));
        journalVolParams.setInternalSiteName(standbyProdJournal.getInternalSiteName());
        journaVols.add(journalVolParams);
        CreateCopyParams standbyProdCopyParams = new CreateCopyParams();
        standbyProdCopyParams.setName(standbyProdJournal.getRpCopyName());
        standbyProdCopyParams.setJournals(journaVols);
        _log.info(String.format("Adding standby journal [%s] to teh RP CG...", standbyProdJournal.getLabel()));
        // TODO BH - Empty, not sure why we need this
        List<CreateRSetParams> rSets = new ArrayList<CreateRSetParams>();
        rp.addStandbyProductionCopy(standbyProdCopyParams, null, rSets, copyParams);
        _log.info("Standby journal added successfully.");
        // TODO Add new Targets if they exist ??
        // Next we need to update the vpool reference of any existing related volumes
        // that were referencing the old vpool.
        // We'll start by getting all source volumes from the ViPR CG
        BlockConsistencyGroup viprCG = _dbClient.queryObject(BlockConsistencyGroup.class, sourceVolume.getConsistencyGroup());
        List<Volume> allSourceVolumesInCG = BlockConsistencyGroupUtils.getActiveVplexVolumesInCG(viprCG, _dbClient, Volume.PersonalityTypes.SOURCE);
        for (Volume sourceVol : allSourceVolumesInCG) {
            // For each source volume, we'll get all the related volumes (Targets, Journals, Backing volumes for
            // VPLEX...etc)
            Set<Volume> allRelatedVolumes = RPHelper.getAllRelatedVolumesForSource(sourceVol.getId(), _dbClient, true, true);
            // If it is, update the reference and persist the change.
            for (Volume rpRelatedVol : allRelatedVolumes) {
                if (rpRelatedVol.getVirtualPool().equals(oldVpool.getId())) {
                    rpRelatedVol.setVirtualPool(newVpool.getId());
                    _dbClient.updateObject(rpRelatedVol);
                    _log.info(String.format("Volume [%s] has had its virtual pool updated to [%s].", rpRelatedVol.getLabel(), newVpool.getLabel()));
                }
            }
        }
    }
}
Also used : CreateRSetParams(com.emc.storageos.recoverpoint.requests.CreateRSetParams) ArrayList(java.util.ArrayList) RPCopyRequestParams(com.emc.storageos.recoverpoint.requests.RPCopyRequestParams) CreateVolumeParams(com.emc.storageos.recoverpoint.requests.CreateVolumeParams) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup) RecoverPointVolumeProtectionInfo(com.emc.storageos.recoverpoint.responses.RecoverPointVolumeProtectionInfo) Volume(com.emc.storageos.db.client.model.Volume) RecoverPointClient(com.emc.storageos.recoverpoint.impl.RecoverPointClient) CreateCopyParams(com.emc.storageos.recoverpoint.requests.CreateCopyParams)

Example 2 with CreateRSetParams

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

the class RPDeviceController method performProtectionOperationStep.

/**
 * Workflow step to perform RP protection operation
 *
 * @param protectionSystem
 * @param cgId
 * @param volId
 * @param copyID
 * @param pointInTime
 * @param imageAccessMode
 * @param op
 * @param stepId
 * @return
 * @throws ControllerException
 */
public boolean performProtectionOperationStep(URI protectionSystem, URI cgId, URI volId, URI copyID, String pointInTime, String imageAccessMode, String op, String stepId) throws ControllerException {
    WorkflowStepCompleter.stepExecuting(stepId);
    try {
        ProtectionSystem rpSystem = getRPSystem(protectionSystem);
        // Take out a workflow step lock on the CG
        _workflowService.getWorkflowFromStepId(stepId);
        List<String> lockKeys = new ArrayList<String>();
        lockKeys.add(ControllerLockingUtil.getConsistencyGroupStorageKey(_dbClient, cgId, rpSystem.getId()));
        boolean lockAcquired = _workflowService.acquireWorkflowStepLocks(stepId, lockKeys, LockTimeoutValue.get(LockType.RP_CG));
        if (!lockAcquired) {
            throw DeviceControllerException.exceptions.failedToAcquireLock(lockKeys.toString(), String.format("failed to get lock while restoring volumes in RP consistency group: %s", cgId.toString()));
        }
        // set the protection volume to the source volume if the copyID is null (operation is performed on all
        // copies)
        // otherwise set it to the volume referenced by the copyID (operation is performed on specifc copy)
        Volume protectionVolume = (copyID == null) ? _dbClient.queryObject(Volume.class, volId) : _dbClient.queryObject(Volume.class, copyID);
        RecoverPointClient rp = RPHelper.getRecoverPointClient(rpSystem);
        RecoverPointVolumeProtectionInfo volumeProtectionInfo = rp.getProtectionInfoForVolume(RPHelper.getRPWWn(protectionVolume.getId(), _dbClient));
        if (op.equals(STOP)) {
            rp.disableProtection(volumeProtectionInfo);
            setProtectionSetStatus(volumeProtectionInfo, ProtectionStatus.DISABLED.toString(), rpSystem);
            _log.info("doStopProtection {} - complete", rpSystem.getId());
        } else if (op.equals(START)) {
            rp.enableProtection(volumeProtectionInfo);
            setProtectionSetStatus(volumeProtectionInfo, ProtectionStatus.ENABLED.toString(), rpSystem);
        } else if (op.equals(SYNC)) {
            Set<String> volumeWWNs = new HashSet<String>();
            volumeWWNs.add(RPHelper.getRPWWn(protectionVolume.getId(), _dbClient));
            // Create and enable a temporary bookmark for the volume associated with this volume
            CreateBookmarkRequestParams request = new CreateBookmarkRequestParams();
            request.setVolumeWWNSet(volumeWWNs);
            request.setBookmark("Sync-Snapshot");
            rp.createBookmarks(request);
        } else if (op.equals(PAUSE)) {
            rp.pauseTransfer(volumeProtectionInfo);
            setProtectionSetStatus(volumeProtectionInfo, ProtectionStatus.PAUSED.toString(), rpSystem);
        } else if (op.equals(RESUME)) {
            rp.resumeTransfer(volumeProtectionInfo);
            setProtectionSetStatus(volumeProtectionInfo, ProtectionStatus.ENABLED.toString(), rpSystem);
        } else if (op.equals(FAILOVER_TEST)) {
            RPCopyRequestParams copyParams = new RPCopyRequestParams();
            copyParams.setCopyVolumeInfo(volumeProtectionInfo);
            rp.failoverCopyTest(copyParams);
        } else if (op.equals(FAILOVER)) {
            // cancel.
            if (protectionVolume.getLinkStatus() != null && protectionVolume.getLinkStatus().equalsIgnoreCase(Volume.LinkStatus.FAILED_OVER.name())) {
                // TODO: ViPR 2.0 needs to support this.
                // TODO BEGIN: allow re-failover perform the same as a failback in 2.0 since the UI support will not
                // be there to do a
                // swap or cancel.
                // Jira CTRL-2773: Once UI adds support for /swap and /failover-cancel, we can remove this and
                // replace with an error.
                // If protectionVolume is a source, then the "source" sent in must be a target. Verify.
                Volume targetVolume = null;
                if (protectionVolume.checkPersonality(Volume.PersonalityTypes.SOURCE.toString())) {
                    targetVolume = _dbClient.queryObject(Volume.class, volId);
                } else {
                    targetVolume = protectionVolume;
                }
                // Disable the image access that is in effect.
                volumeProtectionInfo = rp.getProtectionInfoForVolume(RPHelper.getRPWWn(targetVolume.getId(), _dbClient));
                RPCopyRequestParams copyParams = new RPCopyRequestParams();
                copyParams.setCopyVolumeInfo(volumeProtectionInfo);
                rp.failoverCopyCancel(copyParams);
                // Set the flags back to where they belong.
                updatePostFailoverCancel(targetVolume);
            // TODO END
            // Replace with this error: taskCompleter.error(_dbClient, _locker,
            // DeviceControllerErrors.recoverpoint.stepFailed("performFailoverOperation: source volume specified
            // for failover where target volume specified is not in failover state"));
            } else {
                // Standard failover case.
                RPCopyRequestParams copyParams = new RPCopyRequestParams();
                copyParams.setCopyVolumeInfo(volumeProtectionInfo);
                if (pointInTime != null) {
                    // Build a Date reference.
                    copyParams.setApitTime(TimeUtils.getDateTimestamp(pointInTime));
                }
                rp.failoverCopy(copyParams);
                updatePostFailover(protectionVolume);
            }
        } else if (op.equals(FAILOVER_CANCEL)) {
            // cancel.
            if (protectionVolume.checkPersonality(Volume.PersonalityTypes.SOURCE.name())) {
                throw DeviceControllerExceptions.recoverpoint.failoverWrongTargetSpecified();
            } else {
                if (protectionVolume.getLinkStatus() != null && protectionVolume.getLinkStatus().equalsIgnoreCase(Volume.LinkStatus.FAILED_OVER.name())) {
                    // Disable the image access that is in effect.
                    volumeProtectionInfo = rp.getProtectionInfoForVolume(RPHelper.getRPWWn(protectionVolume.getId(), _dbClient));
                    RPCopyRequestParams copyParams = new RPCopyRequestParams();
                    copyParams.setCopyVolumeInfo(volumeProtectionInfo);
                    rp.failoverCopyCancel(copyParams);
                    // Set the flags back to where they belong.
                    updatePostFailoverCancel(protectionVolume);
                } else {
                    // failed over target.
                    throw DeviceControllerExceptions.recoverpoint.failoverWrongTargetSpecified();
                }
            }
        } else if (op.equals(SWAP)) {
            RPCopyRequestParams copyParams = new RPCopyRequestParams();
            copyParams.setCopyVolumeInfo(volumeProtectionInfo);
            rp.swapCopy(copyParams);
            protectionVolume = updatePostSwapPersonalities(protectionVolume);
            rp.setCopyAsProduction(copyParams);
            // 3. add back the standby CDP copy
            if (RPHelper.isMetroPointVolume(_dbClient, protectionVolume)) {
                // copy exists, we can skip all the CG reconstruction steps.
                if (!rp.doesStandbyProdCopyExist(volumeProtectionInfo)) {
                    _log.info(String.format("Adding back standby production copy after swap back to original VPlex Metro for Metropoint volume %s (%s)", protectionVolume.getLabel(), protectionVolume.getId().toString()));
                    List<Volume> standbyLocalCopyVols = RPHelper.getMetropointStandbyCopies(protectionVolume, _dbClient);
                    CreateCopyParams standbyLocalCopyParams = null;
                    List<CreateRSetParams> rSets = new ArrayList<CreateRSetParams>();
                    Set<URI> journalVolumes = new HashSet<URI>();
                    if (!standbyLocalCopyVols.isEmpty()) {
                        for (Volume standbyCopyVol : standbyLocalCopyVols) {
                            // 1. delete the standby CDP copy if it exists
                            if (rp.doesProtectionVolumeExist(RPHelper.getRPWWn(standbyCopyVol.getId(), _dbClient))) {
                                RecoverPointVolumeProtectionInfo standbyCdpCopy = rp.getProtectionInfoForVolume(RPHelper.getRPWWn(standbyCopyVol.getId(), _dbClient));
                                rp.deleteCopy(standbyCdpCopy);
                            }
                            // set up volume info for the standby copy volume
                            CreateVolumeParams vol = new CreateVolumeParams();
                            vol.setWwn(RPHelper.getRPWWn(standbyCopyVol.getId(), _dbClient));
                            vol.setInternalSiteName(standbyCopyVol.getInternalSiteName());
                            vol.setProduction(false);
                            List<CreateVolumeParams> volumes = new ArrayList<CreateVolumeParams>();
                            volumes.add(vol);
                            CreateRSetParams rSet = new CreateRSetParams();
                            rSet.setName(standbyCopyVol.getRSetName());
                            rSet.setVolumes(volumes);
                            rSets.add(rSet);
                            List<Volume> standbyJournals = RPHelper.findExistingJournalsForCopy(_dbClient, standbyCopyVol.getConsistencyGroup(), standbyCopyVol.getRpCopyName());
                            // compile a unique set of journal volumes
                            for (Volume standbyJournal : standbyJournals) {
                                journalVolumes.add(standbyJournal.getId());
                            }
                        }
                        // prepare journal volumes info
                        String rpCopyName = null;
                        List<CreateVolumeParams> journalVols = new ArrayList<CreateVolumeParams>();
                        for (URI journalVolId : journalVolumes) {
                            Volume standbyLocalJournal = _dbClient.queryObject(Volume.class, journalVolId);
                            if (standbyLocalJournal != null) {
                                _log.info(String.format("Found standby local journal volume %s (%s) for metropoint volume %s (%s)", standbyLocalJournal.getLabel(), standbyLocalJournal.getId().toString(), protectionVolume.getLabel(), protectionVolume.getId().toString()));
                                rpCopyName = standbyLocalJournal.getRpCopyName();
                                CreateVolumeParams journalVolParams = new CreateVolumeParams();
                                journalVolParams.setWwn(RPHelper.getRPWWn(standbyLocalJournal.getId(), _dbClient));
                                journalVolParams.setInternalSiteName(standbyLocalJournal.getInternalSiteName());
                                journalVols.add(journalVolParams);
                            }
                        }
                        // if we found any journal volumes, add them to the local copies list
                        if (!journalVols.isEmpty()) {
                            standbyLocalCopyParams = new CreateCopyParams();
                            standbyLocalCopyParams.setName(rpCopyName);
                            standbyLocalCopyParams.setJournals(journalVols);
                        } else {
                            _log.error("no journal volumes found for standby production copy for source volume " + protectionVolume.getLabel());
                        }
                    }
                    String standbyProductionCopyName = RPHelper.getStandbyProductionCopyName(_dbClient, protectionVolume);
                    // Build standby production journal
                    if (standbyProductionCopyName != null) {
                        List<Volume> existingStandbyJournals = RPHelper.findExistingJournalsForCopy(_dbClient, protectionVolume.getConsistencyGroup(), standbyProductionCopyName);
                        // Get the first standby production journal
                        Volume standbyProdJournal = existingStandbyJournals.get(0);
                        if (standbyProdJournal != null) {
                            _log.info(String.format("Found standby production journal volume %s (%s) for metropoint volume %s (%s)", standbyProdJournal.getLabel(), standbyProdJournal.getId().toString(), protectionVolume.getLabel(), protectionVolume.getId().toString()));
                            List<CreateVolumeParams> journalVols = new ArrayList<CreateVolumeParams>();
                            CreateVolumeParams journalVolParams = new CreateVolumeParams();
                            journalVolParams.setWwn(RPHelper.getRPWWn(standbyProdJournal.getId(), _dbClient));
                            journalVolParams.setInternalSiteName(standbyProdJournal.getInternalSiteName());
                            journalVols.add(journalVolParams);
                            CreateCopyParams standbyProdCopyParams = new CreateCopyParams();
                            standbyProdCopyParams.setName(standbyProdJournal.getRpCopyName());
                            standbyProdCopyParams.setJournals(journalVols);
                            // 2. and 3. add back the standby production copy; add back the standby CDP copy
                            rp.addStandbyProductionCopy(standbyProdCopyParams, standbyLocalCopyParams, rSets, copyParams);
                        } else {
                            _log.error(String.format("Cannot add standby production copy because the standby production journal could not be found for copy %s.", standbyProductionCopyName));
                        }
                    }
                }
            }
            // copy bookmarks before we cleanup the corresponding BlockSnapshot objects from ViPR.
            try {
                Thread.sleep(5000);
            } catch (InterruptedException e) {
                Thread.currentThread().interrupt();
            }
            // When we perform a swap, the target swap copy will become the production copy and lose all
            // its bookmarks so we need to sync with RP.
            RPHelper.cleanupSnapshots(_dbClient, rpSystem);
        } else if (op.equals(FAILOVER_TEST_CANCEL)) {
            RPCopyRequestParams copyParams = new RPCopyRequestParams();
            copyParams.setCopyVolumeInfo(volumeProtectionInfo);
            rp.failoverCopyTestCancel(copyParams);
        } else if (op.equals(CHANGE_ACCESS_MODE)) {
            RPCopyRequestParams copyParams = new RPCopyRequestParams();
            copyParams.setCopyVolumeInfo(volumeProtectionInfo);
            copyParams.setImageAccessMode(imageAccessMode);
            if (imageAccessMode != null) {
                rp.updateImageAccessMode(copyParams);
                // BlockSnapshot objects that reference the target copy being set to direct access mode.
                if (Copy.ImageAccessMode.DIRECT_ACCESS.name().equalsIgnoreCase(imageAccessMode)) {
                    _log.info(String.format("Updated imaged access mode for copy %s at %s to DIRECT_ACCESS. Removing all bookmarks associated with that copy and site.", volumeProtectionInfo.getRpCopyName(), volumeProtectionInfo.getRpSiteName()));
                    // Wait for RP to remove copy snapshots
                    try {
                        Thread.sleep(5000);
                    } catch (InterruptedException e) {
                        Thread.currentThread().interrupt();
                    }
                    RPHelper.cleanupSnapshots(_dbClient, rpSystem);
                }
            } else {
                throw DeviceControllerExceptions.recoverpoint.imageAccessModeNotSupported(imageAccessMode);
            }
        } else {
            throw DeviceControllerExceptions.recoverpoint.protectionOperationNotSupported(op);
        }
        _log.info("performProtectionOperation: after " + op + " operation successful");
        WorkflowStepCompleter.stepSucceded(stepId);
        return true;
    } catch (InternalException e) {
        _log.error("Operation failed with Exception: ", e);
        return stepFailed(stepId, (ServiceCoded) e, "removeProtection operation failed.");
    } catch (Exception e) {
        stepFailed(stepId, e, "removeProtection operation failed.");
        return false;
    }
}
Also used : CreateRSetParams(com.emc.storageos.recoverpoint.requests.CreateRSetParams) ArrayList(java.util.ArrayList) ProtectionSystem(com.emc.storageos.db.client.model.ProtectionSystem) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) RPCopyRequestParams(com.emc.storageos.recoverpoint.requests.RPCopyRequestParams) CreateVolumeParams(com.emc.storageos.recoverpoint.requests.CreateVolumeParams) 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) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) CreateBookmarkRequestParams(com.emc.storageos.recoverpoint.requests.CreateBookmarkRequestParams) RecoverPointVolumeProtectionInfo(com.emc.storageos.recoverpoint.responses.RecoverPointVolumeProtectionInfo) Volume(com.emc.storageos.db.client.model.Volume) ServiceCoded(com.emc.storageos.svcs.errorhandling.model.ServiceCoded) RecoverPointClient(com.emc.storageos.recoverpoint.impl.RecoverPointClient) CreateCopyParams(com.emc.storageos.recoverpoint.requests.CreateCopyParams) HashSet(java.util.HashSet)

Example 3 with CreateRSetParams

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

the class RPDeviceController method updateProtectionSet.

/**
 * Update a protection set in the database that corresponds to the CG.
 *
 * BH Note: Currently this only supports adding to the protection set. We may eventually
 * want to support removal as well.
 *
 * @param params
 *            CG params object
 * @throws InternalException
 */
private ProtectionSet updateProtectionSet(ProtectionSet protectionSet, CGRequestParams params) throws InternalException {
    StringSet protectionSetVolumes = new StringSet();
    _log.info(String.format("Updating protection set [%s]", protectionSet.getLabel()));
    // Keep a list of all volumes that were created. This will be used to ensure we do not
    // consider volumes from this create request when setting access state and link status
    // based on existing volumes in the CG.
    List<URI> volumesInCreateRequest = new ArrayList<URI>();
    for (CreateRSetParams rset : params.getRsets()) {
        for (CreateVolumeParams volume : rset.getVolumes()) {
            volumesInCreateRequest.add(volume.getVolumeURI());
        }
    }
    // protection set
    for (CreateRSetParams rset : params.getRsets()) {
        for (CreateVolumeParams volume : rset.getVolumes()) {
            if (protectionSet.getVolumes() != null && protectionSet.getVolumes().contains(volume.getVolumeURI().toString())) {
                // Protection Set already has a reference to this volume, continue.
                continue;
            } else {
                Volume vol = _dbClient.queryObject(Volume.class, volume.getVolumeURI());
                // hasn't already been set.
                if (protectionSet.getProject() == null) {
                    protectionSet.setProject(vol.getProject().getURI());
                }
                vol.setProtectionSet(new NamedURI(protectionSet.getId(), protectionSet.getLabel()));
                if (vol.checkPersonality(Volume.PersonalityTypes.SOURCE.toString())) {
                    vol.setAccessState(Volume.VolumeAccessState.READWRITE.name());
                    vol.setLinkStatus(Volume.LinkStatus.IN_SYNC.name());
                    // Check the CG for an existing source volume. If the CG has an existing
                    // source volume, we want to mirror the access state and link status for
                    // all new source volumes.
                    List<Volume> existingCgSourceVolumes = RPHelper.getCgSourceVolumes(vol.getConsistencyGroup(), _dbClient);
                    if (existingCgSourceVolumes != null) {
                        for (Volume sourceVolume : existingCgSourceVolumes) {
                            if (!vol.getId().equals(sourceVolume.getId()) && !volumesInCreateRequest.contains(sourceVolume.getId())) {
                                _log.info(String.format("Updating source volume %s. Setting access state = %s, link status = %s.  Based on existing CG source volume %s.", vol.getId(), sourceVolume.getAccessState(), sourceVolume.getLinkStatus(), sourceVolume.getId()));
                                vol.setAccessState(sourceVolume.getAccessState());
                                vol.setLinkStatus(sourceVolume.getLinkStatus());
                                break;
                            }
                        }
                    }
                } else if (vol.checkPersonality(Volume.PersonalityTypes.TARGET.toString())) {
                    vol.setAccessState(Volume.VolumeAccessState.NOT_READY.name());
                    vol.setLinkStatus(Volume.LinkStatus.IN_SYNC.name());
                    // Check the CG for an existing target volume corresponding to the same RP copy
                    // as this volume and mirror its access state and link statues. If the target
                    // copy happens to be in direct access mode, it's important that the new volume
                    // be marked FAILED_OVER and READWRITE.
                    List<Volume> existingCgTargets = RPHelper.getTargetVolumesForVarray(_dbClient, vol.getConsistencyGroup(), vol.getVirtualArray());
                    if (existingCgTargets != null && vol.getRpCopyName() != null) {
                        for (Volume targetVolume : existingCgTargets) {
                            // lets use it to set the access state and link status values.
                            if (!vol.getId().equals(targetVolume.getId()) && !volumesInCreateRequest.contains(targetVolume.getId()) && vol.getRpCopyName().equalsIgnoreCase(targetVolume.getRpCopyName())) {
                                _log.info(String.format("Updating volume %s. Setting access state = %s, link status = %s.  Based on existing CG target volume %s.", vol.getId(), targetVolume.getAccessState(), targetVolume.getLinkStatus(), targetVolume.getId()));
                                vol.setAccessState(targetVolume.getAccessState());
                                vol.setLinkStatus(targetVolume.getLinkStatus());
                                break;
                            }
                        }
                    }
                }
                _dbClient.updateObject(vol);
                protectionSetVolumes.add(vol.getId().toString());
                _log.info(String.format("Adding volume [%s] to protection set [%s]", vol.getLabel(), protectionSet.getLabel()));
            }
        }
    }
    // protection set
    for (CreateCopyParams copy : params.getCopies()) {
        for (CreateVolumeParams volume : copy.getJournals()) {
            if (protectionSet.getVolumes() != null && protectionSet.getVolumes().contains(volume.getVolumeURI().toString())) {
                // Protection Set already has a reference to this volume, continue.
                continue;
            } else {
                Volume vol = _dbClient.queryObject(Volume.class, volume.getVolumeURI());
                vol.setProtectionSet(new NamedURI(protectionSet.getId(), protectionSet.getLabel()));
                vol.setAccessState(Volume.VolumeAccessState.NOT_READY.name());
                _dbClient.updateObject(vol);
                protectionSetVolumes.add(vol.getId().toString());
                _log.info(String.format("Adding volume [%s] to protection set [%s]", vol.getLabel(), protectionSet.getLabel()));
            }
        }
    }
    if (protectionSet.getVolumes() == null) {
        protectionSet.setVolumes(protectionSetVolumes);
    } else {
        protectionSet.getVolumes().addAll(protectionSetVolumes);
    }
    _dbClient.updateObject(protectionSet);
    return protectionSet;
}
Also used : CreateRSetParams(com.emc.storageos.recoverpoint.requests.CreateRSetParams) Volume(com.emc.storageos.db.client.model.Volume) NamedURI(com.emc.storageos.db.client.model.NamedURI) StringSet(com.emc.storageos.db.client.model.StringSet) ArrayList(java.util.ArrayList) ApplicationAddVolumeList(com.emc.storageos.volumecontroller.ApplicationAddVolumeList) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) List(java.util.List) CreateCopyParams(com.emc.storageos.recoverpoint.requests.CreateCopyParams) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) CreateVolumeParams(com.emc.storageos.recoverpoint.requests.CreateVolumeParams)

Example 4 with CreateRSetParams

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

the class RPDeviceController method updateCGParams.

/**
 * Update the params objects with the proper WWN information so the CG can be created.
 *
 * @param params
 *            cg params
 * @throws InternalException
 */
private void updateCGParams(CGRequestParams params) throws InternalException {
    for (CreateCopyParams copy : params.getCopies()) {
        _log.info("View copy: " + copy.getName());
        // Fill the map with varray
        for (CreateVolumeParams volume : copy.getJournals()) {
            Volume dbVolume = _dbClient.queryObject(Volume.class, volume.getVolumeURI());
            volume.setNativeGuid(dbVolume.getNativeGuid());
            volume.setWwn(RPHelper.getRPWWn(dbVolume.getId(), _dbClient));
        }
    }
    for (CreateRSetParams rset : params.getRsets()) {
        _log.info("View rset: " + rset.getName());
        for (CreateVolumeParams volume : rset.getVolumes()) {
            Volume dbVolume = _dbClient.queryObject(Volume.class, volume.getVolumeURI());
            volume.setNativeGuid(dbVolume.getNativeGuid());
            volume.setWwn(RPHelper.getRPWWn(dbVolume.getId(), _dbClient));
        }
    }
}
Also used : CreateRSetParams(com.emc.storageos.recoverpoint.requests.CreateRSetParams) Volume(com.emc.storageos.db.client.model.Volume) CreateCopyParams(com.emc.storageos.recoverpoint.requests.CreateCopyParams) CreateVolumeParams(com.emc.storageos.recoverpoint.requests.CreateVolumeParams)

Example 5 with CreateRSetParams

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

the class RecoverPointClient method configureCGSettingsChangeParams.

/**
 * Configures the consistency group settings change param.
 *
 * @param request the CG create request information
 * @param prodSites the list of production clusters
 * @param clusterIdCache the cached map of internal site names to clusters
 * @param attachAsClean attach as clean can be true if source and target are guaranteed to be the same (as in create
 *            new volume). for change vpool, attach as clean should be false
 * @return the consistency group settings change param
 * @throws FunctionalAPIInternalError_Exception
 * @throws FunctionalAPIActionFailedException_Exception
 */
private ConsistencyGroupSettingsChangesParam configureCGSettingsChangeParams(CGRequestParams request, ConsistencyGroupUID cgUID, List<ClusterUID> prodSites, Map<String, ClusterUID> clusterIdCache, Map<Long, ConsistencyGroupCopyUID> productionCopiesUID, Map<Long, ConsistencyGroupCopyUID> nonProductionCopiesUID, boolean attachAsClean) throws FunctionalAPIActionFailedException_Exception, FunctionalAPIInternalError_Exception {
    Set<RPSite> allSites = getAssociatedRPSites();
    // used to set journal volumes and RSets after the CG is created
    ConsistencyGroupSettingsChangesParam cgSettingsParam = new ConsistencyGroupSettingsChangesParam();
    ActivationSettingsChangesParams cgActivationSettings = new ActivationSettingsChangesParams();
    cgActivationSettings.setEnable(true);
    cgActivationSettings.setStartTransfer(true);
    cgSettingsParam.setActivationParams(cgActivationSettings);
    cgSettingsParam.setGroupUID(cgUID);
    for (CreateCopyParams copyParam : request.getCopies()) {
        ClusterUID clusterUID = getClusterUid(copyParam, clusterIdCache);
        if (clusterUID != null) {
            RecoverPointCGCopyType copyType = getCopyType(copyParam, prodSites, clusterUID);
            if (copyType != null) {
                ConsistencyGroupCopyUID cgCopyUID = getCGCopyUid(clusterUID, copyType, cgUID);
                // set up journal params
                ConsistencyGroupCopySettingsChangesParam copySettingsParam = new ConsistencyGroupCopySettingsChangesParam();
                copySettingsParam.setCopyUID(cgCopyUID);
                ActivationSettingsChangesParams copyActivationSettings = new ActivationSettingsChangesParams();
                copyActivationSettings.setEnable(true);
                copyActivationSettings.setStartTransfer(true);
                copySettingsParam.setActivationParams(copyActivationSettings);
                for (CreateVolumeParams journalVolume : copyParam.getJournals()) {
                    logger.info("Configuring Journal : \n" + journalVolume.toString() + "\n for copy: " + copyParam.getName() + "; CG " + request.getCgName());
                    copySettingsParam.getNewJournalVolumes().add(RecoverPointUtils.getDeviceID(allSites, journalVolume.getInternalSiteName(), journalVolume.getWwn()));
                }
                cgSettingsParam.getCopiesChanges().add(copySettingsParam);
            } else {
                logger.warn("No journal volumes specified for CG: " + copyParam.getName());
            }
        } else {
            logger.warn("No journal volumes specified for CG: " + copyParam.getName());
        }
    }
    String previousProdCopyName = null;
    // configure replication sets
    for (CreateRSetParams rsetParam : request.getRsets()) {
        logger.info("Configuring replication set: " + rsetParam.toString() + " for cg " + request.getCgName());
        ReplicationSetSettingsChangesParam repSetSettings = new ReplicationSetSettingsChangesParam();
        repSetSettings.setName(rsetParam.getName());
        repSetSettings.setShouldAttachAsClean(attachAsClean);
        Set<String> sourceWWNsInRset = new HashSet<String>();
        for (CreateVolumeParams volume : rsetParam.getVolumes()) {
            UserVolumeSettingsChangesParam volSettings = new UserVolumeSettingsChangesParam();
            volSettings.setNewVolumeID(RecoverPointUtils.getDeviceID(allSites, volume.getInternalSiteName(), volume.getWwn()));
            ClusterUID volSiteId = getRPSiteID(volume.getInternalSiteName(), clusterIdCache);
            if (volume.isProduction()) {
                // for metropoint, the same production volume will appear twice; we only want to add it once
                if (sourceWWNsInRset.contains(volume.getWwn())) {
                    continue;
                }
                if (previousProdCopyName == null) {
                    previousProdCopyName = volume.getRpCopyName();
                } else if (!previousProdCopyName.equals(volume.getRpCopyName())) {
                    logger.info(String.format("will not add rset for volume %s to prod copy %s because another rset has already been added to prod copy %s", rsetParam.getName(), volume.getRpCopyName(), previousProdCopyName));
                    continue;
                }
                sourceWWNsInRset.add(volume.getWwn());
                logger.info("Configuring production copy volume : \n" + volume.toString());
                ConsistencyGroupCopyUID copyUID = productionCopiesUID.get(Long.valueOf(volSiteId.getId()));
                copyUID.setGroupUID(cgUID);
                volSettings.setCopyUID(copyUID);
            } else {
                logger.info("Configuring non-production copy volume : \n" + volume.toString());
                ConsistencyGroupCopyUID copyUID = nonProductionCopiesUID.get(Long.valueOf(volSiteId.getId()));
                copyUID.setGroupUID(cgUID);
                volSettings.setCopyUID(copyUID);
            }
            repSetSettings.getVolumesChanges().add(volSettings);
        }
        cgSettingsParam.getReplicationSetsChanges().add(repSetSettings);
    }
    return cgSettingsParam;
}
Also used : ReplicationSetSettingsChangesParam(com.emc.fapiclient.ws.ReplicationSetSettingsChangesParam) ConsistencyGroupSettingsChangesParam(com.emc.fapiclient.ws.ConsistencyGroupSettingsChangesParam) CreateRSetParams(com.emc.storageos.recoverpoint.requests.CreateRSetParams) UserVolumeSettingsChangesParam(com.emc.fapiclient.ws.UserVolumeSettingsChangesParam) CreateVolumeParams(com.emc.storageos.recoverpoint.requests.CreateVolumeParams) ConsistencyGroupCopyUID(com.emc.fapiclient.ws.ConsistencyGroupCopyUID) ClusterUID(com.emc.fapiclient.ws.ClusterUID) ConsistencyGroupCopySettingsChangesParam(com.emc.fapiclient.ws.ConsistencyGroupCopySettingsChangesParam) RPSite(com.emc.storageos.recoverpoint.objectmodel.RPSite) CreateCopyParams(com.emc.storageos.recoverpoint.requests.CreateCopyParams) ActivationSettingsChangesParams(com.emc.fapiclient.ws.ActivationSettingsChangesParams) HashSet(java.util.HashSet)

Aggregations

CreateRSetParams (com.emc.storageos.recoverpoint.requests.CreateRSetParams)12 CreateVolumeParams (com.emc.storageos.recoverpoint.requests.CreateVolumeParams)11 CreateCopyParams (com.emc.storageos.recoverpoint.requests.CreateCopyParams)9 Volume (com.emc.storageos.db.client.model.Volume)6 ArrayList (java.util.ArrayList)6 NamedURI (com.emc.storageos.db.client.model.NamedURI)4 URI (java.net.URI)4 HashSet (java.util.HashSet)4 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)3 StringSet (com.emc.storageos.db.client.model.StringSet)3 FunctionalAPIActionFailedException_Exception (com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception)2 FunctionalAPIInternalError_Exception (com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception)2 VolumeDescriptor (com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor)2 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)2 Constraint (com.emc.storageos.db.client.constraint.Constraint)2 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)2 RecoverPointClient (com.emc.storageos.recoverpoint.impl.RecoverPointClient)2 RPSite (com.emc.storageos.recoverpoint.objectmodel.RPSite)2 CGRequestParams (com.emc.storageos.recoverpoint.requests.CGRequestParams)2 RPCopyRequestParams (com.emc.storageos.recoverpoint.requests.RPCopyRequestParams)2