Merge "Sanitize the config drive UUID"

This commit is contained in:
Zuul 2018-05-09 20:55:02 +00:00 committed by Gerrit Code Review
commit df59df8fb5
2 changed files with 8 additions and 3 deletions

View File

@ -1,4 +1,4 @@
# Copyright 2015, 2017 IBM Corp.
# Copyright 2015, 2018 IBM Corp.
#
# All Rights Reserved.
#
@ -42,7 +42,8 @@ class TestConfigDrivePowerVM(test.NoDBTestCase):
@mock.patch('nova.api.metadata.base.InstanceMetadata', autospec=True)
@mock.patch('nova.virt.configdrive.ConfigDriveBuilder.make_drive',
autospec=True)
def test_crt_cfg_dr_iso(self, mock_mkdrv, mock_meta):
@mock.patch('nova_powervm.virt.powervm.vm.get_pvm_uuid', autospec=True)
def test_crt_cfg_dr_iso(self, mock_pvm_uuid, mock_mkdrv, mock_meta):
"""Validates that the image creation method works."""
cfg_dr_builder = m.ConfigDrivePowerVM(self.apt)
mock_instance = mock.MagicMock()
@ -55,6 +56,7 @@ class TestConfigDrivePowerVM(test.NoDBTestCase):
mock_net)
self.assertEqual('cfg_fake_instance.iso', file_name)
self.assertEqual('/tmp/cfgdrv/cfg_fake_instance.iso', iso_path)
self.assertTrue(mock_pvm_uuid.called)
# Make sure the length is limited properly
mock_instance.name = 'fake-instance-with-name-that-is-too-long'
iso_path, file_name = cfg_dr_builder._create_cfg_dr_iso(mock_instance,

View File

@ -1,4 +1,4 @@
# Copyright 2015, 2017 IBM Corp.
# Copyright 2015, 2018 IBM Corp.
#
# All Rights Reserved.
#
@ -109,6 +109,9 @@ class ConfigDrivePowerVM(object):
extra_md=extra_md,
network_info=network_info)
# fix instance uuid to match uuid assigned to VM
inst_md.uuid = vm.get_pvm_uuid(instance).lower()
# Make sure the path exists.
im_path = CONF.powervm.image_meta_local_path
if not os.path.exists(im_path):