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();
}
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);
}
}
Aggregations