Skip unnecessary SDK get_machine calls

The _process_sdk function starts by calling cloud.list_machines() which
returns all nodes including their names. There is no need to call
cloud.get_machine individually for each node just to get its name
attribute when we might be skipping this node.

This speeds up execution of the Bifrost inventory module when
BIFROST_NODE_NAMES is used.

Change-Id: I27ccc12b9f408d510710d5ba82ad04135169827a
This commit is contained in:
Pierre Riteau 2023-05-11 15:28:11 +02:00
parent ec182e7293
commit 7979498316

View File

@ -232,7 +232,6 @@ def _process_sdk(groups, hostvars):
node_names = node_names.split(',')
for machine in machines:
machine = cloud.get_machine(machine['uuid'])
if machine['name'] is None:
name = machine['uuid']
else:
@ -241,6 +240,7 @@ def _process_sdk(groups, hostvars):
if node_names and name not in node_names:
continue
machine = cloud.get_machine(machine['uuid'])
new_machine = {}
for key, value in machine.items():
# NOTE(TheJulia): We don't want to pass infomrational links