2323from avocado .utils import disk
2424from avocado .utils import multipath
2525from avocado .utils .network .hosts import LocalHost
26+ from avocado .utils .network .interfaces import NetworkInterface
2627
2728IS_POWER_VM = 'pSeries' in open ('/proc/cpuinfo' , 'r' ).read ()
2829
@@ -44,14 +45,33 @@ def setUp(self):
4445 interfaces = os .listdir ('/sys/class/net' )
4546 disks = self .params .get ("disks" , default = None )
4647 ifaces = self .params .get ("interfaces" , default = None )
47- if ifaces :
48+ hbond = self .params .get ("hbond" , default = False )
49+
50+ if hbond and ifaces :
51+ for bond in ifaces .split (" " ):
52+ # Read slave interfaces directly from sysfs
53+ slaves_file = "/sys/class/net/%s/bonding/slaves" % bond
54+ if os .path .exists (slaves_file ):
55+ with open (slaves_file , 'r' ) as f :
56+ slaves_str = f .read ().strip ()
57+ if slaves_str :
58+ slaves = slaves_str .split ()
59+ self .host_interfaces .extend (slaves )
60+ self .log .info ("Bond %s has slaves: %s" % (bond , slaves ))
61+ else :
62+ self .cancel ("No slave interfaces found for bond %s" % bond )
63+ else :
64+ self .cancel ("Bond interface %s not found or not a bond" % bond )
65+ elif ifaces :
4866 for device in ifaces .split (" " ):
4967 if device in interfaces :
5068 self .host_interfaces .append (device )
5169 elif local .validate_mac_addr (device ) and device in local .get_all_hwaddr ():
5270 self .host_interfaces .append (local .get_interface_by_hwaddr (device ).name )
5371 else :
5472 self .cancel ("Please check the network device" )
73+
74+ if self .host_interfaces :
5575 self .names = ' ' .join (self .host_interfaces )
5676 elif disks :
5777 for dev in disks .split ():
0 commit comments