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

get_facts error with switch stack #176

Closed
lampwins opened this issue Jun 29, 2017 · 6 comments
Closed

get_facts error with switch stack #176

lampwins opened this issue Jun 29, 2017 · 6 comments
Assignees
Labels
Milestone

Comments

@lampwins
Copy link
Contributor

Description of Issue/Question

When calling get_facts() on an EX switch stack where the master and backup routing engines are in node positions greater than 0, napalm bombs as RE0 in the facts output is None. This is mostly an upstream issue in junos-pyez but nonetheless napalm should check this when trying to gather the uptime.

Did you follow the steps from https://github.com/napalm-automation/napalm#faq

[ x ] Yes
[ ] No

Setup

napalm-junos version

(Paste verbatim output from pip freeze | grep napalm-junos between quotes below)

napalm-junos==0.10.3

JunOS version

(Paste verbatim output from show version and haiku between quotes below)
The was observed on two stacks. One is a EX4200 stack and the other is an EX4300 stack. There versions are respectively:

Model: ex4200-24px
JUNOS Base OS boot [12.3R12.4]
JUNOS Base OS Software Suite [12.3R12.4]
JUNOS Kernel Software Suite [12.3R12.4]
JUNOS Crypto Software Suite [12.3R12.4]
JUNOS Online Documentation [12.3R12.4]
JUNOS Enterprise Software Suite [12.3R12.4]
JUNOS Packet Forwarding Engine Enterprise Software Suite [12.3R12.4]
JUNOS Routing Software Suite [12.3R12.4]
JUNOS Web Management [12.3R12.4]
JUNOS FIPS mode utilities [12.3R12.4]


        They now make a soap
        With caffeine infused in it
        'A truly clean buzz'



Model: ex4300-48p
Junos: 14.1X53-D42.3
JUNOS EX  Software Suite [14.1X53-D42.3]
JUNOS FIPS mode utilities [14.1X53-D42.3]
JUNOS Online Documentation [14.1X53-D42.3]
JUNOS EX 4300 Software Suite [14.1X53-D42.3]
JUNOS Web Management Platform Package [14.1X53-D42.3]
JUNOS py-base-powerpc [14.1X53-D42.3]
JUNOS Web Management Application package [14.1X53-A2.1]


        Amazing photons
        Carry our data worldwide
        Never seem to stop

Steps to Reproduce the Issue

Error Traceback

(Paste the complete traceback of the exception between quotes below)

Traceback (most recent call last):
  File "wired_access_switch.py", line 86, in <module>
    main()
  File "wired_access_switch.py", line 30, in main
    facts = device_con.get_facts()
  File "/Users/andersonjd/code/netbox-onboarding/venv/lib/python2.7/site-packages/napalm_junos/junos.py", line 257, in get_facts
    uptime = output['RE0']['up_time']
TypeError: 'NoneType' object has no attribute '__getitem__'

The raw ouput from junos-pyez facts tells the story here:

For the 4200 stack where fpc3 and fpc4 are the routing engines:

{'2RE': True,
 'HOME': '/var/home/PROus',
 'RE0': None,
 'RE1': None,
 'RE_hw_mi': False,
 'current_re': ['master',
                'node',
                'fwdd',
                'member',
                'pfem',
                'fpc3',
                'feb0',
                'fpc16'],
 'domain': None,
 'fqdn': None,
 'hostname': 'MYBK-2F1',
 'hostname_info': {'fpc0': 'MYBK-2F1',
                   'fpc1': 'MYBK-2F1',
                   'fpc2': 'MYBK-2F1',
                   'fpc3': 'MYBK-2F1',
                   'fpc4': 'MYBK-2F1',
                   'fpc5': 'MYBK-2F1',
                   'fpc6': 'MYBK-2F1',
                   'fpc7': 'MYBK-2F1'},
 'ifd_style': 'SWITCH',
 'junos_info': {'fpc0': {'object': junos.version_info(major=(12, 3), type=R, minor=12, build=4),
                         'text': '12.3R12.4'},
                'fpc1': {'object': junos.version_info(major=(12, 3), type=R, minor=12, build=4),
                         'text': '12.3R12.4'},
                'fpc2': {'object': junos.version_info(major=(12, 3), type=R, minor=12, build=4),
                         'text': '12.3R12.4'},
                'fpc3': {'object': junos.version_info(major=(12, 3), type=R, minor=12, build=4),
                         'text': '12.3R12.4'},
                'fpc4': {'object': junos.version_info(major=(12, 3), type=R, minor=12, build=4),
                         'text': '12.3R12.4'},
                'fpc5': {'object': junos.version_info(major=(12, 3), type=R, minor=12, build=4),
                         'text': '12.3R12.4'},
                'fpc6': {'object': junos.version_info(major=(12, 3), type=R, minor=12, build=4),
                         'text': '12.3R12.4'},
                'fpc7': {'object': junos.version_info(major=(12, 3), type=R, minor=12, build=4),
                         'text': '12.3R12.4'}},
 'master': 'RE3',
 'model': 'EX4200-24PX',
 'model_info': {'fpc0': 'EX4200-24PX',
                'fpc1': 'EX4200-24PX',
                'fpc2': 'EX4200-24PX',
                'fpc3': 'EX4200-24PX',
                'fpc4': 'EX4200-24PX',
                'fpc5': 'EX4200-24PX',
                'fpc6': 'EX4200-24PX',
                'fpc7': 'EX4200-24PX'},
 'personality': 'SWITCH',
 're_info': {'default': {'3': {'last_reboot_reason': 'Router rebooted after a normal shutdown.',
                               'mastership_state': 'master',
                               'model': 'EX4200-24PX,24 POE+',
                               'status': 'OK'},
                         '4': {'last_reboot_reason': 'Router rebooted after a normal shutdown.',
                               'mastership_state': 'backup',
                               'model': 'EX4200-24PX,24 POE+',
                               'status': 'OK'},
                         'default': {'last_reboot_reason': 'Router rebooted after a normal shutdown.',
                                     'mastership_state': 'master',
                                     'model': 'EX4200-24PX,24 POE+',
                                     'status': 'OK'}}},
 're_master': {'default': '3'},
 'serialnumber': 'XXX',
 'srx_cluster': None,
 'srx_cluster_id': None,
 'srx_cluster_redundancy_group': None,
 'switch_style': 'VLAN',
 'vc_capable': True,
 'vc_fabric': None,
 'vc_master': '3',
 'vc_mode': 'Enabled',
 'version': '12.3R12.4',
 'version_RE0': None,
 'version_RE1': None,
 'version_info': junos.version_info(major=(12, 3), type=R, minor=12, build=4),
 'virtual': False}

And the EX4300 stack where fpc1 and fpc2 are the routing engines:

{'2RE': True,
 'HOME': '/var/home/PROus',
 'RE0': None,
 'RE1': {'last_reboot_reason': '0x1:power cycle/failure',
         'mastership_state': 'master',
         'model': 'EX4300-48P',
         'status': 'OK',
         'up_time': '20 days, 18 hours, 50 minutes, 49 seconds'},
 'RE_hw_mi': False,
 'current_re': ['master',
                'node',
                'fwdd',
                'member',
                'pfem',
                're0',
                'fpc1',
                'feb0',
                'fpc16'],
 'domain': 'nw.cougars.int',
 'fqdn': '176LOC-2F1.nw.cougars.int',
 'hostname': '176LOC-2F1',
 'hostname_info': {'fpc0': '176LOC-2F1',
                   'fpc1': '176LOC-2F1',
                   'fpc2': '176LOC-2F1',
                   'fpc3': '176LOC-2F1'},
 'ifd_style': 'SWITCH',
 'junos_info': {'fpc0': {'object': junos.version_info(major=(14, 1), type=X, minor=(53, 'D', 42), build=3),
                         'text': '14.1X53-D42.3'},
                'fpc1': {'object': junos.version_info(major=(14, 1), type=X, minor=(53, 'D', 42), build=3),
                         'text': '14.1X53-D42.3'},
                'fpc2': {'object': junos.version_info(major=(14, 1), type=X, minor=(53, 'D', 42), build=3),
                         'text': '14.1X53-D42.3'},
                'fpc3': {'object': junos.version_info(major=(14, 1), type=X, minor=(53, 'D', 42), build=3),
                         'text': '14.1X53-D42.3'}},
 'master': 'RE1',
 'model': 'EX4300-48P',
 'model_info': {'fpc0': 'EX4300-48P',
                'fpc1': 'EX4300-48P',
                'fpc2': 'EX4300-48P',
                'fpc3': 'EX4300-48P'},
 'personality': 'SWITCH',
 're_info': {'default': {'1': {'last_reboot_reason': '0x1:power cycle/failure',
                               'mastership_state': 'master',
                               'model': 'EX4300-48P',
                               'status': 'OK'},
                         '2': {'last_reboot_reason': '0x1:power cycle/failure',
                               'mastership_state': 'backup',
                               'model': 'EX4300-48P',
                               'status': 'OK'},
                         'default': {'last_reboot_reason': '0x1:power cycle/failure',
                                     'mastership_state': 'master',
                                     'model': 'EX4300-48P',
                                     'status': 'OK'}}},
 're_master': {'default': '1'},
 'serialnumber': 'XXX',
 'srx_cluster': None,
 'srx_cluster_id': None,
 'srx_cluster_redundancy_group': None,
 'switch_style': 'VLAN_L2NG',
 'vc_capable': True,
 'vc_fabric': None,
 'vc_master': '1',
 'vc_mode': 'Enabled',
 'version': '14.1X53-D42.3',
 'version_RE0': None,
 'version_RE1': None,
 'version_info': junos.version_info(major=(14, 1), type=X, minor=(53, 'D', 42), build=3),
 'virtual': False}
@lampwins
Copy link
Contributor Author

lampwins commented Jun 29, 2017

Upstream issue in junos-pyez Juniper/py-junos-eznc#750

The proposed upstream solution is to include uptime in the routing engine dicts in re_info['default'], which will always be available no matter the fpc location of the routing engines.

@mirceaulinic
Copy link
Member

Thanks for reporting this @lampwins - as you have the environment to reproduce this, would you be able to submit the fix please?

@lampwins
Copy link
Contributor Author

@mirceaulinic sure, I would be happy to. Until the upstream issue is resolved, are you okay with setting the facts uptime to None when it is unavailable from the junos-pyez output?

@dbarrosop
Copy link
Member

@lampwins use -1 instead of None.

@sincerywaing
Copy link
Contributor

I had a similar issue with stack switches that get_facts will timeout. seems to many interfaces that caused this issue.

@dbarrosop
Copy link
Member

@sincerywaing there is a "timeout" attribute you can pass when creating the driver object. Try it and if it doesn't work open a new issue, please.

mirceaulinic added a commit that referenced this issue Sep 15, 2017
fixes #176 get_facts uptime against patch in pyeznc 2.1.5
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants