From 065adc3ab2ee6262b4a1a85762697ac81fc5b084 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Tue, 24 Sep 2019 19:03:57 +0200 Subject: Python/ifconfig: T1557: refactor Interface 'state' property to set_state()/get_state() --- src/conf_mode/interface-bonding.py | 8 ++++---- src/conf_mode/interface-bridge.py | 4 ++-- src/conf_mode/interface-dummy.py | 6 +++--- src/conf_mode/interface-ethernet.py | 8 ++++---- src/conf_mode/interface-vxlan.py | 2 +- src/conf_mode/interface-wireguard.py | 6 +++--- 6 files changed, 17 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/conf_mode/interface-bonding.py b/src/conf_mode/interface-bonding.py index 0fd19ce1e..c7adb0f9a 100755 --- a/src/conf_mode/interface-bonding.py +++ b/src/conf_mode/interface-bonding.py @@ -95,9 +95,9 @@ def apply_vlan_config(vlan, config): # enable/disable VLAN interface if config['disable']: - vlan.state = 'down' + vlan.set_state('down') else: - vlan.state = 'up' + vlan.set_state('up') # Configure interface address(es) # - not longer required addresses get removed first @@ -337,7 +337,7 @@ def apply(bond): else: # Some parameters can not be changed when the bond is up. # Always disable the bond prior changing anything - b.state = 'down' + b.set_state('down') # The bonding mode can not be changed when there are interfaces enslaved # to this bond, thus we will free all interfaces from the bond first! @@ -407,7 +407,7 @@ def apply(bond): # parameters we will only re-enable the interface if it is not # administratively disabled if not bond['disable']: - b.state = 'up' + b.set_state('up') # Configure interface address(es) # - not longer required addresses get removed first diff --git a/src/conf_mode/interface-bridge.py b/src/conf_mode/interface-bridge.py index cb053773a..b20e7f6ff 100755 --- a/src/conf_mode/interface-bridge.py +++ b/src/conf_mode/interface-bridge.py @@ -185,7 +185,7 @@ def apply(bridge): br.remove() else: # enable interface - br.state = 'up' + br.set_state('up') # set ageing time br.set_ageing_time(bridge['aging']) # set bridge forward delay @@ -217,7 +217,7 @@ def apply(bridge): # up/down interface if bridge['disable']: - br.state = 'down' + br.set_state('down') # Configure interface address(es) # - not longer required addresses get removed first diff --git a/src/conf_mode/interface-dummy.py b/src/conf_mode/interface-dummy.py index 2556722fa..16b716e61 100755 --- a/src/conf_mode/interface-dummy.py +++ b/src/conf_mode/interface-dummy.py @@ -84,8 +84,6 @@ def apply(dummy): if dummy['deleted']: d.remove() else: - # enable interface - d.state = 'up' # update interface description used e.g. within SNMP d.set_alias(dummy['description']) @@ -99,7 +97,9 @@ def apply(dummy): # disable interface on demand if dummy['disable']: - d.state = 'down' + d.set_state('down') + else + d.set_state('up') return None diff --git a/src/conf_mode/interface-ethernet.py b/src/conf_mode/interface-ethernet.py index cc9f44753..99450b19e 100755 --- a/src/conf_mode/interface-ethernet.py +++ b/src/conf_mode/interface-ethernet.py @@ -78,9 +78,9 @@ def apply_vlan_config(vlan, config): # enable/disable VLAN interface if config['disable']: - vlan.state = 'down' + vlan.set_state('down') else: - vlan.state = 'up' + vlan.set_state('up') # Configure interface address(es) # - not longer required addresses get removed first @@ -318,9 +318,9 @@ def apply(eth): # Enable/Disable interface if eth['disable']: - e.state = 'down' + e.set_state('down') else: - e.state = 'up' + e.set_state('up') # Configure interface address(es) # - not longer required addresses get removed first diff --git a/src/conf_mode/interface-vxlan.py b/src/conf_mode/interface-vxlan.py index c0c85e64c..1097ae4d0 100755 --- a/src/conf_mode/interface-vxlan.py +++ b/src/conf_mode/interface-vxlan.py @@ -182,7 +182,7 @@ def apply(vxlan): # parameters we will only re-enable the interface if it is not # administratively disabled if not vxlan['disable']: - v.state='up' + v.set_state('up') return None diff --git a/src/conf_mode/interface-wireguard.py b/src/conf_mode/interface-wireguard.py index 7254e153f..3fd29ad4d 100755 --- a/src/conf_mode/interface-wireguard.py +++ b/src/conf_mode/interface-wireguard.py @@ -173,11 +173,11 @@ def apply(c): # interface state if c[ifname]['state'] == 'disable': sl.syslog(sl.LOG_NOTICE, "disable interface " + ifname) - intfc.state = 'down' + intfc.set_state('down') else: - if not intfc.state == 'up': + if not intfc.get_state() == 'up': sl.syslog(sl.LOG_NOTICE, "enable interface " + ifname) - intfc.state = 'up' + intfc.set_state('up') # IP address if not c_eff.exists_effective(ifname + ' address'): -- cgit v1.2.3