From 19cae8e57885034002b3773b289d9f9086937ddc Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Tue, 24 Sep 2019 19:09:26 +0200 Subject: Python/ifconfig: T1557: refactor BondIf 'xmit_hash_policy' property to set_hash_policy() --- python/vyos/ifconfig.py | 25 ++----------------------- src/conf_mode/interface-bonding.py | 2 +- 2 files changed, 3 insertions(+), 24 deletions(-) diff --git a/python/vyos/ifconfig.py b/python/vyos/ifconfig.py index a155ce572..2c627f0b0 100644 --- a/python/vyos/ifconfig.py +++ b/python/vyos/ifconfig.py @@ -1097,27 +1097,8 @@ class BondIf(VLANIf): i = Interface(slave['ifname']) i.set_state(slave['state']) - @property - def xmit_hash_policy(self): - """ - Selects the transmit hash policy to use for slave selection in - balance-xor, 802.3ad, and tlb modes. Possible values are: layer2, - layer2+3, layer3+4, encap2+3, encap3+4. - - The default value is layer2 - - Example: - >>> from vyos.ifconfig import BondIf - >>> BondIf('bond0').xmit_hash_policy - 'layer3+4' - """ - # Linux Kernel appends has policy value to string, e.g. 'layer3+4 1', - # so remove the later part and only return the mode as string. - return self._read_sysfs('/sys/class/net/{}/bonding/xmit_hash_policy' - .format(self._ifname)).split()[0] - @xmit_hash_policy.setter - def xmit_hash_policy(self, mode): + def set_hash_policy(self, mode): """ Selects the transmit hash policy to use for slave selection in balance-xor, 802.3ad, and tlb modes. Possible values are: layer2, @@ -1127,9 +1108,7 @@ class BondIf(VLANIf): Example: >>> from vyos.ifconfig import BondIf - >>> BondIf('bond0').xmit_hash_policy = 'layer2+3' - >>> BondIf('bond0').proxy_arp - '1' + >>> BondIf('bond0').set_hash_policy('layer2+3') """ if not mode in ['layer2', 'layer2+3', 'layer3+4', 'encap2+3', 'encap3+4']: raise ValueError("Value out of range") diff --git a/src/conf_mode/interface-bonding.py b/src/conf_mode/interface-bonding.py index c7adb0f9a..e8e22e305 100755 --- a/src/conf_mode/interface-bonding.py +++ b/src/conf_mode/interface-bonding.py @@ -378,7 +378,7 @@ def apply(bond): # ignore link state changes b.set_link_detect(bond['disable_link_detect']) # Bonding transmit hash policy - b.xmit_hash_policy = bond['hash_policy'] + b.set_hash_policy(bond['hash_policy']) # configure ARP cache timeout in milliseconds b.set_arp_cache_tmo(bond['ip_arp_cache_tmo']) # Enable proxy-arp on this interface -- cgit v1.2.3