diff options
author | Lingxian Kong <anlin.kong@gmail.com> | 2021-07-12 10:41:21 +1200 |
---|---|---|
committer | Lingxian Kong <anlin.kong@gmail.com> | 2021-07-13 16:04:14 +1200 |
commit | 24fc4a53dcf1140349e0ae32386046ff597e416b (patch) | |
tree | a118e3a6ee99299b7efe52f37147e954545ce699 /trove/configuration | |
parent | 7b4631181752be749092add04d5f0ecd57057c73 (diff) | |
download | trove-24fc4a53dcf1140349e0ae32386046ff597e416b.tar.gz |
Allow admin user to get instances attached with any configuration
Change-Id: I5e5f0b99f79ba78c82cbb12482b9167ec69e50f7
Diffstat (limited to 'trove/configuration')
-rw-r--r-- | trove/configuration/service.py | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/trove/configuration/service.py b/trove/configuration/service.py index 7cd6576d..48f705a0 100644 --- a/trove/configuration/service.py +++ b/trove/configuration/service.py @@ -64,10 +64,15 @@ class ConfigurationsController(wsgi.Controller): self.authorize_config_action(context, 'show', configuration) configuration_items = models.Configuration.load_items(context, id) + find_instance = { + 'configuration_id': configuration.id, + 'deleted': False + } + if not context.is_admin: + find_instance['tenant_id'] = context.project_id + configuration.instance_count = instances_models.DBInstance.find_all( - tenant_id=context.project_id, - configuration_id=configuration.id, - deleted=False).count() + **find_instance).count() return wsgi.Result(views.DetailedConfigurationView( configuration, @@ -77,10 +82,15 @@ class ConfigurationsController(wsgi.Controller): context = req.environ[wsgi.CONTEXT_KEY] configuration = models.Configuration.load(context, id) self.authorize_config_action(context, 'instances', configuration) - instances = instances_models.DBInstance.find_all( - tenant_id=context.tenant, - configuration_id=configuration.id, - deleted=False) + + kwargs = { + 'configuration_id': configuration.id, + 'deleted': False + } + if not context.is_admin: + kwargs['tenant_id'] = context.tenant + instances = instances_models.DBInstance.find_all(**kwargs) + limit = int(context.limit or CONF.instances_page_size) if limit > CONF.instances_page_size: limit = CONF.instances_page_size |