Search in sources :

Example 46 with VirtualPool

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

the class BlockVirtualPoolService method getVirtualPool.

/**
 * Get info for block store virtual pool
 *
 * @prereq none
 * @param id the URN of a ViPR VirtualPool
 * @brief Show block store virtual pool
 * @return VirtualPool details
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR }, acls = { ACL.USE })
public BlockVirtualPoolRestRep getVirtualPool(@PathParam("id") URI id) {
    VirtualPool vpool = getVirtualPool(VirtualPool.Type.block, id);
    BlockVirtualPoolRestRep restRep = getBlockVirtualPoolWithProtection(vpool);
    restRep.setNumResources(getNumResources(vpool, _dbClient));
    return restRep;
}
Also used : VirtualPoolMapper.toBlockVirtualPool(com.emc.storageos.api.mapper.VirtualPoolMapper.toBlockVirtualPool) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) BlockVirtualPoolRestRep(com.emc.storageos.model.vpool.BlockVirtualPoolRestRep) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 47 with VirtualPool

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

the class BlockVirtualPoolService method verifyNewHAVpoolForHAVpoolUpdate.

/**
 * When updating a virtual pool, this function verifies that if there is
 * and update to the HA virtual pool, that the specified pool is valid
 * for the virtual pool being updated.
 *
 * @param vPoolBeingUpdated The vpool being updated.
 * @param newHAVpoolId The non-null id of the new HA vpool.
 */
private void verifyNewHAVpoolForHAVpoolUpdate(VirtualPool vPoolBeingUpdated, String newHAVpoolId) {
    URI newHAVpoolURI = URI.create(newHAVpoolId);
    VirtualPool newHAVpool = _dbClient.queryObject(VirtualPool.class, newHAVpoolURI);
    if (newHAVpool == null) {
        throw APIException.badRequests.haVpoolForVpoolUpdateDoesNotExist(newHAVpoolId);
    }
    if (newHAVpool.getInactive()) {
        throw APIException.badRequests.haVpoolForVpoolUpdateIsInactive(newHAVpool.getLabel());
    }
    StringMap newHAVpoolHAMap = newHAVpool.getHaVarrayVpoolMap();
    if ((newHAVpoolHAMap == null) || (newHAVpoolHAMap.isEmpty())) {
        // New HA vpool does not specify VPLEX HA.
        return;
    }
    String newHAVpoolHAVpoolId = newHAVpoolHAMap.get(newHAVpoolHAMap.keySet().iterator().next());
    if (!NullColumnValueGetter.isNotNullValue(newHAVpoolHAVpoolId)) {
        // No HA Vpool specified.
        return;
    }
    VirtualPool newHAVpoolHAVpool = _dbClient.queryObject(VirtualPool.class, URI.create(newHAVpoolHAVpoolId));
    if (newHAVpoolHAVpool == null) {
        // Invalid HA vpool for the new HA vpool does not exist.
        throw APIException.badRequests.haVpoolForNewHAVpoolForVpoolUpdateDoesNotExist(newHAVpoolHAVpoolId, newHAVpool.getLabel());
    }
    // HA vpool is not this vpool being updated. See Jira 6797.
    if (newHAVpoolHAVpool.getId().equals(vPoolBeingUpdated.getId())) {
        throw APIException.badRequests.haVpoolForVpoolUpdateHasInvalidHAVpool(newHAVpool.getLabel());
    }
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap) VirtualPoolMapper.toBlockVirtualPool(com.emc.storageos.api.mapper.VirtualPoolMapper.toBlockVirtualPool) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI)

Example 48 with VirtualPool

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

the class BlockVirtualPoolService method queryFilteredBulkResourceReps.

@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
protected BlockVirtualPoolBulkRep queryFilteredBulkResourceReps(List<URI> ids) {
    if (isSystemOrRestrictedSystemAdmin()) {
        return queryBulkResourceReps(ids);
    }
    if (!ids.iterator().hasNext()) {
        return new BlockVirtualPoolBulkRep();
    }
    // get vdc id from the first id; assume all id's are from the same vdc
    String shortVdcId = VdcUtil.getVdcId(getResourceClass(), ids.iterator().next()).toString();
    Iterator<VirtualPool> dbIterator;
    if (shortVdcId.equals(VdcUtil.getLocalShortVdcId())) {
        dbIterator = _dbClient.queryIterativeObjects(getResourceClass(), ids);
    } else {
        GeoServiceClient geoClient = _geoHelper.getClient(shortVdcId);
        try {
            dbIterator = geoClient.queryObjects(getResourceClass(), ids);
        } catch (Exception ex) {
            // TODO: revisit this exception
            _log.error("error retrieving bulk virtual pools from vdc " + shortVdcId, ex);
            throw APIException.internalServerErrors.genericApisvcError("error retrieving remote virtual pool", ex);
        }
    }
    BulkList.ResourceFilter filter = new BulkList.VirtualPoolFilter(Type.block, getUserFromContext(), _permissionsHelper);
    return new BlockVirtualPoolBulkRep(BulkList.wrapping(dbIterator, BLOCK_VPOOL_MAPPER, filter));
}
Also used : BlockVirtualPoolBulkRep(com.emc.storageos.model.vpool.BlockVirtualPoolBulkRep) GeoServiceClient(com.emc.storageos.security.geo.GeoServiceClient) BulkList(com.emc.storageos.api.service.impl.response.BulkList) VirtualPoolMapper.toBlockVirtualPool(com.emc.storageos.api.mapper.VirtualPoolMapper.toBlockVirtualPool) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException)

Example 49 with VirtualPool

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

the class BlockVirtualPoolService method createBlockVirtualPool.

/**
 * Creates a block store virtual pool
 *
 * @prereq none
 * @param param VirtualPool parameters
 * @brief Create block store virtual pool
 * @return VirtualPool details
 * @throws Exception
 */
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
public BlockVirtualPoolRestRep createBlockVirtualPool(BlockVirtualPoolParam param) throws DatabaseException {
    ArgValidator.checkFieldNotEmpty(param.getName(), VPOOL_NAME);
    checkForDuplicateName(param.getName(), VirtualPool.class);
    ArgValidator.checkFieldNotEmpty(param.getDescription(), VPOOL_DESCRIPTION);
    VirtualPoolUtil.validateBlockVirtualPoolCreateParams(param, _dbClient);
    Map<URI, VpoolRemoteCopyProtectionSettings> remoteSettingsMap = new HashMap<URI, VpoolRemoteCopyProtectionSettings>();
    List<VpoolProtectionVarraySettings> protectionSettings = new ArrayList<VpoolProtectionVarraySettings>();
    Map<URI, VpoolProtectionVarraySettings> protectionSettingsMap = new HashMap<URI, VpoolProtectionVarraySettings>();
    VirtualPool vpool = prepareVirtualPool(param, remoteSettingsMap, protectionSettingsMap, protectionSettings);
    // Set the underlying protection setting objects
    if (!protectionSettings.isEmpty()) {
        _dbClient.createObject(protectionSettings);
    }
    if (!remoteSettingsMap.isEmpty()) {
        _dbClient.createObject(new ArrayList(remoteSettingsMap.values()));
    }
    StringBuffer errorMessage = new StringBuffer();
    // update the implicit pools matching with this VirtualPool.
    ImplicitPoolMatcher.matchVirtualPoolWithAllStoragePools(vpool, _dbClient, _coordinator, errorMessage);
    Set<URI> allSrdfTargetVPools = SRDFUtils.fetchSRDFTargetVirtualPools(_dbClient);
    Set<URI> allRpTargetVPools = RPHelper.fetchRPTargetVirtualPools(_dbClient);
    if (null != vpool.getMatchedStoragePools() || null != vpool.getInvalidMatchedPools()) {
        ImplicitUnManagedObjectsMatcher.matchVirtualPoolsWithUnManagedVolumes(vpool, allSrdfTargetVPools, allRpTargetVPools, _dbClient, true);
    }
    _dbClient.createObject(vpool);
    // Creates a new QoS object in DB based on data from given Virtual Pool
    QosService.createQosSpecification(vpool, _dbClient);
    recordOperation(OperationTypeEnum.CREATE_VPOOL, VPOOL_CREATED_DESCRIPTION, vpool);
    return toBlockVirtualPool(_dbClient, vpool, VirtualPool.getProtectionSettings(vpool, _dbClient), VirtualPool.getRemoteProtectionSettings(vpool, _dbClient));
}
Also used : VpoolRemoteCopyProtectionSettings(com.emc.storageos.db.client.model.VpoolRemoteCopyProtectionSettings) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) VpoolProtectionVarraySettings(com.emc.storageos.db.client.model.VpoolProtectionVarraySettings) VirtualPoolMapper.toBlockVirtualPool(com.emc.storageos.api.mapper.VirtualPoolMapper.toBlockVirtualPool) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 50 with VirtualPool

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

the class BucketService method updateBucket.

/**
 * Updates Bucket values like Quota and Retention.
 *
 * @param id Bucket ID
 * @param param Bucket update parameter
 * @brief Change bucket properties
 * @return Task resource representation
 * @throws InternalException if update fails
 */
@PUT
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public TaskResourceRep updateBucket(@PathParam("id") URI id, BucketUpdateParam param) throws InternalException {
    Bucket bucket = null;
    ArgValidator.checkFieldUriType(id, Bucket.class, "id");
    bucket = _dbClient.queryObject(Bucket.class, id);
    ArgValidator.checkEntity(bucket, id, isIdEmbeddedInURL(id));
    Long softQuota = SizeUtil.translateSize(param.getSoftQuota());
    Long hardQuota = SizeUtil.translateSize(param.getHardQuota());
    Integer retention = null != param.getRetention() ? Integer.valueOf(param.getRetention()) : 0;
    // if no softquota is provided, use the old value
    if (softQuota == 0) {
        softQuota = bucket.getSoftQuota();
    }
    // if no hardquota is provided, use the old value
    if (hardQuota == 0) {
        hardQuota = bucket.getHardQuota();
    }
    // Hard Quota should be more than SoftQuota
    verifyQuotaValues(softQuota, hardQuota, bucket.getLabel());
    // if no retention is provided, use the old value
    if (retention == 0) {
        retention = bucket.getRetention();
    }
    VirtualPool cos = _dbClient.queryObject(VirtualPool.class, bucket.getVirtualPool());
    // verify retention. Its validated only if Retention is configured.
    if (retention != 0 && cos.getMaxRetention() != 0 && retention > cos.getMaxRetention()) {
        throw APIException.badRequests.insufficientRetentionForVirtualPool(cos.getLabel(), "bucket");
    }
    String task = UUID.randomUUID().toString();
    _log.info(String.format("BucketUpdate --- Bucket id: %1$s, Task: %2$s", id, task));
    StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, bucket.getStorageDevice());
    Operation op = _dbClient.createTaskOpStatus(Bucket.class, bucket.getId(), task, ResourceOperationTypeEnum.UPDATE_BUCKET);
    op.setDescription("Bucket update");
    ObjectController controller = getController(ObjectController.class, storageSystem.getSystemType());
    controller.updateBucket(bucket.getStorageDevice(), id, softQuota, hardQuota, retention, task);
    auditOp(OperationTypeEnum.UPDATE_BUCKET, true, AuditLogManager.AUDITOP_BEGIN, bucket.getId().toString(), bucket.getStorageDevice().toString());
    return toTask(bucket, task, op);
}
Also used : Bucket(com.emc.storageos.db.client.model.Bucket) MapBucket(com.emc.storageos.api.mapper.functions.MapBucket) ObjectController(com.emc.storageos.volumecontroller.ObjectController) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) Operation(com.emc.storageos.db.client.model.Operation) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) 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

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