Revert "Fixes Python 3 str issue in ConfigDrive creation"

This reverts commit 0134d88b75.

The commit was breaking tripleo-ci on stable/liberty with this error:
AttributeError: 'module' object has no attribute 'dump_as_bytes'

The root cause is that jsonutils.py from the stable/liberty version of
oslo.serialization does not have a dump_as_bytes method.

Partial-Bug: #1531881
Change-Id: I6a0c90fc319dc3d7fc4ed3347495758cbd7d0cc2
This commit is contained in:
James Slagle 2016-01-07 09:27:26 -05:00
parent 0134d88b75
commit cf75bf233f
2 changed files with 8 additions and 8 deletions

View File

@ -342,7 +342,7 @@ class InstanceMetadata(object):
metadata['project_id'] = self.instance.project_id
self.set_mimetype(MIME_TYPE_APPLICATION_JSON)
return jsonutils.dump_as_bytes(metadata)
return jsonutils.dumps(metadata)
def _handle_content(self, path_tokens):
if len(path_tokens) == 1:
@ -372,8 +372,8 @@ class InstanceMetadata(object):
def _network_data(self, version, path):
if self.network_metadata is None:
return jsonutils.dump_as_bytes({})
return jsonutils.dump_as_bytes(self.network_metadata)
return jsonutils.dumps({})
return jsonutils.dumps(self.network_metadata)
def _password(self, version, path):
if self._check_os_version(GRIZZLY, version):
@ -383,7 +383,7 @@ class InstanceMetadata(object):
def _vendor_data(self, version, path):
if self._check_os_version(HAVANA, version):
self.set_mimetype(MIME_TYPE_APPLICATION_JSON)
return jsonutils.dump_as_bytes(self.vddriver.get())
return jsonutils.dumps(self.vddriver.get())
raise KeyError(path)
def _check_version(self, required, requested, versions=VERSIONS):
@ -462,7 +462,7 @@ class InstanceMetadata(object):
pass
filepath = os.path.join('ec2', version, 'meta-data.json')
yield (filepath, jsonutils.dump_as_bytes(data['meta-data']))
yield (filepath, jsonutils.dumps(data['meta-data']))
ALL_OPENSTACK_VERSIONS = OPENSTACK_VERSIONS + ["latest"]
for version in ALL_OPENSTACK_VERSIONS:

View File

@ -373,8 +373,8 @@ class MetadataTestCase(test.TestCase):
@mock.patch.object(base64, 'b64encode', lambda data: FAKE_SEED)
@mock.patch('nova.cells.rpcapi.CellsAPI.get_keypair_at_top')
@mock.patch.object(objects.KeyPair, 'get_by_name')
@mock.patch.object(jsonutils, 'dump_as_bytes')
def _test_as_json_with_options(self, mock_json_dump_as_bytes,
@mock.patch.object(jsonutils, 'dumps')
def _test_as_json_with_options(self, mock_json_dumps,
mock_keypair, mock_cells_keypair,
is_cells=False, os_version=base.GRIZZLY):
if is_cells:
@ -422,7 +422,7 @@ class MetadataTestCase(test.TestCase):
self.assertIsInstance(mock_keypair.call_args[0][0],
context.RequestContext)
self.assertEqual(md.md_mimetype, base.MIME_TYPE_APPLICATION_JSON)
mock_json_dump_as_bytes.assert_called_once_with(expected_metadata)
mock_json_dumps.assert_called_once_with(expected_metadata)
def test_as_json(self):
for os_version in base.OPENSTACK_VERSIONS: