use of com.emc.storageos.db.client.model.Bucket in project coprhd-controller by CoprHD.
the class ObjectDeviceController method deleteBucket.
@Override
public void deleteBucket(URI storage, URI bucket, String deleteType, String task) throws ControllerException {
_log.info("ObjectDeviceController:deleteBucket Bucket URI : {} ", bucket);
Bucket bucketObj = _dbClient.queryObject(Bucket.class, bucket);
StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
BiosCommandResult result = getDevice(storageObj.getSystemType()).doDeleteBucket(storageObj, bucketObj, deleteType, 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 prepareBucket.
/**
* Allocate, initialize and persist state of the Bucket being created.
*
* @param param
* @param project
* @param tenantOrg
* @param neighborhood
* @param vpool
* @param flags
* @param placement
* @return
*/
private Bucket prepareBucket(BucketParam param, Project project, TenantOrg tenantOrg, VirtualArray neighborhood, VirtualPool vpool, DataObject.Flag[] flags, BucketRecommendation placement) {
_log.debug("Preparing Bucket creation for Param : {}", param);
StoragePool pool = null;
Bucket bucket = new Bucket();
bucket.setId(URIUtil.createId(Bucket.class));
bucket.setLabel(param.getLabel().replaceAll(SPECIAL_CHAR_REGEX, ""));
bucket.setHardQuota(SizeUtil.translateSize(param.getHardQuota()));
bucket.setSoftQuota(SizeUtil.translateSize(param.getSoftQuota()));
bucket.setRetention(Integer.valueOf(param.getRetention()));
bucket.setOwner(param.getOwner());
bucket.setNamespace(tenantOrg.getNamespace());
bucket.setVirtualPool(param.getVpool());
if (project != null) {
bucket.setProject(new NamedURI(project.getId(), bucket.getLabel()));
}
bucket.setTenant(new NamedURI(tenantOrg.getId(), param.getLabel()));
bucket.setVirtualArray(neighborhood.getId());
if (null != placement.getSourceStoragePool()) {
pool = _dbClient.queryObject(StoragePool.class, placement.getSourceStoragePool());
if (null != pool) {
bucket.setProtocol(new StringSet());
bucket.getProtocol().addAll(VirtualPoolUtil.getMatchingProtocols(vpool.getProtocols(), pool.getProtocols()));
}
}
bucket.setStorageDevice(placement.getSourceStorageSystem());
bucket.setPool(placement.getSourceStoragePool());
bucket.setOpStatus(new OpStatusMap());
// Bucket name to be used at Storage System
String bucketName = project.getLabel() + UNDER_SCORE + param.getLabel();
bucket.setName(bucketName.replaceAll(SPECIAL_CHAR_REGEX, ""));
// Update Bucket path
StringBuilder bucketPath = new StringBuilder();
bucketPath.append(tenantOrg.getNamespace()).append(SLASH).append(project.getLabel()).append(SLASH).append(param.getLabel());
bucket.setPath(bucketPath.toString());
if (flags != null) {
bucket.addInternalFlags(flags);
}
_dbClient.createObject(bucket);
return bucket;
}
use of com.emc.storageos.db.client.model.Bucket in project coprhd-controller by CoprHD.
the class BucketService method getBucketACL.
/**
* Gets the ACL settings for bucket
*
* @param id
* @brief Get ACLs for a bucket
* @return BucketACL
* @throws InternalException
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/acl")
@CheckPermission(roles = { Role.SYSTEM_MONITOR, Role.TENANT_ADMIN }, acls = { ACL.ANY })
public BucketACL getBucketACL(@PathParam("id") URI id) throws InternalException {
_log.info("Request recieved to get Bucket ACL with Id: {}", id);
// Validate the Bucket
Bucket bucket = null;
ArgValidator.checkFieldUriType(id, Bucket.class, "id");
bucket = _dbClient.queryObject(Bucket.class, id);
ArgValidator.checkEntity(bucket, id, isIdEmbeddedInURL(id));
if (bucket.getVersion() == null) {
syncBucketACL(bucket);
}
BucketACL bucketAcl = new BucketACL();
BucketACLUtility bucketACLUtil = new BucketACLUtility(_dbClient, bucket.getName(), bucket.getId());
List<BucketACE> bucketAces = bucketACLUtil.queryExistingBucketACL();
_log.info("Number of existing ACLs found : {} ", bucketAces.size());
if (!bucketAces.isEmpty()) {
bucketAcl.setBucketACL(bucketAces);
}
return bucketAcl;
}
use of com.emc.storageos.db.client.model.Bucket in project coprhd-controller by CoprHD.
the class BucketService method queryResource.
@Override
protected Bucket queryResource(URI id) {
ArgValidator.checkUri(id);
Bucket bucket = _permissionsHelper.getObjectById(id, Bucket.class);
ArgValidator.checkEntityNotNull(bucket, id, isIdEmbeddedInURL(id));
return bucket;
}
use of com.emc.storageos.db.client.model.Bucket in project coprhd-controller by CoprHD.
the class BucketService method deleteBucketACL.
/**
* Delete Bucket ACL
*
* @param id
* @brief Delete an ACL
* @return TaskResponse
*/
@DELETE
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/acl")
@CheckPermission(roles = { Role.SYSTEM_MONITOR, Role.TENANT_ADMIN }, acls = { ACL.ANY })
public TaskResourceRep deleteBucketACL(@PathParam("id") URI id) {
_log.info("Request recieved to delete ACL for the Bucket Id: {}", id);
// Validate the Bucket
Bucket bucket = null;
ArgValidator.checkFieldUriType(id, Bucket.class, "id");
bucket = _dbClient.queryObject(Bucket.class, id);
ArgValidator.checkEntity(bucket, id, isIdEmbeddedInURL(id));
StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, bucket.getStorageDevice());
ObjectController controller = getController(ObjectController.class, storageSystem.getSystemType());
String task = UUID.randomUUID().toString();
_log.info(String.format("Delete Bucket ACL --- Bucket id: %1$s, Task: %2$s", id, task));
Operation op = _dbClient.createTaskOpStatus(Bucket.class, bucket.getId(), task, ResourceOperationTypeEnum.DELETE_BUCKET_ACL);
op.setDescription("Delete Bucket ACL");
controller.deleteBucketACL(bucket.getStorageDevice(), id, task);
auditOp(OperationTypeEnum.DELETE_BUCKET_ACL, true, AuditLogManager.AUDITOP_BEGIN, bucket.getId().toString(), bucket.getStorageDevice().toString());
return toTask(bucket, task, op);
}
Aggregations