Fix the inject_metadata_into_fs in the disk API.
Updates the _inject_metadata_into_fs in the disk/api.py so that it uses dict-style access. This resolves an issue introduced in a recent no-db-messaging change. Includes new test case. Fixes LP Bug #1034040. Change-Id: I1bc90a8331419709ab71e5da8c48cd1d54c40f9e
This commit is contained in:
@@ -24,6 +24,8 @@ from nova import utils
|
||||
from nova.virt.disk import api as disk_api
|
||||
from nova.virt import driver
|
||||
|
||||
from nova.openstack.common import jsonutils
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
|
||||
|
||||
@@ -178,3 +180,12 @@ class TestVirtDiskPaths(test.TestCase):
|
||||
disk_api._inject_file_into_fs,
|
||||
'/tmp', '/etc/../../../../etc/passwd',
|
||||
'hax')
|
||||
|
||||
def test_inject_metadata(self):
|
||||
with utils.tempdir() as tmpdir:
|
||||
meta_objs = [{"key": "foo", "value": "bar"}]
|
||||
metadata = {"foo": "bar"}
|
||||
disk_api._inject_metadata_into_fs(meta_objs, tmpdir)
|
||||
json_file = os.path.join(tmpdir, 'meta.js')
|
||||
json_data = jsonutils.loads(open(json_file).read())
|
||||
self.assertEqual(metadata, json_data)
|
||||
|
||||
Reference in New Issue
Block a user