From 9d05d7fdc042b6366b5720feccb393ed1e406324 Mon Sep 17 00:00:00 2001 From: Ritu Sitlani Date: Mon, 11 Jun 2018 11:21:34 +0000 Subject: [PATCH] Putting context as the first parameter Re-order parameters at format_container Closes-Bug: #1771882 Change-Id: I9ac8b4a0faf221b0baa22f6f1e880f781e7ae278 --- zun/api/controllers/v1/containers.py | 18 +++++++++--------- .../controllers/v1/views/containers_view.py | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/zun/api/controllers/v1/containers.py b/zun/api/controllers/v1/containers.py index 976ceed4c..3c3b11e7e 100644 --- a/zun/api/controllers/v1/containers.py +++ b/zun/api/controllers/v1/containers.py @@ -70,7 +70,7 @@ class ContainerCollection(collection.Collection): context = pecan.request.context collection = ContainerCollection() collection.containers = \ - [view.format_container(url, p, context) for p in rpc_containers] + [view.format_container(context, url, p) for p in rpc_containers] collection.next = collection.get_next(limit, url=url, **kwargs) return collection @@ -259,8 +259,8 @@ class ContainersController(base.Controller): except exception.ContainerHostNotUp: raise exception.ServerNotUsable - return view.format_container(pecan.request.host_url, container, - context) + return view.format_container(context, pecan.request.host_url, + container) def _generate_name_for_container(self): """Generate a random name like: zeta-22-container.""" @@ -367,8 +367,8 @@ class ContainersController(base.Controller): pecan.response.location = link.build_url('containers', new_container.uuid) pecan.response.status = 202 - return view.format_container(pecan.request.host_url, new_container, - context) + return view.format_container(context, pecan.request.host_url, + new_container) def _set_default_resource_limit(self, container_dict): # NOTE(kiennt): Default disk size will be set later. @@ -571,8 +571,8 @@ class ContainersController(base.Controller): context = pecan.request.context compute_api = pecan.request.compute_api container = compute_api.container_update(context, container, patch) - return view.format_container(pecan.request.host_url, container, - context) + return view.format_container(context, pecan.request.host_url, + container) @base.Controller.api_version("1.1", "1.13") @pecan.expose('json') @@ -592,8 +592,8 @@ class ContainersController(base.Controller): container.name = name context = pecan.request.context container.save(context) - return view.format_container(pecan.request.host_url, container, - context) + return view.format_container(context, pecan.request.host_url, + container) @pecan.expose('json') @exception.wrap_pecan_controller_exception diff --git a/zun/api/controllers/v1/views/containers_view.py b/zun/api/controllers/v1/views/containers_view.py index a457f4c81..13a253ee9 100644 --- a/zun/api/controllers/v1/views/containers_view.py +++ b/zun/api/controllers/v1/views/containers_view.py @@ -50,7 +50,7 @@ _basic_keys = ( ) -def format_container(url, container, context): +def format_container(context, url, container): def transform(key, value): if key not in _basic_keys: return