Search in sources :

Example 16 with VolumeDescriptor

use of com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor in project coprhd-controller by CoprHD.

the class SRDFBlockServiceApiImpl method changeVolumeVirtualPool.

@Override
public TaskList changeVolumeVirtualPool(List<Volume> volumes, VirtualPool vpool, VirtualPoolChangeParam vpoolChangeParam, String taskId) throws InternalException {
    TaskList taskList = createTasksForVolumes(vpool, volumes, taskId);
    // Check for common Vpool updates handled by generic code. It returns true if handled.
    if (checkCommonVpoolUpdates(volumes, vpool, taskId)) {
        return taskList;
    }
    // TODO Modified the code for COP-20817 Needs to revisit this code flow post release.
    // Run placement algorithm and collect all volume descriptors to create srdf target volumes in array.
    List<VolumeDescriptor> volumeDescriptorsList = new ArrayList<>();
    for (Volume volume : volumes) {
        // Check if the volume is normal without CG but new vPool with CG enabled.
        if (NullColumnValueGetter.isNullURI(volume.getConsistencyGroup()) && (null != vpool.getMultivolumeConsistency() && vpool.getMultivolumeConsistency())) {
            _log.info("VPool change is not permitted as volume is not part of CG but new VPool is consistency enabled.");
            throw APIException.badRequests.changeToVirtualPoolNotSupportedForNonCGVolume(volume.getId(), vpool.getLabel());
        }
        if (!NullColumnValueGetter.isNullNamedURI(volume.getSrdfParent()) || (volume.getSrdfTargets() != null && !volume.getSrdfTargets().isEmpty())) {
            throw APIException.badRequests.srdfVolumeVPoolChangeNotSupported(volume.getId());
        }
        // Get the storage system.
        StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, volume.getStorageController());
        String systemType = storageSystem.getSystemType();
        if (DiscoveredDataObject.Type.vmax.name().equals(systemType)) {
            _log.debug("SRDF Protection VirtualPool change for vmax volume.");
            volumeDescriptorsList.addAll(upgradeToSRDFTargetVolume(volume, vpool, vpoolChangeParam, taskId));
        } else {
            // not vmax volume
            throw APIException.badRequests.srdfVolumeVPoolChangeNotSupported(volume.getId());
        }
    }
    // CG Volume(srdf target) creation should execute as a single operation.
    // Otherwise, CreateGroupReplica method to create srdf pair between source and target group will have count
    // mismatch problem.
    BlockOrchestrationController controller = getController(BlockOrchestrationController.class, BlockOrchestrationController.BLOCK_ORCHESTRATION_DEVICE);
    controller.createVolumes(volumeDescriptorsList, taskId);
    _log.info("Change virutal pool steps has been successfully inititated");
    return taskList;
}
Also used : VolumeDescriptor(com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor) BlockOrchestrationController(com.emc.storageos.blockorchestrationcontroller.BlockOrchestrationController) Volume(com.emc.storageos.db.client.model.Volume) TaskList(com.emc.storageos.model.TaskList) ArrayList(java.util.ArrayList) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 17 with VolumeDescriptor

use of com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor in project coprhd-controller by CoprHD.

the class SRDFBlockServiceApiImpl method expandVolume.

/**
 * {@inheritDoc}
 *
 * @throws ControllerException
 */
@Override
public void expandVolume(final Volume volume, final long newSize, final String taskId) throws ControllerException {
    if (PersonalityTypes.TARGET.toString().equalsIgnoreCase(volume.getPersonality())) {
        throw APIException.badRequests.expandSupportedOnlyOnSource(volume.getId());
    }
    List<VolumeDescriptor> descriptors = getVolumeDescriptorsForExpandVolume(volume, newSize);
    BlockOrchestrationController controller = getController(BlockOrchestrationController.class, BlockOrchestrationController.BLOCK_ORCHESTRATION_DEVICE);
    // TODO : close JIRA CTRL-5335 SRDF expand needs to go via BlockOrchestrationController.
    controller.expandVolume(descriptors, taskId);
}
Also used : VolumeDescriptor(com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor) BlockOrchestrationController(com.emc.storageos.blockorchestrationcontroller.BlockOrchestrationController)

Example 18 with VolumeDescriptor

use of com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor in project coprhd-controller by CoprHD.

the class SRDFBlockServiceApiImpl method createVolumesAndDescriptors.

@Override
public List<VolumeDescriptor> createVolumesAndDescriptors(List<VolumeDescriptor> descriptors, String volumeLabel, Long size, Project project, VirtualArray varray, VirtualPool vpool, List<Recommendation> recommendations, TaskList taskList, String task, VirtualPoolCapabilityValuesWrapper capabilities) {
    List<VolumeDescriptor> volumeDescriptors = new ArrayList<VolumeDescriptor>();
    // If processing SRDFCopyRecommendations, then just return the SRDFTargets.
    for (Recommendation recommendation : recommendations) {
        if (recommendation instanceof SRDFCopyRecommendation) {
            SRDFRecommendation srdfRecommendation = (SRDFRecommendation) recommendation.getRecommendation();
            // Get the Target structure
            SRDFRecommendation.Target target = srdfRecommendation.getVirtualArrayTargetMap().get(recommendation.getVirtualArray());
            if (target.getDescriptors() != null) {
                volumeDescriptors.addAll(target.getDescriptors());
            }
        }
        // so if we had SRDFCopyRecommendations, just return their descriptors now.
        if (!volumeDescriptors.isEmpty()) {
            return volumeDescriptors;
        }
    }
    // operation for each volume to be created.
    if (taskList == null) {
        taskList = new TaskList();
    }
    Iterator<Recommendation> recommendationsIter;
    final BlockConsistencyGroup consistencyGroup = capabilities.getBlockConsistencyGroup() == null ? null : _dbClient.queryObject(BlockConsistencyGroup.class, capabilities.getBlockConsistencyGroup());
    // prepare the volumes
    List<URI> volumeURIs = prepareRecommendedVolumes(task, taskList, project, varray, vpool, capabilities.getResourceCount(), recommendations, consistencyGroup, volumeLabel, size.toString());
    // Execute the volume creations requests for each recommendation.
    recommendationsIter = recommendations.iterator();
    while (recommendationsIter.hasNext()) {
        Recommendation recommendation = recommendationsIter.next();
        volumeDescriptors.addAll(createVolumeDescriptors((SRDFRecommendation) recommendation, volumeURIs, capabilities));
        // Log volume descriptor information
        logVolumeDescriptorPrecreateInfo(volumeDescriptors, task);
    }
    return volumeDescriptors;
}
Also used : SRDFRecommendation(com.emc.storageos.volumecontroller.SRDFRecommendation) VolumeDescriptor(com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor) TaskList(com.emc.storageos.model.TaskList) ArrayList(java.util.ArrayList) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) MetaVolumeRecommendation(com.emc.storageos.volumecontroller.impl.smis.MetaVolumeRecommendation) SRDFCopyRecommendation(com.emc.storageos.volumecontroller.SRDFCopyRecommendation) Recommendation(com.emc.storageos.volumecontroller.Recommendation) SRDFRecommendation(com.emc.storageos.volumecontroller.SRDFRecommendation) SRDFCopyRecommendation(com.emc.storageos.volumecontroller.SRDFCopyRecommendation) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup)

Example 19 with VolumeDescriptor

use of com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor in project coprhd-controller by CoprHD.

the class SRDFBlockServiceApiImpl method createVolumeDescriptors.

/**
 * Prep work to call the orchestrator to create the volume descriptors
 *
 * @param recommendation
 *            recommendation object from SRDFRecommendation
 * @param volumeURIs
 *            volumes already prepared
 * @param capabilities
 *            vpool capabilities
 * @return list of volume descriptors
 * @throws ControllerException
 */
private List<VolumeDescriptor> createVolumeDescriptors(final SRDFRecommendation recommendation, final List<URI> volumeURIs, final VirtualPoolCapabilityValuesWrapper capabilities) throws ControllerException {
    List<VolumeDescriptor> descriptors = new ArrayList<VolumeDescriptor>();
    // Package up the prepared Volumes into descriptors
    for (URI volumeURI : volumeURIs) {
        Volume volume = _dbClient.queryObject(Volume.class, volumeURI);
        VolumeDescriptor.Type volumeType = VolumeDescriptor.Type.SRDF_SOURCE;
        // created
        if (recommendation.getVpoolChangeVolume() != null && recommendation.getVpoolChangeVolume().equals(volume.getId())) {
            volumeType = VolumeDescriptor.Type.SRDF_EXISTING_SOURCE;
            VolumeDescriptor desc = new VolumeDescriptor(volumeType, volume.getStorageController(), volume.getId(), volume.getPool(), null, capabilities, volume.getCapacity());
            Map<String, Object> volumeParams = new HashMap<String, Object>();
            volumeParams.put(VolumeDescriptor.PARAM_VPOOL_CHANGE_EXISTING_VOLUME_ID, recommendation.getVpoolChangeVolume());
            volumeParams.put(VolumeDescriptor.PARAM_VPOOL_CHANGE_NEW_VPOOL_ID, recommendation.getVpoolChangeVpool());
            volumeParams.put(VolumeDescriptor.PARAM_VPOOL_CHANGE_OLD_VPOOL_ID, volume.getVirtualPool());
            desc.setParameters(volumeParams);
            descriptors.add(desc);
            _log.info("Adding Source Volume Descriptor for: " + desc.toString());
        } else {
            // Normal create-from-scratch flow
            if (volume.getPersonality() == null) {
                throw APIException.badRequests.srdfVolumeMissingPersonalityAttribute(volume.getId());
            }
            if (volume.getPersonality().equals(Volume.PersonalityTypes.TARGET.toString())) {
                volumeType = VolumeDescriptor.Type.SRDF_TARGET;
            }
            VolumeDescriptor desc = new VolumeDescriptor(volumeType, volume.getStorageController(), volume.getId(), volume.getPool(), null, capabilities, volume.getCapacity());
            descriptors.add(desc);
            // Then it will be returned if accessed by SRDFCopyRecommendation
            if (volumeType == VolumeDescriptor.Type.SRDF_TARGET) {
                // Find the appropriate target
                SRDFRecommendation.Target target = recommendation.getVirtualArrayTargetMap().get(volume.getVirtualArray());
                if (target != null) {
                    List<VolumeDescriptor> targetDescriptors = target.getDescriptors();
                    if (targetDescriptors == null) {
                        targetDescriptors = new ArrayList<VolumeDescriptor>();
                        target.setDescriptors(targetDescriptors);
                    }
                    targetDescriptors.add(desc);
                }
                _log.error("No target recommendation found in the recommendation virtualArrayTargetMap");
            }
            _log.info("Adding Non-Source Volume Descriptor for: " + desc.toString());
        }
    }
    return descriptors;
}
Also used : VolumeDescriptor(com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) SRDFRecommendation(com.emc.storageos.volumecontroller.SRDFRecommendation) Volume(com.emc.storageos.db.client.model.Volume) DataObject(com.emc.storageos.db.client.model.DataObject) DiscoveredDataObject(com.emc.storageos.db.client.model.DiscoveredDataObject)

Example 20 with VolumeDescriptor

use of com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor in project coprhd-controller by CoprHD.

the class AbstractBlockServiceApiImpl method deleteVolumes.

/**
 * {@inheritDoc}
 *
 * @throws InternalException
 */
@Override
public void deleteVolumes(URI systemURI, List<URI> volumeURIs, String deletionType, String task) throws InternalException {
    // Get volume descriptor for all volumes to be deleted.
    List<VolumeDescriptor> volumeDescriptors = getDescriptorsForVolumesToBeDeleted(systemURI, volumeURIs, deletionType);
    // the controller and delete the volumes.
    if (VolumeDeleteTypeEnum.VIPR_ONLY.name().equals(deletionType)) {
        // Do any cleanup necessary for the ViPR only delete.
        cleanupForViPROnlyDelete(volumeDescriptors);
        // Mark them inactive. Note that some of the volumes may be mirrors,
        // which have a different database type.
        List<VolumeDescriptor> descriptorsForMirrors = VolumeDescriptor.getDescriptors(volumeDescriptors, VolumeDescriptor.Type.BLOCK_MIRROR);
        _dbClient.markForDeletion(_dbClient.queryObject(BlockMirror.class, VolumeDescriptor.getVolumeURIs(descriptorsForMirrors)));
        List<VolumeDescriptor> descriptorsForVolumes = VolumeDescriptor.filterByType(volumeDescriptors, null, new VolumeDescriptor.Type[] { VolumeDescriptor.Type.BLOCK_MIRROR });
        _dbClient.markForDeletion(_dbClient.queryObject(Volume.class, VolumeDescriptor.getVolumeURIs(descriptorsForVolumes)));
        // Delete the corresponding FCZoneReferences
        for (URI volumeURI : volumeURIs) {
            List<FCZoneReference> zoneReferences = CustomQueryUtility.queryActiveResourcesByAltId(_dbClient, FCZoneReference.class, "volumeUri", volumeURI.toString());
            for (FCZoneReference zoneReference : zoneReferences) {
                if (zoneReference != null) {
                    _dbClient.markForDeletion(zoneReference);
                }
            }
        }
        // Update the task status for each volume
        for (URI volumeURI : volumeURIs) {
            Volume volume = _dbClient.queryObject(Volume.class, volumeURI);
            Operation op = volume.getOpStatus().get(task);
            op.ready("Volume succesfully deleted from ViPR");
            volume.getOpStatus().updateTaskStatus(task, op);
            _dbClient.updateObject(volume);
        }
    } else {
        BlockOrchestrationController controller = getController(BlockOrchestrationController.class, BlockOrchestrationController.BLOCK_ORCHESTRATION_DEVICE);
        controller.deleteVolumes(volumeDescriptors, task);
    }
}
Also used : VolumeDescriptor(com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor) BlockOrchestrationController(com.emc.storageos.blockorchestrationcontroller.BlockOrchestrationController) BlockMirror(com.emc.storageos.db.client.model.BlockMirror) Volume(com.emc.storageos.db.client.model.Volume) Operation(com.emc.storageos.db.client.model.Operation) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) FCZoneReference(com.emc.storageos.db.client.model.FCZoneReference)

Aggregations

VolumeDescriptor (com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor)117 Volume (com.emc.storageos.db.client.model.Volume)98 URI (java.net.URI)86 NamedURI (com.emc.storageos.db.client.model.NamedURI)77 ArrayList (java.util.ArrayList)77 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)38 HashMap (java.util.HashMap)38 StringSet (com.emc.storageos.db.client.model.StringSet)29 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)27 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)19 FCTN_STRING_TO_URI (com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_STRING_TO_URI)18 Workflow (com.emc.storageos.workflow.Workflow)18 ApplicationAddVolumeList (com.emc.storageos.volumecontroller.ApplicationAddVolumeList)17 ControllerException (com.emc.storageos.volumecontroller.ControllerException)17 List (java.util.List)17 BlockOrchestrationController (com.emc.storageos.blockorchestrationcontroller.BlockOrchestrationController)16 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)16 InternalServerErrorException (com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException)16 URISyntaxException (java.net.URISyntaxException)16 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)15