summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2019-09-24 19:09:26 +0200
committerChristian Poessinger <christian@poessinger.com>2019-09-24 21:53:26 +0200
commit19cae8e57885034002b3773b289d9f9086937ddc (patch)
tree8996d69781cf0ebc74deb0c4800b87b4d2cb6c48
parent42df77762c8bc436a53350b44355c23e70f7d215 (diff)
downloadvyos-1x-19cae8e57885034002b3773b289d9f9086937ddc.tar.gz
vyos-1x-19cae8e57885034002b3773b289d9f9086937ddc.zip
Python/ifconfig: T1557: refactor BondIf 'xmit_hash_policy' property to set_hash_policy()
-rw-r--r--python/vyos/ifconfig.py25
-rwxr-xr-xsrc/conf_mode/interface-bonding.py2
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