Search in sources :

Example 6 with ObjectController

use of com.emc.storageos.volumecontroller.ObjectController in project coprhd-controller by CoprHD.

the class BucketService method updateBucketACL.

/**
 * Add/Update the ACL settings for bucket
 *
 * @param id
 * @param param
 * @brief Change a bucket ACL
 * @return TaskResponse
 * @throws InternalException
 */
@PUT
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/acl")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public TaskResourceRep updateBucketACL(@PathParam("id") URI id, ObjectBucketACLUpdateParams param) throws InternalException {
    _log.info("Update bucket acl request received. BucketId: {}", id.toString());
    _log.info("Request body: {}", param.toString());
    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);
    }
    // Verify the Bucket ACL Settings
    BucketACLUtility bucketACLUtil = new BucketACLUtility(_dbClient, bucket.getName(), bucket.getId());
    bucketACLUtil.verifyBucketACL(param);
    _log.info("Request payload verified. No errors found.");
    StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, bucket.getStorageDevice());
    ObjectController controller = getController(ObjectController.class, storageSystem.getSystemType());
    String task = UUID.randomUUID().toString();
    _log.info(String.format("Bucket ACL Update --- Bucket id: %1$s, Task: %2$s", id, task));
    Operation op = _dbClient.createTaskOpStatus(Bucket.class, bucket.getId(), task, ResourceOperationTypeEnum.UPDATE_BUCKET_ACL);
    op.setDescription("Bucket ACL update");
    controller.updateBucketACL(bucket.getStorageDevice(), id, param, task);
    auditOp(OperationTypeEnum.UPDATE_BUCKET_ACL, true, AuditLogManager.AUDITOP_BEGIN, bucket.getId().toString(), bucket.getStorageDevice().toString());
    return toTask(bucket, task, op);
}
Also used : 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) 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) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) PUT(javax.ws.rs.PUT) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 7 with ObjectController

use of com.emc.storageos.volumecontroller.ObjectController in project coprhd-controller by CoprHD.

the class BucketService method deactivateBucket.

/**
 * Deactivate Bucket, this will move the Bucket to a "marked-for-delete" state
 *
 * <p>
 * NOTE: This is an asynchronous operation.
 *
 * @param id the URN of a ViPR Bucket
 * @param param Bucket delete param for optional force delete
 * @brief Delete bucket
 * @return Task resource representation
 * @throws InternalException
 */
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/deactivate")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public TaskResourceRep deactivateBucket(@PathParam("id") URI id, BucketDeleteParam param) throws InternalException {
    String task = UUID.randomUUID().toString();
    _log.info(String.format("BucketDelete --- Bucket id: %1$s, Task: %2$s, ForceDelete: %3$s", id, task, param.getForceDelete()));
    ArgValidator.checkFieldUriType(id, Bucket.class, "id");
    Bucket bucket = queryResource(id);
    StorageSystem device = _dbClient.queryObject(StorageSystem.class, bucket.getStorageDevice());
    Operation op = _dbClient.createTaskOpStatus(Bucket.class, bucket.getId(), task, ResourceOperationTypeEnum.DELETE_BUCKET);
    op.setDescription("Bucket deactivate");
    ObjectController controller = getController(ObjectController.class, device.getSystemType());
    controller.deleteBucket(bucket.getStorageDevice(), id, param.getDeleteType(), task);
    auditOp(OperationTypeEnum.DELETE_BUCKET, true, AuditLogManager.AUDITOP_BEGIN, bucket.getId().toString(), device.getId().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) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 8 with ObjectController

use of com.emc.storageos.volumecontroller.ObjectController in project coprhd-controller by CoprHD.

the class BucketService method initiateBucketCreation.

private TaskResourceRep initiateBucketCreation(BucketParam param, Project project, TenantOrg tenant, DataObject.Flag[] flags) throws InternalException {
    ArgValidator.checkFieldUriType(param.getVpool(), VirtualPool.class, "vpool");
    ArgValidator.checkFieldUriType(param.getVarray(), VirtualArray.class, "varray");
    Long softQuota = SizeUtil.translateSize(param.getSoftQuota());
    Long hardQuota = SizeUtil.translateSize(param.getHardQuota());
    Integer retention = Integer.valueOf(param.getRetention());
    // Hard Quota should be more than SoftQuota
    verifyQuotaValues(softQuota, hardQuota, param.getLabel());
    // check varray
    VirtualArray neighborhood = _dbClient.queryObject(VirtualArray.class, param.getVarray());
    ArgValidator.checkEntity(neighborhood, param.getVarray(), false);
    _permissionsHelper.checkTenantHasAccessToVirtualArray(tenant.getId(), neighborhood);
    // check vpool reference
    VirtualPool vpool = _dbClient.queryObject(VirtualPool.class, param.getVpool());
    _permissionsHelper.checkTenantHasAccessToVirtualPool(tenant.getId(), vpool);
    ArgValidator.checkEntity(vpool, param.getVpool(), false);
    if (!VirtualPool.Type.object.name().equals(vpool.getType())) {
        throw APIException.badRequests.virtualPoolNotForObjectStorage(VirtualPool.Type.object.name());
    }
    // verify retention. Its validated only if Retention is configured.
    if (retention != 0 && vpool.getMaxRetention() != 0 && retention > vpool.getMaxRetention()) {
        throw APIException.badRequests.insufficientRetentionForVirtualPool(vpool.getLabel(), "bucket");
    }
    VirtualPoolCapabilityValuesWrapper capabilities = new VirtualPoolCapabilityValuesWrapper();
    capabilities.put(VirtualPoolCapabilityValuesWrapper.RESOURCE_COUNT, Integer.valueOf(1));
    capabilities.put(VirtualPoolCapabilityValuesWrapper.THIN_PROVISIONING, Boolean.FALSE);
    capabilities.put(VirtualPoolCapabilityValuesWrapper.QUOTA, hardQuota.toString());
    Map<String, Object> attributeMap = new HashMap<String, Object>();
    List<BucketRecommendation> placement = _bucketScheduler.placeBucket(neighborhood, vpool, capabilities, attributeMap);
    if (placement.isEmpty()) {
        StringBuffer errorMessage = new StringBuffer();
        if (attributeMap.get(AttributeMatcher.ERROR_MESSAGE) != null) {
            errorMessage = (StringBuffer) attributeMap.get(AttributeMatcher.ERROR_MESSAGE);
        }
        throw APIException.badRequests.noStoragePools(neighborhood.getLabel(), vpool.getLabel(), errorMessage.toString());
    }
    // Randomly select a recommended pool
    Collections.shuffle(placement);
    BucketRecommendation recommendation = placement.get(0);
    String task = UUID.randomUUID().toString();
    Bucket bucket = prepareBucket(param, project, tenant, neighborhood, vpool, flags, recommendation);
    _log.info(String.format("createBucket --- Bucket: %1$s, StoragePool: %2$s, StorageSystem: %3$s", bucket.getId(), recommendation.getSourceStoragePool(), recommendation.getSourceStorageSystem()));
    Operation op = _dbClient.createTaskOpStatus(Bucket.class, bucket.getId(), task, ResourceOperationTypeEnum.CREATE_BUCKET);
    op.setDescription("Bucket Create");
    // Controller invocation
    StorageSystem system = _dbClient.queryObject(StorageSystem.class, recommendation.getSourceStorageSystem());
    ObjectController controller = getController(ObjectController.class, system.getSystemType());
    controller.createBucket(recommendation.getSourceStorageSystem(), recommendation.getSourceStoragePool(), bucket.getId(), bucket.getName(), bucket.getNamespace(), bucket.getRetention(), bucket.getHardQuota(), bucket.getSoftQuota(), bucket.getOwner(), task);
    auditOp(OperationTypeEnum.CREATE_BUCKET, true, AuditLogManager.AUDITOP_BEGIN, param.getLabel(), param.getHardQuota(), neighborhood.getId().toString(), project == null ? null : project.getId().toString());
    return toTask(bucket, task, op);
}
Also used : VirtualPoolCapabilityValuesWrapper(com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper) VirtualArray(com.emc.storageos.db.client.model.VirtualArray) HashMap(java.util.HashMap) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) Operation(com.emc.storageos.db.client.model.Operation) BucketRecommendation(com.emc.storageos.api.service.impl.placement.BucketRecommendation) Bucket(com.emc.storageos.db.client.model.Bucket) MapBucket(com.emc.storageos.api.mapper.functions.MapBucket) ObjectController(com.emc.storageos.volumecontroller.ObjectController) DataObject(com.emc.storageos.db.client.model.DataObject) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 9 with ObjectController

use of com.emc.storageos.volumecontroller.ObjectController 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)

Example 10 with ObjectController

use of com.emc.storageos.volumecontroller.ObjectController in project coprhd-controller by CoprHD.

the class ObjectControllerImpl method lookupDeviceController.

@Override
public Controller lookupDeviceController(DiscoveredSystemObject device) throws ControllerException {
    // dummy impl that returns the first one
    _log.debug("ObjectControllerImpl:lookupDeviceController");
    if (device == null) {
        throw ClientControllerException.fatals.unableToLookupStorageDeviceIsNull();
    }
    ObjectController ob = _deviceImpl.iterator().next();
    if (ob == null) {
        throw ClientControllerException.fatals.unableToLocateDeviceController("BlockController");
    }
    return ob;
}
Also used : ObjectController(com.emc.storageos.volumecontroller.ObjectController)

Aggregations

ObjectController (com.emc.storageos.volumecontroller.ObjectController)10 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)9 Operation (com.emc.storageos.db.client.model.Operation)6 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)6 Produces (javax.ws.rs.Produces)6 MapBucket (com.emc.storageos.api.mapper.functions.MapBucket)5 Bucket (com.emc.storageos.db.client.model.Bucket)5 Path (javax.ws.rs.Path)5 Consumes (javax.ws.rs.Consumes)4 POST (javax.ws.rs.POST)3 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)2 PUT (javax.ws.rs.PUT)2 Controller (com.emc.storageos.Controller)1 TaskMapper.toTask (com.emc.storageos.api.mapper.TaskMapper.toTask)1 BucketRecommendation (com.emc.storageos.api.service.impl.placement.BucketRecommendation)1 BucketACLUtility (com.emc.storageos.api.service.impl.resource.utils.BucketACLUtility)1 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)1 DataObject (com.emc.storageos.db.client.model.DataObject)1 ObjectUserSecretKey (com.emc.storageos.db.client.model.ObjectUserSecretKey)1 Task (com.emc.storageos.db.client.model.Task)1