jedelman8 / nxos-ansible

Ansible modules to automate Cisco NX-OS switches
Other
169 stars 106 forks source link

Loopback interface in switch breaks nxos_get_facts #44

Closed jonasstenling closed 7 years ago

jonasstenling commented 8 years ago

When a loopback interface is configured in the switch it breaks the xml response and causes the module to crash.

With interface loopback10 configured:

failed: [test.foo.se] => {"failed": true, "parsed": false}
Traceback (most recent call last):
  File "/home/e600917/.ansible/tmp/ansible-tmp-1452263534.43-201207582261376/nxos_get_facts.py", line 1953, in <module>
    main()
  File "/home/e600917/.ansible/tmp/ansible-tmp-1452263534.43-201207582261376/nxos_get_facts.py", line 315, in main
    interface_body = parsed_data_from_device(device, interface_command, module)
  File "/home/e600917/.ansible/tmp/ansible-tmp-1452263534.43-201207582261376/nxos_get_facts.py", line 124, in parsed_data_from_device
    data = device.show(command)
  File "/usr/lib/python2.6/site-packages/pycsco/nxos/device.py", line 101, in show
    data_dict = xmltodict.parse(data[1])
  File "/usr/lib/python2.6/site-packages/xmltodict.py", line 248, in parse
    parser.Parse(xml_input, True)
xml.parsers.expat.ExpatError: not well-formed (invalid token): line 462, column 31

When running show interface status in the NXAPI sandbox the following data is returned for the interface:

{
            "interface": "loopback10",
            "name": "test",
            "state": "connected",
            "vlan": "routed",
            "duplex": "auto",
            "speed": "unknown enum:<3>",
            "type": "--"
          }

The value for the speed key causes the response, when in XML format, to be malformed as it is not properly quoted. If you try to use XML as the message format in the sandbox it hangs indefinitively, likely due to the same issue.

Workaround: Remove all loopback interfaces.

jedelman8 commented 8 years ago

What device type is this? I'm seeing this more and more on 7Ks.

That said, speed shouldn't be gathered for loopbacks anyway.

Something seems off b/c vlan says routed...this needs to be looked at in more detail.

Thanks for pointing this out and I'm going to do my best again to dive into these mods next week :)

On Fri, Jan 8, 2016 at 9:37 AM, Jonas Stenling notifications@github.com wrote:

When a loopback interface is configured in the switch it breaks the xml response an causes the module to crash

With interface loopback10 configured:

failed: [testfoose] => {"failed": true, "parsed": false} Traceback (most recent call last): File "/home/e600917/ansible/tmp/ansible-tmp-145226353443-201207582261376/nxos_get_factspy", line 1953, in main() File "/home/e600917/ansible/tmp/ansible-tmp-145226353443-201207582261376/nxos_get_factspy", line 315, in main interface_body = parsed_data_from_device(device, interface_command, module) File "/home/e600917/ansible/tmp/ansible-tmp-145226353443-201207582261376/nxos_get_factspy", line 124, in parsed_data_from_device data = deviceshow(command) File "/usr/lib/python26/site-packages/pycsco/nxos/devicepy", line 101, in show data_dict = xmltodictparse(data[1]) File "/usr/lib/python26/site-packages/xmltodictpy", line 248, in parse parserParse(xml_input, True) xmlparsersexpatExpatError: not well-formed (invalid token): line 462, column 31

When running show interface status in the NXAPI sandbox the following data is returned for the interface:

{ "interface": "loopback10", "name": "test", "state": "connected", "vlan": "routed", "duplex": "auto", "speed": "unknown enum:<3>", "type": "--" }

The response for the speed key causes the response, when in XML format to be malformed as it is not properly quoted If you try to use XML as the message format in the sandbox it hangs indefinitively, likely due to the same issue

Workaround: Remove all loopback interfaces

— Reply to this email directly or view it on GitHub https://github.com/jedelman8/nxos-ansible/issues/44.

jonasstenling commented 8 years ago

ix1-test-s11a# sh ver Cisco Nexus Operating System (NX-OS) Software TAC support: http://www.cisco.com/tac Documents: http://www.cisco.com/en/US/products/ps9372/tsd_products_support_series_home.html Copyright (c) 2002-2015, Cisco Systems, Inc. All rights reserved. The copyrights to certain works contained herein are owned by other third parties and are used and distributed under license. Some parts of this software are covered under the GNU Public License. A copy of the license is available at http://www.gnu.org/licenses/gpl.html.

Software BIOS: version 3.6.0 Power Sequencer Firmware: Module 1: v3.0 Module 1: v1.0 Module 2: v2.0 Microcontroller Firmware: version v1.2.0.1 QSFP Microcontroller Firmware:
Module not detected CXP Microcontroller Firmware:
Module not detected kickstart: version 7.2(1)N1(1) system: version 7.2(1)N1(1) BIOS compile time: 05/09/2012 kickstart image file is: bootflash:///n5000-uk9-kickstart.7.2.1.N1.1.bin kickstart compile time: 10/14/2015 19:00:00 [10/15/2015 05:48:50] system image file is: bootflash:///n5000-uk9.7.2.1.N1.1.bin system compile time: 10/14/2015 19:00:00 [10/15/2015 08:01:24]

Hardware cisco Nexus5548 Chassis ("O2 32X10GE/Modular Universal Platform Supervisor") Intel(R) Xeon(R) CPU with 8253868 kB of memory.

jedelman8 commented 8 years ago

Correction, we're seeing it on 5Ks and 7Ks :)

On Fri, Jan 8, 2016 at 10:26 AM, Jonas Stenling notifications@github.com wrote:

ix1-test-s11a# sh ver Cisco Nexus Operating System (NX-OS) Software TAC support: http://www.cisco.com/tac Documents: http://www.cisco.com/en/US/products/ps9372/tsd_products_support_series_home.html Copyright (c) 2002-2015, Cisco Systems, Inc. All rights reserved. The copyrights to certain works contained herein are owned by other third parties and are used and distributed under license. Some parts of this software are covered under the GNU Public License. A copy of the license is available at http://www.gnu.org/licenses/gpl.html.

Software BIOS: version 3.6.0 Power Sequencer Firmware: Module 1: v3.0 Module 1: v1.0 Module 2: v2.0 Microcontroller Firmware: version v1.2.0.1 QSFP Microcontroller Firmware:

Module not detected CXP Microcontroller Firmware:

Module not detected kickstart: version 7.2(1)N1(1) system: version 7.2(1)N1(1) BIOS compile time: 05/09/2012 kickstart image file is: bootflash:///n5000-uk9-kickstart.7.2.1.N1.1.bin kickstart compile time: 10/14/2015 19:00:00 [10/15/2015 05:48:50] system image file is: bootflash:///n5000-uk9.7.2.1.N1.1.bin system compile time: 10/14/2015 19:00:00 [10/15/2015 08:01:24]

Hardware cisco Nexus5548 Chassis ("O2 32X10GE/Modular Universal Platform Supervisor") Intel(R) Xeon(R) CPU with 8253868 kB of memory.

— Reply to this email directly or view it on GitHub https://github.com/jedelman8/nxos-ansible/issues/44#issuecomment-170031054 .