Search in sources :

Example 11 with TenantOrg

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

the class TenantsService method updateRoleAssignments.

/**
 * Add or remove individual role assignments
 *
 * @param changes Role Assignment changes
 * @param id the URN of a ViPR Tenant/Subtenant
 * @prereq none
 * @brief Add or remove role assignments
 * @return No data returned in response body
 */
@PUT
@Path("/{id}/role-assignments")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SECURITY_ADMIN, Role.TENANT_ADMIN }, blockProxies = true)
public RoleAssignments updateRoleAssignments(@PathParam("id") URI id, RoleAssignmentChanges changes) {
    TenantOrg tenant = getTenantById(id, true);
    _permissionsHelper.updateRoleAssignments(tenant, changes, new TenantRoleInputFilter(tenant));
    _dbClient.updateAndReindexObject(tenant);
    recordTenantEvent(OperationTypeEnum.MODIFY_TENANT_ROLES, tenant.getId(), tenant.getId());
    auditOp(OperationTypeEnum.MODIFY_TENANT_ROLES, true, null, tenant.getId().toString(), tenant.getLabel(), changes);
    return getRoleAssignmentsResponse(tenant);
}
Also used : TenantOrg(com.emc.storageos.db.client.model.TenantOrg) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) PUT(javax.ws.rs.PUT) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 12 with TenantOrg

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

the class TenantsService method getTenantById.

/**
 * Get tenant object from id
 *
 * @param id the URN of a ViPR tenant
 * @return
 */
private TenantOrg getTenantById(URI id, boolean checkInactive) {
    if (id == null) {
        return null;
    }
    TenantOrg org = _permissionsHelper.getObjectById(id, TenantOrg.class);
    ArgValidator.checkEntity(org, id, isIdEmbeddedInURL(id), checkInactive);
    return org;
}
Also used : TenantOrg(com.emc.storageos.db.client.model.TenantOrg)

Example 13 with TenantOrg

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

the class HostService method provisionBareMetalHosts.

/**
 * Provision bare metal hosts by taking compute elements from the compute
 * virtual pool.
 *
 * @param param
 *            parameter for multiple host creation
 * @brief Provision bare metal hosts
 * @return TaskResourceRep (asynchronous call)
 * @throws DatabaseException
 */
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/provision-bare-metal")
public TaskList provisionBareMetalHosts(ProvisionBareMetalHostsParam param) throws DatabaseException {
    ComputeVirtualPool cvp = _dbClient.queryObject(ComputeVirtualPool.class, param.getComputeVpool());
    ArgValidator.checkEntity(cvp, param.getComputeVpool(), false);
    VirtualArray varray = _dbClient.queryObject(VirtualArray.class, param.getVarray());
    ArgValidator.checkEntity(varray, param.getVarray(), false);
    TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, param.getTenant());
    ArgValidator.checkEntity(tenant, param.getTenant(), false);
    if (!NullColumnValueGetter.isNullURI(param.getCluster())) {
        Cluster cluster = _dbClient.queryObject(Cluster.class, param.getCluster());
        ArgValidator.checkEntity(cluster, param.getCluster(), false);
    }
    _log.debug("checking if CVP is accessible");
    _permissionsHelper.checkTenantHasAccessToComputeVirtualPool(tenant.getId(), cvp);
    validateHostNames(param);
    InterProcessLock lock = lockBladeReservation();
    List<String> ceList = null;
    try {
        ceList = takeComputeElementsFromPool(cvp, param.getHostNames().size(), varray, param.getCluster());
    } catch (Exception e) {
        _log.error("unable to takeComputeElementsFromPool", e);
        throw e;
    } finally {
        unlockBladeReservation(lock);
    }
    Set<Host> hosts = new HashSet<Host>();
    for (int i = 0; i < param.getHostNames().size(); i++) {
        Host host = populateHost(tenant, param.getHostNames().get(i), ceList.get(i), param.getCluster(), cvp.getId());
        hosts.add(host);
        _dbClient.createObject(host);
    }
    return createHostTasks(hosts, param.getComputeVpool(), param.getVarray());
}
Also used : VirtualArray(com.emc.storageos.db.client.model.VirtualArray) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) Cluster(com.emc.storageos.db.client.model.Cluster) InterProcessLock(org.apache.curator.framework.recipes.locks.InterProcessLock) Host(com.emc.storageos.db.client.model.Host) ComputeVirtualPool(com.emc.storageos.db.client.model.ComputeVirtualPool) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) BadRequestException(com.emc.storageos.svcs.errorhandling.resources.BadRequestException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) HashSet(java.util.HashSet) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Example 14 with TenantOrg

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

the class InternalFileResource method deactivateFileSystemInternal.

/*
     * POST to deactivate filesystem
     */
@POST
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/deactivate")
public TaskResourceRep deactivateFileSystemInternal(@PathParam("id") URI id, FileSystemDeleteParam param) throws InternalException {
    ArgValidator.checkFieldUriType(id, FileShare.class, "id");
    FileShare fs = _fileService.queryResource(id);
    checkFileShareInternal(fs);
    TenantOrg tenant = _permissionsHelper.getRootTenant();
    if (!_permissionsHelper.userHasGivenRole(getUserFromContext(), tenant.getId(), Role.SYSTEM_ADMIN, Role.TENANT_ADMIN)) {
        throw APIException.forbidden.onlyAdminsCanDeactivateFileSystems(Role.SYSTEM_ADMIN.toString(), Role.TENANT_ADMIN.toString());
    }
    return _fileService.deactivateFileSystem(id, param);
}
Also used : TenantOrg(com.emc.storageos.db.client.model.TenantOrg) FileShare(com.emc.storageos.db.client.model.FileShare)

Example 15 with TenantOrg

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

the class InternalFileResource method createFileSystemInternal.

/*
     * POST to create
     */
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public TaskResourceRep createFileSystemInternal(FileSystemParam param) {
    TenantOrg tenant = _permissionsHelper.getRootTenant();
    TaskResourceRep rep = null;
    if (!_permissionsHelper.userHasGivenRole(getUserFromContext(), tenant.getId(), Role.SYSTEM_ADMIN, Role.TENANT_ADMIN)) {
        rep = new TaskResourceRep();
        _log.error("Unable to process the request as Only [system_admin, tenant_admin] can provision file systems for object");
        rep.setMessage("Only [system_admin, tenant_admin] can provision file systems for object");
        rep.setState(Operation.Status.error.name());
        return rep;
    }
    try {
        rep = _fileService.createFSInternal(param, _internalProject, tenant, INTERNAL_FILESHARE_FLAGS);
    } catch (Exception ex) {
        rep = new TaskResourceRep();
        _log.error("Exception occurred while creating file system due to:", ex);
        rep.setMessage(ex.getMessage());
        rep.setState(Operation.Status.error.name());
    }
    return rep;
}
Also used : TenantOrg(com.emc.storageos.db.client.model.TenantOrg) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException)

Aggregations

TenantOrg (com.emc.storageos.db.client.model.TenantOrg)138 URI (java.net.URI)64 NamedURI (com.emc.storageos.db.client.model.NamedURI)57 Project (com.emc.storageos.db.client.model.Project)54 Volume (com.emc.storageos.db.client.model.Volume)41 ArrayList (java.util.ArrayList)40 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)37 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)34 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)33 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)29 StringSet (com.emc.storageos.db.client.model.StringSet)29 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)28 VirtualArray (com.emc.storageos.db.client.model.VirtualArray)26 Produces (javax.ws.rs.Produces)26 StoragePool (com.emc.storageos.db.client.model.StoragePool)25 List (java.util.List)23 Test (org.junit.Test)23 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)22 StringMap (com.emc.storageos.db.client.model.StringMap)21 Consumes (javax.ws.rs.Consumes)21