@@ -95,7 +95,7 @@ def setUp(self):
9595 for ipaddr , interface in zip (self .ipaddr , self .host_interfaces ):
9696 networkinterface = NetworkInterface (interface , self .localhost )
9797 try :
98- networkinterface .flush_ipaddr ()
98+ networkinterface .nm_flush_ipaddr ()
9999 networkinterface .add_ipaddr (ipaddr , self .netmask )
100100 networkinterface .save (ipaddr , self .netmask )
101101 except Exception :
@@ -110,7 +110,7 @@ def setUp(self):
110110 peer_networkinterface = NetworkInterface (interface ,
111111 self .remotehost )
112112 try :
113- peer_networkinterface .flush_ipaddr ()
113+ peer_networkinterface .nm_flush_ipaddr ()
114114 peer_networkinterface .add_ipaddr (ipaddr , self .netmask )
115115 peer_networkinterface .save (ipaddr , self .netmask )
116116 except Exception :
@@ -391,9 +391,9 @@ def bond_setup(self, arg1, arg2):
391391 if arg1 == "local" :
392392 self .log .info ("Configuring Bonding on Local machine" )
393393 self .log .info ("--------------------------------------" )
394- for ifs in self .host_interfaces :
395- cmd = "ip addr flush dev %s" % ifs
396- process . system ( cmd , shell = True , ignore_status = True )
394+ for ipaddr , interface in zip ( self .ipaddr , self . host_interfaces ) :
395+ networkinterface = NetworkInterface ( interface , self . localhost )
396+ networkinterface . nm_flush_ipaddr ( )
397397 for ifs in self .host_interfaces :
398398 cmd = "ip link set %s down" % ifs
399399 process .system (cmd , shell = True , ignore_status = True )
@@ -457,6 +457,12 @@ def bond_setup(self, arg1, arg2):
457457 else :
458458 self .log .info ("Configuring Bonding on Peer machine" )
459459 self .log .info ("------------------------------------------" )
460+ for ipaddr , interface in zip (self .peer_first_ipinterface ,
461+ self .peer_interfaces ):
462+ peer_networkinterface = NetworkInterface (interface ,
463+ self .remotehost )
464+ peer_networkinterface .nm_flush_ipaddr ()
465+
460466 cmd = ''
461467 for val in self .peer_interfaces :
462468 cmd += 'ip addr flush dev %s;' % val
@@ -520,23 +526,16 @@ def test_cleanup(self):
520526 cmd = 'ip route add default via %s' % \
521527 (self .gateway )
522528 process .system (cmd , shell = True , ignore_status = True )
523-
524529 for ipaddr , host_interface in zip (self .ipaddr , self .host_interfaces ):
525530 networkinterface = NetworkInterface (host_interface , self .localhost )
526531 try :
527- networkinterface .flush_ipaddr ()
528- networkinterface .add_ipaddr ( ipaddr , self . netmask )
532+ networkinterface .nm_flush_ipaddr ()
533+ networkinterface .restore_from_backup ( )
529534 networkinterface .bring_up ()
530535 except Exception :
531536 self .fail ("Interface is taking long time to link up" )
532537 if networkinterface .set_mtu ("1500" ) is not None :
533538 self .cancel ("Failed to set mtu in host" )
534- try :
535- networkinterface .restore_from_backup ()
536- except Exception :
537- self .log .info (
538- "backup file not available, could not restore file." )
539-
540539 if self .peer_bond_needed :
541540 self .bond_remove ("peer" )
542541 for ipaddr , interface in zip (self .peer_first_ipinterface ,
@@ -547,8 +546,8 @@ def test_cleanup(self):
547546 peer_networkinterface = NetworkInterface (interface ,
548547 self .remotehost )
549548 try :
550- peer_networkinterface .flush_ipaddr ()
551- peer_networkinterface . add_ipaddr ( ipaddr , self . netmask )
549+ peer_networkinterface .nm_flush_ipaddr ()
550+ networkinterface . restore_from_backup ( )
552551 peer_networkinterface .bring_up ()
553552 except Exception :
554553 peer_networkinterface .save (ipaddr , self .netmask )
0 commit comments