diff options
author | Christian Poessinger <christian@poessinger.com> | 2019-09-24 19:27:54 +0200 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2019-09-24 21:53:26 +0200 |
commit | f95659216b0816f53bdf5cb8ccc02afff970dd53 (patch) | |
tree | 0ba646af17b6e41e2f7cdea08f4bd118b219abcc | |
parent | bc9b28132ca7270f226968d0c1207adefe768049 (diff) | |
download | vyos-1x-f95659216b0816f53bdf5cb8ccc02afff970dd53.tar.gz vyos-1x-f95659216b0816f53bdf5cb8ccc02afff970dd53.zip |
Python/ifconfig: T1557: refactor BondIf 'mode' property to set_mode()
-rw-r--r-- | python/vyos/ifconfig.py | 24 | ||||
-rwxr-xr-x | src/conf_mode/interface-bonding.py | 2 |
2 files changed, 3 insertions, 23 deletions
diff --git a/python/vyos/ifconfig.py b/python/vyos/ifconfig.py index 8b333b81d..8f81bc9f6 100644 --- a/python/vyos/ifconfig.py +++ b/python/vyos/ifconfig.py @@ -1254,25 +1254,7 @@ class BondIf(VLANIf): return self._write_sysfs('/sys/class/net/{}/bonding/primary' .format(self._ifname), interface) - @property - def mode(self): - """ - Specifies one of the bonding policies. The default is balance-rr - (round robin). - - Possible values are: balance-rr (0), active-backup (1), balance-xor (2), - broadcast (3), 802.3ad (4), balance-tlb (5), balance-alb (6) - - Example: - >>> from vyos.ifconfig import BondIf - >>> BondIf('bond0').mode - 'balance-rr' - """ - return self._read_sysfs('/sys/class/net/{}/bonding/mode' - .format(self._ifname)).split()[0] - - @mode.setter - def mode(self, mode): + def set_mode(self, mode): """ Specifies one of the bonding policies. The default is balance-rr (round robin). @@ -1285,9 +1267,7 @@ class BondIf(VLANIf): Example: >>> from vyos.ifconfig import BondIf - >>> BondIf('bond0').mode = '802.3ad' - >>> BondIf('bond0').mode - '802.3ad' + >>> BondIf('bond0').set_mode('802.3ad') """ if not mode in [ 'balance-rr', 'active-backup', 'balance-xor', 'broadcast', diff --git a/src/conf_mode/interface-bonding.py b/src/conf_mode/interface-bonding.py index 6092d0732..4d5009c73 100755 --- a/src/conf_mode/interface-bonding.py +++ b/src/conf_mode/interface-bonding.py @@ -388,7 +388,7 @@ def apply(bond): b.set_mac(bond['mac']) # Bonding policy - b.mode = bond['mode'] + b.set_mode(bond['mode']) # Maximum Transmission Unit (MTU) b.set_mtu(bond['mtu']) |