-
Notifications
You must be signed in to change notification settings - Fork 42
support for 40G/100G optical information #208
Conversation
Release 0.4.0 Thanks @kderynski @grizz @fooelisa @dbarrosop for contributions!
Release 0.4.2 - master
Release 0.4.3 - master
Merging develop into master for the new testing framework
napalm_junos/junos.py
Outdated
@@ -1763,20 +1763,47 @@ def get_optics(self): | |||
optics_table.get() | |||
optics_items = optics_table.items() | |||
|
|||
# Formatting data into return data structure | |||
optics_detail = {} | |||
# Format data inserting lane 0 for single lane optics. Format: [(iface, lane, [optical_values]), ...] |
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.
pylama is complaining this line is too long
Changes Unknown when pulling c6cf072 on ckishimo:develop into ** on napalm-automation:develop**. |
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.
@ckishimo please remove the print
, and avoid the explicit unicode
call.
napalm_junos/junos.py
Outdated
@@ -444,7 +444,9 @@ def _get_address_family(table): | |||
'inet6': 'ipv6', | |||
'inetflow': 'flow' | |||
} | |||
print("Table: %s" % table) |
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.
Please remove these print
napalm_junos/junos.py
Outdated
for item in optics_40Gitems: | ||
lane = item[0] | ||
iface = item[1].pop(0) | ||
new_optics_40Gitems.append((iface[1], unicode(lane), item[1])) |
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.
Remove unicode. For Python 2-3 compatibility, we recommend using https://github.com/napalm-automation/napalm-base/blob/develop/napalm_base/utils/py23_compat.py#L12, e.g. py23_compat.text_type(lane)
. py23_compat
should already be imported here.
Changes Unknown when pulling 214d1c6 on ckishimo:develop into ** on napalm-automation:develop**. |
Changes Unknown when pulling 708bed7 on ckishimo:develop into ** on napalm-automation:develop**. |
napalm_junos/junos.py
Outdated
for intf_optic_item in optics_items: | ||
a = list(intf_optic_item) | ||
a.insert(1, u"0") | ||
new_intf_optic_item = tuple(a) |
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.
Can you please explain these three lines @ckishimo? (1770, 1771, 1772)
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.
Sure. I'm just inserting the lane 0 for each element of optics_items list, so when later getting the information for 40G/100G optics, all items will have a lane and the format will be:
[ ( interface_name, lane_X, [optical_values_for_lane_X] ) ]
So for instance the first element of the list being:
('xe-0/0/0', [('output_power', '- Inf'), ('laser_bias_current', '38.346'), ('input_power', '- Inf')]),
it will become::
('xe-0/0/0', u'0', [('output_power', '- Inf'), ('laser_bias_current', '38.346'), ('input_power', '- Inf')]),
Then later the list new_optics_40Gitems will have the information for all optics 10G/40G/100G and will be like:
('xe-0/0/0', u'0', [('output_power', '- Inf'), ('laser_bias_current', '38.346'), ('input_power', '- Inf')]),
('et-0/0/49', u'0', [('output_power', '-1.30'), ('laser_bias_current', '6.987'), ('input_power', '-1.24')]),
('et-0/0/49', u'1', [('output_power', '-0.96'), ('laser_bias_current', '6.791'), ('input_power', '-1.19')]),
('et-0/0/49', u'2', [('output_power', '-1.08'), ('laser_bias_current', '6.791'), ('input_power', '-1.00')]),
('et-0/0/49', u'3', [('output_power', '-1.07'), ('laser_bias_current', '6.955'), ('input_power', '-1.17')]),
Once all information is in the same format we can iterate in the last loop...
if that was not clear I'm sure there is a better way of coding that 😃 I'm still newbie ... Let me know. Thanks @mirceaulinic !
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.
Okay, that makes sense - thanks @ckishimo.
As this is not immediately obvious, can you please insert some comments to explain this (what you wrote above works too, eventually a shorter version).
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.
And maybe rename a
to temp_list
or something more descriptive.
Changes Unknown when pulling 4875a48 on ckishimo:develop into ** on napalm-automation:develop**. |
Changes Unknown when pulling 4875a48 on ckishimo:develop into ** on napalm-automation:develop**. |
Just modified the get_optics() method to include the optical information from 40G/100G optics using four different lanes. Not sure that is the best way of doing it but as I wanted to keep the main loop structure I had to re-format the input data a bit. Example:
The output from the get_optics() method:
The output before was:
Note I had to temporary tweak the code to overcome the error #146
'ValueError: could not convert string to float: - Inf'
Let me know. Thanks