Skip to content

Commit

Permalink
Do neighbor VM restore only if there's VM's (#4015)
Browse files Browse the repository at this point in the history
Execute the logic of neighbor_vm_restore only in cases where vm_neighbors is not an empty list.

Summary:
Function neighbor_vm_restore is run during sanity in cases of failure in the setup.
However in setups that do not include VM's this function is causing errors in the test.
It is more correct to run the recover logic only if the vm_neighbors list is not empty.
that way we could avoided such errors and the function is more correct.

- How did you do it?
Add an if statement to function

- How did you verify/test it?
I run the tests with sanity afterward and verified they passed

- Any platform specific information?
It's relevant to all platforms
  • Loading branch information
slutati1536 authored Aug 15, 2021
1 parent 88edc51 commit 909c7b3
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions tests/common/plugins/sanity_check/recover.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,17 @@ def neighbor_vm_restore(duthost, nbrhosts, tbinfo):
logger.info("Restoring neighbor VMs for {}".format(duthost))
mg_facts = duthost.get_extended_minigraph_facts(tbinfo)
vm_neighbors = mg_facts['minigraph_neighbors']
lag_facts = duthost.lag_facts(host = duthost.hostname)['ansible_facts']['lag_facts']

for lag_name in lag_facts['names']:
nbr_intf = lag_facts['lags'][lag_name]['po_config']['ports'].keys()[0]
peer_device = vm_neighbors[nbr_intf]['name']
nbr_host = nbrhosts[peer_device]['host']
intf_list = nbrhosts[peer_device]['conf']['interfaces'].keys()
# restore interfaces and portchannels
for intf in intf_list:
nbr_host.no_shutdown(intf)
asn = nbrhosts[peer_device]['conf']['bgp']['asn']
# restore BGP session
nbr_host.no_shutdown_bgp(asn)
if vm_neighbors:
lag_facts = duthost.lag_facts(host = duthost.hostname)['ansible_facts']['lag_facts']

for lag_name in lag_facts['names']:
nbr_intf = lag_facts['lags'][lag_name]['po_config']['ports'].keys()[0]
peer_device = vm_neighbors[nbr_intf]['name']
nbr_host = nbrhosts[peer_device]['host']
intf_list = nbrhosts[peer_device]['conf']['interfaces'].keys()
# restore interfaces and portchannels
for intf in intf_list:
nbr_host.no_shutdown(intf)
asn = nbrhosts[peer_device]['conf']['bgp']['asn']
# restore BGP session
nbr_host.no_shutdown_bgp(asn)

0 comments on commit 909c7b3

Please sign in to comment.