-
Notifications
You must be signed in to change notification settings - Fork 9
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
Environment Support #25
base: development
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
"""Get the environment variables of the switch/es""" | ||
|
||
import logging | ||
|
||
from napalm.base.helpers import textfsm_extractor | ||
|
||
logger = logging.getLogger("arubaoss.helper.get_environment") | ||
|
||
|
||
def get_environment(self): | ||
""" | ||
Get device's Environment table. | ||
|
||
:param self: object from class | ||
:return: | ||
""" | ||
|
||
out = { | ||
"fans": {}, | ||
"temperature": {}, | ||
"power": {}, | ||
"cpu": {}, | ||
"memory": {} | ||
} | ||
|
||
raw_system = self.connection.run_cmd("show system") | ||
system_list = textfsm_extractor(self, "show_system", raw_system) | ||
|
||
memtotal = 0 | ||
memfree = 0 | ||
|
||
for switch in system_list: | ||
member = switch.pop("member") | ||
if member == "": | ||
member = 0 | ||
else: | ||
member = "Member " + member | ||
|
||
out["cpu"][member] = { | ||
"%usage": float(switch.pop("cpu")) | ||
} | ||
|
||
memtotal += int(switch.pop("memtotal").replace(',', '')) | ||
memfree += int(switch.pop("memfree").replace(',', '')) | ||
Comment on lines
+33
to
+44
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there any reason for using
Comment on lines
+43
to
+44
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the increment for the stack switches use-case ? If that's the case I think it's probably better to report back the memory of the device running the control-plane/primary-switch instead of the sum of the whole stack. |
||
|
||
out["memory"] = { | ||
"available_ram": int(memtotal), | ||
"used_ram": int(memfree) | ||
} | ||
|
||
raw_system_fans = self.connection.run_cmd("show system fans") | ||
system_fans_list = textfsm_extractor(self, "show_system_fans", raw_system_fans) | ||
for fan in system_fans_list: | ||
member = fan.pop("member") | ||
if member != "": | ||
member = "Member " + member + " " | ||
|
||
out["fans"][member + fan.pop('location') + " " + fan.pop('num')] = { | ||
"status": True if fan.pop('state') == "Fan OK" else False | ||
} | ||
|
||
raw_system_temperature = self.connection.run_cmd("show system temperature") | ||
system_temperature_list = textfsm_extractor(self, "show_system_temperature", raw_system_temperature) | ||
for temp in system_temperature_list: | ||
member = temp.pop("member") | ||
if member != "": | ||
member = "Member " + member + " " | ||
|
||
overtemp = True if temp.pop('overtemp') == "YES" else False | ||
|
||
out["temperature"][member + temp.pop('sensor')] = { | ||
"temperature": float(temp.pop('temperature')), | ||
"is_alert": overtemp, | ||
"is_critical": overtemp | ||
} | ||
|
||
raw_system_power = self.connection.run_cmd("show system power-supply") | ||
system_power_list = textfsm_extractor(self, "show_system_power-supply", raw_system_power) | ||
for power in system_power_list: | ||
member = power.pop("member") | ||
if member != "": | ||
member = "Member " + member + " " | ||
|
||
out["power"][member + power.pop('ps')] = { | ||
"status": True if power.pop('state') == "Powered" else False, | ||
"capacity": float(power.pop('max')), | ||
"output": float(power.pop('wattage')) | ||
} | ||
|
||
return out |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Value Filldown Member (\d) | ||
Value Required CPU (\d+) | ||
Value MemTotal (.{5,}) | ||
Value MemFree (.{5,}) | ||
|
||
Start | ||
^.*General System -> System | ||
|
||
System | ||
^\s+Member\s+:${Member} | ||
^.*Total\s+:\s${MemTotal} | ||
^.*CPU\sUtil\s\(%\)\s+:\s${CPU} -> Continue | ||
^.*Free\s+:\s${MemFree} -> Record |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Value Filldown Member (\d) | ||
Value Required NUM (\S+) | ||
Value STATE (\S+\s+\S+) | ||
Value FAILURES (\d+) | ||
Value LOCATION (\S+) | ||
|
||
Start | ||
^.*Fan Information -> Fans | ||
|
||
Fans | ||
^Member\s+${Member} | ||
^${NUM}\s+\|\s+${STATE}\s+\|\s+${FAILURES}\s+\|\s+${LOCATION} -> Record |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
Value Member (\d) | ||
Value PS (\d) | ||
Value State (\S+) | ||
Value Wattage (\d+) | ||
Value Max (\d+) | ||
|
||
Start | ||
^.*Member\s+PS#\s+Model\s+Serial\s+State\s+AC\/DC\s+\+\sV\s+Wattage\s+Max -> Member | ||
^.*PS#\s+Model\s+Serial\s+State\s+AC\/DC\s+\+\sV\s+Wattage\s+Max -> Standalone | ||
|
||
Standalone | ||
^ ${PS}\s+\S+\s+\S+\s+${State}\s+\S\S\s\d+\S+\d+\S\s+${Wattage}\s+${Max} -> Record | ||
|
||
Member | ||
^ ${Member}\s+${PS}\s+\S+\s+\S+\s+${State}\s+\S\S\s\d+\S+\d+\S\s+${Wattage}\s+${Max} -> Record |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Value Filldown Member (\d) | ||
Value Required Sensor (\S+) | ||
Value Temperature (\d+) | ||
Value OverTemp (YES|NO) | ||
|
||
Start | ||
^.*Air -> Temperature | ||
|
||
Temperature | ||
^ Member ${Member} | ||
^ ${Sensor}\s+${Temperature}\S\s+\d+\S\s+\d+\S\s+\d+\S\s+${OverTemp} -> Record |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"show system": "\n Status and Counters - General System Information\n\n System Name : Name\n System Contact : Contact\n System Location : Location\n\n MAC Age Time (sec) : 300\n\n Time Zone : 0\n Daylight Time Rule : None\n\n Software revision : WC.16.11.0001 Base MAC Addr : 1a3b3c-4d5e6f\n ROM Version : WC.17.02.0007 Serial Number : NANANANANA\n\n Up Time : 68 days Memory - Total : 338,190,848\n CPU Util (%) : 0 Free : 177,716,208\n\n IP Mgmt - Pkts Rx : 260,263 Packet - Total : 6600\n Pkts Tx : 263,776 Buffers Free : 4347\n Lowest : 4216\n Missed : 0\n\n", | ||
"show system fans": "\nFan Information\n Num | State | Failures | Location\n-------+-------------+----------+----------\nFan-1 | Fan OK | 0 | Chassis\nFan-2 | Fan OK | 0 | Chassis\nFan-3 | Fan OK | 0 | Chassis\nFan-4 | Fan OK | 0 | PS 1\nFan-5 | Fan OK | 0 | PS 2\n\n0 / 5 Fans in Failure State\n0 / 5 Fans have been in Failure State\n\n", | ||
"show system temperature": "\n System Air Temperature\n Temp Current Max Min\n Sensor Temp Temp Temp Threshold OverTemp\n ------- -------- ----- ----- ---------- ---------\n Chassis 12C 17C 10C 50C NO\n\n", | ||
"show system power-supply": "\nPower Supply Status:\n\n PS# Model Serial State AC/DC + V Wattage Max\n ----- --------- ----------- --------------- ----------------- --------- ------\n 1 JL086A NANANANANA Powered AC 120V/240V 14 680\n 2 JL086A NANANANANA Powered AC 120V/240V 19 680\n\n\n 2 / 2 supply bays delivering power.\n Currently supplying 33 W / 1360 W total power.\n\n" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
{ | ||
"fans": { | ||
"Chassis Fan-1": { | ||
"status": true | ||
}, | ||
"Chassis Fan-2": { | ||
"status": true | ||
}, | ||
"Chassis Fan-3": { | ||
"status": true | ||
}, | ||
"PS Fan-4": { | ||
"status": true | ||
}, | ||
"PS Fan-5": { | ||
"status": true | ||
} | ||
}, | ||
"temperature": { | ||
"Chassis": { | ||
"temperature": 12, | ||
"is_alert": false, | ||
"is_critical": false | ||
} | ||
}, | ||
"power": { | ||
"1": { | ||
"status": true, | ||
"capacity": 680, | ||
"output": 14 | ||
}, | ||
"2": { | ||
"status": true, | ||
"capacity": 680, | ||
"output": 19 | ||
} | ||
}, | ||
"cpu": { | ||
"0": { | ||
"%usage": 0 | ||
} | ||
}, | ||
"memory": { | ||
"available_ram": 338190848, | ||
"used_ram": 177716208 | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"show system": "\n Status and Counters - General System Information\n\n System Name : Switch101\n System Contact : Contact\n System Location : Location\n MAC Age Time (sec) : 300\n Time Zone : 0\n Daylight Time Rule : None\n\n Software revision : WC.16.11.0014\n Base MAC Addr : 1a3b3c-4d5e6f\n\n Member :1\n\n ROM Version : WC.17.02.0007\n Up Time : 119 days\n CPU Util (%) : 2\n MAC Addr : 1a3b3c-4d5e6f\n Serial Number : NANANANANA\n Memory - Total : 333,533,696\n Free : 169,758,520\n\n\n\n Member :2\n\n ROM Version : WC.17.02.0007\n Up Time : 11 days\n CPU Util (%) : 0\n MAC Addr : 1a3b3c-4d5e6f\n Serial Number : NANANANANA\n Memory - Total : 333,533,696\n Free : 186,152,132\n", | ||
"show system fans": "\nFan Information\n\nMember 1\n\n Num | State | Failures | Location\n-------+-------------+----------+----------\nSys-1 | Fan OK | 0 | Chassis\nSys-2 | Fan OK | 0 | Chassis\nSys-3 | Fan OK | 0 | Chassis\nSys-4 | Fan OK | 0 | PS 1\nSys-5 | Fan OK | 0 | PS 2\n\n0 / 5 Fans in Failure State\n0 / 5 Fans have been in Failure State\n\nMember 2\n\n Num | State | Failures | Location\n-------+-------------+----------+----------\nSys-1 | Fan OK | 0 | Chassis\nSys-2 | Fan OK | 0 | Chassis\nSys-3 | Fan OK | 0 | Chassis\nSys-4 | Fan OK | 0 | PS 1\nSys-5 | Fan OK | 0 | PS 2\n\n0 / 5 Fans in Failure State\n0 / 5 Fans have been in Failure State\n", | ||
"show system temperature": "\n System Air Temperatures\n\n Member 1\n\n Temp Current Max Min\n Sensor Temp Temp Temp Threshold OverTemp\n ------- -------- ----- ----- ---------- ---------\n Chassis 26C 26C 19C 55C NO\n\n\n Member 2\n\n Temp Current Max Min\n Sensor Temp Temp Temp Threshold OverTemp\n ------- -------- ----- ----- ---------- ---------\n Chassis 27C 27C 20C 50C NO\n\n\n", | ||
"show system power-supply": "\nPower Supply Status:\n\n Member PS# Model Serial State AC/DC + V Wattage Max\n ------- ----- --------- ----------- --------------- ----------------- --------- ------\n 1 1 JL086A NANANANANA Powered AC 120V/240V 79 680\n 1 2 JL086A NANANANANA Powered AC 120V/240V 66 680\n 2 1 JL086A NANANANANA Powered AC 120V/240V 29 680\n 2 2 JL086A NANANANANA Powered AC 120V/240V 38 680" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
{ | ||
"fans": { | ||
"Member 1 Chassis Sys-1": { | ||
"status": true | ||
}, | ||
"Member 1 Chassis Sys-2": { | ||
"status": true | ||
}, | ||
"Member 1 Chassis Sys-3": { | ||
"status": true | ||
}, | ||
"Member 1 PS Sys-4": { | ||
"status": true | ||
}, | ||
"Member 1 PS Sys-5": { | ||
"status": true | ||
}, | ||
"Member 2 Chassis Sys-1": { | ||
"status": true | ||
}, | ||
"Member 2 Chassis Sys-2": { | ||
"status": true | ||
}, | ||
"Member 2 Chassis Sys-3": { | ||
"status": true | ||
}, | ||
"Member 2 PS Sys-4": { | ||
"status": true | ||
}, | ||
"Member 2 PS Sys-5": { | ||
"status": true | ||
} | ||
}, | ||
"temperature": { | ||
"Member 1 Chassis": { | ||
"temperature": 26, | ||
"is_alert": false, | ||
"is_critical": false | ||
}, | ||
"Member 2 Chassis": { | ||
"temperature": 27, | ||
"is_alert": false, | ||
"is_critical": false | ||
} | ||
}, | ||
"power": { | ||
"Member 1 1": { | ||
"status": true, | ||
"capacity": 680, | ||
"output": 79 | ||
}, | ||
"Member 1 2": { | ||
"status": true, | ||
"capacity": 680, | ||
"output": 66 | ||
}, | ||
"Member 2 1": { | ||
"status": true, | ||
"capacity": 680, | ||
"output": 29 | ||
}, | ||
"Member 2 2": { | ||
"status": true, | ||
"capacity": 680, | ||
"output": 38 | ||
} | ||
}, | ||
"cpu": { | ||
"Member 1": { | ||
"%usage": 2 | ||
}, | ||
"Member 2": { | ||
"%usage": 0 | ||
} | ||
}, | ||
"memory": { | ||
"available_ram": 667067392, | ||
"used_ram": 355910652 | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Value Filldown Member (\d) | ||
Value Required CPU (\d+) | ||
Value MemTotal (.{5,}) | ||
Value MemFree (.{5,}) | ||
|
||
Start | ||
^.*General System -> System | ||
|
||
System | ||
^\s+Member\s+:${Member} | ||
^.*Total\s+:\s${MemTotal} | ||
^.*CPU\sUtil\s\(%\)\s+:\s${CPU} -> Continue | ||
^.*Free\s+:\s${MemFree} -> Record |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Value Filldown Member (\d) | ||
Value Required NUM (\S+) | ||
Value STATE (\S+\s+\S+) | ||
Value FAILURES (\d+) | ||
Value LOCATION (\S+) | ||
|
||
Start | ||
^.*Fan Information -> Fans | ||
|
||
Fans | ||
^Member\s+${Member} | ||
^${NUM}\s+\|\s+${STATE}\s+\|\s+${FAILURES}\s+\|\s+${LOCATION} -> Record |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this coming from a different change? seems unrelated to the PR.