use of com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor.Type in project coprhd-controller by CoprHD.
the class VPlexDeviceController method buildArrayMap.
/**
* Build a map of URI to cached StorageSystem for the underlying arrays.
*
* @param descriptors
* @param VolmeDescriptor.Type
* used to filter descriptors
* @return Map<arrayURI, StorageSystem>
*/
private Map<URI, StorageSystem> buildArrayMap(List<VolumeDescriptor> descriptors, VolumeDescriptor.Type type) {
Map<URI, StorageSystem> arrayMap = new HashMap<URI, StorageSystem>();
// Get only the descriptors for the type if specified..
if (type != null) {
descriptors = VolumeDescriptor.filterByType(descriptors, new VolumeDescriptor.Type[] { type }, new VolumeDescriptor.Type[] {});
}
for (VolumeDescriptor desc : descriptors) {
if (arrayMap.containsKey(desc.getDeviceURI()) == false) {
StorageSystem array = getDataObject(StorageSystem.class, desc.getDeviceURI(), _dbClient);
arrayMap.put(desc.getDeviceURI(), array);
}
}
return arrayMap;
}
use of com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor.Type in project coprhd-controller by CoprHD.
the class VPlexDeviceController method buildVolumeMap.
/**
* Build a map of URI to cached Volumes for the underlying Storage Volumes that
* should be already present (and created).
*
* @param vplexSystem
* Only return Volume associated with this VPlex
* @param descriptors
* VolumeDescriptors
* @param VolmeDescriptor.Type
* used to filter descriptors
* @return Map<volumeURI, Volume>
*/
private Map<URI, Volume> buildVolumeMap(StorageSystem vplexSystem, List<VolumeDescriptor> descriptors, VolumeDescriptor.Type type) {
Map<URI, Volume> volumeMap = new HashMap<URI, Volume>();
// Get only the descriptors for the type if specified.
if (type != null) {
descriptors = VolumeDescriptor.filterByType(descriptors, new VolumeDescriptor.Type[] { type }, new VolumeDescriptor.Type[] {});
}
// Loop through all the descriptors / filtered descriptors
for (VolumeDescriptor desc : descriptors) {
// Check to see if the volumeMap already contains the volume URI.
if (volumeMap.containsKey(desc.getVolumeURI()) == false) {
// Load the volume from the descriptor
Volume volume = getDataObject(Volume.class, desc.getVolumeURI(), _dbClient);
if (vplexSystem == null) {
// If the vplexSystem hasn't been passed in, just add the volume the volumeMap.
volumeMap.put(desc.getVolumeURI(), volume);
} else {
// Check the storage controller of this Virtual Volume
if (desc.getType().equals(VolumeDescriptor.Type.VPLEX_VIRT_VOLUME) && volume.getStorageController().toString().equals(vplexSystem.getId().toString())) {
StringSet backingVolumes = volume.getAssociatedVolumes();
if (null == backingVolumes || backingVolumes.isEmpty()) {
_log.warn("VPLEX volume {} has no backend volumes.", volume.forDisplay());
} else {
// Add all backing volumes found to the volumeMap
for (String backingVolumeId : backingVolumes) {
URI backingVolumeURI = URI.create(backingVolumeId);
Volume backingVolume = getDataObject(Volume.class, backingVolumeURI, _dbClient);
volumeMap.put(backingVolumeURI, backingVolume);
}
}
}
}
}
}
return volumeMap;
}
use of com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor.Type in project coprhd-controller by CoprHD.
the class VPlexDeviceController method buildArrayMap.
/**
* Build a map of URI to cached StorageSystem for the underlying arrays.
*
* @param vplexSystem
* Only return Storage Systems connected this VPlex
* @param descriptors
* @param VolmeDescriptor.Type
* used to filter descriptors
* @return Map<arrayURI, StorageSystem>
*/
private Map<URI, StorageSystem> buildArrayMap(StorageSystem vplexSystem, List<VolumeDescriptor> descriptors, VolumeDescriptor.Type[] types) {
Map<URI, StorageSystem> arrayMap = new HashMap<URI, StorageSystem>();
// Get only the descriptors for the type if specified..
if (types != null) {
descriptors = VolumeDescriptor.filterByType(descriptors, types, new VolumeDescriptor.Type[] {});
}
for (VolumeDescriptor desc : descriptors) {
if (arrayMap.containsKey(desc.getDeviceURI()) == false) {
if (vplexSystem == null) {
StorageSystem array = getDataObject(StorageSystem.class, desc.getDeviceURI(), _dbClient);
arrayMap.put(desc.getDeviceURI(), array);
} else {
Set<URI> connectedSystems = ConnectivityUtil.getStorageSystemAssociationsByNetwork(_dbClient, vplexSystem.getId(), StoragePort.PortType.backend);
if (connectedSystems.contains(desc.getDeviceURI())) {
StorageSystem array = getDataObject(StorageSystem.class, desc.getDeviceURI(), _dbClient);
arrayMap.put(desc.getDeviceURI(), array);
}
}
}
}
return arrayMap;
}
use of com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor.Type in project coprhd-controller by CoprHD.
the class VPlexDeviceController method buildVolumeMap.
/**
* Build a map of URI to cached Volumes for the underlying Storage Volumes that
* should be already present (and created).
*
* @param descriptors
* VolumeDescriptors
* @param VolmeDescriptor.Type
* used to filter descriptors
* @return Map<volumeURI, Volume>
*/
private Map<URI, Volume> buildVolumeMap(List<VolumeDescriptor> descriptors, VolumeDescriptor.Type type) {
Map<URI, Volume> volumeMap = new HashMap<URI, Volume>();
// Get only the descriptors for the type if specified.
if (type != null) {
descriptors = VolumeDescriptor.filterByType(descriptors, new VolumeDescriptor.Type[] { type }, new VolumeDescriptor.Type[] {});
}
for (VolumeDescriptor desc : descriptors) {
if (volumeMap.containsKey(desc.getVolumeURI()) == false) {
Volume volume = getDataObject(Volume.class, desc.getVolumeURI(), _dbClient);
volumeMap.put(desc.getVolumeURI(), volume);
}
}
return volumeMap;
}
use of com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor.Type in project coprhd-controller by CoprHD.
the class VPlexDeviceController method addStepsForCreateVolumes.
/**
* {@inheritDoc}
* <p>
* Here we should have already created any underlying volumes. What remains to be done: 1. Export the underlying Storage Volumes from
* the array to the VPlex. 2. Create the Virtual volume. 3. If a consistency group was specified, then create the consistency group if
* it does not exist, then add the volumes. If it already exists, just add the volumes.
*/
@Override
public String addStepsForCreateVolumes(Workflow workflow, String waitFor, List<VolumeDescriptor> volumes, String taskId) throws ControllerException {
try {
// Get only the VPlex volumes from the descriptors.
List<VolumeDescriptor> vplexVolumes = VolumeDescriptor.filterByType(volumes, new VolumeDescriptor.Type[] { VolumeDescriptor.Type.VPLEX_VIRT_VOLUME }, new VolumeDescriptor.Type[] {});
// If there are no VPlex volumes, just return
if (vplexVolumes.isEmpty()) {
_log.info("No VPLEX create volume steps required.");
return waitFor;
}
_log.info("Adding VPLEX create volume steps...");
// Segregate the volumes by Device.
Map<URI, List<VolumeDescriptor>> vplexDescMap = VolumeDescriptor.getDeviceMap(vplexVolumes);
// For each VPLEX to be provisioned (normally there is only one)
String lastStep = waitFor;
for (URI vplexURI : vplexDescMap.keySet()) {
StorageSystem vplexSystem = getDataObject(StorageSystem.class, vplexURI, _dbClient);
// Build some needed maps to get started.
Type[] types = new Type[] { Type.BLOCK_DATA, Type.SRDF_SOURCE, Type.SRDF_EXISTING_SOURCE, Type.SRDF_TARGET };
Map<URI, StorageSystem> arrayMap = buildArrayMap(vplexSystem, volumes, types);
Map<URI, Volume> volumeMap = buildVolumeMap(vplexSystem, volumes, Type.VPLEX_VIRT_VOLUME);
// Set the project and tenant to those of an underlying volume.
// These are used to set the project and tenant of a new ExportGroup if needed.
Volume firstVolume = volumeMap.values().iterator().next();
Project vplexProject = VPlexUtil.lookupVplexProject(firstVolume, vplexSystem, _dbClient);
URI tenantURI = vplexProject.getTenantOrg().getURI();
_log.info("Project is {}, Tenant is {}", vplexProject.getId(), tenantURI);
try {
// Now we need to do the necessary zoning and export steps to ensure
// the VPlex can see these new backend volumes.
lastStep = createWorkflowStepsForBlockVolumeExport(workflow, vplexSystem, arrayMap, volumeMap, vplexProject.getId(), tenantURI, lastStep);
} catch (Exception ex) {
_log.error("Could not create volumes for vplex: " + vplexURI, ex);
TaskCompleter completer = new VPlexTaskCompleter(Volume.class, vplexURI, taskId, null);
ServiceError serviceError = VPlexApiException.errors.jobFailed(ex);
completer.error(_dbClient, serviceError);
throw ex;
}
Map<URI, URI> computeResourceMap = new HashMap<>();
List<VolumeDescriptor> vplexDescrs = vplexDescMap.get(vplexURI);
for (VolumeDescriptor descr : vplexDescrs) {
URI computeResourceURI = descr.getComputeResource();
if (computeResourceURI != null) {
computeResourceMap.put(descr.getVolumeURI(), computeResourceURI);
}
}
// Now create each of the Virtual Volumes that may be necessary.
List<URI> vplexVolumeURIs = VolumeDescriptor.getVolumeURIs(vplexDescrs);
// Now make a Step to create the VPlex Virtual volume.
// This will be done from this controller.
String stepId = workflow.createStepId();
lastStep = workflow.createStep(VPLEX_STEP, String.format("VPlex %s creating virtual volumes:%n%s", vplexSystem.getId().toString(), BlockDeviceController.getVolumesMsg(_dbClient, vplexVolumeURIs)), lastStep, vplexURI, vplexSystem.getSystemType(), this.getClass(), createVirtualVolumesMethod(vplexURI, vplexVolumeURIs, computeResourceMap), rollbackCreateVirtualVolumesMethod(vplexURI, vplexVolumeURIs, stepId), stepId);
// Get one of the vplex volumes so we can determine what ConsistencyGroupManager
// implementation to use.
Volume vol = getDataObject(Volume.class, vplexVolumeURIs.get(0), _dbClient);
ConsistencyGroupManager consistencyGroupManager = getConsistencyGroupManager(vol);
// Deal with CGs.
// Filter out any VPlex Volumes that front the SRDF targets for now.
List<URI> volsForCG = VPlexSrdfUtil.filterOutVplexSrdfTargets(_dbClient, vplexVolumeURIs);
if (!volsForCG.isEmpty()) {
lastStep = consistencyGroupManager.addStepsForCreateConsistencyGroup(workflow, lastStep, vplexSystem, volsForCG, false);
}
// If there are VPlex Volumes fronting SRDF targets, handle them.
// They will go into a separate CG that represents the SRDF targets.
// That CG will have already been generated?
volsForCG = VPlexSrdfUtil.returnVplexSrdfTargets(_dbClient, vplexVolumeURIs);
if (!volsForCG.isEmpty()) {
lastStep = consistencyGroupManager.addStepsForAddingVolumesToSRDFTargetCG(workflow, vplexSystem, volsForCG, lastStep);
}
_log.info("Added steps for creating consistency group");
}
return lastStep;
} catch (Exception ex) {
throw VPlexApiException.exceptions.addStepsForCreateVolumesFailed(ex);
}
}
Aggregations