From d77f68ef3198cff019e1e2d74dfe2290800a1ea6 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Tue, 24 Sep 2019 18:04:17 +0200 Subject: Python/ifconfig: T1557: refactor 'mtu' property to get_mtu()/set_mtu() --- src/conf_mode/interface-vxlan.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/conf_mode/interface-vxlan.py') diff --git a/src/conf_mode/interface-vxlan.py b/src/conf_mode/interface-vxlan.py index e97b4bf99..f0fa7596a 100755 --- a/src/conf_mode/interface-vxlan.py +++ b/src/conf_mode/interface-vxlan.py @@ -13,9 +13,9 @@ # # You should have received a copy of the GNU General Public License # along with this program. If not, see . -# -from os import environ +import os + from sys import exit from copy import deepcopy @@ -48,7 +48,7 @@ def get_config(): # determine tagNode instance try: - vxlan['intf'] = environ['VYOS_TAGNODE_VALUE'] + vxlan['intf'] = os.environ['VYOS_TAGNODE_VALUE'] except KeyError as E: print("Interface not specified") @@ -127,7 +127,7 @@ def verify(vxlan): if vxlan['link']: # VXLAN adds a 50 byte overhead - we need to check the underlaying MTU # if our configured MTU is at least 50 bytes less - underlay_mtu = int(Interface(vxlan['link']).mtu) + underlay_mtu = int(Interface(vxlan['link']).get_mtu()) if underlay_mtu < (vxlan['mtu'] + 50): raise ConfigError('VXLAN has a 50 byte overhead, underlaying device ' \ 'MTU is to small ({})'.format(underlay_mtu)) @@ -165,7 +165,7 @@ def apply(vxlan): # update interface description used e.g. by SNMP v.ifalias = vxlan['description'] # Maximum Transfer Unit (MTU) - v.mtu = vxlan['mtu'] + v.set_mtu(vxlan['mtu']) # configure ARP cache timeout in milliseconds v.arp_cache_tmp = vxlan['ip_arp_cache_tmo'] -- cgit v1.2.3 From 12d0cdf69ba15dccb705e212ea605b692f825dbd Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Tue, 24 Sep 2019 18:40:07 +0200 Subject: Python/ifconfig: T1557: refactor Interface 'ifalias' property to set_alias() --- python/vyos/ifconfig.py | 29 +++++------------------------ src/conf_mode/interface-bonding.py | 4 ++-- src/conf_mode/interface-bridge.py | 2 +- src/conf_mode/interface-dummy.py | 14 +++++++------- src/conf_mode/interface-ethernet.py | 4 ++-- src/conf_mode/interface-loopback.py | 3 +-- src/conf_mode/interface-vxlan.py | 2 +- src/conf_mode/interface-wireguard.py | 2 +- 8 files changed, 20 insertions(+), 40 deletions(-) (limited to 'src/conf_mode/interface-vxlan.py') diff --git a/python/vyos/ifconfig.py b/python/vyos/ifconfig.py index 749bc6a1a..86e2084d3 100644 --- a/python/vyos/ifconfig.py +++ b/python/vyos/ifconfig.py @@ -261,36 +261,17 @@ class Interface: else: raise ValueError("Value out of range") - @property - def ifalias(self): - """ - Get/set interface alias name - - Example: - - >>> from vyos.ifconfig import Interface - >>> Interface('eth0').ifalias - '' - """ - return self._read_sysfs('/sys/class/net/{}/ifalias' - .format(self._ifname)) - - @ifalias.setter - def ifalias(self, ifalias=None): + def set_alias(self, ifalias=None): """ - Get/set interface alias name + Set interface alias name used by e.g. SNMP Example: >>> from vyos.ifconfig import Interface - >>> Interface('eth0').ifalias = 'VyOS upstream interface' - >>> Interface('eth0').ifalias - 'VyOS upstream interface' + >>> Interface('eth0').set_alias('VyOS upstream interface') - to clear interface alias e.g. delete it use: + to clear alias e.g. delete it use: - >>> Interface('eth0').ifalias = '' - >>> Interface('eth0').ifalias - '' + >>> Interface('eth0').set_ifalias('') """ if not ifalias: # clear interface alias diff --git a/src/conf_mode/interface-bonding.py b/src/conf_mode/interface-bonding.py index dce4a8106..8b4c8b625 100755 --- a/src/conf_mode/interface-bonding.py +++ b/src/conf_mode/interface-bonding.py @@ -84,7 +84,7 @@ def apply_vlan_config(vlan, config): raise TypeError() # update interface description used e.g. within SNMP - vlan.ifalias = config['description'] + vlan.set_alias(config['description']) # ignore link state changes vlan.set_link_detect(config['disable_link_detect']) # Maximum Transmission Unit (MTU) @@ -369,7 +369,7 @@ def apply(bond): b.arp_ip_target = '+' + addr # update interface description used e.g. within SNMP - b.ifalias = bond['description'] + b.set_alias(bond['description']) # # missing DHCP/DHCPv6 options go here diff --git a/src/conf_mode/interface-bridge.py b/src/conf_mode/interface-bridge.py index 558ec3cc6..cadd44feb 100755 --- a/src/conf_mode/interface-bridge.py +++ b/src/conf_mode/interface-bridge.py @@ -201,7 +201,7 @@ def apply(bridge): # enable or disable IGMP querier br.set_multicast_querier(bridge['igmp_querier']) # update interface description used e.g. within SNMP - br.ifalias = bridge['description'] + br.set_alias(bridge['description']) # Change interface MAC address if bridge['mac']: diff --git a/src/conf_mode/interface-dummy.py b/src/conf_mode/interface-dummy.py index 1b3fbcc93..2556722fa 100755 --- a/src/conf_mode/interface-dummy.py +++ b/src/conf_mode/interface-dummy.py @@ -78,28 +78,28 @@ def generate(dummy): return None def apply(dummy): - du = DummyIf(dummy['intf']) + d = DummyIf(dummy['intf']) # Remove dummy interface if dummy['deleted']: - du.remove() + d.remove() else: # enable interface - du.state = 'up' + d.state = 'up' # update interface description used e.g. within SNMP - du.ifalias = dummy['description'] + d.set_alias(dummy['description']) # Configure interface address(es) # - not longer required addresses get removed first # - newly addresses will be added second for addr in dummy['address_remove']: - du.del_addr(addr) + d.del_addr(addr) for addr in dummy['address']: - du.add_addr(addr) + d.add_addr(addr) # disable interface on demand if dummy['disable']: - du.state = 'down' + d.state = 'down' return None diff --git a/src/conf_mode/interface-ethernet.py b/src/conf_mode/interface-ethernet.py index f4bc53a32..5c8c76827 100755 --- a/src/conf_mode/interface-ethernet.py +++ b/src/conf_mode/interface-ethernet.py @@ -67,7 +67,7 @@ def apply_vlan_config(vlan, config): raise TypeError() # update interface description used e.g. within SNMP - vlan.ifalias = config['description'] + vlan.set_alias(config['description']) # ignore link state changes vlan.set_link_detect(config['disable_link_detect']) # Maximum Transmission Unit (MTU) @@ -271,7 +271,7 @@ def apply(eth): e.remove() else: # update interface description used e.g. within SNMP - e.ifalias = eth['description'] + e.set_alias(eth['description']) # # missing DHCP/DHCPv6 options go here diff --git a/src/conf_mode/interface-loopback.py b/src/conf_mode/interface-loopback.py index aba682f31..46fc6809b 100755 --- a/src/conf_mode/interface-loopback.py +++ b/src/conf_mode/interface-loopback.py @@ -75,8 +75,7 @@ def apply(loopback): lo = LoopbackIf(loopback['intf']) if not loopback['deleted']: # update interface description used e.g. within SNMP - # update interface description used e.g. within SNMP - lo.ifalias = loopback['description'] + lo.set_alias(loopback['description']) # 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 f0fa7596a..638efda31 100755 --- a/src/conf_mode/interface-vxlan.py +++ b/src/conf_mode/interface-vxlan.py @@ -163,7 +163,7 @@ def apply(vxlan): # Finally create the new interface v = VXLANIf(vxlan['intf'], config=conf) # update interface description used e.g. by SNMP - v.ifalias = vxlan['description'] + v.set_alias(vxlan['description']) # Maximum Transfer Unit (MTU) v.set_mtu(vxlan['mtu']) diff --git a/src/conf_mode/interface-wireguard.py b/src/conf_mode/interface-wireguard.py index 069298265..7254e153f 100755 --- a/src/conf_mode/interface-wireguard.py +++ b/src/conf_mode/interface-wireguard.py @@ -210,7 +210,7 @@ def apply(c): # ifalias for snmp from description descr_eff = c_eff.return_effective_value(ifname + ' description') if descr_eff != c[ifname]['descr']: - intfc.ifalias = str(c[ifname]['descr']) + intfc.set_alias(str(c[ifname]['descr'])) # peer deletion peer_eff = c_eff.list_effective_nodes(ifname + ' peer') -- cgit v1.2.3 From 3cedc3358c6aeb9e6caad4251958fa1a05723ea3 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Tue, 24 Sep 2019 18:51:03 +0200 Subject: Python/ifconfig: T1557: refactor Interface 'proxy_arp' property to set_proxy_arp() --- python/vyos/ifconfig.py | 20 ++------------------ src/conf_mode/interface-bonding.py | 2 +- src/conf_mode/interface-ethernet.py | 2 +- src/conf_mode/interface-vxlan.py | 2 +- 4 files changed, 5 insertions(+), 21 deletions(-) (limited to 'src/conf_mode/interface-vxlan.py') diff --git a/python/vyos/ifconfig.py b/python/vyos/ifconfig.py index 776fe1a23..86a080602 100644 --- a/python/vyos/ifconfig.py +++ b/python/vyos/ifconfig.py @@ -314,29 +314,13 @@ class Interface: cmd = 'ip link set dev {} {}'.format(self._ifname, state) self._cmd(cmd) - @property - def proxy_arp(self): - """ - Get current proxy ARP configuration from sysfs. Default: 0 - - Example: - >>> from vyos.ifconfig import Interface - >>> Interface('eth0').proxy_arp - '0' - """ - return self._read_sysfs('/proc/sys/net/ipv4/conf/{}/proxy_arp' - .format(self._ifname)) - - @proxy_arp.setter - def proxy_arp(self, enable): + def set_proxy_arp(self, enable): """ Set per interface proxy ARP configuration Example: >>> from vyos.ifconfig import Interface - >>> Interface('eth0').proxy_arp = 1 - >>> Interface('eth0').proxy_arp - '1' + >>> Interface('eth0').set_proxy_arp(1) """ if int(enable) >= 0 and int(enable) <= 1: return self._write_sysfs('/proc/sys/net/ipv4/conf/{}/proxy_arp' diff --git a/src/conf_mode/interface-bonding.py b/src/conf_mode/interface-bonding.py index 8b4c8b625..2058a3342 100755 --- a/src/conf_mode/interface-bonding.py +++ b/src/conf_mode/interface-bonding.py @@ -382,7 +382,7 @@ def apply(bond): # configure ARP cache timeout in milliseconds b.arp_cache_tmp = bond['ip_arp_cache_tmo'] # Enable proxy-arp on this interface - b.proxy_arp = bond['ip_proxy_arp'] + b.set_proxy_arp(bond['ip_proxy_arp']) # Enable private VLAN proxy ARP on this interface b.proxy_arp_pvlan = bond['ip_proxy_arp_pvlan'] diff --git a/src/conf_mode/interface-ethernet.py b/src/conf_mode/interface-ethernet.py index 5c8c76827..e15e89232 100755 --- a/src/conf_mode/interface-ethernet.py +++ b/src/conf_mode/interface-ethernet.py @@ -284,7 +284,7 @@ def apply(eth): # configure ARP cache timeout in milliseconds e.arp_cache_tmo = eth['ip_arp_cache_tmo'] # Enable proxy-arp on this interface - e.proxy_arp = eth['ip_proxy_arp'] + e.set_proxy_arp(eth['ip_proxy_arp']) # Enable private VLAN proxy ARP on this interface e.proxy_arp_pvlan = eth['ip_proxy_arp_pvlan'] diff --git a/src/conf_mode/interface-vxlan.py b/src/conf_mode/interface-vxlan.py index 638efda31..b7aa55b61 100755 --- a/src/conf_mode/interface-vxlan.py +++ b/src/conf_mode/interface-vxlan.py @@ -170,7 +170,7 @@ def apply(vxlan): # configure ARP cache timeout in milliseconds v.arp_cache_tmp = vxlan['ip_arp_cache_tmo'] # Enable proxy-arp on this interface - v.proxy_arp = vxlan['ip_proxy_arp'] + v.set_proxy_arp(vxlan['ip_proxy_arp']) # Configure interface address(es) - no need to implicitly delete the # old addresses as they have already been removed by deleting the -- cgit v1.2.3 From 09f4553ffdbf3c35696f08118d75793db33cb59b Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Tue, 24 Sep 2019 18:56:05 +0200 Subject: Python/ifconfig: T1557: refactor Interface 'arp_cache_tmo' property to set_set_arp_cache_tmo() --- python/vyos/ifconfig.py | 18 ++---------------- src/conf_mode/interface-bonding.py | 2 +- src/conf_mode/interface-bridge.py | 2 +- src/conf_mode/interface-ethernet.py | 2 +- src/conf_mode/interface-vxlan.py | 2 +- 5 files changed, 6 insertions(+), 20 deletions(-) (limited to 'src/conf_mode/interface-vxlan.py') diff --git a/python/vyos/ifconfig.py b/python/vyos/ifconfig.py index d32b54199..5fa9f4f2b 100644 --- a/python/vyos/ifconfig.py +++ b/python/vyos/ifconfig.py @@ -208,29 +208,15 @@ class Interface: cmd = 'ip link set dev {} address {}'.format(self._ifname, mac) self._cmd(cmd) - @property - def arp_cache_tmo(self): - """ - Get configured ARP cache timeout value from interface in seconds. - Internal Kernel representation is in milliseconds. - - Example: - >>> from vyos.ifconfig import Interface - >>> Interface('eth0').arp_cache_tmo - '30' - """ - return (self._read_sysfs('/proc/sys/net/ipv4/neigh/{0}/base_reachable_time_ms' - .format(self._ifname)) / 1000) - @arp_cache_tmo.setter - def arp_cache_tmo(self, tmo): + def set_arp_cache_tmo(self, tmo): """ Set ARP cache timeout value in seconds. Internal Kernel representation is in milliseconds. Example: >>> from vyos.ifconfig import Interface - >>> Interface('eth0').arp_cache_tmo = '40' + >>> Interface('eth0').set_arp_cache_tmo(40) """ return self._write_sysfs('/proc/sys/net/ipv4/neigh/{0}/base_reachable_time_ms' .format(self._ifname), (int(tmo) * 1000)) diff --git a/src/conf_mode/interface-bonding.py b/src/conf_mode/interface-bonding.py index 0b6ac14a6..0fd19ce1e 100755 --- a/src/conf_mode/interface-bonding.py +++ b/src/conf_mode/interface-bonding.py @@ -380,7 +380,7 @@ def apply(bond): # Bonding transmit hash policy b.xmit_hash_policy = bond['hash_policy'] # configure ARP cache timeout in milliseconds - b.arp_cache_tmp = bond['ip_arp_cache_tmo'] + b.set_arp_cache_tmo(bond['ip_arp_cache_tmo']) # Enable proxy-arp on this interface b.set_proxy_arp(bond['ip_proxy_arp']) # Enable private VLAN proxy ARP on this interface diff --git a/src/conf_mode/interface-bridge.py b/src/conf_mode/interface-bridge.py index cadd44feb..cb053773a 100755 --- a/src/conf_mode/interface-bridge.py +++ b/src/conf_mode/interface-bridge.py @@ -236,7 +236,7 @@ def apply(bridge): i = Interface(member['name']) # configure ARP cache timeout - i.arp_cache_tmo = bridge['arp_cache_tmo'] + i.set_arp_cache_tmo(bridge['arp_cache_tmo']) # ignore link state changes i.set_link_detect(bridge['disable_link_detect']) diff --git a/src/conf_mode/interface-ethernet.py b/src/conf_mode/interface-ethernet.py index 02a45408f..cc9f44753 100755 --- a/src/conf_mode/interface-ethernet.py +++ b/src/conf_mode/interface-ethernet.py @@ -282,7 +282,7 @@ def apply(eth): # disable ethernet flow control (pause frames) e.set_flow_control(eth['flow_control']) # configure ARP cache timeout in milliseconds - e.arp_cache_tmo = eth['ip_arp_cache_tmo'] + e.set_arp_cache_tmo(eth['ip_arp_cache_tmo']) # Enable proxy-arp on this interface e.set_proxy_arp(eth['ip_proxy_arp']) # Enable private VLAN proxy ARP on this interface diff --git a/src/conf_mode/interface-vxlan.py b/src/conf_mode/interface-vxlan.py index b7aa55b61..c0c85e64c 100755 --- a/src/conf_mode/interface-vxlan.py +++ b/src/conf_mode/interface-vxlan.py @@ -168,7 +168,7 @@ def apply(vxlan): v.set_mtu(vxlan['mtu']) # configure ARP cache timeout in milliseconds - v.arp_cache_tmp = vxlan['ip_arp_cache_tmo'] + v.set_arp_cache_tmo(vxlan['ip_arp_cache_tmo']) # Enable proxy-arp on this interface v.set_proxy_arp(vxlan['ip_proxy_arp']) -- cgit v1.2.3 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() --- python/vyos/ifconfig.py | 25 ++++++++++--------------- 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 +++--- 7 files changed, 27 insertions(+), 32 deletions(-) (limited to 'src/conf_mode/interface-vxlan.py') diff --git a/python/vyos/ifconfig.py b/python/vyos/ifconfig.py index 5fa9f4f2b..d10015e2d 100644 --- a/python/vyos/ifconfig.py +++ b/python/vyos/ifconfig.py @@ -60,7 +60,6 @@ class Interface: >>> i = Interface('eth0') """ self._ifname = str(ifname) - self._state = 'down' if not os.path.exists('/sys/class/net/{}'.format(ifname)) and not type: raise Exception('interface "{}" not found'.format(self._ifname)) @@ -266,35 +265,31 @@ class Interface: self._write_sysfs('/sys/class/net/{}/ifalias' .format(self._ifname), ifalias) - @property - def state(self): + def get_state(self): """ Enable (up) / Disable (down) an interface Example: >>> from vyos.ifconfig import Interface - >>> Interface('eth0').state + >>> Interface('eth0').get_state() 'up' """ return self._read_sysfs('/sys/class/net/{}/operstate' .format(self._ifname)) - @state.setter - def state(self, state): + def set_state(self, state): """ Enable (up) / Disable (down) an interface Example: >>> from vyos.ifconfig import Interface - >>> Interface('eth0').state = 'down' - >>> Interface('eth0').state + >>> Interface('eth0').set_state('down') + >>> Interface('eth0').get_state() 'down' """ if state not in ['up', 'down']: raise ValueError('state must be "up" or "down"') - self._state = state - # Assemble command executed on system. Unfortunately there is no way # to up/down an interface via sysfs cmd = 'ip link set dev {} {}'.format(self._ifname, state) @@ -468,7 +463,7 @@ class Interface: with open(self._dhcp_cfg_file, 'w') as f: f.write(dhcp_text) - if self._state == 'up': + if self.get_state() == 'up': cmd = 'start-stop-daemon --start --quiet --pidfile ' + \ self._dhcp_pid_file cmd += ' --exec /sbin/dhclient --' @@ -546,7 +541,7 @@ class Interface: with open(self._dhcpv6_cfg_file, 'w') as f: f.write(dhcpv6_text) - if self._state == 'up': + if self.get_state() == 'up': # https://bugs.launchpad.net/ubuntu/+source/ifupdown/+bug/1447715 # # wee need to wait for IPv6 DAD to finish once and interface is added @@ -1115,7 +1110,7 @@ class BondIf(VLANIf): for s in self.get_slaves(): slave = { 'ifname' : s, - 'state': Interface(s).state + 'state': Interface(s).get_state() } slave_list.append(slave) @@ -1126,7 +1121,7 @@ class BondIf(VLANIf): # physical interface for slave in slave_list: i = Interface(slave['ifname']) - i.state = slave['state'] + i.set_state(slave['state']) @property def xmit_hash_policy(self): @@ -1301,7 +1296,7 @@ class BondIf(VLANIf): # An interface can only be added to a bond if it is in 'down' state. If # interface is in 'up' state, the following Kernel error will be thrown: # bond0: eth1 is up - this may be due to an out of date ifenslave. - Interface(interface).state = 'down' + Interface(interface).set_state('down') return self._write_sysfs('/sys/class/net/{}/bonding/slaves' .format(self._ifname), '+' + interface) 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