Search in sources :

Example 56 with VirtualPoolCapabilityValuesWrapper

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

the class AbstractBlockFullCopyApiImpl method getCapabilitiesForFullCopyCreate.

/**
 * Creates a capabilities wrapper specifying some parameters for the
 * full copy create request.
 *
 * @param fcSourceObj A reference to the full copy source.
 * @param vpool A reference to the source's virtual pool.
 * @param count A count of the number of full copies requested.
 *
 * @return VirtualPoolCapabilityValuesWrapper
 */
protected VirtualPoolCapabilityValuesWrapper getCapabilitiesForFullCopyCreate(BlockObject fcSourceObj, VirtualPool vpool, int count) {
    VirtualPoolCapabilityValuesWrapper capabilities = new VirtualPoolCapabilityValuesWrapper();
    capabilities.put(VirtualPoolCapabilityValuesWrapper.RESOURCE_COUNT, count);
    capabilities.put(VirtualPoolCapabilityValuesWrapper.SIZE, BlockFullCopyUtils.getCapacityForFullCopySource(fcSourceObj, _dbClient));
    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, BlockFullCopyUtils.getAllocatedCapacityForFullCopySource(fcSourceObj, _dbClient));
    }
    return capabilities;
}
Also used : VirtualPoolCapabilityValuesWrapper(com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper)

Example 57 with VirtualPoolCapabilityValuesWrapper

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

the class VPlexBlockFullCopyApiImpl method create.

/**
 * {@inheritDoc}
 */
@Override
public TaskList create(List<BlockObject> fcSourceObjList, VirtualArray varray, String name, boolean createInactive, int count, String taskId) {
    // Populate the descriptors list with all volumes required
    // to create the VPLEX volume copies.
    int sourceCounter = 0;
    URI vplexSrcSystemId = null;
    List<Volume> allNewVolumes = new ArrayList<>();
    List<Volume> vplexCopyVolumes = new ArrayList<>();
    List<VolumeDescriptor> volumeDescriptors = new ArrayList<>();
    List<BlockObject> sortedSourceObjectList = sortFullCopySourceList(fcSourceObjList);
    Map<URI, VirtualArray> vArrayCache = new HashMap<>();
    BlockObject aFCSource = null;
    try {
        for (BlockObject fcSourceObj : sortedSourceObjectList) {
            if (aFCSource == null) {
                aFCSource = fcSourceObj;
            }
            URI fcSourceURI = fcSourceObj.getId();
            // volumes in VolumeGroup can be from different vArrays
            varray = getVarrayFromCache(vArrayCache, fcSourceObj.getVirtualArray());
            String copyName = null;
            if (fcSourceObj instanceof Volume && ((Volume) fcSourceObj).getApplication(_dbClient) != null) {
                Volume backendVolume = VPlexUtil.getVPLEXBackendVolume((Volume) fcSourceObj, true, _dbClient);
                if (NullColumnValueGetter.isNotNullValue(backendVolume.getReplicationGroupInstance())) {
                    copyName = name + "-" + backendVolume.getReplicationGroupInstance() + (sortedSourceObjectList.size() > 1 ? "-" + ++sourceCounter : "");
                }
            }
            if (copyName == null) {
                copyName = name + (sortedSourceObjectList.size() > 1 ? "-" + ++sourceCounter : "");
            }
            vplexSrcSystemId = fcSourceObj.getStorageController();
            if (fcSourceObj instanceof Volume) {
                // DO IT ONLY FOR VOLUME CLONE - In case of snapshot new VPLEX volume needs to be created
                // Create a volume descriptor for the source VPLEX volume being copied.
                // and add it to the descriptors list. Be sure to identify this VPLEX
                // volume as the source volume being copied.
                VolumeDescriptor vplexSrcVolumeDescr = new VolumeDescriptor(VolumeDescriptor.Type.VPLEX_VIRT_VOLUME, vplexSrcSystemId, fcSourceURI, null, null);
                Map<String, Object> descrParams = new HashMap<>();
                descrParams.put(VolumeDescriptor.PARAM_IS_COPY_SOURCE_ID, Boolean.TRUE);
                vplexSrcVolumeDescr.setParameters(descrParams);
                volumeDescriptors.add(vplexSrcVolumeDescr);
            } else {
                BlockSnapshot sourceSnapshot = (BlockSnapshot) fcSourceObj;
                URIQueryResultList queryResults = new URIQueryResultList();
                _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getVolumeByAssociatedVolumesConstraint(sourceSnapshot.getParent().getURI().toString()), queryResults);
                URI vplexVolumeURI = queryResults.iterator().next();
                if (null != vplexVolumeURI) {
                    Volume vplexVolume = _dbClient.queryObject(Volume.class, vplexVolumeURI);
                    vplexSrcSystemId = vplexVolume.getStorageController();
                }
            }
            // Get some info about the VPLEX volume being copied and its storage system.
            Project vplexSrcProject = BlockFullCopyUtils.queryFullCopySourceProject(fcSourceObj, _dbClient);
            StorageSystem vplexSrcSystem = _dbClient.queryObject(StorageSystem.class, vplexSrcSystemId);
            Project vplexSystemProject = VPlexBlockServiceApiImpl.getVplexProject(vplexSrcSystem, _dbClient, _tenantsService);
            Volume vplexSrcPrimaryVolume = null;
            Volume vplexSrcHAVolume = null;
            Volume vplexSrcVolume = null;
            if (fcSourceObj instanceof Volume) {
                // For the VPLEX volume being copied, determine which of the associated
                // backend volumes is the primary and, for distributed volumes, which
                // is the HA volume. The primary volume will be natively copied and we
                // we need to place and prepare a volume to hold the copy. This copy
                // will be the primary backend volume for the VPLEX volume copy. For
                // a distributed virtual volume, we will need to place and prepare
                // a volume to hold the HA volume of the VPLEX volume copy.
                vplexSrcVolume = (Volume) fcSourceObj;
                StringSet assocVolumeURIs = vplexSrcVolume.getAssociatedVolumes();
                if (null == assocVolumeURIs || assocVolumeURIs.isEmpty()) {
                    s_logger.error("VPLEX volume {} has no backend volumes.", vplexSrcVolume.forDisplay());
                    throw InternalServerErrorException.internalServerErrors.noAssociatedVolumesForVPLEXVolume(vplexSrcVolume.forDisplay());
                }
                Iterator<String> assocVolumeURIsIter = assocVolumeURIs.iterator();
                while (assocVolumeURIsIter.hasNext()) {
                    URI assocVolumeURI = URI.create(assocVolumeURIsIter.next());
                    Volume assocVolume = _dbClient.queryObject(Volume.class, assocVolumeURI);
                    if (assocVolume.getVirtualArray().toString().equals(varray.getId().toString())) {
                        vplexSrcPrimaryVolume = assocVolume;
                    } else {
                        vplexSrcHAVolume = assocVolume;
                    }
                }
            }
            // Get the capabilities
            VirtualPool vpool = BlockFullCopyUtils.queryFullCopySourceVPool(fcSourceObj, _dbClient);
            VirtualPoolCapabilityValuesWrapper capabilities = getCapabilitiesForFullCopyCreate(fcSourceObj, vpool, count);
            // Get the number of copies to create and the size of the volumes.
            // Note that for the size, we must use the actual provisioned size
            // of the source side backend volume. The size passed in the
            // capabilities will be the size of the VPLEX volume. When the
            // source side backend volume for the copy is provisioned, you
            // might not get that actual size. On VMAX, the size will be slightly
            // larger while for VNX the size will be exactly what is requested.
            // So, if the source side is a VMAX, the source side for the copy
            // will be slightly larger than the size in the capabilities. If the HA
            // side is VNX and we use the size in the capabilities, then you will
            // get exactly that size for the HA backend volume. As a result, source
            // side backend volume for the copy will be slightly larger than the
            // HA side. Now the way a VPLEX copy is made is it uses native full
            // copy to create a native full copy of the source side backend
            // volume. It then provisions the HA side volume. The new source side
            // backend copy is then imported into VPLEX in the same way as is done
            // for a vpool change that imports a volume to VPLEX. This code in the
            // VPLEX controller creates a local VPLEX volume using the source side
            // copy and for a distributed volume it then attaches as a remote
            // mirror the HA backend volume that is provisioned. If the HA volume
            // is slightly smaller, then this will fail on the VPLEX. So, we must
            // ensure that HA side volume is big enough by using the provisioned
            // capacity of the source side backend volume of the VPLEX volume being
            // copied.
            long size = 0L;
            List<Volume> vplexCopyPrimaryVolumes = null;
            if (null != vplexSrcPrimaryVolume) {
                size = vplexSrcPrimaryVolume.getProvisionedCapacity();
                // Place and prepare a volume for each copy to serve as a native
                // copy of a VPLEX backend volume. The VPLEX backend volume that
                // is copied is the backend volume in the same virtual array as the
                // VPLEX volume i.e, the primary backend volume. Create
                // descriptors for these prepared volumes and add them to the list.
                vplexCopyPrimaryVolumes = prepareFullCopyPrimaryVolumes(copyName, count, vplexSrcPrimaryVolume, capabilities, volumeDescriptors, vpool);
            } else {
                // Get the provisioned capacity of the snapshot
                size = ((BlockSnapshot) fcSourceObj).getProvisionedCapacity();
                // Place and prepare a back-end volume for each block snapshot
                vplexCopyPrimaryVolumes = prepareFullCopyPrimaryVolumes(copyName, count, fcSourceObj, capabilities, volumeDescriptors, vpool);
            }
            allNewVolumes.addAll(vplexCopyPrimaryVolumes);
            // If the VPLEX volume being copied is distributed, then the VPLEX
            // HA volume should be non-null. We use the VPLEX scheduler to place
            // and then prepare volumes for the HA volumes of the VPLEX volume
            // copies. This should be done in the same manner as is done for the
            // import volume routine. This is because to form the VPLEX volume
            // copy we import the copy of the primary backend volume.
            List<Volume> vplexCopyHAVolumes = new ArrayList<>();
            if (vplexSrcHAVolume != null) {
                vplexCopyHAVolumes.addAll(prepareFullCopyHAVolumes(copyName, count, size, vplexSrcSystem, vplexSystemProject, varray, vplexSrcHAVolume, taskId, volumeDescriptors));
            }
            allNewVolumes.addAll(vplexCopyHAVolumes);
            // and add them to the volume descriptors list.
            for (int i = 0; i < count; i++) {
                // Prepare a new VPLEX volume for each copy.
                Volume vplexCopyPrimaryVolume = vplexCopyPrimaryVolumes.get(i);
                Volume vplexCopyHAVolume = null;
                if (!vplexCopyHAVolumes.isEmpty()) {
                    vplexCopyHAVolume = vplexCopyHAVolumes.get(i);
                }
                Volume vplexCopyVolume = prepareFullCopyVPlexVolume(copyName, name, count, i, size, fcSourceObj, vplexSrcProject, varray, vpool, vplexSrcSystemId, vplexCopyPrimaryVolume, vplexCopyHAVolume, taskId, volumeDescriptors);
                vplexCopyVolumes.add(vplexCopyVolume);
                allNewVolumes.addAll(vplexCopyHAVolumes);
            }
        }
    } catch (Exception e) {
        handlePlacementFailure(allNewVolumes);
        throw e;
    }
    // get all tasks
    TaskList taskList = getTasksForCreateFullCopy(aFCSource, vplexCopyVolumes, taskId);
    // Invoke the VPLEX controller to create the copies.
    try {
        s_logger.info("Getting Orchestration controller {}.", taskId);
        BlockOrchestrationController controller = getController(BlockOrchestrationController.class, BlockOrchestrationController.BLOCK_ORCHESTRATION_DEVICE);
        controller.createFullCopy(volumeDescriptors, taskId);
        s_logger.info("Successfully invoked controller.");
    } catch (InternalException e) {
        s_logger.error("Controller error", e);
        // Update the status for the VPLEX copy volume and CG tasks.
        handleFailedRequest(taskId, taskList, new ArrayList<Volume>(), e, false);
        // we were trying to copy.
        for (VolumeDescriptor descriptor : volumeDescriptors) {
            if (descriptor.getParameters().get(VolumeDescriptor.PARAM_IS_COPY_SOURCE_ID) == null) {
                Volume volume = _dbClient.queryObject(Volume.class, descriptor.getVolumeURI());
                volume.setInactive(true);
                _dbClient.updateObject(volume);
            }
        }
    }
    return taskList;
}
Also used : VirtualPoolCapabilityValuesWrapper(com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper) VirtualArray(com.emc.storageos.db.client.model.VirtualArray) BlockOrchestrationController(com.emc.storageos.blockorchestrationcontroller.BlockOrchestrationController) HashMap(java.util.HashMap) TaskList(com.emc.storageos.model.TaskList) ArrayList(java.util.ArrayList) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) StringSet(com.emc.storageos.db.client.model.StringSet) BlockObject(com.emc.storageos.db.client.model.BlockObject) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) VolumeDescriptor(com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) InternalServerErrorException(com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) Project(com.emc.storageos.db.client.model.Project) Volume(com.emc.storageos.db.client.model.Volume) BlockObject(com.emc.storageos.db.client.model.BlockObject) DiscoveredDataObject(com.emc.storageos.db.client.model.DiscoveredDataObject)

Example 58 with VirtualPoolCapabilityValuesWrapper

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

the class VPlexBlockFullCopyApiImpl method prepareFullCopyHAVolumes.

/**
 * Places and prepares the HA volumes when copying a distributed VPLEX
 * volume.
 *
 * @param name The base name for the volume.
 * @param copyCount The number of copies to be made.
 * @param size The size for the HA volume.
 * @param vplexSystem A reference to the VPLEX storage system.
 * @param vplexSystemProject A reference to the VPLEX system project.
 * @param srcVarray The virtual array for the VPLEX volume being copied.
 * @param srcHAVolume The HA volume of the VPLEX volume being copied.
 * @param taskId The task identifier.
 * @param volumeDescriptors The list of descriptors.
 *
 * @return A list of the prepared HA volumes for the VPLEX volume copy.
 */
private List<Volume> prepareFullCopyHAVolumes(String name, int copyCount, Long size, StorageSystem vplexSystem, Project vplexSystemProject, VirtualArray srcVarray, Volume srcHAVolume, String taskId, List<VolumeDescriptor> volumeDescriptors) {
    List<Volume> copyHAVolumes = new ArrayList<>();
    // Get the storage placement recommendations for the volumes.
    // Placement must occur on the same VPLEX system
    Set<URI> vplexSystemURIS = new HashSet<>();
    vplexSystemURIS.add(vplexSystem.getId());
    VirtualArray haVarray = _dbClient.queryObject(VirtualArray.class, srcHAVolume.getVirtualArray());
    VirtualPool haVpool = _dbClient.queryObject(VirtualPool.class, srcHAVolume.getVirtualPool());
    VirtualPoolCapabilityValuesWrapper haCapabilities = new VirtualPoolCapabilityValuesWrapper();
    haCapabilities.put(VirtualPoolCapabilityValuesWrapper.SIZE, size);
    haCapabilities.put(VirtualPoolCapabilityValuesWrapper.RESOURCE_COUNT, copyCount);
    VirtualPool vpool = BlockFullCopyUtils.queryFullCopySourceVPool(srcHAVolume, _dbClient);
    if (VirtualPool.ProvisioningType.Thin.toString().equalsIgnoreCase(vpool.getSupportedProvisioningType())) {
        haCapabilities.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
        haCapabilities.put(VirtualPoolCapabilityValuesWrapper.THIN_VOLUME_PRE_ALLOCATE_SIZE, BlockFullCopyUtils.getAllocatedCapacityForFullCopySource(srcHAVolume, _dbClient));
    }
    List<Recommendation> recommendations = ((VPlexScheduler) _scheduler).scheduleStorageForImport(srcVarray, vplexSystemURIS, haVarray, haVpool, haCapabilities);
    if (recommendations.isEmpty()) {
        throw APIException.badRequests.noStorageForHaVolumesForVplexVolumeCopies();
    }
    // Prepare the HA volumes for the VPLEX volume copy.
    int copyIndex = 1;
    for (Recommendation recommendation : recommendations) {
        VPlexRecommendation haRecommendation = (VPlexRecommendation) recommendation;
        for (int i = 0; i < haRecommendation.getResourceCount(); i++) {
            // Determine the name for the HA volume copy.
            StringBuilder nameBuilder = new StringBuilder(name);
            nameBuilder.append("-1");
            if (copyCount > 1) {
                nameBuilder.append("-");
                nameBuilder.append(copyIndex++);
            }
            // Prepare the volume.
            Volume volume = VPlexBlockServiceApiImpl.prepareVolumeForRequest(size, vplexSystemProject, haVarray, haVpool, haRecommendation.getSourceStorageSystem(), haRecommendation.getSourceStoragePool(), nameBuilder.toString(), null, taskId, _dbClient);
            volume.addInternalFlags(Flag.INTERNAL_OBJECT);
            _dbClient.persistObject(volume);
            copyHAVolumes.add(volume);
            // Create the volume descriptor and add it to the passed list.
            VolumeDescriptor volumeDescriptor = new VolumeDescriptor(VolumeDescriptor.Type.BLOCK_DATA, volume.getStorageController(), volume.getId(), volume.getPool(), haCapabilities);
            volumeDescriptors.add(volumeDescriptor);
        }
    }
    return copyHAVolumes;
}
Also used : VirtualPoolCapabilityValuesWrapper(com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper) VirtualArray(com.emc.storageos.db.client.model.VirtualArray) VolumeDescriptor(com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor) VPlexRecommendation(com.emc.storageos.volumecontroller.VPlexRecommendation) ArrayList(java.util.ArrayList) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) URI(java.net.URI) VPlexRecommendation(com.emc.storageos.volumecontroller.VPlexRecommendation) Recommendation(com.emc.storageos.volumecontroller.Recommendation) VolumeRecommendation(com.emc.storageos.api.service.impl.placement.VolumeRecommendation) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) Volume(com.emc.storageos.db.client.model.Volume) VPlexScheduler(com.emc.storageos.api.service.impl.placement.VPlexScheduler) HashSet(java.util.HashSet)

Example 59 with VirtualPoolCapabilityValuesWrapper

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

the class FilePolicyServiceUtils method vPoolSpecifiesFileReplication.

/**
 * Verifies the vpool supports replication and has replication policy
 *
 * @param dbClient
 * @param vPool
 * @param fs
 * @return true/false
 */
public static boolean vPoolSpecifiesFileReplication(FileShare fs, VirtualPool vPool, DbClient dbClient) {
    if (vPool == null) {
        vPool = dbClient.queryObject(VirtualPool.class, fs.getVirtualPool());
    }
    Project project = dbClient.queryObject(Project.class, fs.getProject().getURI());
    VirtualPoolCapabilityValuesWrapper capabilities = new VirtualPoolCapabilityValuesWrapper();
    capabilities.put(VirtualPoolCapabilityValuesWrapper.FILE_REPLICATION_TYPE, FileReplicationType.NONE.name());
    StringBuilder errorMsg = new StringBuilder();
    if (vPool.getFileReplicationSupported()) {
        updateReplicationTypeCapabilities(dbClient, vPool, project, fs, capabilities, errorMsg);
    }
    return vPoolSpecifiesFileReplication(capabilities);
}
Also used : VirtualPoolCapabilityValuesWrapper(com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper) Project(com.emc.storageos.db.client.model.Project) VirtualPool(com.emc.storageos.db.client.model.VirtualPool)

Example 60 with VirtualPoolCapabilityValuesWrapper

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

the class BlockService method addJournalCapacity.

/**
 * This api allows the user to add new journal volume(s) to a recoverpoint
 * consistency group copy
 *
 * @param param
 *            POST data containing the journal volume(s) creation information.
 *
 * @brief Add journal volume(s) to the existing recoverpoint CG copy
 * @return A reference to a BlockTaskList containing a list of
 *         TaskResourceRep references specifying the task data for the
 *         journal volume creation tasks.
 */
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/protection/addJournalCapacity")
public TaskList addJournalCapacity(VolumeCreate param) throws InternalException {
    ArgValidator.checkFieldNotNull(param, "volume_create");
    ArgValidator.checkFieldNotNull(param.getName(), "name");
    ArgValidator.checkFieldNotNull(param.getSize(), "size");
    ArgValidator.checkFieldNotNull(param.getCount(), "count");
    ArgValidator.checkFieldUriType(param.getProject(), Project.class, "project");
    // Get and validate the project.
    Project project = _permissionsHelper.getObjectById(param.getProject(), Project.class);
    ArgValidator.checkEntity(project, param.getProject(), isIdEmbeddedInURL(param.getProject()));
    final URI actualId = project.getId();
    // Verify the user is authorized.
    BlockServiceUtils.verifyUserIsAuthorizedForRequest(project, getUserFromContext(), _permissionsHelper);
    // Get and validate the varray
    ArgValidator.checkFieldUriType(param.getVarray(), VirtualArray.class, "varray");
    VirtualArray varray = BlockServiceUtils.verifyVirtualArrayForRequest(project, param.getVarray(), uriInfo, _permissionsHelper, _dbClient);
    ArgValidator.checkEntity(varray, param.getVarray(), isIdEmbeddedInURL(param.getVarray()));
    // Get and validate the journal vPool.
    VirtualPool vpool = getVirtualPoolForVolumeCreateRequest(project, param);
    VirtualPoolCapabilityValuesWrapper capabilities = new VirtualPoolCapabilityValuesWrapper();
    capabilities.put(VirtualPoolCapabilityValuesWrapper.ADD_JOURNAL_CAPACITY, Boolean.TRUE);
    // Get the count indicating the number of journal volumes to add. If not
    // passed assume 1.
    Integer volumeCount = 1;
    Long volumeSize = 0L;
    if (param.getCount() <= 0) {
        throw APIException.badRequests.parameterMustBeGreaterThan("count", 0);
    }
    if (param.getCount() > MAX_VOLUME_COUNT) {
        throw APIException.badRequests.exceedingLimit("count", MAX_VOLUME_COUNT);
    }
    volumeCount = param.getCount();
    capabilities.put(VirtualPoolCapabilityValuesWrapper.RESOURCE_COUNT, volumeCount);
    // Validate the requested volume size is greater then 0.
    volumeSize = SizeUtil.translateSize(param.getSize());
    // Validate the requested volume size is at least 1 GB.
    if (volumeSize < GB) {
        throw APIException.badRequests.leastVolumeSize("1");
    }
    capabilities.put(VirtualPoolCapabilityValuesWrapper.SIZE, volumeSize);
    // verify quota
    long size = volumeCount * SizeUtil.translateSize(param.getSize());
    TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, project.getTenantOrg().getURI());
    ArgValidator.checkEntity(tenant, project.getTenantOrg().getURI(), false);
    CapacityUtils.validateQuotasForProvisioning(_dbClient, vpool, project, tenant, size, "volume");
    if (null != vpool.getThinVolumePreAllocationPercentage() && 0 < vpool.getThinVolumePreAllocationPercentage()) {
        capabilities.put(VirtualPoolCapabilityValuesWrapper.THIN_VOLUME_PRE_ALLOCATE_SIZE, VirtualPoolUtil.getThinVolumePreAllocationSize(vpool.getThinVolumePreAllocationPercentage(), volumeSize));
    }
    if (VirtualPool.ProvisioningType.Thin.toString().equalsIgnoreCase(vpool.getSupportedProvisioningType())) {
        capabilities.put(VirtualPoolCapabilityValuesWrapper.THIN_PROVISIONING, Boolean.TRUE);
    }
    // Get and validate the BlockConsistencyGroup
    BlockConsistencyGroup consistencyGroup = queryConsistencyGroup(param.getConsistencyGroup());
    // Check that the project and the CG project are the same
    final URI expectedId = consistencyGroup.getProject().getURI();
    checkProjectsMatch(expectedId, project.getId());
    // Validate the CG type is RP
    if (!consistencyGroup.getRequestedTypes().contains(BlockConsistencyGroup.Types.RP.toString())) {
        throw APIException.badRequests.consistencyGroupIsNotCompatibleWithRequest(consistencyGroup.getId(), consistencyGroup.getTypes().toString(), BlockConsistencyGroup.Types.RP.toString());
    }
    capabilities.put(VirtualPoolCapabilityValuesWrapper.BLOCK_CONSISTENCY_GROUP, consistencyGroup.getId());
    // Create a unique task id if one is not passed in the request.
    String task = UUID.randomUUID().toString();
    auditOp(OperationTypeEnum.ADD_JOURNAL_VOLUME, true, AuditLogManager.AUDITOP_BEGIN, param.getName(), volumeCount, varray.getId().toString(), actualId.toString());
    // add the journal capacity to the CG
    RPBlockServiceApiImpl blockServiceImpl = (RPBlockServiceApiImpl) getBlockServiceImpl(DiscoveredDataObject.Type.rp.name());
    return blockServiceImpl.addJournalCapacity(param, project, varray, vpool, consistencyGroup, capabilities, task);
}
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) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) URI(java.net.URI) NullColumnValueGetter.isNullURI(com.emc.storageos.db.client.util.NullColumnValueGetter.isNullURI) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

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