From f95659216b0816f53bdf5cb8ccc02afff970dd53 Mon Sep 17 00:00:00 2001
From: Christian Poessinger <christian@poessinger.com>
Date: Tue, 24 Sep 2019 19:27:54 +0200
Subject: Python/ifconfig: T1557: refactor BondIf 'mode' property to set_mode()

---
 python/vyos/ifconfig.py            | 24 ++----------------------
 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'])
 
-- 
cgit v1.2.3