summaryrefslogtreecommitdiff
path: root/python/vyos/ifconfig.py
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2019-10-18 18:05:46 +0200
committerChristian Poessinger <christian@poessinger.com>2019-10-18 18:05:46 +0200
commitca4f0dc76f918323c69905399a2dba9b2a21a8ec (patch)
treeaef7d94be962cc96a2514fa3a9eb88803e77473a /python/vyos/ifconfig.py
parente4424dce0d387c5f9e9a710369cd5136fcd63c77 (diff)
downloadvyos-1x-ca4f0dc76f918323c69905399a2dba9b2a21a8ec.tar.gz
vyos-1x-ca4f0dc76f918323c69905399a2dba9b2a21a8ec.zip
Python/ifconfig: T1557: get_status() must use admin state not operstate
Diffstat (limited to 'python/vyos/ifconfig.py')
-rw-r--r--python/vyos/ifconfig.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/python/vyos/ifconfig.py b/python/vyos/ifconfig.py
index 0692f77f3..1ffa10978 100644
--- a/python/vyos/ifconfig.py
+++ b/python/vyos/ifconfig.py
@@ -16,6 +16,7 @@
import os
import re
import jinja2
+import json
from vyos.validate import *
from ipaddress import IPv4Network, IPv6Address
@@ -116,7 +117,7 @@ class Interface:
self._debug_msg("returned:\n{}".format(tmp.decode()))
# do we need some error checking code here?
- return tmp
+ return tmp.decode()
def _read_sysfs(self, filename):
"""
@@ -300,8 +301,10 @@ class Interface:
>>> Interface('eth0').get_state()
'up'
"""
- return self._read_sysfs('/sys/class/net/{}/operstate'
- .format(self._ifname))
+ cmd = 'ip -json link show dev {}'.format(self._ifname)
+ tmp = self._cmd(cmd)
+ out = json.loads(tmp)
+ return out[0]['operstate'].lower()
def set_state(self, state):
"""