Skip to content

Commit d6cbf9c

Browse files
committed
extend bootlist test for bond interfaces
Enable bootlist_test.py to check bootlist options for HNV bond slaves Signed-off-by: Vaishnavi Bhat <vaishnavi@linux.vnet.ibm.com>
1 parent db6934e commit d6cbf9c

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

io/common/bootlist_test.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from avocado.utils import disk
2424
from avocado.utils import multipath
2525
from avocado.utils.network.hosts import LocalHost
26+
from avocado.utils.network.interfaces import NetworkInterface
2627

2728
IS_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():
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
interfaces: ""
2+
hbond: ""

0 commit comments

Comments
 (0)