Make _upload_file to work with Python 3

Open the content from the file in Swift as bytes and in read
mode, otherwise Python 3 fails to open it as it comes as a string by default.

Closes-Bug: #1819665
Change-Id: I0da24d3508174190b431b660e67365f242ef04d8
This commit is contained in:
Emilien Macchi 2019-03-12 10:34:04 -04:00
parent 8fb3b96633
commit 3982259973
3 changed files with 4 additions and 4 deletions

View File

@ -337,7 +337,7 @@ class TestOvercloudCreatePlan(utils.TestCommand):
})
mock_open_context.assert_has_calls(
[mock.call('the_plan_environment.yaml')])
[mock.call('the_plan_environment.yaml', 'rb')])
self.tripleoclient.object_store.put_object.assert_called_once_with(
'overcast', 'plan-environment.yaml', mock_open_context())

View File

@ -155,7 +155,7 @@ class TestPlanCreationWorkflows(utils.TestCommand):
'validate_stack': False})
mock_open_context.assert_has_calls(
[mock.call('the-plan-environment.yaml')])
[mock.call('the-plan-environment.yaml', 'rb')])
self.tripleoclient.object_store.put_object.assert_called_once_with(
'test-overcloud', 'plan-environment.yaml', mock_open_context())
@ -190,7 +190,7 @@ class TestPlanCreationWorkflows(utils.TestCommand):
'validate_stack': False})
mock_open_context.assert_has_calls(
[mock.call('the-network-data.yaml')])
[mock.call('the-network-data.yaml', 'rb')])
self.tripleoclient.object_store.put_object.assert_called_once_with(
'test-overcloud', 'network_data.yaml', mock_open_context())

View File

@ -277,7 +277,7 @@ def _list_plan_files(swift_client, container):
def _upload_file(swift_client, container, filename, local_filename):
with open(local_filename) as file_content:
with open(local_filename, 'rb') as file_content:
swift_client.put_object(container, filename, file_content)