Add support for enrolling nodes with "ipmi" hardware type

This is a future replacement for pxe_ipmitool driver and is functionally
equivalent to it by default.

Part of blueprint ironic-driver-composition

Change-Id: I83f6eada13839cf204c0e522ae9e48930c8e6a69
This commit is contained in:
Dmitry Tantsur 2017-04-05 13:12:10 +02:00
parent a2a8b26f6c
commit 8aef178eb1
4 changed files with 50 additions and 9 deletions

View File

@ -0,0 +1,4 @@
---
features:
- |
Add support for enrolling nodes with ``ipmi`` hardware type.

View File

@ -275,7 +275,8 @@ class GenerateFencingParametersAction(base.TripleOAction):
"bm_name": hostmap[mac_addr]["baremetal_name"]}) "bm_name": hostmap[mac_addr]["baremetal_name"]})
if self.delay: if self.delay:
params["delay"] = self.delay params["delay"] = self.delay
elif node["pm_type"].split('_')[1] in ("ipmitool", "ilo", "drac"): elif (node['pm_type'] == 'ipmi' or node["pm_type"].split('_')[1] in
("ipmitool", "ilo", "drac")):
# IPMI fencing driver # IPMI fencing driver
node_data["agent"] = "fence_ipmilan" node_data["agent"] = "fence_ipmilan"
if self.fence_action: if self.fence_action:

View File

@ -167,6 +167,7 @@ class FindNodeHandlerTest(base.TestCase):
('fake_pxe', 'fake'), ('fake_pxe', 'fake'),
('pxe_ssh', 'ssh'), ('pxe_ssh', 'ssh'),
('pxe_ipmitool', 'ipmi'), ('pxe_ipmitool', 'ipmi'),
('ipmi', 'ipmi'),
('pxe_ilo', 'ilo'), ('pxe_ilo', 'ilo'),
('agent_irmc', 'irmc')] ('agent_irmc', 'irmc')]
for driver, prefix in test: for driver, prefix in test:
@ -390,6 +391,9 @@ class NodesTest(base.TestCase):
ironic.node.update.assert_called_once_with( ironic.node.update.assert_called_once_with(
ironic.node.get.return_value.uuid, mock.ANY) ironic.node.get.return_value.uuid, mock.ANY)
def test_update_node_ironic_ipmi(self):
self._update_by_type('ipmi')
def test_update_node_ironic_pxe_ipmitool(self): def test_update_node_ironic_pxe_ipmitool(self):
self._update_by_type('pxe_ipmitool') self._update_by_type('pxe_ipmitool')
@ -509,6 +513,22 @@ class NodesTest(base.TestCase):
driver_info={'ucs_password': 'random', 'ucs_address': 'foo.bar', driver_info={'ucs_password': 'random', 'ucs_address': 'foo.bar',
'ucs_username': 'test'}) 'ucs_username': 'test'})
def test_register_ironic_node_ipmi(self):
node_properties = {"cpus": "1",
"memory_mb": "2048",
"local_gb": "30",
"cpu_arch": "amd64",
"capabilities": "num_nics:6"}
node = self._get_node()
node['pm_type'] = 'ipmi'
node['pm_port'] = '6230'
client = mock.MagicMock()
nodes.register_ironic_node(node, client=client)
client.node.create.assert_called_once_with(
driver='ipmi', name='node1', properties=node_properties,
driver_info={'ipmi_password': 'random', 'ipmi_address': 'foo.bar',
'ipmi_username': 'test', 'ipmi_port': '6230'})
def test_register_ironic_node_pxe_ipmitool(self): def test_register_ironic_node_pxe_ipmitool(self):
node_properties = {"cpus": "1", node_properties = {"cpus": "1",
"memory_mb": "2048", "memory_mb": "2048",
@ -612,12 +632,12 @@ class TestPopulateNodeMapping(base.TestCase):
node1 = ironic_node('abcdef', 'pxe_ssh', None) node1 = ironic_node('abcdef', 'pxe_ssh', None)
node2 = ironic_node('fedcba', 'pxe_ipmitool', node2 = ironic_node('fedcba', 'pxe_ipmitool',
{'ipmi_address': '10.0.1.2'}) {'ipmi_address': '10.0.1.2'})
client.node.list_ports.side_effect = ([ironic_port('aaa')], node3 = ironic_node('xyz', 'ipmi', {'ipmi_address': '10.0.1.3'})
[]) client.node.list_ports.side_effect = ([ironic_port('aaa')], [], [])
client.node.list.return_value = [node1, node2] client.node.list.return_value = [node1, node2, node3]
expected = {'mac': {'aaa': 'abcdef'}, expected = {'mac': {'aaa': 'abcdef'},
'pm_addr': {'10.0.1.2': 'fedcba'}, 'pm_addr': {'10.0.1.2': 'fedcba', '10.0.1.3': 'xyz'},
'uuids': {'abcdef', 'fedcba'}} 'uuids': {'abcdef', 'fedcba', 'xyz'}}
self.assertEqual(expected, nodes._populate_node_mapping(client)) self.assertEqual(expected, nodes._populate_node_mapping(client))
def test_populate_node_mapping_ironic_fake_pxe(self): def test_populate_node_mapping_ironic_fake_pxe(self):
@ -645,6 +665,10 @@ VALID_NODE_JSON = [
'pm_addr': '192.168.0.1', 'pm_addr': '192.168.0.1',
'pm_user': 'root', 'pm_user': 'root',
'pm_password': 'p@$$w0rd'}, 'pm_password': 'p@$$w0rd'},
{'pm_type': 'ipmi',
'pm_addr': '192.168.1.1',
'pm_user': 'root',
'pm_password': 'p@$$w0rd'},
{'pm_type': 'pxe_ipmitool', {'pm_type': 'pxe_ipmitool',
'pm_addr': '192.168.0.1', 'pm_addr': '192.168.0.1',
'pm_user': 'root', 'pm_user': 'root',
@ -657,6 +681,18 @@ VALID_NODE_JSON = [
'capabilities': {'foo': 'bar'}, 'capabilities': {'foo': 'bar'},
'kernel_id': 'kernel1', 'kernel_id': 'kernel1',
'ramdisk_id': 'ramdisk1'}, 'ramdisk_id': 'ramdisk1'},
{'pm_type': 'ipmi',
'pm_addr': '192.168.1.1',
'pm_user': 'root',
'pm_password': 'p@$$w0rd',
'pm_port': 1234,
'ipmi_priv_level': 'USER',
'mac': ['dd:ee:ff:aa:bb:cc',
'44:55:66:11:22:33'],
'name': 'foobar2',
'capabilities': {'foo': 'bar'},
'kernel_id': 'kernel1',
'ramdisk_id': 'ramdisk1'},
{'pm_type': 'pxe_ssh', {'pm_type': 'pxe_ssh',
'pm_addr': '1.2.3.4', 'pm_addr': '1.2.3.4',
'pm_user': 'root', 'pm_user': 'root',
@ -696,7 +732,7 @@ class TestValidateNodes(base.TestCase):
'pm_addr': '1.1.1.1', 'pm_addr': '1.1.1.1',
'pm_user': 'root', 'pm_user': 'root',
'pm_password': 'p@$$w0rd'}, 'pm_password': 'p@$$w0rd'},
{'pm_type': 'pxe_ipmitool', {'pm_type': 'ipmi',
'pm_addr': '1.1.1.1', 'pm_addr': '1.1.1.1',
'pm_user': 'user', 'pm_user': 'user',
'pm_password': 'p@$$w0rd'}, 'pm_password': 'p@$$w0rd'},
@ -724,7 +760,7 @@ class TestValidateNodes(base.TestCase):
'pm_user': 'root', 'pm_user': 'root',
'pm_password': 'p@$$w0rd', 'pm_password': 'p@$$w0rd',
'mac': ['11:22:33:44:55:66']}, 'mac': ['11:22:33:44:55:66']},
{'pm_type': 'pxe_ipmitool', {'pm_type': 'ipmi',
'pm_addr': '1.2.1.1', 'pm_addr': '1.2.1.1',
'pm_user': 'user', 'pm_user': 'user',
'pm_password': 'p@$$w0rd', 'pm_password': 'p@$$w0rd',

View File

@ -189,7 +189,7 @@ class iBootDriverInfo(PrefixedDriverInfo):
DRIVER_INFO = { DRIVER_INFO = {
# production drivers # production drivers
'.*_ipmi(tool|native)': PrefixedDriverInfo('ipmi', has_port=True), '(ipmi|.*_ipmitool)': PrefixedDriverInfo('ipmi', has_port=True),
'.*_drac': PrefixedDriverInfo('drac', address_field='host', '.*_drac': PrefixedDriverInfo('drac', address_field='host',
has_port=True), has_port=True),
'.*_ilo': PrefixedDriverInfo('ilo'), '.*_ilo': PrefixedDriverInfo('ilo'),