Closed bkeifer closed 7 years ago
Would you mind adding tests? Just add an extra folder here with the relevant mocked data:
Getting sucked into a meeting. Will take care of the build errors later.
Getting sucked into a meeting.
Have fun @bkeifer
I'm back to the original conditional logic. Here's why:
This line, suggested by @dbarrosop will update the object with the correct class name.
structured_object_data['class'] = structured_object_data['class'] or current_class
However, since Juniper only gives us a 'class' for the first instance of an object of that class, we also need to track when we see a new class name to let us know that the following data is about a different class of object. That's where the else:
and current_class comes in.
I've added some comments to hopefully explain whats going on a bit better, and Travis seems happier now.
…or each entry.
The get-environment-information RPC output corresponds to the "show chassis environment" CLI command. The output from this command in a multi-chassis EX switch environment is as follows:
That's all well and good on the command line, but the RPC output seems to correspond to the CLI output a bit too faithfully. PrettyPrinting from within the napalm-junos module reveals the structure:
Note that each power supply, temperature sensor, or fan after those in the first chassis are given a 'class' of None, likely taken straight from the human-readable output of the CLI command.
This patch modifies the behavior of the main loop within get_environment() so that if a sensor object is encountered with a 'class' of None, the previous valid class is used.
This works on all models of EX switch that I have access to test against. Testing against other JunOS platforms is likely warranted.