register-nodes: add iboot support for node updates

Updates register-nodes so that it supports node updates when
using the iboot driver. When updating instances for most drivers
we base search for the existing Ironic UUID by the pm_addr
(which is usually an IPMI address or something). For iboot
PDU's the same IP can be shared for multiple compute nodes
so we use a combination of the pm address, relay ID, and port
to uniquely identify each node for the update.

Also, temporarily ignoring C901 (complexity) with this
commit until we can refactor things to remove some
of the deprecated nova baremetal code.

Change-Id: I8e058e0822f5306c2704d737ebdde23271fc08be
This commit is contained in:
Dan Prince 2015-06-22 10:08:16 -04:00
parent 09c3ec1069
commit 9c8a5a035a
2 changed files with 18 additions and 1 deletions

View File

@ -173,6 +173,15 @@ def _populate_node_mapping(ironic_in_use, client):
elif node_details.driver == 'pxe_drac':
pm_addr = node_details.driver_info['drac_host']
node_map['pm_addr'][pm_addr] = node['uuid']
elif node_details.driver == 'pxe_iboot':
iboot_addr = node_details.driver_info['iboot_address']
if "iboot_port" in node_details.driver_info:
iboot_addr += (':%s' %
node_details.driver_info['iboot_port'])
if "iboot_relay_id" in node_details.driver_info:
iboot_addr += ('#%s' %
node_details.driver_info['iboot_relay_id'])
node_map['pm_addr'][iboot_addr] = node['uuid']
else:
nodes = [bmn.to_dict() for bmn in client.baremetal.list()]
for node in nodes:
@ -187,6 +196,14 @@ def _get_node_id(node, node_map):
for mac in node['mac']:
if mac.lower() in node_map['mac']:
return node_map['mac'][mac.lower()]
elif node['pm_type'] == 'pxe_iboot':
iboot_addr = node["pm_addr"]
if "pm_port" in node:
iboot_addr += ':%s' % node["pm_port"]
if "pm_relay_id" in node:
iboot_addr += '#%s' % node["pm_relay_id"]
if iboot_addr in node_map['pm_addr']:
return node_map['pm_addr'][iboot_addr]
else:
if node['pm_addr'] in node_map['pm_addr']:
return node_map['pm_addr'][node['pm_addr']]

View File

@ -30,7 +30,7 @@ commands = python setup.py test --coverage --coverage-package-name='os_cloud_con
# E123, E125 skipped as they are invalid PEP-8.
show-source = True
ignore = E123,E125,H302,H803
ignore = E123,E125,H302,H803,C901
builtins = _
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build
max-complexity=14