Support multi-tenant for clusters and machines.
Change-Id: I4af6c82d2243977903d71366a538808dd5cd92f8
This commit is contained in:
parent
d3f203535a
commit
d00035ca0b
@ -162,9 +162,13 @@ UPDATED_CLUSTERHOST_LOG_FIELDS = [
|
||||
@utils.wrap_to_dict(RESP_FIELDS)
|
||||
def list_clusters(user=None, session=None, **filters):
|
||||
"""List clusters."""
|
||||
return utils.list_db_objects(
|
||||
clusters = utils.list_db_objects(
|
||||
session, models.Cluster, **filters
|
||||
)
|
||||
logging.info('user is %s', user.email)
|
||||
if not user.is_admin and len(clusters):
|
||||
clusters = [c for c in clusters if c.owner == user.email]
|
||||
return clusters
|
||||
|
||||
|
||||
def _get_cluster(cluster_id, session=None, **kwargs):
|
||||
|
@ -130,9 +130,12 @@ def get_machine(
|
||||
@utils.wrap_to_dict(RESP_FIELDS)
|
||||
def list_machines(user=None, session=None, **filters):
|
||||
"""List machines."""
|
||||
return utils.list_db_objects(
|
||||
machines = utils.list_db_objects(
|
||||
session, models.Machine, **filters
|
||||
)
|
||||
if not user.is_admin and len(machines):
|
||||
machines = [m for m in machines if m.owner_id == user.id]
|
||||
return machines
|
||||
|
||||
|
||||
@utils.wrap_to_dict(RESP_FIELDS)
|
||||
|
Loading…
x
Reference in New Issue
Block a user