Skip to content

Commit

Permalink
bonding: Add support for mac base input interfaces
Browse files Browse the repository at this point in the history
In a contineous test environement setups where device names
are not persistent accross os, having a unique key like mac
addr as yaml input which does not change across reboots,
dlpar or os install with different linux flavours, also
the legacy interface name still works.

Signed-off-by: Abdul Haleem <abdhalee@linux.vnet.ibm.com>
  • Loading branch information
abdhaleegit committed Aug 31, 2023
1 parent 43b8258 commit 00800b7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
19 changes: 13 additions & 6 deletions io/net/bonding.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ def setUp(self):
'''
To check and install dependencies for the test
'''
self.localhost = LocalHost()
detected_distro = distro.detect()
smm = SoftwareManager()
self.host_interfaces = []
depends = []
# FIXME: "redhat" as the distro name for RHEL is deprecated
# on Avocado versions >= 50.0. This is a temporary compatibility
Expand All @@ -73,10 +75,15 @@ def setUp(self):
self.user = self.params.get("user_name", default="root")
self.password = self.params.get("peer_password", '*',
default="None")
self.host_interfaces = self.params.get("bond_interfaces",
default="").split(" ")
if not self.host_interfaces:
self.cancel("user should specify host interfaces")
devices = self.params.get("bond_interfaces", default=None)
if devices:
for device in devices.split(" "):
if device in interfaces:
self.host_interfaces.append(device)
elif self.localhost.validate_mac_addr(device) and device in self.localhost.get_all_hwaddr():
self.host_interfaces.append(self.localhost.get_interface_by_hwaddr(device).name)
else:
self.cancel("user should specify host interfaces")
self.peer_interfaces = self.params.get("peer_interfaces",
default="").split(" ")
for self.host_interface in self.host_interfaces:
Expand All @@ -90,7 +97,6 @@ def setUp(self):
self.netmask = self.params.get("netmask", default="")
self.peer_bond_needed = self.params.get("peer_bond_needed",
default=False)
self.localhost = LocalHost()
if 'setup' in str(self.name.name):
for ipaddr, interface in zip(self.ipaddr, self.host_interfaces):
networkinterface = NetworkInterface(interface, self.localhost)
Expand Down Expand Up @@ -579,4 +585,5 @@ def error_check(self):
self.fail("Tests failed. Details:\n%s" % "\n".join(self.err))

def tearDown(self):
self.session.quit()
if self.host_interfaces:
self.session.quit()
4 changes: 1 addition & 3 deletions io/net/bonding.py.data/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Note:
-----------------------------
Inputs Needed To Run Tests:
------------------------------
bond_interfaces --> Interfaces in the Host machine requird for Bonding
bond_interfaces --> Interfaces names or mac address space separated in the Host machine requird for Bonding
Note: example bond_interfaces = "ib0 ib1", Space between the interface names
peerip --> peer ip address
peer_interfaces --> This is needed only if a Bond interface is to be created in the Peer machine, space separated names if specifying multiple
Expand All @@ -31,5 +31,3 @@ Requirements:
-----------------------
1. install netifaces using pip
command: pip install netifaces
2. Generate sshkey for your test partner to run the test uninterrupted.(Have a passwordless ssh between the peers)
3. Make sure IPs are set for interfaces to be used, via configuration file. ifup / ifdown should set the IPs back.

0 comments on commit 00800b7

Please sign in to comment.