Search in sources :

Example 11 with QosSpecification

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

the class BlockVirtualPoolService method updateBlockVirtualPool.

/**
 * The block virtual pool can be modified only if there are no associated resources.
 *
 * @prereq No associated resources such as volumes or snapshots should exist
 * @param param VirtualPool parameters
 * @brief Update block store virtual pool
 * @return VirtualPool details
 */
@PUT
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
public BlockVirtualPoolRestRep updateBlockVirtualPool(@PathParam("id") URI id, BlockVirtualPoolUpdateParam param) {
    VirtualPool vpool = null;
    ArgValidator.checkFieldUriType(id, VirtualPool.class, "id");
    vpool = _dbClient.queryObject(VirtualPool.class, id);
    ArgValidator.checkEntity(vpool, id, isIdEmbeddedInURL(id));
    if (!vpool.getType().equals(VirtualPool.Type.block.name())) {
        throw APIException.badRequests.providedVirtualPoolNotCorrectType();
    }
    // Get the QoS for the VirtualPool, otherwise throw exception.
    QosSpecification qosSpecification = QosService.getQos(vpool.getId(), _dbClient);
    URIQueryResultList resultList = new URIQueryResultList();
    _dbClient.queryByConstraint(ContainmentConstraint.Factory.getVirtualPoolVolumeConstraint(id), resultList);
    boolean isActiveVolumePartOfPool = false;
    for (URI uri : resultList) {
        Volume volume = _dbClient.queryObject(Volume.class, uri);
        if (!volume.getInactive()) {
            isActiveVolumePartOfPool = true;
            break;
        }
    }
    if (isActiveVolumePartOfPool && checkAttributeValuesChanged(param, vpool)) {
        throw APIException.badRequests.updateVirtualPoolOnlyAllowedToChange();
    }
    // set common VirtualPool update parameters here.
    populateCommonVirtualPoolUpdateParams(vpool, param);
    if (null != param.getSystemType()) {
        if (vpool.getArrayInfo() == null) {
            vpool.setArrayInfo(new StringSetMap());
        }
        if (vpool.getArrayInfo().containsKey(VirtualPoolCapabilityValuesWrapper.SYSTEM_TYPE)) {
            for (String systemType : vpool.getArrayInfo().get(VirtualPoolCapabilityValuesWrapper.SYSTEM_TYPE)) {
                vpool.getArrayInfo().remove(VirtualPoolCapabilityValuesWrapper.SYSTEM_TYPE, systemType);
            }
        }
        if (!(VirtualPool.SystemType.NONE.name().equalsIgnoreCase(param.getSystemType()) || VirtualPool.SystemType.isBlockTypeSystem(param.getSystemType()))) {
            throw APIException.badRequests.invalidSystemType("Block");
        }
        if (VirtualPool.SystemType.vnxblock.name().equalsIgnoreCase(param.getSystemType())) {
            Integer thinVolumePreAllocation = vpool.getThinVolumePreAllocationPercentage();
            Integer thinVolumePreAllocationParam = param.getThinVolumePreAllocationPercentage();
            if (thinVolumePreAllocation != null && thinVolumePreAllocation > 0 && (thinVolumePreAllocationParam == null || thinVolumePreAllocationParam > 0)) {
                throw APIException.badRequests.thinVolumePreallocationPercentageOnlyApplicableToVMAX();
            }
        }
        vpool.getArrayInfo().put(VirtualPoolCapabilityValuesWrapper.SYSTEM_TYPE, param.getSystemType());
    } else {
        if (vpool.getArrayInfo() == null) {
            vpool.setArrayInfo(new StringSetMap());
            vpool.getArrayInfo().put(VirtualPoolCapabilityValuesWrapper.SYSTEM_TYPE, NONE);
        }
    }
    if (null != param.getRaidLevelChanges()) {
        if (null != param.getRaidLevelChanges().getAdd()) {
            for (String raidLevel : param.getRaidLevelChanges().getAdd().getRaidLevels()) {
                vpool.getArrayInfo().put(VirtualPoolCapabilityValuesWrapper.RAID_LEVEL, raidLevel);
            }
        }
        if (null != param.getRaidLevelChanges().getRemove()) {
            for (String raidLevel : param.getRaidLevelChanges().getRemove().getRaidLevels()) {
                vpool.getArrayInfo().remove(VirtualPoolCapabilityValuesWrapper.RAID_LEVEL, raidLevel);
            }
        }
    }
    if (null != param.getAutoTieringPolicyName()) {
        if (param.getAutoTieringPolicyName().isEmpty()) {
            // To unset a policy name.
            vpool.setAutoTierPolicyName(NONE);
        } else {
            vpool.setAutoTierPolicyName(param.getAutoTieringPolicyName());
        }
    }
    if (null != param.getCompressionEnabled()) {
        vpool.setCompressionEnabled(param.getCompressionEnabled());
    }
    vpool.setHostIOLimitBandwidth(param.getHostIOLimitBandwidth());
    vpool.setHostIOLimitIOPs(param.getHostIOLimitIOPs());
    if (null != param.getDriveType()) {
        vpool.setDriveType(param.getDriveType());
    } else {
        vpool.setDriveType(NONE);
    }
    validateAndSetPathParams(vpool, param.getMaxPaths(), param.getMinPaths(), param.getPathsPerInitiator());
    if (param.getThinVolumePreAllocationPercentage() != null) {
        vpool.setThinVolumePreAllocationPercentage(param.getThinVolumePreAllocationPercentage());
    }
    if (param.getMultiVolumeConsistency() != null) {
        vpool.setMultivolumeConsistency(param.getMultiVolumeConsistency());
    }
    if (null != param.getExpandable()) {
        vpool.setExpandable(param.getExpandable());
    }
    if (param.getFastExpansion() != null) {
        vpool.setFastExpansion(param.getFastExpansion());
    }
    if (null != param.getUniquePolicyNames()) {
        vpool.setUniquePolicyNames(param.getUniquePolicyNames());
    }
    // Update HA settings.
    if (null != param.getHighAvailability()) {
        updateHAParametersForVirtualPool(vpool, param.getHighAvailability());
    }
    // Update Protection settings.
    if (null != param.getProtection()) {
        updateProtectionParamsForVirtualPool(vpool, param.getProtection(), param.getHighAvailability());
    }
    // update placement policy
    if (param.getPlacementPolicy() != null) {
        vpool.setPlacementPolicy(param.getPlacementPolicy());
    }
    // dedup vpool can be made non-dedup because dedup storage pools will always remain
    if (null != param.getDedupCapable()) {
        if (vpool.getDedupCapable() != null && !vpool.getDedupCapable() && param.getDedupCapable()) {
            ArgValidator.checkReference(VirtualPool.class, id, checkForDelete(vpool));
        }
        vpool.setDedupCapable(param.getDedupCapable());
    }
    // Validate Block VirtualPool update params.
    VirtualPoolUtil.validateBlockVirtualPoolUpdateParams(vpool, param, _dbClient);
    StringBuffer errorMessage = new StringBuffer();
    // invokes implicit pool matching algorithm.
    ImplicitPoolMatcher.matchVirtualPoolWithAllStoragePools(vpool, _dbClient, _coordinator, errorMessage);
    if (null != vpool.getMatchedStoragePools() || null != vpool.getInvalidMatchedPools()) {
        Set<URI> allSrdfTargetVPools = SRDFUtils.fetchSRDFTargetVirtualPools(_dbClient);
        Set<URI> allRpTargetVPools = RPHelper.fetchRPTargetVirtualPools(_dbClient);
        ImplicitUnManagedObjectsMatcher.matchVirtualPoolsWithUnManagedVolumes(vpool, allSrdfTargetVPools, allRpTargetVPools, _dbClient, true);
    }
    // Validate Mirror Vpool
    if (vpool.getMirrorVirtualPool() != null && !NullColumnValueGetter.isNullURI(URI.create(vpool.getMirrorVirtualPool()))) {
        VirtualPool protectionMirrorVPool = _permissionsHelper.getObjectById(URI.create(vpool.getMirrorVirtualPool()), VirtualPool.class);
        validateMirrorVpool(vpool.getHighAvailability(), protectionMirrorVPool);
    }
    // Validate Max Native Continuous Copies
    if (vpool.getMaxNativeContinuousCopies() != null) {
        validateMaxNativeContinuousCopies(vpool.getMaxNativeContinuousCopies(), vpool.getHighAvailability());
    }
    _dbClient.updateObject(vpool);
    // Update VirtualPool and QoS with new parameters
    QosService.updateQos(vpool, qosSpecification, _dbClient);
    recordOperation(OperationTypeEnum.UPDATE_VPOOL, VPOOL_UPDATED_DESCRIPTION, vpool);
    return toBlockVirtualPool(_dbClient, vpool, VirtualPool.getProtectionSettings(vpool, _dbClient), VirtualPool.getRemoteProtectionSettings(vpool, _dbClient));
}
Also used : StringSetMap(com.emc.storageos.db.client.model.StringSetMap) Volume(com.emc.storageos.db.client.model.Volume) VirtualPoolMapper.toBlockVirtualPool(com.emc.storageos.api.mapper.VirtualPoolMapper.toBlockVirtualPool) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) QosSpecification(com.emc.storageos.db.client.model.QosSpecification) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) PUT(javax.ws.rs.PUT) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Aggregations

QosSpecification (com.emc.storageos.db.client.model.QosSpecification)11 URI (java.net.URI)8 StringMap (com.emc.storageos.db.client.model.StringMap)4 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)4 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)4 Produces (javax.ws.rs.Produces)4 GET (javax.ws.rs.GET)3 Path (javax.ws.rs.Path)3 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)2 VirtualPoolMapper.toBlockVirtualPool (com.emc.storageos.api.mapper.VirtualPoolMapper.toBlockVirtualPool)1 CinderQosDetail (com.emc.storageos.cinder.model.CinderQosDetail)1 CinderQosListRestResp (com.emc.storageos.cinder.model.CinderQosListRestResp)1 QosAssociationsRestResp (com.emc.storageos.cinder.model.QosAssociationsRestResp)1 DbClient (com.emc.storageos.db.client.DbClient)1 FilePolicy (com.emc.storageos.db.client.model.FilePolicy)1 NamedURI (com.emc.storageos.db.client.model.NamedURI)1 QuotaOfCinder (com.emc.storageos.db.client.model.QuotaOfCinder)1 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)1 Volume (com.emc.storageos.db.client.model.Volume)1 VpoolProtectionVarraySettings (com.emc.storageos.db.client.model.VpoolProtectionVarraySettings)1