Skip to content

Commit

Permalink
Merge pull request avocado-framework-tests#2907 from FarooqAbdulla02/…
Browse files Browse the repository at this point in the history
…bonding_cleanup

Fix cleanup issues of bond interface
  • Loading branch information
abdhaleegit authored Oct 18, 2024
2 parents 1519656 + 1af3c81 commit 3c6069c
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions io/net/bonding.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def setUp(self):
for ipaddr, interface in zip(self.ipaddr, self.host_interfaces):
networkinterface = NetworkInterface(interface, self.localhost)
try:
networkinterface.flush_ipaddr()
networkinterface.nm_flush_ipaddr()
networkinterface.add_ipaddr(ipaddr, self.netmask)
networkinterface.save(ipaddr, self.netmask)
except Exception:
Expand All @@ -110,7 +110,7 @@ def setUp(self):
peer_networkinterface = NetworkInterface(interface,
self.remotehost)
try:
peer_networkinterface.flush_ipaddr()
peer_networkinterface.nm_flush_ipaddr()
peer_networkinterface.add_ipaddr(ipaddr, self.netmask)
peer_networkinterface.save(ipaddr, self.netmask)
except Exception:
Expand Down Expand Up @@ -391,9 +391,9 @@ def bond_setup(self, arg1, arg2):
if arg1 == "local":
self.log.info("Configuring Bonding on Local machine")
self.log.info("--------------------------------------")
for ifs in self.host_interfaces:
cmd = "ip addr flush dev %s" % ifs
process.system(cmd, shell=True, ignore_status=True)
for ipaddr, interface in zip(self.ipaddr, self.host_interfaces):
networkinterface = NetworkInterface(interface, self.localhost)
networkinterface.nm_flush_ipaddr()
for ifs in self.host_interfaces:
cmd = "ip link set %s down" % ifs
process.system(cmd, shell=True, ignore_status=True)
Expand Down Expand Up @@ -457,6 +457,12 @@ def bond_setup(self, arg1, arg2):
else:
self.log.info("Configuring Bonding on Peer machine")
self.log.info("------------------------------------------")
for ipaddr, interface in zip(self.peer_first_ipinterface,
self.peer_interfaces):
peer_networkinterface = NetworkInterface(interface,
self.remotehost)
peer_networkinterface.nm_flush_ipaddr()

cmd = ''
for val in self.peer_interfaces:
cmd += 'ip addr flush dev %s;' % val
Expand Down Expand Up @@ -520,23 +526,16 @@ def test_cleanup(self):
cmd = 'ip route add default via %s' % \
(self.gateway)
process.system(cmd, shell=True, ignore_status=True)

for ipaddr, host_interface in zip(self.ipaddr, self.host_interfaces):
networkinterface = NetworkInterface(host_interface, self.localhost)
try:
networkinterface.flush_ipaddr()
networkinterface.add_ipaddr(ipaddr, self.netmask)
networkinterface.nm_flush_ipaddr()
networkinterface.restore_from_backup()
networkinterface.bring_up()
except Exception:
self.fail("Interface is taking long time to link up")
if networkinterface.set_mtu("1500") is not None:
self.cancel("Failed to set mtu in host")
try:
networkinterface.restore_from_backup()
except Exception:
self.log.info(
"backup file not available, could not restore file.")

if self.peer_bond_needed:
self.bond_remove("peer")
for ipaddr, interface in zip(self.peer_first_ipinterface,
Expand All @@ -547,8 +546,8 @@ def test_cleanup(self):
peer_networkinterface = NetworkInterface(interface,
self.remotehost)
try:
peer_networkinterface.flush_ipaddr()
peer_networkinterface.add_ipaddr(ipaddr, self.netmask)
peer_networkinterface.nm_flush_ipaddr()
networkinterface.restore_from_backup()
peer_networkinterface.bring_up()
except Exception:
peer_networkinterface.save(ipaddr, self.netmask)
Expand Down

0 comments on commit 3c6069c

Please sign in to comment.