From 2f458f5efbd95640780554cc83fb54ec790bd4cc Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Tue, 24 Sep 2019 18:26:28 +0200 Subject: Python/ifconfig: T1557: refactor BridgeIf 'priority' property to set_priority() --- python/vyos/ifconfig.py | 24 +++++------------------- src/conf_mode/interface-bridge.py | 10 +++++----- 2 files changed, 10 insertions(+), 24 deletions(-) diff --git a/python/vyos/ifconfig.py b/python/vyos/ifconfig.py index 4ffeaa729..6b4d102fb 100644 --- a/python/vyos/ifconfig.py +++ b/python/vyos/ifconfig.py @@ -789,27 +789,13 @@ class BridgeIf(Interface): return self._write_sysfs('/sys/class/net/{}/bridge/max_age' .format(self._ifname), (int(time) * 100)) - @property - def priority(self): - """ - Get bridge max aging time in seconds. - - Example: - >>> from vyos.ifconfig import Interface - >>> BridgeIf('br0').priority - '32768' - """ - return self._read_sysfs('/sys/class/net/{}/bridge/priority' - .format(self._ifname)) - - @priority.setter - def priority(self, priority): + def set_priority(self, priority): """ Set bridge max aging time in seconds. Example: - >>> from vyos.ifconfig import Interface - >>> BridgeIf('br0').priority = 8192 + >>> from vyos.ifconfig import BridgeIf + >>> BridgeIf('br0').set_priority(8192) """ return self._write_sysfs('/sys/class/net/{}/bridge/priority' .format(self._ifname), priority) @@ -891,7 +877,7 @@ class BridgeIf(Interface): cmd = 'ip link set dev {} nomaster'.format(interface) self._cmd(cmd) - def set_cost(self, interface, cost): + def set_path_cost(self, interface, cost): """ Set interface path cost, only relevant for STP enabled interfaces @@ -903,7 +889,7 @@ class BridgeIf(Interface): return self._write_sysfs('/sys/class/net/{}/brif/{}/path_cost' .format(self._ifname, interface), cost) - def set_priority(self, interface, priority): + def set_path_priority(self, interface, priority): """ Set interface path priority, only relevant for STP enabled interfaces diff --git a/src/conf_mode/interface-bridge.py b/src/conf_mode/interface-bridge.py index 3b18e24ab..b120ac663 100755 --- a/src/conf_mode/interface-bridge.py +++ b/src/conf_mode/interface-bridge.py @@ -195,7 +195,7 @@ def apply(bridge): # set max message age br.set_max_age(bridge['max_age']) # set bridge priority - br.priority = bridge['priority'] + br.set_priority(bridge['priority']) # turn stp on/off br.stp_state = bridge['stp'] # enable or disable IGMP querier @@ -229,10 +229,10 @@ def apply(bridge): # configure additional bridge member options for member in bridge['member']: - # set bridge port cost - br.set_cost(member['name'], member['cost']) - # set bridge port priority - br.set_priority(member['name'], member['priority']) + # set bridge port path cost + br.set_path_cost(member['name'], member['cost']) + # set bridge port path priority + br.set_path_priority(member['name'], member['priority']) i = Interface(member['name']) # configure ARP cache timeout -- cgit v1.2.3