diff --git a/nova/cloudpipe/pipelib.py b/nova/cloudpipe/pipelib.py index 59df355fcf25..97a8a777ef8f 100644 --- a/nova/cloudpipe/pipelib.py +++ b/nova/cloudpipe/pipelib.py @@ -20,6 +20,7 @@ an instance with it. """ +import base64 import os import string import zipfile @@ -78,12 +79,13 @@ class CloudPipe(object): 'server.crt') z.write(server_crt, 'server.crt') z.close() - with open(zippath, "r") as zippy: + with open(zippath, "rb") as zippy: # NOTE(vish): run instances expects encoded userdata, # it is decoded in the get_metadata_call. # autorun.sh also decodes the zip file, # hence the double encoding. - encoded = zippy.read().encode("base64").encode("base64") + encoded = base64.b64encode(zippy.read()) + encoded = base64.b64encode(encoded) return encoded diff --git a/nova/tests/unit/policy_fixture.py b/nova/tests/unit/policy_fixture.py index 49d3d65e87c8..df2c9c5800a7 100644 --- a/nova/tests/unit/policy_fixture.py +++ b/nova/tests/unit/policy_fixture.py @@ -100,7 +100,9 @@ class RoleBasedPolicyFixture(RealPolicyFixture): self.role = role def _prepare_policy(self): - policy = jsonutils.load(open(CONF.oslo_policy.policy_file)) + with open(CONF.oslo_policy.policy_file) as fp: + policy = fp.read() + policy = jsonutils.loads(policy) # Convert all actions to require specified role for action, rule in six.iteritems(policy): diff --git a/tests-py3.txt b/tests-py3.txt index 7625428b11e3..5dc9242de2f9 100644 --- a/tests-py3.txt +++ b/tests-py3.txt @@ -68,10 +68,6 @@ nova.tests.unit.test_metadata.MetadataHandlerTestCase nova.tests.unit.test_metadata.MetadataPasswordTestCase nova.tests.unit.test_metadata.MetadataTestCase nova.tests.unit.test_metadata.OpenStackMetadataTestCase -nova.tests.unit.test_pipelib.PipelibTest -nova.tests.unit.test_policy.AdminRolePolicyTestCase -nova.tests.unit.test_quota.QuotaIntegrationTestCase -nova.tests.unit.test_test_utils.TestUtilsTestCase nova.tests.unit.test_wsgi.TestWSGIServerWithSSL nova.tests.unit.virt.disk.mount.test_nbd.NbdTestCase nova.tests.unit.virt.ironic.test_driver.IronicDriverTestCase