summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorThomas Mangin <thomas.mangin@exa.net.uk>2020-03-20 13:57:27 +0000
committerThomas Mangin <thomas.mangin@exa.net.uk>2020-03-20 14:44:34 +0000
commitafe80145e280509e8d9fa4dcf926f0ed98b34fa9 (patch)
treec60c1b671698eda08cd06b8ac367cfd984b6ac4e /python
parentaca6154bfd25cf62dbbce21d6a3bf56024f62035 (diff)
downloadvyos-1x-afe80145e280509e8d9fa4dcf926f0ed98b34fa9.tar.gz
vyos-1x-afe80145e280509e8d9fa4dcf926f0ed98b34fa9.zip
ifconfig: T2057: make set_state use set_interface
Diffstat (limited to 'python')
-rw-r--r--python/vyos/ifconfig/interface.py12
1 files changed, 5 insertions, 7 deletions
diff --git a/python/vyos/ifconfig/interface.py b/python/vyos/ifconfig/interface.py
index b002e0171..bb6c33f5f 100644
--- a/python/vyos/ifconfig/interface.py
+++ b/python/vyos/ifconfig/interface.py
@@ -77,6 +77,10 @@ class Interface(Control):
}
_command_set = {
+ 'state': {
+ 'validate': lambda v: assert_list(v, ['up', 'down']),
+ 'shellcmd': 'ip link set dev {ifname} {value}',
+ },
'mac': {
'validate': assert_mac,
'shellcmd': 'ip link set dev {ifname} address {value}',
@@ -452,13 +456,7 @@ class Interface(Control):
>>> Interface('eth0').get_state()
'down'
"""
- if state not in ['up', 'down']:
- raise ValueError('state must be "up" or "down"')
-
- # Assemble command executed on system. Unfortunately there is no way
- # to up/down an interface via sysfs
- cmd = 'ip link set dev {} {}'.format(self.config['ifname'], state)
- return self._cmd(cmd)
+ return self.set_interface('state', state)
def set_proxy_arp(self, enable):
"""