From aa1b14d6ee8845ecd94565d9f33748c9b2eb9489 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Mon, 23 Mar 2020 15:58:39 +0100 Subject: ifconfig: T2151: get_state() must use administrative state and not operstate ... as set_state() changes the interface administrative state, too! --- python/vyos/ifconfig/interface.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'python') 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 -- cgit v1.2.3