Fake missing local_gb for root_device_hint plugin
At the first run of discovery, the RAID volumes might be missing from the node. To avoid the standard plugin erroring, root_device_hint plugin fakes the missing local_gb value. The fake value will be overwritten with the correct one during later runs. Change-Id: I2d38557fa356656e44e9915d3c4a5abb9cf1731d
This commit is contained in:
parent
d6404d2f99
commit
730b0bf34f
@ -37,8 +37,20 @@ class RootDeviceHintHook(base.ProcessingHook):
|
||||
information about the created RAID disks. Using this plugin immediately
|
||||
before and after creating the root RAID device will solve the issue of root
|
||||
device hints.
|
||||
|
||||
In cases where there's no RAID volume on the node, the standard plugin will
|
||||
fail due to the missing local_gb value. This plugin fakes the missing
|
||||
value, until it's corrected during later runs. Note, that for this to work
|
||||
the plugin needs to take precedence over the standard plugin.
|
||||
"""
|
||||
|
||||
def before_processing(self, node_info):
|
||||
"""Adds fake local_gb value if it's missing from node_info."""
|
||||
if not node_info.get('local_gb'):
|
||||
LOG.info(_LI('No volume is found on the node. Adding a fake '
|
||||
'value for "local_gb"'))
|
||||
node_info['local_gb'] = 1
|
||||
|
||||
def before_update(self, node, ports, node_info):
|
||||
if 'block_devices' not in node_info:
|
||||
LOG.warning(_LW('No block device was received from ramdisk'))
|
||||
|
@ -21,6 +21,18 @@ class TestRootDeviceHint(test_base.NodeTest):
|
||||
super(TestRootDeviceHint, self).setUp()
|
||||
self.hook = root_device_hint.RootDeviceHintHook()
|
||||
|
||||
def test_missing_local_gb(self):
|
||||
node_info = {}
|
||||
self.hook.before_processing(node_info)
|
||||
|
||||
self.assertEqual(1, node_info['local_gb'])
|
||||
|
||||
def test_local_gb_not_changes(self):
|
||||
node_info = {'local_gb': 42}
|
||||
self.hook.before_processing(node_info)
|
||||
|
||||
self.assertEqual(42, node_info['local_gb'])
|
||||
|
||||
def test_no_previous_block_devices(self):
|
||||
node_info = {'block_devices': {'serials': ['foo', 'bar']}}
|
||||
node_patches, _ = self.hook.before_update(self.node, None, node_info)
|
||||
|
Loading…
Reference in New Issue
Block a user