From afbd29c5e009ce787771465101e4edeeb28896a5 Mon Sep 17 00:00:00 2001 From: Jan Tluka Date: Thu, 26 Sep 2024 08:52:57 +0200 Subject: [PATCH] Recipes/ENRT/VlansOverBondRecipe.py: use BondingMixin Signed-off-by: Jan Tluka --- lnst/Recipes/ENRT/VlansOverBondRecipe.py | 36 +++++++++++------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/lnst/Recipes/ENRT/VlansOverBondRecipe.py b/lnst/Recipes/ENRT/VlansOverBondRecipe.py index cd6f2065..5793f4ea 100644 --- a/lnst/Recipes/ENRT/VlansOverBondRecipe.py +++ b/lnst/Recipes/ENRT/VlansOverBondRecipe.py @@ -2,7 +2,6 @@ from lnst.Common.Parameters import ( Param, IntParam, - StrParam, IPv4NetworkParam, IPv6NetworkParam, ) @@ -18,14 +17,14 @@ CommonHWSubConfigMixin) from lnst.Recipes.ENRT.ConfigMixins.PerfReversibleFlowMixin import ( PerfReversibleFlowMixin) +from lnst.Recipes.ENRT.BondingMixin import BondingMixin from lnst.Devices import VlanDevice from lnst.Devices.VlanDevice import VlanDevice as Vlan -from lnst.Devices import BondDevice from lnst.Devices import RemoteDevice from lnst.Recipes.ENRT.PingMixins import VlanPingEvaluatorMixin from lnst.RecipeCommon.Ping.PingEndpoints import PingEndpoints -class VlansOverBondRecipe(PerfReversibleFlowMixin, VlanPingEvaluatorMixin, +class VlansOverBondRecipe(BondingMixin, PerfReversibleFlowMixin, VlanPingEvaluatorMixin, CommonHWSubConfigMixin, OffloadSubConfigMixin, BaremetalEnrtRecipe): r""" @@ -51,16 +50,9 @@ class VlansOverBondRecipe(PerfReversibleFlowMixin, VlanPingEvaluatorMixin, | host1 | | host2 | '------------------------' '---------------------' - The recipe provides additional recipe parameters to configure the bonding + Refer to :any:`BondingMixin` for parameters to configure the bonding device. - :param bonding_mode: - (mandatory test parameter) the bonding mode to be configured on - the bond0 device - :param miimon_value: - (mandatory test parameter) the miimon interval to be configured - on the bond0 device - All sub configurations are included via Mixin classes. The actual test machinery is implemented in the :any:`BaseEnrtRecipe` class. @@ -91,9 +83,6 @@ class VlansOverBondRecipe(PerfReversibleFlowMixin, VlanPingEvaluatorMixin, vlan2_ipv4 = IPv4NetworkParam(default="192.168.30.0/24") vlan2_ipv6 = IPv6NetworkParam(default="fc00:0:0:3::/64") - bonding_mode = StrParam(mandatory=True) - miimon_value = IntParam(mandatory=True) - def test_wide_configuration(self): """ Test wide configuration for this recipe involves creating one bonding @@ -118,11 +107,14 @@ def test_wide_configuration(self): host1, host2 = self.matched.host1, self.matched.host2 config = super().test_wide_configuration() - host1.bond0 = BondDevice(mode=self.params.bonding_mode, - miimon=self.params.miimon_value) - for dev in [host1.eth0, host1.eth1]: - dev.down() - host1.bond0.slave_add(dev) + self.create_bond_devices( + { + "host1": + { + "bond0": [host1.eth0, host1.eth1] + } + } + ) host1.vlan0 = VlanDevice(realdev=host1.bond0, vlan_id=self.params.vlan0_id) host1.vlan1 = VlanDevice(realdev=host1.bond0, vlan_id=self.params.vlan1_id) @@ -201,6 +193,12 @@ def generate_test_wide_description(self, config: EnrtConfiguration): host1.bond0.miimon ) ] + + if self.params.bonding_mode in ["active-backup", "1"]: + desc += ["Configured {}.{}.fail_over_mac = {}".format( + host1.hostid, host1.bond0.name, + host1.bond0.fail_over_mac + )] return desc def generate_ping_endpoints(self, config):