Skip to content
This repository was archived by the owner on Feb 10, 2018. It is now read-only.

Commit

Permalink
Merge pull request #211 from ckishimo/devel-psu
Browse files Browse the repository at this point in the history
Improve power supply information in get_enviornment()
  • Loading branch information
mirceaulinic authored Oct 10, 2017
2 parents 0fbda09 + 35bb0e5 commit b087b8b
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
17 changes: 16 additions & 1 deletion napalm_junos/junos.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ def get_environment(self):
environment = junos_views.junos_enviroment_table(self.device)
routing_engine = junos_views.junos_routing_engine_table(self.device)
temperature_thresholds = junos_views.junos_temperature_thresholds(self.device)
power_supplies = junos_views.junos_pem_table(self.device)
environment.get()
routing_engine.get()
temperature_thresholds.get()
Expand All @@ -347,7 +348,6 @@ def get_environment(self):
environment_data['power'] = {}
environment_data['power'][sensor_object] = {}

# Set these values to -1, because Junos does not provide them
environment_data['power'][sensor_object]['capacity'] = -1.0
environment_data['power'][sensor_object]['output'] = -1.0

Expand Down Expand Up @@ -399,6 +399,21 @@ def get_environment(self):
elif structured_temperature_data['yellow-alarm'] <= temp:
environment_data['temperature'][sensor_object]['is_alert'] = True

# Try to correct Power Supply information
pem_table = dict()
try:
power_supplies.get()
except RpcError:
# Not all platforms have support for this
pass
else:
# Format PEM information and correct capacity and output values
for pem in power_supplies.items():
pem_name = pem[0].replace("PEM", "Power Supply")
pem_table[pem_name] = dict(pem[1])
environment_data['power'][pem_name]['capacity'] = pem_table[pem_name]['capacity']
environment_data['power'][pem_name]['output'] = pem_table[pem_name]['output']

for routing_engine_object, routing_engine_data in routing_engine.items():
structured_routing_engine_data = {k: v for k, v in routing_engine_data}
# Create dicts for 'cpu' and 'memory'.
Expand Down
12 changes: 12 additions & 0 deletions napalm_junos/utils/junos_views.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,18 @@ junos_enviroment_view:
status: status
temperature: { temperature/@celsius: int }

junos_pem_table:
rpc: get-power-usage-information-detail
args:
item: power-usage-item
key: name
view: junos_pem_view

junos_pem_view:
fields:
capacity: { pem-capacity-detail/capacity-actual: float }
output: { dc-output-detail/dc-power: float }

junos_routing_engine_table:
rpc: get-route-engine-information
args:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<power-usage-information>
<power-usage-item>
</power-usage-item>
</power-usage-information>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<power-usage-information>
<power-usage-item>
</power-usage-item>
</power-usage-information>

0 comments on commit b087b8b

Please sign in to comment.