Make root_device_hint plugin not to fail if no block device was received

Change-Id: I4fdb6049527e17f9840caa7fc86e8f7c00337765
This commit is contained in:
Imre Farkas 2015-02-12 15:15:11 +01:00
parent e724de4dc6
commit e953f2cda2
2 changed files with 14 additions and 3 deletions

View File

@ -39,8 +39,12 @@ class RootDeviceHintHook(base.ProcessingHook):
"""
def before_update(self, node, ports, node_info):
if 'block_devices' not in node_info:
LOG.warning('No block device was received from ramdisk')
return [], {}
if 'root_device' in node.properties:
LOG.info('Root device is already known for the node.')
LOG.info('Root device is already known for the node')
return [], {}
if 'block_devices' in node.extra:
@ -52,10 +56,10 @@ class RootDeviceHintHook(base.ProcessingHook):
if len(new_devices) > 1:
LOG.warning('Root device cannot be identified because '
'multiple new devices were found.')
'multiple new devices were found')
return [], {}
elif len(new_devices) == 0:
LOG.warning('No new devices were found.')
LOG.warning('No new devices were found')
return [], {}
return [

View File

@ -72,3 +72,10 @@ class TestRootDeviceHint(test_base.NodeTest):
node_patches, _ = self.hook.before_update(self.node, None, node_info)
self.assertEqual(0, len(node_patches))
def test_no_block_devices_from_ramdisk(self):
node_info = {}
self.hook.before_processing(node_info)
node_patches, _ = self.hook.before_update(self.node, None, node_info)
self.assertEqual(0, len(node_patches))