Fix for LLDP portname issue (#2886)
* Fix for LLDP portname issue First check for operstate and if its not present then check for ifindex * Addressing review comments
This commit is contained in:
parent
f32243b334
commit
3a8ce5f388
@ -74,11 +74,14 @@ def signal_handler(sig, frame):
|
||||
# ========================== Helpers ==================================
|
||||
|
||||
def is_port_exist(port_name):
|
||||
filename = "/sys/class/net/%s/ifindex" % port_name
|
||||
if not os.path.exists(filename):
|
||||
return False
|
||||
|
||||
return True
|
||||
filename = "/sys/class/net/%s/operstate" % port_name
|
||||
if os.path.exists(filename):
|
||||
with open(filename) as fp:
|
||||
state = fp.read()
|
||||
return "up" in state
|
||||
else:
|
||||
filename = "/sys/class/net/%s/ifindex" % port_name
|
||||
return os.path.exists(filename)
|
||||
|
||||
# ============================== Classes ==============================
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user