From 1d8b917fb934060c3d0f79e7039ae3a468f51f2c Mon Sep 17 00:00:00 2001 From: kroy Date: Thu, 24 Oct 2019 12:16:54 -0500 Subject: T1759: ioctl.pm/interface.pm rewrite --- python/vyos/interface.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'python/vyos/interface.py') diff --git a/python/vyos/interface.py b/python/vyos/interface.py index 1aae6db60..cc726e5cc 100644 --- a/python/vyos/interface.py +++ b/python/vyos/interface.py @@ -16,6 +16,8 @@ import vyos from vyos.config import Config import vyos.interfaces +import vyos.ioctl +from vyos.iflag import IFlag import re import json @@ -33,11 +35,18 @@ class Interface(): intf = None intf_type = None valid = False + flags = None def __init__(self,intf): self.intf = intf self.intf_type = vyos.interfaces.get_type_of_interface(self.intf) self.valid = (self.intf in vyos.interfaces.list_interfaces()) + if (self.valid): + self.flags = vyos.ioctl.get_interface_flags(intf) + + def up(self): + """ return whether interface is up or not """ + return self.flags & IFlag.IFF_UP def print_interface(self): -- cgit v1.2.3