Search in sources :

Example 26 with VirtualPoolCapabilityValuesWrapper

use of com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper in project coprhd-controller by CoprHD.

the class BucketService method initiateBucketCreation.

private TaskResourceRep initiateBucketCreation(BucketParam param, Project project, TenantOrg tenant, DataObject.Flag[] flags) throws InternalException {
    ArgValidator.checkFieldUriType(param.getVpool(), VirtualPool.class, "vpool");
    ArgValidator.checkFieldUriType(param.getVarray(), VirtualArray.class, "varray");
    Long softQuota = SizeUtil.translateSize(param.getSoftQuota());
    Long hardQuota = SizeUtil.translateSize(param.getHardQuota());
    Integer retention = Integer.valueOf(param.getRetention());
    // Hard Quota should be more than SoftQuota
    verifyQuotaValues(softQuota, hardQuota, param.getLabel());
    // check varray
    VirtualArray neighborhood = _dbClient.queryObject(VirtualArray.class, param.getVarray());
    ArgValidator.checkEntity(neighborhood, param.getVarray(), false);
    _permissionsHelper.checkTenantHasAccessToVirtualArray(tenant.getId(), neighborhood);
    // check vpool reference
    VirtualPool vpool = _dbClient.queryObject(VirtualPool.class, param.getVpool());
    _permissionsHelper.checkTenantHasAccessToVirtualPool(tenant.getId(), vpool);
    ArgValidator.checkEntity(vpool, param.getVpool(), false);
    if (!VirtualPool.Type.object.name().equals(vpool.getType())) {
        throw APIException.badRequests.virtualPoolNotForObjectStorage(VirtualPool.Type.object.name());
    }
    // verify retention. Its validated only if Retention is configured.
    if (retention != 0 && vpool.getMaxRetention() != 0 && retention > vpool.getMaxRetention()) {
        throw APIException.badRequests.insufficientRetentionForVirtualPool(vpool.getLabel(), "bucket");
    }
    VirtualPoolCapabilityValuesWrapper capabilities = new VirtualPoolCapabilityValuesWrapper();
    capabilities.put(VirtualPoolCapabilityValuesWrapper.RESOURCE_COUNT, Integer.valueOf(1));
    capabilities.put(VirtualPoolCapabilityValuesWrapper.THIN_PROVISIONING, Boolean.FALSE);
    capabilities.put(VirtualPoolCapabilityValuesWrapper.QUOTA, hardQuota.toString());
    Map<String, Object> attributeMap = new HashMap<String, Object>();
    List<BucketRecommendation> placement = _bucketScheduler.placeBucket(neighborhood, vpool, capabilities, attributeMap);
    if (placement.isEmpty()) {
        StringBuffer errorMessage = new StringBuffer();
        if (attributeMap.get(AttributeMatcher.ERROR_MESSAGE) != null) {
            errorMessage = (StringBuffer) attributeMap.get(AttributeMatcher.ERROR_MESSAGE);
        }
        throw APIException.badRequests.noStoragePools(neighborhood.getLabel(), vpool.getLabel(), errorMessage.toString());
    }
    // Randomly select a recommended pool
    Collections.shuffle(placement);
    BucketRecommendation recommendation = placement.get(0);
    String task = UUID.randomUUID().toString();
    Bucket bucket = prepareBucket(param, project, tenant, neighborhood, vpool, flags, recommendation);
    _log.info(String.format("createBucket --- Bucket: %1$s, StoragePool: %2$s, StorageSystem: %3$s", bucket.getId(), recommendation.getSourceStoragePool(), recommendation.getSourceStorageSystem()));
    Operation op = _dbClient.createTaskOpStatus(Bucket.class, bucket.getId(), task, ResourceOperationTypeEnum.CREATE_BUCKET);
    op.setDescription("Bucket Create");
    // Controller invocation
    StorageSystem system = _dbClient.queryObject(StorageSystem.class, recommendation.getSourceStorageSystem());
    ObjectController controller = getController(ObjectController.class, system.getSystemType());
    controller.createBucket(recommendation.getSourceStorageSystem(), recommendation.getSourceStoragePool(), bucket.getId(), bucket.getName(), bucket.getNamespace(), bucket.getRetention(), bucket.getHardQuota(), bucket.getSoftQuota(), bucket.getOwner(), task);
    auditOp(OperationTypeEnum.CREATE_BUCKET, true, AuditLogManager.AUDITOP_BEGIN, param.getLabel(), param.getHardQuota(), neighborhood.getId().toString(), project == null ? null : project.getId().toString());
    return toTask(bucket, task, op);
}
Also used : VirtualPoolCapabilityValuesWrapper(com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper) VirtualArray(com.emc.storageos.db.client.model.VirtualArray) HashMap(java.util.HashMap) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) Operation(com.emc.storageos.db.client.model.Operation) BucketRecommendation(com.emc.storageos.api.service.impl.placement.BucketRecommendation) Bucket(com.emc.storageos.db.client.model.Bucket) MapBucket(com.emc.storageos.api.mapper.functions.MapBucket) ObjectController(com.emc.storageos.volumecontroller.ObjectController) DataObject(com.emc.storageos.db.client.model.DataObject) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 27 with VirtualPoolCapabilityValuesWrapper

use of com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper in project coprhd-controller by CoprHD.

the class VPlexScheduler method getRecommendationsForPools.

/**
 * Uses the block scheduler to get the placement recommendations.
 *
 * @param varrayId The virtual array id.
 * @param vpool A reference to the virtual pool
 * @param candidatePools The list of candidate pools.
 * @param capabilities The virtual pool capabilities.
 *
 * @return The list of placement recommendations.
 */
private List<Recommendation> getRecommendationsForPools(String varrayId, VirtualPool vpool, List<StoragePool> candidatePools, VirtualPoolCapabilityValuesWrapper capabilities) {
    VirtualPoolCapabilityValuesWrapper updatedCapabilities = capabilities;
    if (VirtualPool.ProvisioningType.Thin.toString().equalsIgnoreCase(vpool.getSupportedProvisioningType())) {
        updatedCapabilities = new VirtualPoolCapabilityValuesWrapper(capabilities);
        updatedCapabilities.put(VirtualPoolCapabilityValuesWrapper.THIN_PROVISIONING, Boolean.TRUE);
    }
    return _blockScheduler.getRecommendationsForPools(varrayId, candidatePools, updatedCapabilities);
}
Also used : VirtualPoolCapabilityValuesWrapper(com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper)

Example 28 with VirtualPoolCapabilityValuesWrapper

use of com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper in project coprhd-controller by CoprHD.

the class RPBlockServiceApiImpl method upgradeToMetroPointVolume.

/**
 * Upgrade a local block volume to a protected RP volume
 *
 * @param volume the existing volume being protected.
 * @param newVpool the requested virtual pool
 * @param taskId the task identifier
 * @throws InternalException
 */
private void upgradeToMetroPointVolume(Volume volume, VirtualPool newVpool, VirtualPoolChangeParam vpoolChangeParam, String taskId) throws InternalException {
    _log.info(String.format("Upgrade [%s] to MetroPoint", volume.getLabel()));
    Project project = _dbClient.queryObject(Project.class, volume.getProject());
    // Now that we have a handle on the current vpool, let's set the new vpool on the volume.
    // The volume will not be persisted just yet but we need to have the new vpool to
    // properly make placement decisions and to add reference to the new vpool to the
    // recommendation objects that will be created.
    URI currentVpool = volume.getVirtualPool();
    volume.setVirtualPool(newVpool.getId());
    List<Recommendation> recommendations = getRecommendationsForVirtualPoolChangeRequest(volume, newVpool, vpoolChangeParam, null);
    volume.setVirtualPool(currentVpool);
    if (recommendations.isEmpty()) {
        throw APIException.badRequests.noStorageFoundForVolume();
    }
    // Get the volume's varray
    VirtualArray varray = _dbClient.queryObject(VirtualArray.class, volume.getVirtualArray());
    // Generate a VolumeCreate object that contains the information that createVolumes likes to consume.
    VolumeCreate param = new VolumeCreate(volume.getLabel(), String.valueOf(volume.getCapacity()), 1, newVpool.getId(), volume.getVirtualArray(), volume.getProject().getURI());
    VirtualPoolCapabilityValuesWrapper capabilities = new VirtualPoolCapabilityValuesWrapper();
    capabilities.put(VirtualPoolCapabilityValuesWrapper.RESOURCE_COUNT, 1);
    capabilities.put(VirtualPoolCapabilityValuesWrapper.BLOCK_CONSISTENCY_GROUP, volume.getConsistencyGroup());
    TaskList taskList = new TaskList();
    createTaskForVolume(volume, ResourceOperationTypeEnum.CHANGE_BLOCK_VOLUME_VPOOL, taskList, taskId);
    Map<VpoolUse, List<Recommendation>> recommendationMap = new HashMap<VpoolUse, List<Recommendation>>();
    recommendationMap.put(VpoolUse.ROOT, recommendations);
    createVolumes(param, project, varray, newVpool, recommendationMap, taskList, taskId, capabilities);
}
Also used : VirtualPoolCapabilityValuesWrapper(com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper) Project(com.emc.storageos.db.client.model.Project) VirtualArray(com.emc.storageos.db.client.model.VirtualArray) VpoolUse(com.emc.storageos.api.service.impl.placement.VpoolUse) HashMap(java.util.HashMap) TaskList(com.emc.storageos.model.TaskList) ApplicationAddVolumeList(com.emc.storageos.volumecontroller.ApplicationAddVolumeList) ArrayList(java.util.ArrayList) TaskList(com.emc.storageos.model.TaskList) VolumeGroupVolumeList(com.emc.storageos.model.application.VolumeGroupUpdateParam.VolumeGroupVolumeList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) StorageSystemConnectivityList(com.emc.storageos.model.systems.StorageSystemConnectivityList) List(java.util.List) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) Recommendation(com.emc.storageos.volumecontroller.Recommendation) RPRecommendation(com.emc.storageos.volumecontroller.RPRecommendation) RPProtectionRecommendation(com.emc.storageos.volumecontroller.RPProtectionRecommendation) VolumeCreate(com.emc.storageos.model.block.VolumeCreate)

Example 29 with VirtualPoolCapabilityValuesWrapper

use of com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper in project coprhd-controller by CoprHD.

the class VPlexDeviceController method addStepsForImportClonesOfApplicationVolumes.

/**
 * This method will add steps to import the clone of the source backend volumes,
 * create clone VPlex virtual volumes
 * create HA backend volume for clone virtual volume if distributed.
 *
 * @param workflow
 * @param waitFor
 * @param sourceVolumes
 * @param opId
 * @return
 */
public void addStepsForImportClonesOfApplicationVolumes(Workflow workflow, String waitFor, List<URI> sourceVolumes, String opId) {
    _log.info("Creating steps for importing clones");
    for (URI vplexSrcUri : sourceVolumes) {
        Volume vplexSrcVolume = getDataObject(Volume.class, vplexSrcUri, _dbClient);
        Volume backendSrc = VPlexUtil.getVPLEXBackendVolume(vplexSrcVolume, true, _dbClient);
        long size = backendSrc.getProvisionedCapacity();
        Volume backendHASrc = VPlexUtil.getVPLEXBackendVolume(vplexSrcVolume, false, _dbClient);
        StringSet backSrcCopies = backendSrc.getFullCopies();
        if (backSrcCopies != null && !backSrcCopies.isEmpty()) {
            for (String copy : backSrcCopies) {
                List<VolumeDescriptor> vplexVolumeDescriptors = new ArrayList<VolumeDescriptor>();
                List<VolumeDescriptor> blockDescriptors = new ArrayList<VolumeDescriptor>();
                Volume backCopy = getDataObject(Volume.class, URI.create(copy), _dbClient);
                String name = backCopy.getLabel();
                _log.info(String.format("Creating steps for import clone %s.", name));
                VolumeDescriptor vplexCopyVolume = prepareVolumeDescriptor(vplexSrcVolume, name, VolumeDescriptor.Type.VPLEX_VIRT_VOLUME, size, false);
                Volume vplexCopy = getDataObject(Volume.class, vplexCopyVolume.getVolumeURI(), _dbClient);
                vplexCopy.setAssociatedVolumes(new StringSet());
                StringSet assVol = vplexCopy.getAssociatedVolumes();
                if (null == assVol) {
                    assVol = new StringSet();
                    vplexCopy.setAssociatedVolumes(assVol);
                }
                assVol.add(backCopy.getId().toString());
                VirtualPoolCapabilityValuesWrapper capabilities = getCapabilities(backCopy, size);
                VolumeDescriptor backCopyDesc = new VolumeDescriptor(VolumeDescriptor.Type.VPLEX_IMPORT_VOLUME, backCopy.getStorageController(), backCopy.getId(), backCopy.getPool(), capabilities);
                blockDescriptors.add(backCopyDesc);
                if (backendHASrc != null) {
                    // distributed volume
                    name = name + "-ha";
                    VolumeDescriptor haDesc = prepareVolumeDescriptor(backendHASrc, name, VolumeDescriptor.Type.BLOCK_DATA, size, true);
                    blockDescriptors.add(haDesc);
                    assVol.add(haDesc.getVolumeURI().toString());
                }
                vplexCopy.setFullCopySetName(backCopy.getFullCopySetName());
                vplexCopy.setAssociatedSourceVolume(vplexSrcUri);
                StringSet srcClones = vplexSrcVolume.getFullCopies();
                if (srcClones == null) {
                    srcClones = new StringSet();
                }
                srcClones.add(vplexCopy.getId().toString());
                backCopy.setFullCopySetName(NullColumnValueGetter.getNullStr());
                backCopy.addInternalFlags(Flag.INTERNAL_OBJECT);
                _dbClient.updateObject(backCopy);
                _dbClient.updateObject(vplexCopy);
                _dbClient.updateObject(vplexSrcVolume);
                vplexVolumeDescriptors.add(vplexCopyVolume);
                createStepsForFullCopyImport(workflow, vplexSrcVolume.getStorageController(), vplexVolumeDescriptors, blockDescriptors, waitFor);
            }
        }
    }
    _log.info("Created workflow steps to import the backend full copies");
}
Also used : VirtualPoolCapabilityValuesWrapper(com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper) VolumeDescriptor(com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor) Volume(com.emc.storageos.db.client.model.Volume) StringSet(com.emc.storageos.db.client.model.StringSet) ArrayList(java.util.ArrayList) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI)

Example 30 with VirtualPoolCapabilityValuesWrapper

use of com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper in project coprhd-controller by CoprHD.

the class VPlexDeviceController method getCapabilities.

/**
 * Create a VirtualPoolCapabilityValuesWrapper based on the passed in volume
 *
 * @param volume
 *            - The volume used to create the VirtualPoolCapabilityValuesWrapper.
 * @param size
 * @return
 */
private VirtualPoolCapabilityValuesWrapper getCapabilities(Volume volume, long size) {
    URI vpoolUri = volume.getVirtualPool();
    VirtualPool vpool = getDataObject(VirtualPool.class, vpoolUri, _dbClient);
    VirtualPoolCapabilityValuesWrapper capabilities = new VirtualPoolCapabilityValuesWrapper();
    capabilities.put(VirtualPoolCapabilityValuesWrapper.SIZE, size);
    capabilities.put(VirtualPoolCapabilityValuesWrapper.RESOURCE_COUNT, 1);
    if (VirtualPool.ProvisioningType.Thin.toString().equalsIgnoreCase(vpool.getSupportedProvisioningType())) {
        capabilities.put(VirtualPoolCapabilityValuesWrapper.THIN_PROVISIONING, Boolean.TRUE);
        // To guarantee that storage pool for a copy has enough physical
        // space to contain current allocated capacity of thin source volume
        capabilities.put(VirtualPoolCapabilityValuesWrapper.THIN_VOLUME_PRE_ALLOCATE_SIZE, volume.getAllocatedCapacity());
    }
    return capabilities;
}
Also used : VirtualPoolCapabilityValuesWrapper(com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI)

Aggregations

VirtualPoolCapabilityValuesWrapper (com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper)65 ArrayList (java.util.ArrayList)50 VirtualArray (com.emc.storageos.db.client.model.VirtualArray)44 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)44 Project (com.emc.storageos.db.client.model.Project)41 URI (java.net.URI)34 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)33 NamedURI (com.emc.storageos.db.client.model.NamedURI)32 List (java.util.List)31 StoragePool (com.emc.storageos.db.client.model.StoragePool)28 StringSet (com.emc.storageos.db.client.model.StringSet)25 Volume (com.emc.storageos.db.client.model.Volume)22 RPProtectionRecommendation (com.emc.storageos.volumecontroller.RPProtectionRecommendation)22 RPRecommendation (com.emc.storageos.volumecontroller.RPRecommendation)22 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)21 Recommendation (com.emc.storageos.volumecontroller.Recommendation)21 TenantOrg (com.emc.storageos.db.client.model.TenantOrg)20 Test (org.junit.Test)20 Network (com.emc.storageos.db.client.model.Network)19 StringMap (com.emc.storageos.db.client.model.StringMap)19