From 8951fe1028a433800250ff1954d347a067c15cde Mon Sep 17 00:00:00 2001 From: Gonzalo Rafuls Date: Thu, 20 Feb 2020 10:27:29 -0500 Subject: [PATCH] fix: ordering for interfaces on verify_switchconf Change-Id: Ia31e1bf5380915eaa86a299b15cc5ea757806605 --- quads/tools/move_and_rebuild_hosts.py | 3 ++- quads/tools/verify_switchconf.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/quads/tools/move_and_rebuild_hosts.py b/quads/tools/move_and_rebuild_hosts.py index 8491a3c11..e1a9b7b94 100755 --- a/quads/tools/move_and_rebuild_hosts.py +++ b/quads/tools/move_and_rebuild_hosts.py @@ -28,7 +28,8 @@ def switch_config(host, old_cloud, new_cloud): logger.debug("Connecting to switch on: %s" % _host_obj.interfaces[0].ip_address) switch_ip = None ssh_helper = None - for i, interface in enumerate(_host_obj.interfaces): + interfaces = sorted(_host_obj.interfaces, key=lambda k: k['name']) + for i, interface in enumerate(interfaces): if not switch_ip: switch_ip = interface.ip_address ssh_helper = SSHHelper(switch_ip, conf["junos_username"]) diff --git a/quads/tools/verify_switchconf.py b/quads/tools/verify_switchconf.py index 514842ddf..0fb247435 100755 --- a/quads/tools/verify_switchconf.py +++ b/quads/tools/verify_switchconf.py @@ -28,8 +28,8 @@ def verify(_cloud_name, change=False): for _host in hosts: _host_obj = Host.objects(name=_host["name"]).first() if _host_obj.interfaces: - - for i, interface in enumerate(_host_obj.interfaces): + interfaces = sorted(_host_obj.interfaces, key=lambda k: k['name']) + for i, interface in enumerate(interfaces): ssh_helper = SSHHelper(interface.ip_address, conf["junos_username"]) last_nic = i == len(_host_obj.interfaces) - 1 vlan = get_vlan(_cloud_obj, i, last_nic)