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

Improve power supply information in get_enviornment() #211

Merged
merged 8 commits into from
Oct 10, 2017

Conversation

ckishimo
Copy link
Contributor

@ckishimo ckishimo commented Oct 2, 2017

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 mirceaulinic requested a review from a team October 3, 2017 12:13
@mirceaulinic mirceaulinic modified the milestones: 0.12.1, 0.12.2 Oct 3, 2017
try:
power_supplies.get()
except RpcError:
# Not all platforms have support for this
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What platforms have support for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know... I only know it works for a QFX10k but it does not work in the qfx5110-48s-4c. I do not have access to other platforms to test that...

user@juniper> show chassis power 
error: command is not valid on the qfx5110-48s-4c

According to https://www.juniper.net/documentation/en_US/junos/topics/reference/command-summary/show-chassis-power.html this command is supported in the MX (same output), also
supported in the PTX (but the output is different) and EX9200

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, that tends to be very obscure... I check on MX and it is fine.

@mirceaulinic
Copy link
Member

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
Copy link

coveralls commented Oct 10, 2017

Coverage Status

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

@@ -0,0 +1,4 @@
<power-usage-information>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ckishimo if you add this file here, it means a device that does not have this capability, for example your qfx5110-48s-4c, does not error when retrieving this RPC & returns exactly this XML back. Is this correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mirceaulinic not sure I'm following... the qfx5110 does not have this capability but it does not error as the get() is within the try...except clause. The two files I committed are just to pass the failing tests... The qfx5110 will indeed fail when retrieving the RPC:
jnpr.junos.exception.RpcError: RpcError(severity: error, bad_element: None, message: command is not valid on the qfx5110-48s-4c)
I don't have other devices (ie: virtual chassis) to test this more extensively... 😢

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, agreed there's no good way to reproduce a RpcError using mock files.

@mirceaulinic mirceaulinic merged commit b087b8b into napalm-automation:develop Oct 10, 2017
@mirceaulinic mirceaulinic modified the milestones: 0.12.2, 0.12.1 Oct 11, 2017
@ckishimo ckishimo deleted the devel-psu branch October 13, 2017 09:24
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants