From aa65f7eef7b368cde8d2f9e0332ae5bc84355008 Mon Sep 17 00:00:00 2001 From: xxj Date: Sun, 5 Mar 2017 13:17:00 +0800 Subject: [PATCH] Support --all-tenant in server side If all-tenant is determined to be 1, then set context.all_tenant to true. Change-Id: I82121f159ed3e8de44caa21dd390236ce391e62b Closes-Bug: #1647387 --- zun/api/controllers/v1/containers.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/zun/api/controllers/v1/containers.py b/zun/api/controllers/v1/containers.py index d503b3885..819c00b93 100644 --- a/zun/api/controllers/v1/containers.py +++ b/zun/api/controllers/v1/containers.py @@ -17,6 +17,7 @@ from oslo_log import log as logging from oslo_utils import strutils import pecan from pecan import rest +import six from zun.api.controllers import link from zun.api.controllers.v1 import collection @@ -108,6 +109,17 @@ class ContainersController(rest.RestController): def _get_containers_collection(self, **kwargs): context = pecan.request.context + all_tenants = kwargs.get('all_tenants') + if all_tenants: + try: + all_tenants = strutils.bool_from_string(all_tenants, True) + except ValueError as err: + raise exception.InvalidInput(six.text_type(err)) + else: + # If no value, it's considered to disable all_tenants + all_tenants = False + if all_tenants: + context.all_tenants = True compute_api = pecan.request.compute_api limit = api_utils.validate_limit(kwargs.get('limit')) sort_dir = api_utils.validate_sort_dir(kwargs.get('sort_dir', 'asc'))