Merge "Fix iLO drivers to not clear local_gb if its not detected"

This commit is contained in:
Jenkins 2016-10-05 00:58:03 +00:00 committed by Gerrit Code Review
commit 3a2c065876
3 changed files with 63 additions and 0 deletions

View File

@ -217,7 +217,22 @@ class IloInspect(base.InspectInterface):
inspected_properties = {}
result = _get_essential_properties(task.node, ilo_object)
# A temporary hook for OOB inspection to not to update 'local_gb'
# for hardware if the storage is a "Direct Attached Storage" or
# "Dynamic Smart Array Controllers" and the operator has manually
# updated the local_gb in node properties prior to node inspection.
# This will be removed once we have inband inspection support for
# ilo drivers.
current_local_gb = task.node.properties.get('local_gb')
properties = result['properties']
if current_local_gb:
if properties['local_gb'] == 0 and current_local_gb > 0:
properties['local_gb'] = current_local_gb
LOG.warning(_LW('Could not discover size of disk on the node '
'%s. Value of `properties/local_gb` of the '
'node is not overwritten.'), task.node.uuid)
for known_property in self.ESSENTIAL_PROPERTIES:
inspected_properties[known_property] = properties[known_property]
node_properties = task.node.properties

View File

@ -94,6 +94,49 @@ class IloInspectTestCase(db_base.DbTestCase):
ilo_object_mock)
create_port_mock.assert_called_once_with(task, macs)
@mock.patch.object(ilo_inspect.LOG, 'warning',
spec_set=True, autospec=True)
@mock.patch.object(ilo_inspect, '_get_capabilities', spec_set=True,
autospec=True)
@mock.patch.object(ilo_inspect, '_create_ports_if_not_exist',
spec_set=True, autospec=True)
@mock.patch.object(ilo_inspect, '_get_essential_properties', spec_set=True,
autospec=True)
@mock.patch.object(ilo_power.IloPower, 'get_power_state', spec_set=True,
autospec=True)
@mock.patch.object(ilo_common, 'get_ilo_object', spec_set=True,
autospec=True)
def test_inspect_essential_ok_local_gb_zero(self, get_ilo_object_mock,
power_mock,
get_essential_mock,
create_port_mock,
get_capabilities_mock,
log_mock):
ilo_object_mock = get_ilo_object_mock.return_value
properties = {'memory_mb': '512', 'local_gb': 0,
'cpus': '1', 'cpu_arch': 'x86_64'}
macs = {'Port 1': 'aa:aa:aa:aa:aa:aa', 'Port 2': 'bb:bb:bb:bb:bb:bb'}
capabilities = ''
result = {'properties': properties, 'macs': macs}
get_essential_mock.return_value = result
get_capabilities_mock.return_value = capabilities
power_mock.return_value = states.POWER_ON
with task_manager.acquire(self.context, self.node.uuid,
shared=False) as task:
task.node.properties['local_gb'] = 10
task.node.save()
expected_properties = {'memory_mb': '512', 'local_gb': 10,
'cpus': '1', 'cpu_arch': 'x86_64'}
task.driver.inspect.inspect_hardware(task)
self.assertEqual(expected_properties, task.node.properties)
power_mock.assert_called_once_with(mock.ANY, task)
get_essential_mock.assert_called_once_with(task.node,
ilo_object_mock)
self.assertTrue(log_mock.called)
get_capabilities_mock.assert_called_once_with(task.node,
ilo_object_mock)
create_port_mock.assert_called_once_with(task, macs)
@mock.patch.object(ilo_inspect, '_get_capabilities', spec_set=True,
autospec=True)
@mock.patch.object(ilo_inspect, '_create_ports_if_not_exist',

View File

@ -0,0 +1,5 @@
---
fixes:
- Fixes a bug in the iLO drivers' inspection where
an existing ``local_gb`` node property was
overwritten with "0" if not detected.