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)