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 ==================================
|
# ========================== Helpers ==================================
|
||||||
|
|
||||||
def is_port_exist(port_name):
|
def is_port_exist(port_name):
|
||||||
filename = "/sys/class/net/%s/ifindex" % port_name
|
filename = "/sys/class/net/%s/operstate" % port_name
|
||||||
if not os.path.exists(filename):
|
if os.path.exists(filename):
|
||||||
return False
|
with open(filename) as fp:
|
||||||
|
state = fp.read()
|
||||||
return True
|
return "up" in state
|
||||||
|
else:
|
||||||
|
filename = "/sys/class/net/%s/ifindex" % port_name
|
||||||
|
return os.path.exists(filename)
|
||||||
|
|
||||||
# ============================== Classes ==============================
|
# ============================== Classes ==============================
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user