napalm-automation / napalm-junos

Apache License 2.0
22 stars 42 forks source link

Improve power supply information in get_enviornment() #211

Closed ckishimo closed 7 years ago

ckishimo commented 7 years ago

This PR will improve the output of get_environment(), as the command show chassis power available in some platforms reports capacity and output per power supply

<rpc-reply xmlns:junos="http://xml.juniper.net/junos/17.3R1/junos">
    <rpc>
        <get-power-usage-information>
        </get-power-usage-information>
    </rpc>
    <cli>
        <banner></banner>
    </cli>
</rpc-reply>

Example:

user@juniper> show chassis power                      

PEM 0:
  State:     Online
  Capacity:  2700 W (maximum 2700 W)
  DC output: 612 W (zone 0, 51 A at 12 V, 22% of capacity)

PEM 1:
  State:     Online
  Capacity:  2700 W (maximum 2700 W)
  DC output: 612 W (zone 0, 51 A at 12 V, 22% of capacity)

PEM 2:
  State:     Online
  Capacity:  2700 W (maximum 2700 W)
  DC output: 612 W (zone 0, 51 A at 12 V, 22% of capacity)

PEM 3:
  State:     Online
  Capacity:  2700 W (maximum 2700 W)
  DC output: 624 W (zone 0, 52 A at 12 V, 23% of capacity)

The output from get_environment() will be now:

    "power": {
        "Power Supply 0": {
            "capacity": 2700, 
            "output": 612, 
            "status": true
        }, 
        "Power Supply 1": {
            "capacity": 2700, 
            "output": 612, 
            "status": true
        }, 
        "Power Supply 2": {
            "capacity": 2700, 
            "output": 612, 
            "status": true
        }, 
        "Power Supply 3": {
            "capacity": 2700, 
            "output": 624, 
            "status": true
        }, 
        .....

Let me know. Thanks

mirceaulinic commented 7 years ago

Okay, this seems to break the test case for the virtual chassis, as virtual chassis most probably don't have the power supply section. Can you please check @ckishimo?

coveralls commented 7 years ago

Coverage Status

Coverage decreased (-0.08%) to 78.766% when pulling 35bb0e584d66c17db2e4cb99fd84741307cc6c30 on ckishimo:devel-psu into 21c3512dbce5676b5a059b389707cb297c5c43d3 on napalm-automation:develop.