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

support for 40G/100G optical information #208

Merged
merged 33 commits into from
Sep 29, 2017

Conversation

ckishimo
Copy link
Contributor

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:

juniper> show interfaces diagnostics optics et-0/0/50 
Physical interface: et-0/0/50
    Module temperature                        :  34 degrees C / 94 degrees F
    Module voltage                            :  3.2730 V
    Module temperature high alarm             :  Off
    Module temperature low alarm              :  Off
    Module temperature high warning           :  Off
    Module temperature low warning            :  Off
    Module voltage high alarm                 :  Off
    Module voltage low alarm                  :  Off
    Module voltage high warning               :  Off
    Module voltage low warning                :  Off
    Module temperature high alarm threshold   :  75 degrees C / 167 degrees F
    Module temperature low alarm threshold    :  -5 degrees C / 23 degrees F
    Module temperature high warning threshold :  70 degrees C / 158 degrees F
    Module temperature low warning threshold  :  0 degrees C / 32 degrees F
    Module voltage high alarm threshold       :  3.6300 V
    Module voltage low alarm threshold        :  2.9700 V
    Module voltage high warning threshold     :  3.4640 V
    Module voltage low warning threshold      :  3.1340 V
    Laser bias current high alarm threshold   :  9.999 mA
    Laser bias current low alarm threshold    :  0.499 mA
    Laser bias current high warning threshold :  9.499 mA
    Laser bias current low warning threshold  :  0.999 mA
    Laser output power high alarm threshold   :  Not supported
    Laser output power low alarm threshold    :  Not supported
    Laser output power high warning threshold :  Not supported
    Laser output power low warning threshold  :  Not supported
    Laser rx power high alarm threshold       :  2.1878 mW / 3.40 dBm
    Laser rx power low alarm threshold        :  0.0446 mW / -13.51 dBm
    Laser rx power high warning threshold     :  1.7378 mW / 2.40 dBm
    Laser rx power low warning threshold      :  0.1122 mW / -9.50 dBm
  Lane 0
    Laser bias current                        :  6.677 mA
    Laser output power                        :  0.763 mW / -1.17 dBm
    Laser receiver power                      :  0.759 mW / -1.20 dBm
    Laser bias current high alarm             :  Off
    Laser bias current low alarm              :  Off
    Laser bias current high warning           :  Off
    Laser bias current low warning            :  Off
    Laser receiver power high alarm           :  Off
    Laser receiver power low alarm            :  Off
    Laser receiver power high warning         :  Off
    Laser receiver power low warning          :  Off
    Tx loss of signal functionality alarm     :  Off
    Rx loss of signal alarm                   :  Off
    Tx laser disabled alarm                   :  Off
  Lane 1
    Laser bias current                        :  6.705 mA
    Laser output power                        :  0.834 mW / -0.79 dBm
    Laser receiver power                      :  0.719 mW / -1.43 dBm
    Laser bias current high alarm             :  Off
    Laser bias current low alarm              :  Off
    Laser bias current high warning           :  Off
    Laser bias current low warning            :  Off
    Laser receiver power high alarm           :  Off
    Laser receiver power low alarm            :  Off
    Laser receiver power high warning         :  Off
    Laser receiver power low warning          :  Off
    Tx loss of signal functionality alarm     :  Off
    Rx loss of signal alarm                   :  Off
    Tx laser disabled alarm                   :  Off
  Lane 2
    Laser bias current                        :  6.921 mA
    Laser output power                        :  0.823 mW / -0.84 dBm
    Laser receiver power                      :  0.744 mW / -1.29 dBm
    Laser bias current high alarm             :  Off
    Laser bias current low alarm              :  Off
    Laser bias current high warning           :  Off
    Laser bias current low warning            :  Off
    Laser receiver power high alarm           :  Off
    Laser receiver power low alarm            :  Off
    Laser receiver power high warning         :  Off
    Laser receiver power low warning          :  Off
    Tx loss of signal functionality alarm     :  Off
    Rx loss of signal alarm                   :  Off
    Tx laser disabled alarm                   :  Off
  Lane 3
    Laser bias current                        :  6.972 mA
    Laser output power                        :  0.814 mW / -0.89 dBm
    Laser receiver power                      :  0.752 mW / -1.23 dBm
    Laser bias current high alarm             :  Off
    Laser bias current low alarm              :  Off
    Laser bias current high warning           :  Off
    Laser bias current low warning            :  Off
    Laser receiver power high alarm           :  Off
    Laser receiver power low alarm            :  Off
    Laser receiver power high warning         :  Off
    Laser receiver power low warning          :  Off
    Tx loss of signal functionality alarm     :  Off
    Rx loss of signal alarm                   :  Off
    Tx laser disabled alarm                   :  Off

The output from the get_optics() method:

{
    "et-0/0/50": {
        "physical_channels": {
            "channel": [
                {
                    "index": 0, 
                    "state": {
                        "input_power": {
                            "avg": 0.0, 
                            "instant": -1.22, 
                            "max": 0.0, 
                            "min": 0.0
                        }, 
                        "laser_bias_current": {
                            "avg": 0.0, 
                            "instant": 6.679, 
                            "max": 0.0, 
                            "min": 0.0
                        }, 
                        "output_power": {
                            "avg": 0.0, 
                            "instant": -1.14, 
                            "max": 0.0, 
                            "min": 0.0
                        }
                    }
                }, 
                {
                    "index": 1, 
                    "state": {
                        "input_power": {
                            "avg": 0.0, 
                            "instant": -1.46, 
                            "max": 0.0, 
                            "min": 0.0
                        }, 
                        "laser_bias_current": {
                            "avg": 0.0, 
                            "instant": 6.659, 
                            "max": 0.0, 
                            "min": 0.0
                        }, 
                        "output_power": {
                            "avg": 0.0, 
                            "instant": -0.81, 
                            "max": 0.0, 
                            "min": 0.0
                        }
                    }
                }, 
                {
                    "index": 2, 
                    "state": {
                        "input_power": {
                            "avg": 0.0, 
                            "instant": -1.29, 
                            "max": 0.0, 
                            "min": 0.0
                        }, 
                        "laser_bias_current": {
                            "avg": 0.0, 
                            "instant": 6.973, 
                            "max": 0.0, 
                            "min": 0.0
                        }, 
                        "output_power": {
                            "avg": 0.0, 
                            "instant": -0.85, 
                            "max": 0.0, 
                            "min": 0.0
                        }
                    }
                }, 
                {
                    "index": 3, 
                    "state": {
                        "input_power": {
                            "avg": 0.0, 
                            "instant": -1.22, 
                            "max": 0.0, 
                            "min": 0.0
                        }, 
                        "laser_bias_current": {
                            "avg": 0.0, 
                            "instant": 6.934, 
                            "max": 0.0, 
                            "min": 0.0
                        }, 
                        "output_power": {
                            "avg": 0.0, 
                            "instant": -0.9, 
                            "max": 0.0, 
                            "min": 0.0
                        }
                    }
                }
            ]
        }
   },
}

The output before was:

{
    "et-0/0/50": {
        "physical_channels": {
            "channel": [
                {
                    "index": 0, 
                    "state": {
                        "input_power": {
                            "avg": 0.0, 
                            "instant": 0.0, 
                            "max": 0.0, 
                            "min": 0.0
                        }, 
                        "laser_bias_current": {
                            "avg": 0.0, 
                            "instant": 0.0, 
                            "max": 0.0, 
                            "min": 0.0
                        }, 
                        "output_power": {
                            "avg": 0.0, 
                            "instant": 0.0, 
                            "max": 0.0, 
                            "min": 0.0
                        }
                    }
                }
            ]
        }
    }, 
}

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

dbarrosop and others added 27 commits September 10, 2016 13:33
Merging develop into master for the new testing framework
@@ -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]), ...]
Copy link
Member

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

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling c6cf072 on ckishimo:develop into ** on napalm-automation:develop**.

Copy link
Member

@mirceaulinic mirceaulinic left a 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.

@@ -444,7 +444,9 @@ def _get_address_family(table):
'inet6': 'ipv6',
'inetflow': 'flow'
}
print("Table: %s" % table)
Copy link
Member

Choose a reason for hiding this comment

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

Please remove these print

for item in optics_40Gitems:
lane = item[0]
iface = item[1].pop(0)
new_optics_40Gitems.append((iface[1], unicode(lane), item[1]))
Copy link
Member

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.

@mirceaulinic mirceaulinic added this to the 0.12.1 milestone Sep 27, 2017
@mirceaulinic mirceaulinic requested a review from a team September 27, 2017 10:42
@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 214d1c6 on ckishimo:develop into ** on napalm-automation:develop**.

@coveralls
Copy link

coveralls commented Sep 27, 2017

Coverage Status

Changes Unknown when pulling 708bed7 on ckishimo:develop into ** on napalm-automation:develop**.

for intf_optic_item in optics_items:
a = list(intf_optic_item)
a.insert(1, u"0")
new_intf_optic_item = tuple(a)
Copy link
Member

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)

Copy link
Contributor Author

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 !

Copy link
Member

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).

Copy link
Member

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.

@coveralls
Copy link

coveralls commented Sep 29, 2017

Coverage Status

Changes Unknown when pulling 4875a48 on ckishimo:develop into ** on napalm-automation:develop**.

@coveralls
Copy link

coveralls commented Sep 29, 2017

Coverage Status

Changes Unknown when pulling 4875a48 on ckishimo:develop into ** on napalm-automation:develop**.

@mirceaulinic mirceaulinic merged commit 21c3512 into napalm-automation:develop Sep 29, 2017
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.

4 participants