diff options
author | Christian Poessinger <christian@poessinger.com> | 2020-03-23 15:58:39 +0100 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2020-03-23 15:58:41 +0100 |
commit | aa1b14d6ee8845ecd94565d9f33748c9b2eb9489 (patch) | |
tree | 2fdb1c44fccbedc42cdfe6a16acf4ddcca14811d | |
parent | 02d12b89d48416971941a063e620f9055ac0b07c (diff) | |
download | vyos-1x-aa1b14d6ee8845ecd94565d9f33748c9b2eb9489.tar.gz vyos-1x-aa1b14d6ee8845ecd94565d9f33748c9b2eb9489.zip |
ifconfig: T2151: get_state() must use administrative state and not operstate
... as set_state() changes the interface administrative state, too!
-rw-r--r-- | python/vyos/ifconfig/interface.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/python/vyos/ifconfig/interface.py b/python/vyos/ifconfig/interface.py index 8fe0de921..18256cf99 100644 --- a/python/vyos/ifconfig/interface.py +++ b/python/vyos/ifconfig/interface.py @@ -450,7 +450,7 @@ class Interface(Control): def get_state(self): """ - Enable (up) / Disable (down) an interface + Get interface administrative state. Function will return 'up' or 'down' Example: >>> from vyos.ifconfig import Interface @@ -460,11 +460,16 @@ class Interface(Control): cmd = 'ip -json link show dev {}'.format(self.config['ifname']) tmp = self._cmd(cmd) out = json.loads(tmp) - return out[0]['operstate'].lower() + + state = 'down' + if 'UP' in out[0]['flags']: + state = 'up' + + return state def set_state(self, state): """ - Enable (up) / Disable (down) an interface + Set interface administrative state to be 'up' or 'down' Example: >>> from vyos.ifconfig import Interface |