Search in sources :

Example 11 with Bucket

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());
}
Also used : Bucket(com.emc.storageos.db.client.model.Bucket) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 12 with Bucket

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;
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) Bucket(com.emc.storageos.db.client.model.Bucket) MapBucket(com.emc.storageos.api.mapper.functions.MapBucket) NamedURI(com.emc.storageos.db.client.model.NamedURI) StringSet(com.emc.storageos.db.client.model.StringSet) OpStatusMap(com.emc.storageos.db.client.model.OpStatusMap)

Example 13 with 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;
}
Also used : BucketACL(com.emc.storageos.model.object.BucketACL) BucketACLUtility(com.emc.storageos.api.service.impl.resource.utils.BucketACLUtility) Bucket(com.emc.storageos.db.client.model.Bucket) MapBucket(com.emc.storageos.api.mapper.functions.MapBucket) BucketACE(com.emc.storageos.model.object.BucketACE) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 14 with Bucket

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;
}
Also used : Bucket(com.emc.storageos.db.client.model.Bucket) MapBucket(com.emc.storageos.api.mapper.functions.MapBucket)

Example 15 with 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);
}
Also used : Bucket(com.emc.storageos.db.client.model.Bucket) MapBucket(com.emc.storageos.api.mapper.functions.MapBucket) ObjectController(com.emc.storageos.volumecontroller.ObjectController) Operation(com.emc.storageos.db.client.model.Operation) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) Produces(javax.ws.rs.Produces) 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