eDeploy plugin to save BIOS and RAID configuration to node.extra

Change-Id: I359fe03ba5b13c2689ec097c9b824def929134c5
This commit is contained in:
Imre Farkas 2015-03-16 06:03:06 -04:00 committed by Dmitry Tantsur
parent d5541bfe8f
commit d374bb3621
2 changed files with 77 additions and 6 deletions

View File

@ -65,7 +65,16 @@ class eDeployHook(base.ProcessingHook):
sobj.load(conf.get('edeploy', 'configdir', '/etc/edeploy'))
prof, var = sobj.find_match(hw_items)
var['profile'] = prof
if 'logical_disks' in var:
node_info['target_raid_configuration'] = {
'logical_disks': var.pop('logical_disks')}
if 'bios_settings' in var:
node_info['bios_settings'] = var.pop('bios_settings')
node_info['hardware'] = var
except Exception as excpt:
LOG.warning(_LW(
'Unable to find a matching hardware profile: %s'), excpt)
@ -100,16 +109,31 @@ class eDeployHook(base.ProcessingHook):
def before_update(self, node, ports, node_info):
"""Store the hardware data from what has been discovered."""
patches = []
if 'hardware' in node_info:
capabilities_dict = utils.capabilities_to_dict(
node.properties.get('capabilities'))
capabilities_dict['profile'] = node_info['hardware']['profile']
return [
{'op': 'add',
'path': '/extra/configdrive_metadata',
'value': {'hardware': node_info['hardware']}},
patches.append({'op': 'add',
'path': '/extra/configdrive_metadata',
'value': {'hardware': node_info['hardware']}})
patches.append(
{'op': 'add',
'path': '/properties/capabilities',
'value': utils.dict_to_capabilities(capabilities_dict)}
], {}
'value': utils.dict_to_capabilities(capabilities_dict)})
if 'target_raid_configuration' in node_info:
patches.append(
{'op': 'add',
'path': '/extra/target_raid_configuration',
'value': node_info['target_raid_configuration']})
if 'bios_settings' in node_info:
patches.append(
{'op': 'add',
'path': '/extra/bios_settings',
'value': node_info['bios_settings']})
return patches, {}

View File

@ -13,6 +13,7 @@
import os
from hardware import cmdb
from hardware import state
import mock
@ -84,3 +85,49 @@ class TestEdeploy(test_base.NodeTest):
node_info = {'data': []}
hook.before_processing(node_info)
self.assertTrue(mock_log.warning.called)
@mock.patch.object(cmdb, 'load_cmdb')
def test_raid_configuration_passed(self, mock_load_cmdb):
hook = edeploy.eDeployHook()
mock_load_cmdb.return_value = [
{'logical_disks': (
{'disk_type': 'hdd',
'interface_type': 'sas',
'is_root_volume': 'true',
'raid_level': '1+0',
'size_gb': 50,
'volume_name': 'root_volume'},
{'disk_type': 'hdd',
'interface_type': 'sas',
'number_of_physical_disks': 3,
'raid_level': '5',
'size_gb': 100,
'volume_name': 'data_volume'})}]
node_info = {'data': [
['network', 'eth0', 'serial', '99:99:99:99:99:99'],
['network', 'eth0', 'ipv4', '192.168.100.12'],
]}
hook.before_processing(node_info)
self.assertIn('target_raid_configuration', node_info)
node_patches, _ = hook.before_update(self.node, None, node_info)
self.assertEqual('/extra/target_raid_configuration',
node_patches[2]['path'])
@mock.patch.object(cmdb, 'load_cmdb')
def test_bios_configuration_passed(self, mock_load_cmdb):
hook = edeploy.eDeployHook()
mock_load_cmdb.return_value = [
{'bios_settings': {'ProcVirtualization': 'Disabled'}}]
node_info = {'data': [
['network', 'eth0', 'serial', '99:99:99:99:99:99'],
['network', 'eth0', 'ipv4', '192.168.100.12'],
]}
hook.before_processing(node_info)
self.assertIn('bios_settings', node_info)
node_patches, _ = hook.before_update(self.node, None, node_info)
self.assertEqual('/extra/bios_settings',
node_patches[2]['path'])