Handle nova instance having no image
There will be no image when the instance boots from volume. In the future there could be a fallback to fetch the metadata from the volume but for now just return None for boot mode and secure boot. Change-Id: I00576ee19571bd91683fd6c1754e0624e469b2c9
This commit is contained in:
parent
905a39b4eb
commit
382a548e31
@ -85,6 +85,8 @@ class OpenStackDriver(AbstractSystemsDriver):
|
||||
|
||||
@memoize.memoize(permanent_cache=PERMANENT_CACHE)
|
||||
def _get_image_info(self, identity):
|
||||
if not identity:
|
||||
return
|
||||
return self._cc.image.find_image(identity)
|
||||
|
||||
def _get_server_metadata(self, identity):
|
||||
|
@ -155,6 +155,16 @@ class NovaDriverTestCase(base.BaseTestCase):
|
||||
|
||||
self.assertEqual('Legacy', boot_mode)
|
||||
|
||||
def test_get_boot_mode_no_image(self):
|
||||
server = mock.Mock(id=self.uuid, image=dict(id=self.uuid))
|
||||
self.nova_mock.return_value.get_server.return_value = server
|
||||
|
||||
self.nova_mock.return_value.image.find_image.return_value = None
|
||||
|
||||
boot_mode = self.test_driver.get_boot_mode(self.uuid)
|
||||
|
||||
self.assertIsNone(boot_mode)
|
||||
|
||||
def test_set_boot_mode(self):
|
||||
self.assertRaises(
|
||||
error.FishyError, self.test_driver.set_boot_mode,
|
||||
|
Loading…
x
Reference in New Issue
Block a user