diff options
author | Christian Poessinger <christian@poessinger.com> | 2019-09-24 18:29:02 +0200 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2019-09-24 21:53:25 +0200 |
commit | 78badc8690cb06a0062694c21eb5329b830233d5 (patch) | |
tree | 3e8aee6acded0446f453fcf0dbb1000beea749ea | |
parent | 2f458f5efbd95640780554cc83fb54ec790bd4cc (diff) | |
download | vyos-1x-78badc8690cb06a0062694c21eb5329b830233d5.tar.gz vyos-1x-78badc8690cb06a0062694c21eb5329b830233d5.zip |
Python/ifconfig: T1557: refactor BridgeIf 'stp_state' property to set_stp()
-rw-r--r-- | python/vyos/ifconfig.py | 26 | ||||
-rwxr-xr-x | src/conf_mode/interface-bridge.py | 2 |
2 files changed, 5 insertions, 23 deletions
diff --git a/python/vyos/ifconfig.py b/python/vyos/ifconfig.py index 6b4d102fb..1f8612681 100644 --- a/python/vyos/ifconfig.py +++ b/python/vyos/ifconfig.py @@ -800,31 +800,13 @@ class BridgeIf(Interface): return self._write_sysfs('/sys/class/net/{}/bridge/priority' .format(self._ifname), priority) - @property - def stp_state(self): - """ - Get current bridge STP (Spanning Tree) state. - - Example: - >>> from vyos.ifconfig import Interface - >>> BridgeIf('br0').stp_state - '0' + def set_stp(self, state): """ - - state = 0 - with open('/sys/class/net/{}/bridge/stp_state'.format(self._ifname), 'r') as f: - state = int(f.read().rstrip('\n')) - - return state - - @stp_state.setter - def stp_state(self, state): - """ - Set bridge STP (Spannign Tree) state. 0 -> STP disabled, 1 -> STP enabled + Set bridge STP (Spanning Tree) state. 0 -> STP disabled, 1 -> STP enabled Example: - >>> from vyos.ifconfig import Interface - >>> BridgeIf('br0').stp_state = 1 + >>> from vyos.ifconfig import BridgeIf + >>> BridgeIf('br0').set_stp(1) """ if int(state) >= 0 and int(state) <= 1: diff --git a/src/conf_mode/interface-bridge.py b/src/conf_mode/interface-bridge.py index b120ac663..ef8680c5f 100755 --- a/src/conf_mode/interface-bridge.py +++ b/src/conf_mode/interface-bridge.py @@ -197,7 +197,7 @@ def apply(bridge): # set bridge priority br.set_priority(bridge['priority']) # turn stp on/off - br.stp_state = bridge['stp'] + br.set_stp(bridge['stp']) # enable or disable IGMP querier br.set_multicast_querier(bridge['igmp_querier']) # update interface description used e.g. within SNMP |