Skip to content

Commit

Permalink
fix: ordering for interfaces on verify_switchconf
Browse files Browse the repository at this point in the history
Change-Id: Ia31e1bf5380915eaa86a299b15cc5ea757806605
  • Loading branch information
grafuls committed Feb 20, 2020
1 parent ef48064 commit 8951fe1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion quads/tools/move_and_rebuild_hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand Down
4 changes: 2 additions & 2 deletions quads/tools/verify_switchconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 8951fe1

Please sign in to comment.