From 220a7cdc684043139de43ef5e8d4602ad4d9faf0 Mon Sep 17 00:00:00 2001 From: Eric Fried Date: Thu, 2 Feb 2017 15:22:34 -0600 Subject: [PATCH] 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 5d438733eb310b278d44aada7340a56ee9325063) --- nova_powervm/tests/virt/powervm/test_media.py | 6 ++++-- nova_powervm/virt/powervm/media.py | 5 ++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/nova_powervm/tests/virt/powervm/test_media.py b/nova_powervm/tests/virt/powervm/test_media.py index bc3f7b7e..54eb26b3 100644 --- a/nova_powervm/tests/virt/powervm/test_media.py +++ b/nova_powervm/tests/virt/powervm/test_media.py @@ -1,4 +1,4 @@ -# Copyright 2015, 2017 IBM Corp. +# Copyright 2015, 2018 IBM Corp. # # All Rights Reserved. # @@ -41,7 +41,8 @@ class TestConfigDrivePowerVM(test.NoDBTestCase): @mock.patch('nova.api.metadata.base.InstanceMetadata') @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.""" cfg_dr_builder = m.ConfigDrivePowerVM(self.apt) mock_instance = mock.MagicMock() @@ -54,6 +55,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, diff --git a/nova_powervm/virt/powervm/media.py b/nova_powervm/virt/powervm/media.py index 1b85a5cc..70ed77cd 100644 --- a/nova_powervm/virt/powervm/media.py +++ b/nova_powervm/virt/powervm/media.py @@ -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):