Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fixing get_interfaces() to support interfaces without line pro… #37

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions napalm_huawei_vrp/huawei_vrp.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ def get_environment(self):
# 定义执行命令
fan_cmd = "display fan"
"""
Slot FanID Online Status Speed Mode Airflow
Slot FanID Online Status Speed Mode Airflow
-------------------------------------------------------------------------
0 1 Present Normal 55% Auto Side-to-Back
1 1 Present Normal 55% Auto Side-to-Back
Expand All @@ -321,10 +321,10 @@ def get_environment(self):
------------------------------------------------------------
Slot PowerID Online Mode State Power(W)
------------------------------------------------------------
0 PWR1 Present AC Supply 600.00
0 PWR2 Present AC Supply 600.00
1 PWR1 Present AC Supply 600.00
1 PWR2 Present AC Supply 600.00
0 PWR1 Present AC Supply 600.00
0 PWR2 Present AC Supply 600.00
1 PWR1 Present AC Supply 600.00
1 PWR2 Present AC Supply 600.00
"""
temp_cmd = "display temperature all"
"""
Expand All @@ -339,7 +339,7 @@ def get_environment(self):
"""
CPU Usage Stat. Cycle: 60 (Second)
CPU Usage : 28% Max: 87%
CPU Usage Stat. Time : 2022-01-13 18:57:06
CPU Usage Stat. Time : 2022-01-13 18:57:06
CPU utilization for five seconds: 28%: one minute: 28%: five minutes: 20%
Max CPU Usage Stat. Time : 2021-10-05 17:50:44.
"""
Expand Down Expand Up @@ -618,15 +618,17 @@ def get_interfaces(self):
match_intf = re.search(re_intf_name_state, interface, flags=re.M)
match_proto = re.search(re_protocol, interface, flags=re.M)

if match_intf is None or match_proto is None:
if match_intf is None:
msg = "Unexpected interface format: {}".format(interface)
raise ValueError(msg)
intf_name = match_intf.group("intf_name")
intf_state = match_intf.group("intf_state")
is_enabled = bool("up" in intf_state.lower())

protocol = match_proto.group("protocol")
is_up = bool("up" in protocol.lower())
is_up = False
if match_proto:
protocol = match_proto.group("protocol")
is_up = bool("up" in protocol.lower())

match_mac = re.search(re_mac, interface, flags=re.M)
if match_mac:
Expand Down