Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cleanup issues of bond interface #2907

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading