Merge "Fixed the file I/O issues on archive api"
This commit is contained in:
commit
6748e5dbba
@ -477,8 +477,9 @@ class ContainersController(rest.RestController):
|
||||
% (container.uuid, kw['path']))
|
||||
context = pecan.request.context
|
||||
compute_api = pecan.request.compute_api
|
||||
return compute_api.container_get_archive(context,
|
||||
container, kw['path'])
|
||||
data, stat = compute_api.container_get_archive(
|
||||
context, container, kw['path'])
|
||||
return {"data": data, "stat": stat}
|
||||
|
||||
@pecan.expose('json')
|
||||
@exception.wrap_pecan_controller_exception
|
||||
|
@ -354,7 +354,9 @@ class DockerDriver(driver.ContainerDriver):
|
||||
def get_archive(self, container, path):
|
||||
with docker_utils.docker_client() as docker:
|
||||
try:
|
||||
return docker.get_archive(container.container_id, path)
|
||||
stream, stat = docker.get_archive(container.container_id, path)
|
||||
filedata = stream.read()
|
||||
return filedata, stat
|
||||
except errors.APIError:
|
||||
raise
|
||||
|
||||
@ -362,9 +364,7 @@ class DockerDriver(driver.ContainerDriver):
|
||||
def put_archive(self, container, path, data):
|
||||
with docker_utils.docker_client() as docker:
|
||||
try:
|
||||
f = open(data, 'rb')
|
||||
filedata = f.read()
|
||||
docker.put_archive(container.container_id, path, filedata)
|
||||
docker.put_archive(container.container_id, path, data)
|
||||
except errors.APIError:
|
||||
raise
|
||||
|
||||
|
@ -1356,7 +1356,7 @@ class TestContainerController(api_base.FunctionalTest):
|
||||
mock_get_by_uuid,
|
||||
container_get_archive,
|
||||
mock_validate):
|
||||
container_get_archive.return_value = ""
|
||||
container_get_archive.return_value = ("", "")
|
||||
test_container = utils.get_test_container()
|
||||
test_container_obj = objects.Container(self.context, **test_container)
|
||||
mock_get_by_uuid.return_value = test_container_obj
|
||||
@ -1376,7 +1376,7 @@ class TestContainerController(api_base.FunctionalTest):
|
||||
mock_get_by_name,
|
||||
container_get_archive,
|
||||
mock_validate):
|
||||
container_get_archive.return_value = ""
|
||||
container_get_archive.return_value = ("", "")
|
||||
test_container = utils.get_test_container()
|
||||
test_container_obj = objects.Container(self.context, **test_container)
|
||||
mock_get_by_name.return_value = test_container_obj
|
||||
|
Loading…
Reference in New Issue
Block a user