From aeff750bf9800191f5409050fc8a440335cd8307 Mon Sep 17 00:00:00 2001 From: Julia Kreger Date: Wed, 22 Jul 2015 09:00:43 -0400 Subject: [PATCH] Add nics information to ironic inventory Addition of information in the form required by the playbooks and modules to potentially permit bulk actions involving network MAC addresses, which ideally would involve configuraiton drives or potentially deleting nodes in a particular state, if the user were to so choose to write a playbook to do so. Change-Id: Icb12d985998a81ee4956db7b076aa1911909da0a --- playbooks/inventory/bifrost_inventory.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/playbooks/inventory/bifrost_inventory.py b/playbooks/inventory/bifrost_inventory.py index 7a1c50a68..51bd69733 100755 --- a/playbooks/inventory/bifrost_inventory.py +++ b/playbooks/inventory/bifrost_inventory.py @@ -314,15 +314,25 @@ def _process_shade(groups, hostvars): else: name = machine['name'] new_machine = {} - # TODO(TheJulia): At some point we need to retrieve the list of - # mac addresses from the ports and provide that information in the - # inventory output. for key, value in six.iteritems(machine): # NOTE(TheJulia): We don't want to pass infomrational links # nor do we want to pass links about the ports since they # are API endpoint URLs. if key not in ['links', 'ports']: new_machine[key] = value + + # NOTE(TheJulia): Collect network information, enumerate through + # and extract important values, presently MAC address. Once done, + # return the network information to the inventory. + nics = cloud.list_nics_for_machine(machine['uuid']) + new_nics = [] + new_nic = {} + for nic in nics: + if 'address' in nic: + new_nic['mac'] = nic['address'] + new_nics.append(new_nic) + new_machine['nics'] = new_nics + new_machine['addressing_mode'] = "dhcp" groups['baremetal']['hosts'].append(name) hostvars.update({name: new_machine})