From 0fa763925da6b408ed0170ee682daa81465d7c9d Mon Sep 17 00:00:00 2001 From: Riff Date: Wed, 22 May 2024 17:41:11 -0700 Subject: [PATCH] Fix sonic-mgmt testbed-cli interface_to_vms undefined failure. (#12890) What is the motivation for this PR? This change is to fix the error above, when VM list is empty. How did you do it? The fix is straightforward - to give it a default value that is an empty list when enumerating. How did you verify/test it? The change is run locally with topology with empty VMs, and it works. --- ansible/config_sonic_basedon_testbed.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ansible/config_sonic_basedon_testbed.yml b/ansible/config_sonic_basedon_testbed.yml index 7d85e3bba25..63f3d6c4e86 100644 --- a/ansible/config_sonic_basedon_testbed.yml +++ b/ansible/config_sonic_basedon_testbed.yml @@ -262,7 +262,7 @@ set_fact: intf_names: "{{ intf_names | default({}) | combine({item.0.name: intf_names[item.0.name]|default([]) + [ port_alias[item.1]] }) }}" with_subelements: - - "{{ interface_to_vms }}" + - "{{ interface_to_vms | default([]) }}" - "ports" when: "'cable' not in topo" @@ -272,7 +272,7 @@ vm_asic_ifnames: "{{ vm_asic_ifnames | default({}) | combine({item.0.name: vm_asic_ifnames[item.0.name]|default([]) + [ front_panel_asic_ifnames[item.1]] }) }}" vm_asic_ids: "{{ vm_asic_ids | default({}) | combine({item.0.name: vm_asic_ids[item.0.name]|default([]) + [ front_panel_asic_ifs_asic_id[item.1]] }) }}" with_subelements: - - "{{ interface_to_vms }}" + - "{{ interface_to_vms | default([]) }}" - "ports" when: front_panel_asic_ifnames != []