Search in sources :

Example 11 with CreateRSetParams

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

the class RPDeviceController method generateStorageSystemExportMaps.

/**
 * Helper method that consolidates all of the volumes into storage systems to make the minimum amount of export
 * calls.
 *
 * @param volumeDescriptors
 *
 * @param recommendation
 */
private Collection<RPExport> generateStorageSystemExportMaps(CGRequestParams cgParams, List<VolumeDescriptor> volumeDescriptors) {
    _log.info("Generate the storage system exports...START");
    Map<String, RPExport> rpExportMap = new HashMap<String, RPExport>();
    // volume.
    for (CreateRSetParams rset : cgParams.getRsets()) {
        _log.info("Replication Set: " + rset.getName());
        Set<CreateVolumeParams> createVolumeParams = new HashSet<CreateVolumeParams>();
        createVolumeParams.addAll(rset.getVolumes());
        List<URI> processedRsetVolumes = new ArrayList<URI>();
        for (CreateVolumeParams rsetVolume : createVolumeParams) {
            // the second reference and continue processing.
            if (processedRsetVolumes.contains(rsetVolume.getVolumeURI())) {
                continue;
            }
            processedRsetVolumes.add(rsetVolume.getVolumeURI());
            // Retrieve the volume
            Volume volume = _dbClient.queryObject(Volume.class, rsetVolume.getVolumeURI());
            _log.info(String.format("Generating Exports for %s volume [%s](%s)...", volume.getPersonality().toString(), volume.getLabel(), volume.getId()));
            // List of volumes to export, normally just one volume will be added to this list unless
            // we have a MetroPoint config. In which case we would have two (each leg of the VPLEX).
            Set<Volume> volumes = new HashSet<Volume>();
            // Check to see if this is a SOURCE volume
            if (volume.checkPersonality(PersonalityTypes.SOURCE.toString())) {
                // Check the vpool to ensure we're exporting the source volume to the correct storage system.
                // In the case of MetroPoint, however, it could be a change vpool. In that case get the change
                // vpool new vpool.
                URI vpoolURI = null;
                if (VolumeDescriptor.getVirtualPoolChangeVolume(volumeDescriptors) != null) {
                    vpoolURI = getVirtualPoolChangeNewVirtualPool(volumeDescriptors);
                } else {
                    vpoolURI = volume.getVirtualPool();
                }
                VirtualPool vpool = _dbClient.queryObject(VirtualPool.class, vpoolURI);
                // In an RP+VPLEX distributed setup, the user can choose to protect only the HA side,
                // so we would export only to the HA StorageView on the VPLEX.
                boolean exportToHASideOnly = VirtualPool.isRPVPlexProtectHASide(vpool);
                if (exportToHASideOnly || VirtualPool.vPoolSpecifiesMetroPoint(vpool)) {
                    _log.info("Export is for {}. Basing export(s) off backing VPLEX volumes for RP Source volume [{}].", (exportToHASideOnly ? "RP+VPLEX distributed HA side only" : "MetroPoint"), volume.getLabel());
                    // If MetroPoint is enabled we need to create exports for each leg of the VPLEX.
                    // Get the associated volumes and add them to the list so we can create RPExports
                    // for each one.
                    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 volumeId : backingVolumes) {
                        Volume vol = _dbClient.queryObject(Volume.class, URI.create(volumeId));
                        // Check to see if we only want to export to the HA side of the RP+VPLEX setup
                        if (exportToHASideOnly) {
                            if (!vol.getVirtualArray().toString().equals(vpool.getHaVarrayConnectedToRp())) {
                                continue;
                            }
                        }
                        volumes.add(vol);
                    }
                } else {
                    // Not RP+VPLEX distributed or MetroPoint, add the volume and continue on.
                    volumes.add(volume);
                }
            } else {
                // Not a SOURCE volume, add the volume and continue on.
                volumes.add(volume);
            }
            for (Volume vol : volumes) {
                URI storageSystem = rsetVolume.getStorageSystem();
                String rpSiteName = vol.getInternalSiteName();
                URI varray = vol.getVirtualArray();
                // Intentionally want the ID of the parent volume, not the inner looping vol.
                // This is because we could be trying to create exports for MetroPoint.
                URI volumeId = volume.getId();
                // Generate a unique key based on Storage System + Internal Site + Virtual Array
                String key = storageSystem.toString() + rpSiteName + varray.toString();
                // Try and get an existing rp export object from the map using the key
                RPExport rpExport = rpExportMap.get(key);
                // If it doesn't exist, create the entry and add it to the map with the key
                if (rpExport == null) {
                    rpExport = new RPExport(storageSystem, rpSiteName, varray);
                    rpExportMap.put(key, rpExport);
                }
                // Add host information to the export if specified
                if (vol.checkPersonality(Volume.PersonalityTypes.SOURCE.name())) {
                    for (VolumeDescriptor desc : volumeDescriptors) {
                        if (desc.getVolumeURI().equals(vol.getId())) {
                            if (!NullColumnValueGetter.isNullURI(desc.getComputeResource())) {
                                _log.info("Add Host/Cluster information for source volume exports");
                                rpExport.setComputeResource(desc.getComputeResource());
                                break;
                            }
                        }
                    }
                }
                _log.info(String.format("Adding %s volume [%s](%s) to export: %s", volume.getPersonality().toString(), volume.getLabel(), volume.getId(), rpExport.toString()));
                rpExport.getVolumes().add(volumeId);
            }
        }
    }
    // created for the journal.
    for (CreateCopyParams copy : cgParams.getCopies()) {
        _log.info("Copy: " + copy.getName());
        for (CreateVolumeParams journalVolume : copy.getJournals()) {
            // Retrieve the volume
            Volume volume = _dbClient.queryObject(Volume.class, journalVolume.getVolumeURI());
            _log.info(String.format("Generating export for %s volume [%s](%s)...", volume.getPersonality().toString(), volume.getLabel(), volume.getId()));
            URI storageSystem = journalVolume.getStorageSystem();
            String rpSiteName = volume.getInternalSiteName();
            URI varray = volume.getVirtualArray();
            URI volumeId = volume.getId();
            // Generate a unique key based on Storage System + Internal Site + Virtual Array
            String key = storageSystem.toString() + rpSiteName + varray.toString();
            // Try and get an existing rp export object from the map using the key
            // If a separate varray is specified is for journals, a new entry will be created.
            RPExport rpExport = rpExportMap.get(key);
            // If it doesn't exist, create the entry and add it to the map with the key
            if (rpExport == null) {
                _log.info("RPExport is for journals only");
                rpExport = new RPExport(storageSystem, rpSiteName, varray);
                rpExport.setIsJournalExport(true);
                rpExportMap.put(key, rpExport);
            }
            _log.info(String.format("Adding %s volume [%s](%s) to export: %s", volume.getPersonality().toString(), volume.getLabel(), volume.getId(), rpExport.toString()));
            rpExport.getVolumes().add(volumeId);
        }
    }
    _log.info("Generate the storage system exports...END");
    return rpExportMap.values();
}
Also used : VolumeDescriptor(com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor) CreateRSetParams(com.emc.storageos.recoverpoint.requests.CreateRSetParams) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) CreateVolumeParams(com.emc.storageos.recoverpoint.requests.CreateVolumeParams) Volume(com.emc.storageos.db.client.model.Volume) StringSet(com.emc.storageos.db.client.model.StringSet) CreateCopyParams(com.emc.storageos.recoverpoint.requests.CreateCopyParams) HashSet(java.util.HashSet)

Example 12 with CreateRSetParams

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

the class RPDeviceController method populateRsetsMap.

/**
 * Adds the volumes to the replication sets map.
 *
 * @param rsetParamsMap
 *            the replication sets map.
 * @param volumeParams
 *            the volume params.
 * @param volume
 *            the volume from which to pull the replication set name.
 */
private void populateRsetsMap(Map<String, CreateRSetParams> rsetParamsMap, CreateVolumeParams volumeParams, Volume volume) {
    String key = volume.getRSetName();
    if (rsetParamsMap.containsKey(key)) {
        rsetParamsMap.get(key).getVolumes().add(volumeParams);
    } else {
        CreateRSetParams rsetParams = new CreateRSetParams();
        rsetParams.setName(key);
        rsetParams.setVolumes(new ArrayList<CreateVolumeParams>());
        rsetParams.getVolumes().add(volumeParams);
        rsetParamsMap.put(key, rsetParams);
    }
}
Also used : CreateRSetParams(com.emc.storageos.recoverpoint.requests.CreateRSetParams) CreateVolumeParams(com.emc.storageos.recoverpoint.requests.CreateVolumeParams)

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