From 64fd2a86c571ea02b0758a6cac9a0e203a754b54 Mon Sep 17 00:00:00 2001 From: Pierre Riteau Date: Thu, 11 May 2023 15:28:11 +0200 Subject: [PATCH] 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 (cherry picked from commit 3017112fe9d6fd010be4743e947a3a603edf4d7d) --- bifrost/inventory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bifrost/inventory.py b/bifrost/inventory.py index dc549eb5..4717b350 100755 --- a/bifrost/inventory.py +++ b/bifrost/inventory.py @@ -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