Search in sources :

Example 1 with Type

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;
}
Also used : LockType(com.emc.storageos.locking.LockType) Type(com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor.Type) TechnologyType(com.emc.storageos.db.client.model.BlockSnapshot.TechnologyType) Initiator_Type(com.emc.storageos.vplex.api.VPlexInitiatorInfo.Initiator_Type) VolumeDescriptor(com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor) HashMap(java.util.HashMap) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 2 with Type

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;
}
Also used : LockType(com.emc.storageos.locking.LockType) Type(com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor.Type) TechnologyType(com.emc.storageos.db.client.model.BlockSnapshot.TechnologyType) Initiator_Type(com.emc.storageos.vplex.api.VPlexInitiatorInfo.Initiator_Type) VolumeDescriptor(com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor) Volume(com.emc.storageos.db.client.model.Volume) HashMap(java.util.HashMap) StringSet(com.emc.storageos.db.client.model.StringSet) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI)

Example 3 with Type

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;
}
Also used : LockType(com.emc.storageos.locking.LockType) Type(com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor.Type) TechnologyType(com.emc.storageos.db.client.model.BlockSnapshot.TechnologyType) Initiator_Type(com.emc.storageos.vplex.api.VPlexInitiatorInfo.Initiator_Type) VolumeDescriptor(com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor) HashMap(java.util.HashMap) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 4 with Type

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;
}
Also used : LockType(com.emc.storageos.locking.LockType) Type(com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor.Type) TechnologyType(com.emc.storageos.db.client.model.BlockSnapshot.TechnologyType) Initiator_Type(com.emc.storageos.vplex.api.VPlexInitiatorInfo.Initiator_Type) VolumeDescriptor(com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor) Volume(com.emc.storageos.db.client.model.Volume) HashMap(java.util.HashMap) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI)

Example 5 with Type

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);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) VolumeDescriptor(com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor) HashMap(java.util.HashMap) 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) VPlexApiException(com.emc.storageos.vplex.api.VPlexApiException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) Project(com.emc.storageos.db.client.model.Project) LockType(com.emc.storageos.locking.LockType) Type(com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor.Type) TechnologyType(com.emc.storageos.db.client.model.BlockSnapshot.TechnologyType) Initiator_Type(com.emc.storageos.vplex.api.VPlexInitiatorInfo.Initiator_Type) Volume(com.emc.storageos.db.client.model.Volume) ApplicationAddVolumeList(com.emc.storageos.volumecontroller.ApplicationAddVolumeList) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) List(java.util.List) ExportTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportTaskCompleter) MigrationTaskCompleter(com.emc.storageos.vplexcontroller.completers.MigrationTaskCompleter) CloneTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneTaskCompleter) MigrationOperationTaskCompleter(com.emc.storageos.vplexcontroller.completers.MigrationOperationTaskCompleter) CacheStatusTaskCompleter(com.emc.storageos.vplexcontroller.completers.CacheStatusTaskCompleter) VplexMirrorTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VplexMirrorTaskCompleter) VolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeTaskCompleter) VolumeGroupUpdateTaskCompleter(com.emc.storageos.vplexcontroller.completers.VolumeGroupUpdateTaskCompleter) TaskCompleter(com.emc.storageos.volumecontroller.TaskCompleter) WorkflowTaskCompleter(com.emc.storageos.workflow.WorkflowTaskCompleter) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

VolumeDescriptor (com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor)5 Type (com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor.Type)5 TechnologyType (com.emc.storageos.db.client.model.BlockSnapshot.TechnologyType)5 NamedURI (com.emc.storageos.db.client.model.NamedURI)5 LockType (com.emc.storageos.locking.LockType)5 Initiator_Type (com.emc.storageos.vplex.api.VPlexInitiatorInfo.Initiator_Type)5 URI (java.net.URI)5 HashMap (java.util.HashMap)5 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)3 Volume (com.emc.storageos.db.client.model.Volume)3 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)1 Project (com.emc.storageos.db.client.model.Project)1 StringSet (com.emc.storageos.db.client.model.StringSet)1 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)1 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)1 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)1 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)1 InternalServerErrorException (com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException)1 ApplicationAddVolumeList (com.emc.storageos.volumecontroller.ApplicationAddVolumeList)1 ControllerException (com.emc.storageos.volumecontroller.ControllerException)1