Search in sources :

Example 1 with Bucket

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

the class ObjectDeviceController method updateBucketACL.

@Override
public void updateBucketACL(URI storage, URI bucket, BucketACLUpdateParams param, String opId) throws InternalException {
    ControllerUtils.setThreadLocalLogData(bucket, opId);
    _log.info("ObjectDeviceController:updateBucketACL Bucket URI : {} ", bucket);
    Bucket bucketObj = _dbClient.queryObject(Bucket.class, bucket);
    StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
    ObjectDeviceInputOutput objectArgs = new ObjectDeviceInputOutput();
    objectArgs.setAllBuckectAcl(param);
    objectArgs.setName(bucketObj.getName());
    objectArgs.setNamespace(bucketObj.getNamespace());
    // Query for existing ACL and setting it.
    objectArgs.setExistingBucketAcl(queryExistingBucketAcl(objectArgs, bucket));
    BiosCommandResult result = getDevice(storageObj.getSystemType()).doUpdateBucketACL(storageObj, bucketObj, objectArgs, param, opId);
    if (result.getCommandPending()) {
        return;
    }
    bucketObj.getOpStatus().updateTaskStatus(opId, result.toOperation());
}
Also used : Bucket(com.emc.storageos.db.client.model.Bucket) ObjectDeviceInputOutput(com.emc.storageos.volumecontroller.ObjectDeviceInputOutput) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 2 with Bucket

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

the class ObjectDeviceController method deleteBucketACL.

@Override
public void deleteBucketACL(URI storage, URI bucket, String opId) throws InternalException {
    ControllerUtils.setThreadLocalLogData(bucket, opId);
    _log.info("ObjectDeviceController:updateBucketACL Bucket URI : {} ", bucket);
    Bucket bucketObj = _dbClient.queryObject(Bucket.class, bucket);
    StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
    ObjectDeviceInputOutput objectArgs = new ObjectDeviceInputOutput();
    objectArgs.setName(bucketObj.getName());
    objectArgs.setNamespace(bucketObj.getNamespace());
    // Query for existing ACL and setting it for deletion.
    objectArgs.setBucketAclToDelete(queryExistingBucketAcl(objectArgs, bucket));
    BiosCommandResult result = getDevice(storageObj.getSystemType()).doDeleteBucketACL(storageObj, bucketObj, objectArgs, opId);
    if (result.getCommandPending()) {
        return;
    }
    bucketObj.getOpStatus().updateTaskStatus(opId, result.toOperation());
}
Also used : Bucket(com.emc.storageos.db.client.model.Bucket) ObjectDeviceInputOutput(com.emc.storageos.volumecontroller.ObjectDeviceInputOutput) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 3 with Bucket

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

the class ObjectDeviceController method updateBucket.

@Override
public void updateBucket(URI storage, URI bucket, Long softQuota, Long hardQuota, Integer retention, String task) throws ControllerException {
    _log.info("ObjectDeviceController:updateBucket Bucket URI : {} ", bucket);
    Bucket bucketObj = _dbClient.queryObject(Bucket.class, bucket);
    StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
    BiosCommandResult result = getDevice(storageObj.getSystemType()).doUpdateBucket(storageObj, bucketObj, softQuota, hardQuota, retention, task);
    if (result.getCommandPending()) {
        return;
    }
    bucketObj.getOpStatus().updateTaskStatus(task, result.toOperation());
}
Also used : Bucket(com.emc.storageos.db.client.model.Bucket) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 4 with Bucket

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

the class ObjectDeviceController method createBucket.

@Override
public void createBucket(URI storage, URI uriPool, URI bkt, String label, String namespace, Integer retention, Long hardQuota, Long softQuota, String owner, String task) throws ControllerException {
    _log.info("ObjectDeviceController:createBucket Bucket URI : {} ", bkt);
    StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
    Bucket bucketObj = _dbClient.queryObject(Bucket.class, bkt);
    StoragePool stPool = _dbClient.queryObject(StoragePool.class, uriPool);
    ObjectDeviceInputOutput args = new ObjectDeviceInputOutput();
    args.setName(label);
    args.setNamespace(namespace);
    // recommended storage pool
    args.setDevStoragePool(stPool.getNativeId());
    args.setRetentionPeriod(retention);
    args.setBlkSizeHQ(hardQuota);
    args.setNotSizeSQ(softQuota);
    args.setOwner(owner);
    _log.info("ObjectDeviceController:createBucket URI and Type: " + storage.toString() + "   " + storageObj.getSystemType());
    BiosCommandResult result = getDevice(storageObj.getSystemType()).doCreateBucket(storageObj, bucketObj, args, task);
    if (result.getCommandPending()) {
        return;
    }
    bucketObj.getOpStatus().updateTaskStatus(task, result.toOperation());
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) Bucket(com.emc.storageos.db.client.model.Bucket) ObjectDeviceInputOutput(com.emc.storageos.volumecontroller.ObjectDeviceInputOutput) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 5 with Bucket

use of com.emc.storageos.db.client.model.Bucket 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

Bucket (com.emc.storageos.db.client.model.Bucket)16 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)11 MapBucket (com.emc.storageos.api.mapper.functions.MapBucket)9 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)6 Path (javax.ws.rs.Path)6 Produces (javax.ws.rs.Produces)6 Operation (com.emc.storageos.db.client.model.Operation)5 ObjectController (com.emc.storageos.volumecontroller.ObjectController)5 ObjectDeviceInputOutput (com.emc.storageos.volumecontroller.ObjectDeviceInputOutput)4 Consumes (javax.ws.rs.Consumes)3 BucketACLUtility (com.emc.storageos.api.service.impl.resource.utils.BucketACLUtility)2 StoragePool (com.emc.storageos.db.client.model.StoragePool)2 StringSet (com.emc.storageos.db.client.model.StringSet)2 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)2 GET (javax.ws.rs.GET)2 PUT (javax.ws.rs.PUT)2 BucketRecommendation (com.emc.storageos.api.service.impl.placement.BucketRecommendation)1 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)1 DataObject (com.emc.storageos.db.client.model.DataObject)1 FileShare (com.emc.storageos.db.client.model.FileShare)1