diff --git a/rally_openstack/services/image/glance_v1.py b/rally_openstack/services/image/glance_v1.py index bc5d6070..c667943e 100644 --- a/rally_openstack/services/image/glance_v1.py +++ b/rally_openstack/services/image/glance_v1.py @@ -52,7 +52,7 @@ class GlanceV1Service(service.Service, glance_common.GlanceMixin): try: if os.path.isfile(image_location): - kwargs["data"] = open(image_location) + kwargs["data"] = open(image_location, "rb") else: kwargs["copy_from"] = image_location diff --git a/rally_openstack/services/image/glance_v2.py b/rally_openstack/services/image/glance_v2.py index 070076ad..0bd8e171 100644 --- a/rally_openstack/services/image/glance_v2.py +++ b/rally_openstack/services/image/glance_v2.py @@ -44,7 +44,7 @@ class GlanceV2Service(service.Service, glance_common.GlanceMixin): response = None try: if os.path.isfile(image_location): - image_data = open(image_location) + image_data = open(image_location, "rb") else: response = requests.get(image_location, stream=True) image_data = response.raw diff --git a/tests/unit/services/image/test_glance_v1.py b/tests/unit/services/image/test_glance_v1.py index 0bc4ae18..5cb7f3bb 100755 --- a/tests/unit/services/image/test_glance_v1.py +++ b/tests/unit/services/image/test_glance_v1.py @@ -70,7 +70,7 @@ class GlanceV1ServiceTestCase(test.TestCase): if location.startswith("/"): call_args["data"] = mock_open.return_value - mock_open.assert_called_once_with(location) + mock_open.assert_called_once_with(location, "rb") mock_open.return_value.close.assert_called_once_with() else: call_args["copy_from"] = location diff --git a/tests/unit/services/image/test_glance_v2.py b/tests/unit/services/image/test_glance_v2.py index 6369d143..3ea61ff7 100755 --- a/tests/unit/services/image/test_glance_v2.py +++ b/tests/unit/services/image/test_glance_v2.py @@ -51,7 +51,7 @@ class GlanceV2ServiceTestCase(test.TestCase): self.service.upload_data(image_id, image_location=location) if location.startswith("/"): - mock_open.assert_called_once_with(location) + mock_open.assert_called_once_with(location, "rb") mock_open.return_value.close.assert_called_once_with() self.gc.images.upload.assert_called_once_with( image_id, mock_open.return_value)