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:
Sumukha Tumkur Vani 2019-05-10 14:28:24 -07:00 committed by GitHub
parent f32243b334
commit 3a8ce5f388
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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 ==============================