Skip to content

Commit

Permalink
Skip unnecessary SDK get_machine calls
Browse files Browse the repository at this point in the history
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
(cherry picked from commit 3017112)
  • Loading branch information
priteau committed Jul 10, 2023
1 parent e0930eb commit 64fd2a8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion bifrost/inventory.py
Expand Up @@ -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:
Expand All @@ -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
Expand Down

0 comments on commit 64fd2a8

Please sign in to comment.