diff options
-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 |