Add support for pxe_ilo driver

allow os-cloud-config to configure pxe_ilo driver, if chosen.

Change-Id: I91f8f31ba5250d2cd99b184ba4b4db82984103e9
This commit is contained in:
Tom Hancock 2014-12-04 12:58:42 +00:00
parent 287229bee8
commit 606a96448f
2 changed files with 36 additions and 0 deletions

View File

@ -77,6 +77,10 @@ def _extract_driver_info(node):
"ssh_username": node["pm_user"],
"ssh_key_contents": node["pm_password"],
"ssh_virt_type": node["pm_virt_type"]}
elif node["pm_type"] == "pxe_ilo":
driver_info = {"ilo_address": node["pm_addr"],
"ilo_username": node["pm_user"],
"ilo_password": node["pm_password"]}
elif node["pm_type"] == "pxe_iboot":
driver_info = {"iboot_address": node["pm_addr"],
"iboot_username": node["pm_user"],
@ -144,6 +148,9 @@ def _populate_node_mapping(ironic_in_use, client):
elif 'ipmi' in node_details.driver:
pm_addr = node_details.driver_info['ipmi_address']
node_map['pm_addr'][pm_addr] = node['uuid']
elif node_details.driver == 'pxe_ilo':
pm_addr = node_details.driver_info['ilo_address']
node_map['pm_addr'][pm_addr] = node['uuid']
else:
nodes = [bmn.to_dict() for bmn in client.baremetal.list()]
for node in nodes:
@ -193,6 +200,10 @@ def _update_or_register_ironic_node(service_host, node, node_map, client=None,
massage_map.update({'pm_addr': '/driver_info/ssh_address',
'pm_user': '/driver_info/ssh_username',
'pm_password': '/driver_info/ssh_key_contents'})
elif node['pm_type'] == 'pxe_ilo':
massage_map.update({'pm_addr': '/driver_info/ilo_address',
'pm_user': '/driver_info/ilo_username',
'pm_password': '/driver_info/ilo_password'})
if node_uuid:
ironic_node = client.node.get(node_uuid)
else:

View File

@ -186,6 +186,14 @@ class NodesTest(base.TestCase):
"iboot_port": "8080"}
self.assertEqual(expected, nodes._extract_driver_info(node))
def test_extract_driver_info_pxe_ilo(self):
node = self._get_node()
node["pm_type"] = "pxe_ilo"
expected = {"ilo_address": "foo.bar",
"ilo_username": "test",
"ilo_password": "random"}
self.assertEqual(expected, nodes._extract_driver_info(node))
def test_extract_driver_info_unknown_type(self):
node = self._get_node()
node["pm_type"] = "unknown_type"
@ -262,6 +270,23 @@ class NodesTest(base.TestCase):
ironic.node.update.assert_called_once_with(
ironic.node.get.return_value.uuid, mock.ANY)
def _update_by_type(self, pm_type):
ironic = mock.MagicMock()
node_map = {'mac': {}, 'pm_addr': {}}
node = self._get_node()
node['pm_type'] = pm_type
node_map['pm_addr']['foo.bar'] = ironic.node.get.return_value.uuid
nodes._update_or_register_ironic_node('servicehost', node,
node_map, client=ironic)
ironic.node.update.assert_called_once_with(
ironic.node.get.return_value.uuid, mock.ANY)
def test_update_node_ironic_pxe_ipmitool(self):
self._update_by_type('pxe_ipmitool')
def test_update_node_ironic_pxe_ilo(self):
self._update_by_type('pxe_ilo')
def test_register_ironic_node_update_uppercase_mac(self):
node = self._get_node()
node['mac'][0] = node['mac'][0].upper()