diff --git a/avocado/utils/network/interfaces.py b/avocado/utils/network/interfaces.py index 40bc072d17..78145dd3d6 100644 --- a/avocado/utils/network/interfaces.py +++ b/avocado/utils/network/interfaces.py @@ -217,6 +217,27 @@ def _get_bondinterface_details(self): f"Slave interface not found for " f"the bond {self.name}" ) from exc + def _get_bondingmaster(self): + """Get the bonding master interface name from a slave interface. + + This method returns the bond interface name for the current slave interface. + + :return: Bond master interface name as string + :raises NWException: If bonding master not found or interface is not a slave + """ + master_path = f"/sys/class/net/{self.name}/master" + cmd = f"readlink -f {master_path}" + try: + output = run_command(cmd, self.host) + # Extract the bond interface name from the path + # Output will be like: /sys/devices/virtual/net/bond0 + bond_name = os.path.basename(output.strip()) + return bond_name + except Exception as exc: + raise NWException( + f"Bonding master not found for interface {self.name}" + ) from exc + def _move_file_to_backup(self, filename, ignore_missing=True): """Moves a file to a backup location.