stage call fails with TypeError

image-stage call fails with TypeError saying 'stage() takes exactly
3 arguments (4 given). The reason is stage() also accepts image_size
as a argument which is not provided.

Further it raises 'NoneType' object has no attribute 'headers'. The
reason is stage() internally calls upload method which
returns a object of RequestIdWrapper on body (which is None) and
response. In stage call it again tries to add request id which requires
response object but instead it has a RequestIdWrapper which fails to
retrieve headers.

Change-Id: I4de4be7a55f35c3533b53acd48042c7c95b4bdc0
Closes-bug: #1711090
(cherry picked from commit 0e50837a37)
This commit is contained in:
Abhishek Kekane 2017-08-16 15:49:47 +05:30 committed by Brian Rosmaita
parent bd4d010531
commit f7ce62b089
1 changed files with 6 additions and 4 deletions

View File

@ -240,16 +240,18 @@ class Controller(object):
return body, resp
@utils.add_req_id_to_object()
def stage(self, image_id, image_data):
def stage(self, image_id, image_data, image_size=None):
"""Upload the data to image staging.
:param image_id: ID of the image to upload data for.
:param image_data: File-like object supplying the data to upload.
:param image_size: Unused - present for backwards compatibility
"""
url = '/v2/images/%s/stage' % image_id
return self.upload(image_id,
image_data,
u_url=url)
resp, body = self.upload(image_id,
image_data,
u_url=url)
return body, resp
@utils.add_req_id_to_object()
def image_import(self, image_id, method='glance-direct'):