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());
}
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());
}
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());
}
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());
}
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);
}
Aggregations