Merge "Putting context as the first parameter"

This commit is contained in:
Zuul 2018-06-20 07:41:08 +00:00 committed by Gerrit Code Review
commit fb0dcf1a18
2 changed files with 10 additions and 10 deletions

View File

@ -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."""
@ -369,8 +369,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.
@ -573,8 +573,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')
@ -594,8 +594,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

View File

@ -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