diff options
| author | Devananda van der Veen <devananda.vdv@gmail.com> | 2013-01-17 09:09:32 -0800 |
|---|---|---|
| committer | Devananda van der Veen <devananda.vdv@gmail.com> | 2013-01-17 09:37:30 -0800 |
| commit | 2af896ceccc6fa947bbdb8b06442439db1c6dc1f (patch) | |
| tree | 7ca805296756f8f34e7dce6e231a47414b21dc74 | |
| parent | 52fe25a5281a50a5e4c1ff093ce9ed966241a3d7 (diff) | |
| download | nova-2af896ceccc6fa947bbdb8b06442439db1c6dc1f.tar.gz nova-2af896ceccc6fa947bbdb8b06442439db1c6dc1f.tar.xz nova-2af896ceccc6fa947bbdb8b06442439db1c6dc1f.zip | |
PXE driver should not accept empty kernel UUID.
Baremetal PXE driver was aborting only if the kernel and ramdisk
specified in image metadata were None, but not if they were another
non-true value, such as "". Now, exception is raised if they are any
non-true value.
Fix bug 1100589.
Change-Id: I9783a14cc242e1b9db04d797c61d54b06d52c680
| -rw-r--r-- | nova/tests/baremetal/test_pxe.py | 18 | ||||
| -rw-r--r-- | nova/virt/baremetal/pxe.py | 2 |
2 files changed, 19 insertions, 1 deletions
diff --git a/nova/tests/baremetal/test_pxe.py b/nova/tests/baremetal/test_pxe.py index 45c9ede43..02d1a26e6 100644 --- a/nova/tests/baremetal/test_pxe.py +++ b/nova/tests/baremetal/test_pxe.py @@ -254,6 +254,13 @@ class PXEClassMethodsTestCase(BareMetalPXETestCase): pxe.get_tftp_image_info, self.instance) + # Test that other non-true values also raise an exception + CONF.baremetal.deploy_kernel = "" + CONF.baremetal.deploy_ramdisk = "" + self.assertRaises(exception.NovaException, + pxe.get_tftp_image_info, + self.instance) + # Even if the instance includes kernel_id and ramdisk_id, # we still need deploy_kernel_id and deploy_ramdisk_id. # If those aren't present in instance[], and not specified in @@ -295,6 +302,17 @@ class PXEClassMethodsTestCase(BareMetalPXETestCase): self.assertEqual(res['deploy_kernel'][0], 'eeee') self.assertEqual(res['deploy_ramdisk'][0], 'ffff') + # However, if invalid values are passed on the image extra_specs, + # this should still raise an exception. + extra_specs = { + 'deploy_kernel_id': '', + 'deploy_ramdisk_id': '', + } + self.instance['extra_specs'] = extra_specs + self.assertRaises(exception.NovaException, + pxe.get_tftp_image_info, + self.instance) + class PXEPrivateMethodsTestCase(BareMetalPXETestCase): diff --git a/nova/virt/baremetal/pxe.py b/nova/virt/baremetal/pxe.py index b94ac9032..cc3790a8f 100644 --- a/nova/virt/baremetal/pxe.py +++ b/nova/virt/baremetal/pxe.py @@ -219,7 +219,7 @@ def get_tftp_image_info(instance): missing_labels = [] for label in image_info.keys(): (uuid, path) = image_info[label] - if uuid is None: + if not uuid: missing_labels.append(label) else: image_info[label][1] = os.path.join(CONF.baremetal.tftp_root, |
