Search in sources :

Example 81 with VirtualPool

use of com.emc.storageos.db.client.model.VirtualPool in project coprhd-controller by CoprHD.

the class VPlexBlockServiceApiImpl method updateBackendVolumeToMirrorVpoolMap.

/**
 * Convenience method to update backendVolumeToMirrorVpoolMap for the VPLEX Distributed volume.
 * In case if there is already mirror for the vplex volume, this method ensures
 * to add entry to the map only if there isn't already mirror on either leg.
 *
 * @param vplexVolume The reference to vplex distributed volume
 * @param associatedVolumeIds URIs of the associated volumes
 * @param sourceVirtualPool The reference to virtual pool to which vplex volume is associated with
 * @param sourceMirrorVPool The reference to virtual pool for the mirror on the source side
 * @param haMirrorVPool The reference to virtual pool for the mirror on the HA side
 * @param backendVolumeToMirrorVpoolMap OUT param containing map of backend volume to mirror vpool
 */
private void updateBackendVolumeToMirrorVpoolMap(Volume vplexVolume, StringSet associatedVolumeIds, VirtualPool sourceVirtualPool, VirtualPool sourceMirrorVPool, VirtualPool haMirrorVPool, Map<Volume, VirtualPool> backendVolumeToMirrorVpoolMap) {
    Set<String> vplexClusterWithMirrorForVolume = new HashSet<String>();
    // Set vplexClusterWithMirrorForVolume contains Vplex Cluster on which mirror already exist for the vplex volume
    if (vplexVolume.getMirrors() != null && !vplexVolume.getMirrors().isEmpty()) {
        StringSet existingMirrors = vplexVolume.getMirrors();
        for (String existingMirrorURI : existingMirrors) {
            VplexMirror existingMirror = _dbClient.queryObject(VplexMirror.class, URI.create(existingMirrorURI));
            if (existingMirror != null && !existingMirror.getInactive()) {
                String cluster = ConnectivityUtil.getVplexClusterForVarray(existingMirror.getVirtualArray(), vplexVolume.getStorageController(), _dbClient);
                checkIfClusterIsUnknown(cluster, existingMirror.getVirtualArray().toString(), vplexVolume.getStorageController().toString());
                vplexClusterWithMirrorForVolume.add(cluster);
            }
        }
        s_logger.info("Vplex Mirror(s) already exists for Vplex volume" + vplexVolume.getLabel() + " " + vplexVolume.getId() + " on cluster " + vplexClusterWithMirrorForVolume);
    }
    for (String associatedVolumeId : associatedVolumeIds) {
        if (sourceMirrorVPool != null && sourceVirtualPool.getMaxNativeContinuousCopies() > 0) {
            // Get the source backend volume
            Volume associatedVolume = VPlexUtil.getVPLEXBackendVolume(vplexVolume, true, _dbClient);
            if (associatedVolume != null && associatedVolume.getId().toString().equals(associatedVolumeId)) {
                if (!vplexClusterWithMirrorForVolume.isEmpty()) {
                    // Get the vplex cluster for the source varray
                    String cluster = ConnectivityUtil.getVplexClusterForVarray(vplexVolume.getVirtualArray(), vplexVolume.getStorageController(), _dbClient);
                    checkIfClusterIsUnknown(cluster, vplexVolume.getVirtualArray().toString(), vplexVolume.getStorageController().toString());
                    // If there isn't already mirror on the source side then add entry to backendVolumeToMirrorVpoolMap
                    if (!vplexClusterWithMirrorForVolume.contains(cluster)) {
                        backendVolumeToMirrorVpoolMap.put(associatedVolume, sourceMirrorVPool);
                    }
                } else {
                    backendVolumeToMirrorVpoolMap.put(associatedVolume, sourceMirrorVPool);
                }
            }
        } else {
            s_logger.info("The max native continuous copies for the source Vpool {} is {} ", sourceVirtualPool.getLabel(), sourceVirtualPool.getMaxNativeContinuousCopies());
            if (sourceMirrorVPool == null) {
                s_logger.info("The mirror will not be created on the source side as the source mirror pool is not provided " + "in the virtual pool {} {}", sourceVirtualPool.getLabel(), sourceVirtualPool.getId());
            }
        }
        VirtualPool haVPool = VirtualPool.getHAVPool(sourceVirtualPool, _dbClient);
        if (haMirrorVPool != null && haVPool != null && haVPool.getMaxNativeContinuousCopies() > 0) {
            // Get the HA backend volume
            Volume associatedVolume = VPlexUtil.getVPLEXBackendVolume(vplexVolume, false, _dbClient);
            if (associatedVolume != null && associatedVolume.getId().toString().equals(associatedVolumeId)) {
                if (!vplexClusterWithMirrorForVolume.isEmpty()) {
                    // Get HA varray
                    URI haVarrayURI = VPlexUtil.getHAVarray(sourceVirtualPool);
                    if (haVarrayURI != null) {
                        // Get the vplex cluster for the HA varray
                        String cluster = ConnectivityUtil.getVplexClusterForVarray(haVarrayURI, vplexVolume.getStorageController(), _dbClient);
                        checkIfClusterIsUnknown(cluster, haVarrayURI.toString(), vplexVolume.getStorageController().toString());
                        // If there isn't already mirror on the HA side then add entry to backendVolumeToMirrorVpoolMap
                        if (!vplexClusterWithMirrorForVolume.contains(cluster)) {
                            backendVolumeToMirrorVpoolMap.put(associatedVolume, haMirrorVPool);
                        }
                    }
                } else {
                    backendVolumeToMirrorVpoolMap.put(associatedVolume, haMirrorVPool);
                }
            }
        } else {
            if (haVPool != null) {
                s_logger.info("The max native continuous copies for the HA Vpool {} is {} ", haVPool.getLabel(), haVPool.getMaxNativeContinuousCopies());
                if (haMirrorVPool == null) {
                    s_logger.info("The mirror will not be created on the HA side as the HA mirror pool is not provided " + "in the virtual pool {} {}", haVPool.getLabel(), haVPool.getId());
                }
            }
        }
    }
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) StringSet(com.emc.storageos.db.client.model.StringSet) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) VplexMirror(com.emc.storageos.db.client.model.VplexMirror) FCTN_STRING_TO_URI(com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_STRING_TO_URI) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) FCTN_VPLEX_MIRROR_TO_URI(com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_VPLEX_MIRROR_TO_URI) HashSet(java.util.HashSet)

Example 82 with VirtualPool

use of com.emc.storageos.db.client.model.VirtualPool in project coprhd-controller by CoprHD.

the class VPlexBlockServiceApiImpl method makeBackendVolumeDescriptors.

/**
 * Takes a list of recommendations and makes the backend volumes and volume descriptors needed to
 * provision. When possible (e.g. for SRDF and Block), All recommendations must be in single varray.
 * calls the underlying storage routine createVolumesAndDescriptors().
 *
 * @param recommendations -- a VPlex recommendation list
 * @param project - Project containing the Vplex volumes
 * @param vplexProject -- private project of the Vplex
 * @param rootVpool -- top level Virtual Pool (VpoolUse.ROOT)
 * @param varrayCount -- instance count of the varray being provisioned
 * @param size -- size of each volume
 * @param backendCG -- the CG to be used on the backend Storage Systems
 * @param vPoolCapabilities - a VirtualPoolCapabilityValuesWrapper containing provisioning arguments
 * @param createTask -- boolean if true creates a task
 * @param task -- Overall task id
 * @return -- list of VolumeDescriptors to be provisioned
 */
private List<VolumeDescriptor> makeBackendVolumeDescriptors(List<VPlexRecommendation> recommendations, Project project, Project vplexProject, VirtualPool rootVpool, String volumeLabel, int varrayCount, long size, BlockConsistencyGroup backendCG, VirtualPoolCapabilityValuesWrapper vPoolCapabilities, boolean createTask, String task) {
    VPlexRecommendation firstRecommendation = recommendations.get(0);
    List<VolumeDescriptor> descriptors = new ArrayList<VolumeDescriptor>();
    URI varrayId = firstRecommendation.getVirtualArray();
    VirtualPool vpool = firstRecommendation.getVirtualPool();
    s_logger.info("Generated backend descriptors for {} recommendations varray {}", recommendations.size(), varrayCount);
    vPoolCapabilities.put(VirtualPoolCapabilityValuesWrapper.AUTO_TIER__POLICY_NAME, vpool.getAutoTierPolicyName());
    if (firstRecommendation.getRecommendation() != null) {
        // If these recommendations have lower level recommendation, process them.
        // This path is used for the source side of Distributed Volumes and for Local volumes
        // where we support building on top of SRDF or the BlockStorage as appropriate.
        List<Recommendation> childRecommendations = new ArrayList<Recommendation>();
        Recommendation childRecommendation = null;
        for (VPlexRecommendation recommendation : recommendations) {
            childRecommendation = recommendation.getRecommendation();
            childRecommendations.add(childRecommendation);
        }
        VirtualArray varray = _dbClient.queryObject(VirtualArray.class, varrayId);
        String newVolumeLabel = generateVolumeLabel(volumeLabel, varrayCount, 0, 0);
        boolean srdfTarget = (childRecommendation instanceof SRDFCopyRecommendation);
        boolean srdfSource = (childRecommendation instanceof SRDFRecommendation);
        if (srdfTarget) {
            newVolumeLabel = newVolumeLabel + "-target";
        } else if (srdfSource) {
        } else {
            // nothing special about these volumes, hide them in the vplex project
            // We can't use the vplexProject for SRDF volumes as they determine their RDF group
            // grom the project.
            project = vplexProject;
        }
        TaskList taskList = new TaskList();
        descriptors = super.createVolumesAndDescriptors(descriptors, newVolumeLabel, size, project, varray, vpool, childRecommendations, taskList, task, vPoolCapabilities);
        VolumeDescriptor.Type[] types;
        if (srdfTarget) {
            types = new VolumeDescriptor.Type[] { VolumeDescriptor.Type.SRDF_TARGET };
        } else {
            types = new VolumeDescriptor.Type[] { VolumeDescriptor.Type.BLOCK_DATA, VolumeDescriptor.Type.SRDF_SOURCE, VolumeDescriptor.Type.SRDF_EXISTING_SOURCE };
        }
        descriptors = VolumeDescriptor.filterByType(descriptors, types);
        for (VolumeDescriptor descriptor : descriptors) {
            Volume volume = _dbClient.queryObject(Volume.class, descriptor.getVolumeURI());
            s_logger.info(String.format("Received prepared volume %s (%s, args) type %s", volume.getLabel(), volume.getId(), descriptor.getType().name()));
            volume.addInternalFlags(DataObject.Flag.INTERNAL_OBJECT);
            configureCGAndReplicationGroup(rootVpool, vPoolCapabilities, backendCG, volume);
            _dbClient.updateObject(volume);
        }
        return descriptors;
    }
    // Sum resourceCount across all recommendations
    int totalResourceCount = 0;
    for (VPlexRecommendation recommendation : recommendations) {
        totalResourceCount += recommendation.getResourceCount();
    }
    // The code below is used for the HA side of distributed volumes.
    // The HA side does not currently call the lower level schedulers to get descriptors.
    s_logger.info("Processing recommendations for Virtual Array {}", varrayId);
    int volumeCounter = 0;
    for (VPlexRecommendation recommendation : recommendations) {
        for (int i = 0; i < recommendation.getResourceCount(); i++) {
            vpool = recommendation.getVirtualPool();
            URI storageDeviceURI = recommendation.getSourceStorageSystem();
            URI storagePoolURI = recommendation.getSourceStoragePool();
            String newVolumeLabel = generateVolumeLabel(volumeLabel, varrayCount, volumeCounter, totalResourceCount);
            validateVolumeLabel(newVolumeLabel, project);
            s_logger.info("Volume label is {}", newVolumeLabel);
            VirtualArray varray = _dbClient.queryObject(VirtualArray.class, varrayId);
            // This is also handled in StorageScheduler.prepareRecomendedVolumes
            long thinVolumePreAllocationSize = 0;
            if (null != vpool.getThinVolumePreAllocationPercentage()) {
                thinVolumePreAllocationSize = VirtualPoolUtil.getThinVolumePreAllocationSize(vpool.getThinVolumePreAllocationPercentage(), size);
            }
            Volume volume = prepareVolume(VolumeType.BLOCK_VOLUME, null, size, thinVolumePreAllocationSize, vplexProject, varray, vpool, storageDeviceURI, storagePoolURI, newVolumeLabel, backendCG, vPoolCapabilities);
            configureCGAndReplicationGroup(rootVpool, vPoolCapabilities, backendCG, volume);
            volume.addInternalFlags(Flag.INTERNAL_OBJECT);
            _dbClient.persistObject(volume);
            if (createTask) {
                _dbClient.createTaskOpStatus(Volume.class, volume.getId(), task, ResourceOperationTypeEnum.CREATE_BLOCK_VOLUME);
            }
            s_logger.info("Prepared volume {} ({}) ", volume.getLabel(), volume.getId());
            VolumeDescriptor descriptor = new VolumeDescriptor(VolumeDescriptor.Type.BLOCK_DATA, storageDeviceURI, volume.getId(), storagePoolURI, backendCG == null ? null : backendCG.getId(), vPoolCapabilities, size);
            descriptors.add(descriptor);
            volumeCounter++;
        }
    }
    return descriptors;
}
Also used : VolumeDescriptor(com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor) VirtualArray(com.emc.storageos.db.client.model.VirtualArray) VPlexRecommendation(com.emc.storageos.volumecontroller.VPlexRecommendation) TaskList(com.emc.storageos.model.TaskList) ArrayList(java.util.ArrayList) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) FCTN_STRING_TO_URI(com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_STRING_TO_URI) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) FCTN_VPLEX_MIRROR_TO_URI(com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_VPLEX_MIRROR_TO_URI) SRDFCopyRecommendation(com.emc.storageos.volumecontroller.SRDFCopyRecommendation) VolumeRecommendation(com.emc.storageos.api.service.impl.placement.VolumeRecommendation) VPlexRecommendation(com.emc.storageos.volumecontroller.VPlexRecommendation) Recommendation(com.emc.storageos.volumecontroller.Recommendation) SRDFRecommendation(com.emc.storageos.volumecontroller.SRDFRecommendation) PrefixConstraint(com.emc.storageos.db.client.constraint.PrefixConstraint) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) ContainmentPrefixConstraint(com.emc.storageos.db.client.constraint.ContainmentPrefixConstraint) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) SRDFCopyRecommendation(com.emc.storageos.volumecontroller.SRDFCopyRecommendation) SRDFRecommendation(com.emc.storageos.volumecontroller.SRDFRecommendation) VolumeType(com.emc.storageos.api.service.impl.placement.VolumeRecommendation.VolumeType) Volume(com.emc.storageos.db.client.model.Volume)

Example 83 with VirtualPool

use of com.emc.storageos.db.client.model.VirtualPool in project coprhd-controller by CoprHD.

the class VirtualDataCenterCapacityService method getVirtualArrayVirtualPoolCapacities.

private VirtualArrayVirtualPoolCapacity getVirtualArrayVirtualPoolCapacities(URI vArrayId) {
    VirtualArrayVirtualPoolCapacity vArrayCap = new VirtualArrayVirtualPoolCapacity();
    vArrayCap.setId(vArrayId);
    vArrayCap.setVpoolCapacities(new ArrayList<VirtualPoolCapacity>());
    URIQueryResultList resultList = new URIQueryResultList();
    _dbClient.queryByConstraint(ContainmentConstraint.Factory.getVirtualArrayVirtualPoolConstraint(vArrayId), resultList);
    Iterator<URI> vPoolIterator = resultList.iterator();
    int c = 0;
    while (vPoolIterator.hasNext()) {
        URI vPoolId = vPoolIterator.next();
        VirtualPool vPool = _permissionsHelper.getObjectById(vPoolId, VirtualPool.class);
        vArrayCap.getVpoolCapacities().add(getVirtualPoolCapacities(vArrayId, vPool));
        c++;
    }
    logger.info("{} vpool in varray {}", c, vArrayId);
    return vArrayCap;
}
Also used : VirtualPoolCapacity(com.emc.storageos.model.vpool.VirtualPoolCapacity) VirtualArrayVirtualPoolCapacity(com.emc.storageos.model.vpool.VirtualArrayVirtualPoolCapacity) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) URI(java.net.URI) VirtualArrayVirtualPoolCapacity(com.emc.storageos.model.vpool.VirtualArrayVirtualPoolCapacity) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint)

Example 84 with VirtualPool

use of com.emc.storageos.db.client.model.VirtualPool in project coprhd-controller by CoprHD.

the class VirtualPoolService method populateCommonVirtualPoolCreateParams.

/**
 * This method is used to set the common VirtualPool create params in
 * VirtualPool model.
 *
 * @param vpool : VirtualPool object to populate params.
 * @param param : VirtualPoolCreate params.
 * @throws DatabaseException
 */
protected void populateCommonVirtualPoolCreateParams(VirtualPool vpool, VirtualPoolCommonParam param) throws DatabaseException {
    // ArgValidator.checkFieldNotEmpty(param.getName(), VPOOL_NAME);
    if (StringUtils.isNotEmpty(param.getName())) {
        vpool.setLabel(param.getName());
    }
    if (StringUtils.isNotEmpty(param.getDescription())) {
        vpool.setDescription(param.getDescription());
    }
    ArgValidator.checkFieldNotEmpty(param.getProvisionType(), VPOOL_PROVISIONING_TYPE);
    ArgValidator.checkFieldValueFromEnum(param.getProvisionType(), VPOOL_PROVISIONING_TYPE, EnumSet.of(ProvisioningType.Thick, ProvisioningType.Thin));
    vpool.setId(URIUtil.createId(VirtualPool.class));
    if (null != param.getProvisionType()) {
        vpool.setSupportedProvisioningType(param.getProvisionType());
    }
    vpool.setMaxNativeSnapshots(0);
    vpool.setProtocols(new StringSet());
    // Validate the protocols for not null and non-empty values
    ArgValidator.checkFieldNotEmpty(param.getProtocols(), VPOOL_PROTOCOLS);
    // Validate the protocols for type of VirtualPool.
    validateVirtualPoolProtocol(vpool.getType(), param.getProtocols());
    vpool.getProtocols().addAll(param.getProtocols());
    // validate and set neighborhoods
    if (param.getVarrays() != null) {
        vpool.setVirtualArrays(new StringSet());
        for (String neighborhood : param.getVarrays()) {
            URI neighborhoodURI = URI.create(neighborhood);
            ArgValidator.checkUri(neighborhoodURI);
            VirtualArray varray = _dbClient.queryObject(VirtualArray.class, neighborhoodURI);
            ArgValidator.checkEntity(varray, neighborhoodURI, isIdEmbeddedInURL(neighborhoodURI));
            vpool.getVirtualArrays().add(neighborhood);
        }
    }
    // Set the useMatchedPools flag.
    vpool.setUseMatchedPools(param.getUseMatchedPools());
}
Also used : VirtualArray(com.emc.storageos.db.client.model.VirtualArray) StringSet(com.emc.storageos.db.client.model.StringSet) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) URI(java.net.URI)

Example 85 with VirtualPool

use of com.emc.storageos.db.client.model.VirtualPool in project coprhd-controller by CoprHD.

the class VirtualPoolService method updateAclsOnVirtualPool.

protected ACLAssignments updateAclsOnVirtualPool(VirtualPool.Type type, URI id, ACLAssignmentChanges changes) {
    VirtualPool vpool = queryResource(id);
    ArgValidator.checkEntityNotNull(vpool, id, isIdEmbeddedInURL(id));
    if (!vpool.getType().equals(type.name())) {
        throw APIException.badRequests.providedVirtualPoolNotCorrectType();
    }
    _permissionsHelper.updateACLs(vpool, changes, new PermissionsHelper.UsageACLFilter(_permissionsHelper, vpool.getType()));
    _dbClient.updateAndReindexObject(vpool);
    auditOp(OperationTypeEnum.MODIFY_VPOOL_ACL, true, null, vpool.getId().toString(), vpool.getLabel(), vpool.getType());
    return getAclsOnVirtualPool(type, id);
}
Also used : PermissionsHelper(com.emc.storageos.api.service.authorization.PermissionsHelper) VirtualPool(com.emc.storageos.db.client.model.VirtualPool)

Aggregations

VirtualPool (com.emc.storageos.db.client.model.VirtualPool)339 URI (java.net.URI)189 ArrayList (java.util.ArrayList)122 Volume (com.emc.storageos.db.client.model.Volume)103 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)92 NamedURI (com.emc.storageos.db.client.model.NamedURI)88 VirtualArray (com.emc.storageos.db.client.model.VirtualArray)88 StringSet (com.emc.storageos.db.client.model.StringSet)76 Project (com.emc.storageos.db.client.model.Project)65 StoragePool (com.emc.storageos.db.client.model.StoragePool)57 StringMap (com.emc.storageos.db.client.model.StringMap)53 HashMap (java.util.HashMap)52 Produces (javax.ws.rs.Produces)50 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)45 VirtualPoolCapabilityValuesWrapper (com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper)44 List (java.util.List)44 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)42 Path (javax.ws.rs.Path)42 TenantOrg (com.emc.storageos.db.client.model.TenantOrg)37 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)37