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']))
|
% (container.uuid, kw['path']))
|
||||||
context = pecan.request.context
|
context = pecan.request.context
|
||||||
compute_api = pecan.request.compute_api
|
compute_api = pecan.request.compute_api
|
||||||
return compute_api.container_get_archive(context,
|
data, stat = compute_api.container_get_archive(
|
||||||
container, kw['path'])
|
context, container, kw['path'])
|
||||||
|
return {"data": data, "stat": stat}
|
||||||
|
|
||||||
@pecan.expose('json')
|
@pecan.expose('json')
|
||||||
@exception.wrap_pecan_controller_exception
|
@exception.wrap_pecan_controller_exception
|
||||||
|
@ -354,7 +354,9 @@ class DockerDriver(driver.ContainerDriver):
|
|||||||
def get_archive(self, container, path):
|
def get_archive(self, container, path):
|
||||||
with docker_utils.docker_client() as docker:
|
with docker_utils.docker_client() as docker:
|
||||||
try:
|
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:
|
except errors.APIError:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
@ -362,9 +364,7 @@ class DockerDriver(driver.ContainerDriver):
|
|||||||
def put_archive(self, container, path, data):
|
def put_archive(self, container, path, data):
|
||||||
with docker_utils.docker_client() as docker:
|
with docker_utils.docker_client() as docker:
|
||||||
try:
|
try:
|
||||||
f = open(data, 'rb')
|
docker.put_archive(container.container_id, path, data)
|
||||||
filedata = f.read()
|
|
||||||
docker.put_archive(container.container_id, path, filedata)
|
|
||||||
except errors.APIError:
|
except errors.APIError:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
@ -1356,7 +1356,7 @@ class TestContainerController(api_base.FunctionalTest):
|
|||||||
mock_get_by_uuid,
|
mock_get_by_uuid,
|
||||||
container_get_archive,
|
container_get_archive,
|
||||||
mock_validate):
|
mock_validate):
|
||||||
container_get_archive.return_value = ""
|
container_get_archive.return_value = ("", "")
|
||||||
test_container = utils.get_test_container()
|
test_container = utils.get_test_container()
|
||||||
test_container_obj = objects.Container(self.context, **test_container)
|
test_container_obj = objects.Container(self.context, **test_container)
|
||||||
mock_get_by_uuid.return_value = test_container_obj
|
mock_get_by_uuid.return_value = test_container_obj
|
||||||
@ -1376,7 +1376,7 @@ class TestContainerController(api_base.FunctionalTest):
|
|||||||
mock_get_by_name,
|
mock_get_by_name,
|
||||||
container_get_archive,
|
container_get_archive,
|
||||||
mock_validate):
|
mock_validate):
|
||||||
container_get_archive.return_value = ""
|
container_get_archive.return_value = ("", "")
|
||||||
test_container = utils.get_test_container()
|
test_container = utils.get_test_container()
|
||||||
test_container_obj = objects.Container(self.context, **test_container)
|
test_container_obj = objects.Container(self.context, **test_container)
|
||||||
mock_get_by_name.return_value = test_container_obj
|
mock_get_by_name.return_value = test_container_obj
|
||||||
|
Loading…
x
Reference in New Issue
Block a user