Do not fail if ipmi_address is not present in discovery data

ipmi_address never was a required field actually.

Change-Id: I85fabfd513a8464f31a03e920b69486a845980d8
This commit is contained in:
Dmitry Tantsur
2014-12-05 15:13:28 +01:00
parent d3df6178ca
commit d2a35f4d66
2 changed files with 13 additions and 5 deletions

View File

@@ -38,6 +38,8 @@ def process(node_info):
node_info['error'])
raise utils.DiscoveryFailed(node_info['error'])
bmc_address = node_info.get('ipmi_address')
compat = conf.getboolean('discoverd', 'ports_for_inactive_interfaces')
if 'interfaces' not in node_info and 'macs' in node_info:
LOG.warning('Using "macs" field is deprecated, please '
@@ -59,11 +61,10 @@ def process(node_info):
{'invalid': {n: iface
for n, iface in node_info['interfaces'].items()
if n not in valid_interfaces},
'ipmi_address': node_info.get('ipmi_address')})
'ipmi_address': bmc_address})
LOG.info('Eligible interfaces are %s', valid_interfaces)
uuid = node_cache.pop_node(bmc_address=node_info['ipmi_address'],
mac=valid_macs)
uuid = node_cache.pop_node(bmc_address=bmc_address, mac=valid_macs)
ironic = utils.get_client()
try:
node = ironic.node.get(uuid)

View File

@@ -80,6 +80,7 @@ class TestProcess(BaseTest):
}
self.macs = ['11:22:33:44:55:66', 'broken', '', '66:55:44:33:22:11']
self.port = Mock(uuid='port_uuid')
self.attributes = dict(bmc_address='1.2.3.4', mac=ANY)
def _do_test(self, client_mock, pop_mock, filters_mock, pre_mock,
post_mock):
@@ -102,8 +103,7 @@ class TestProcess(BaseTest):
discoverd.process(self.data)
pop_mock.assert_called_once_with(bmc_address='1.2.3.4',
mac=ANY)
pop_mock.assert_called_once_with(**self.attributes)
cli.node.get.assert_called_once_with(self.node.uuid)
self.assertEqual(['11:22:33:44:55:66', '66:55:44:33:22:11'],
sorted(pop_mock.call_args[1]['mac']))
@@ -129,6 +129,13 @@ class TestProcess(BaseTest):
self._do_test(client_mock, pop_mock, filters_mock, pre_mock, post_mock)
self.assertFalse(client_mock.return_value.node.set_power_state.called)
def test_no_ipmi(self, client_mock, pop_mock, filters_mock, pre_mock,
post_mock):
del self.data['ipmi_address']
self.attributes = dict(bmc_address=None, mac=ANY)
self._do_test(client_mock, pop_mock, filters_mock, pre_mock, post_mock)
self.assertFalse(client_mock.return_value.node.set_power_state.called)
def test_force_off(self, client_mock, pop_mock, filters_mock, pre_mock,
post_mock):
conf.CONF.set('discoverd', 'power_off_after_discovery', 'true')