Merge "Fixes Python 3 str issue in ConfigDrive creation"
This commit is contained in:
commit
56dc61d752
@ -342,7 +342,7 @@ class InstanceMetadata(object):
|
||||
metadata['project_id'] = self.instance.project_id
|
||||
|
||||
self.set_mimetype(MIME_TYPE_APPLICATION_JSON)
|
||||
return jsonutils.dumps(metadata)
|
||||
return jsonutils.dump_as_bytes(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.dumps({})
|
||||
return jsonutils.dumps(self.network_metadata)
|
||||
return jsonutils.dump_as_bytes({})
|
||||
return jsonutils.dump_as_bytes(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.dumps(self.vddriver.get())
|
||||
return jsonutils.dump_as_bytes(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.dumps(data['meta-data']))
|
||||
yield (filepath, jsonutils.dump_as_bytes(data['meta-data']))
|
||||
|
||||
ALL_OPENSTACK_VERSIONS = OPENSTACK_VERSIONS + ["latest"]
|
||||
for version in ALL_OPENSTACK_VERSIONS:
|
||||
|
@ -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, 'dumps')
|
||||
def _test_as_json_with_options(self, mock_json_dumps,
|
||||
@mock.patch.object(jsonutils, 'dump_as_bytes')
|
||||
def _test_as_json_with_options(self, mock_json_dump_as_bytes,
|
||||
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_dumps.assert_called_once_with(expected_metadata)
|
||||
mock_json_dump_as_bytes.assert_called_once_with(expected_metadata)
|
||||
|
||||
def test_as_json(self):
|
||||
for os_version in base.OPENSTACK_VERSIONS:
|
||||
|
Loading…
Reference in New Issue
Block a user