Sanitize the config drive UUID

When cloud-init processes an instance to determine
if it is first boot or not, it compares the config
drive UUID with the VM UUID.  This change makes those
values the same now for a given VM / config drive pair.

Closes-Bug: #1770696
Change-Id: I128a0bc886b020d67241c67a874cf8d06e791b57
(cherry picked from commit 5d438733eb)
This commit is contained in:
Eric Fried 2017-02-02 15:22:34 -06:00 committed by Matthew Edmonds
parent eb252a14ac
commit 220a7cdc68
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. # All Rights Reserved.
# #
@ -41,7 +41,8 @@ class TestConfigDrivePowerVM(test.NoDBTestCase):
@mock.patch('nova.api.metadata.base.InstanceMetadata') @mock.patch('nova.api.metadata.base.InstanceMetadata')
@mock.patch('nova.virt.configdrive.ConfigDriveBuilder.make_drive') @mock.patch('nova.virt.configdrive.ConfigDriveBuilder.make_drive')
def test_crt_cfg_dr_iso(self, mock_mkdrv, mock_meta): @mock.patch('nova_powervm.virt.powervm.vm.get_pvm_uuid')
def test_crt_cfg_dr_iso(self, mock_pvm_uuid, mock_mkdrv, mock_meta):
"""Validates that the image creation method works.""" """Validates that the image creation method works."""
cfg_dr_builder = m.ConfigDrivePowerVM(self.apt) cfg_dr_builder = m.ConfigDrivePowerVM(self.apt)
mock_instance = mock.MagicMock() mock_instance = mock.MagicMock()
@ -54,6 +55,7 @@ class TestConfigDrivePowerVM(test.NoDBTestCase):
mock_net) mock_net)
self.assertEqual('cfg_fake_instance.iso', file_name) self.assertEqual('cfg_fake_instance.iso', file_name)
self.assertEqual('/tmp/cfgdrv/cfg_fake_instance.iso', iso_path) self.assertEqual('/tmp/cfgdrv/cfg_fake_instance.iso', iso_path)
self.assertTrue(mock_pvm_uuid.called)
# Make sure the length is limited properly # Make sure the length is limited properly
mock_instance.name = 'fake-instance-with-name-that-is-too-long' mock_instance.name = 'fake-instance-with-name-that-is-too-long'
iso_path, file_name = cfg_dr_builder._create_cfg_dr_iso(mock_instance, 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. # All Rights Reserved.
# #
@ -109,6 +109,9 @@ class ConfigDrivePowerVM(object):
extra_md=extra_md, extra_md=extra_md,
network_info=network_info) 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. # Make sure the path exists.
im_path = CONF.powervm.image_meta_local_path im_path = CONF.powervm.image_meta_local_path
if not os.path.exists(im_path): if not os.path.exists(im_path):