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