summaryrefslogtreecommitdiff
path: root/python/vyos/ifconfig
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-03-20 16:19:21 +0100
committerGitHub <noreply@github.com>2020-03-20 16:19:21 +0100
commitf5a5befd7625b5acb9122236a3e14722581d6527 (patch)
treec60c1b671698eda08cd06b8ac367cfd984b6ac4e /python/vyos/ifconfig
parentaca6154bfd25cf62dbbce21d6a3bf56024f62035 (diff)
parentafe80145e280509e8d9fa4dcf926f0ed98b34fa9 (diff)
downloadvyos-1x-f5a5befd7625b5acb9122236a3e14722581d6527.tar.gz
vyos-1x-f5a5befd7625b5acb9122236a3e14722581d6527.zip
Merge pull request #252 from thomas-mangin/T2057-state
ifconfig: T2057: make set_state use set_interface
Diffstat (limited to 'python/vyos/ifconfig')
-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):
"""