Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix nxos and nxos_ssh hostname change handling #999

Merged
merged 2 commits into from
Jun 18, 2019

Conversation

ktbyers
Copy link
Contributor

@ktbyers ktbyers commented Jun 18, 2019

I ran into issues with both nxos driver and nxos_ssh driver with hostname changes. Made fixes here to incorporate.

I also updated the napalm_custom_test suite to test this for both nxos and nxos_ssh for both merge and replace operations. This generally runs daily against virtual network devices and the develop branch.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.01%) to 80.658% when pulling 8c6c833 on ktbyers:nxos_hostname into 7980208 on napalm-automation:develop.

2 similar comments
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.01%) to 80.658% when pulling 8c6c833 on ktbyers:nxos_hostname into 7980208 on napalm-automation:develop.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.01%) to 80.658% when pulling 8c6c833 on ktbyers:nxos_hostname into 7980208 on napalm-automation:develop.

@ktbyers ktbyers merged commit 262ec5f into napalm-automation:develop Jun 18, 2019
@lazhao123
Copy link

lazhao123 commented Jun 24, 2019

The bug has not fixed yet. I changed hostname with load_merge_candidate( ), the base_prompt is not changed, so check_enable_mode( ) still search old hostname and timeout. Attached stack trace.

        if self.replace:
            self._load_cfg_from_checkpoint()
            # If hostname changes ensure Netmiko state is updated properly
            self._netmiko_device.set_base_prompt()         <========= should call when merge config
        else:
            self._commit_merge()

Error thrown from base_connection.py: "Timed-out reading channel, data not available."
except socket.timeout:
raise NetMikoTimeoutException(
"Timed-out reading channel, data not available."
)

image

@lazhao123
Copy link

lazhao123 commented Jun 24, 2019

move set_base_prompt( ) before self._copy_run_start( ) fixed it.

    if self.loaded:
        # Create checkpoint from current running-config
        self._save_to_checkpoint(self.rollback_cfg)

        if self.replace:
            self._load_cfg_from_checkpoint()
        else:
            self._commit_merge()

        # If hostname changes ensure Netmiko state is updated properly
        self._netmiko_device.set_base_prompt()
        self._copy_run_start()

@lazhao123
Copy link

lazhao123 commented Jun 24, 2019

After rollback( ), prompt gets changed, but "copy_run_start( )" still look for old prompt, that caused timeout.
So I added set_base_promt( ) after rollback to fixed it.

image

def rollback(self):
    if self.changed:
        command = "rollback running-config file {}".format(self.rollback_cfg)
        result = self._send_command(command)
        if "completed" not in result.lower():
            raise ReplaceConfigException(result)
        # If hostname changes ensure Netmiko state is updated properly   
        self._netmiko_device.set_base_prompt()             <=== change prompt before "copy run st"
        self._copy_run_start()
        self.changed = False

@ktbyers
Copy link
Contributor Author

ktbyers commented Jun 25, 2019

@lazhao123 Okay, I opened the referenced new issue.

Yes, this is still broke. My test case was working for merge, but it was because I chose poorly on the new hostname (i.e. it had part of the old prompt in the new prompt name).

There is a good chance your fix for the merge part of this won't work (i.e. I think that is probably going to break NX-API as there is no Netmiko connection there for a merge operation...need to double check this though).

bharath-ravindranath pushed a commit to bharath-ravindranath/napalm that referenced this pull request Jul 1, 2019
@mirceaulinic mirceaulinic added this to the 2.5.0 milestone Sep 2, 2019
mirceaulinic added a commit that referenced this pull request Oct 10, 2019
* namespace fix for napalm cli (#950)

* Fix broken get_bgp_neighbors when 6PE configured on eos (#945)

* fix _RE_BGP_PREFIX and NEIGHBOR_FILTER for 6PE into eos

* add testcase for 6PE version

* Renamed testcase mocked file for regexp syntax change

* If parent_table None call exception (#939)

Hi, i have this situation when ipv6 is turned off:
$ napalm --user oxi --password gdfw23 --vendor nxos  10.143.36.8 call get_interfaces_ip
2019-03-07 15:08:10,226 - napalm - ERROR - method - Failed: 'NoneType' object has no attribute 'get'

================= Traceback =================

Traceback (most recent call last):
  File "/opt/py3.6/bin/napalm", line 10, in <module>
    sys.exit(main())
  File "/opt/py3.6/lib/python3.6/site-packages/napalm/base/clitools/cl_napalm.py", line 309, in main
    run_tests(args)
  File "/opt/py3.6/lib/python3.6/site-packages/napalm/base/clitools/cl_napalm.py", line 292, in run_tests
    call_getter(device, args.method, **method_kwargs)
  File "/opt/py3.6/lib/python3.6/site-packages/napalm/base/clitools/cl_napalm.py", line 31, in wrapper
    r = func(*args, **kwargs)
  File "/opt/py3.6/lib/python3.6/site-packages/napalm/base/clitools/cl_napalm.py", line 256, in call_getter
    r = func(**kwargs)
  File "/opt/py3.6/lib/python3.6/site-packages/napalm/nxos/nxos.py", line 1091, in get_interfaces_ip
    ipv6_command, "TABLE_intf", "ROW_intf"
  File "/opt/py3.6/lib/python3.6/site-packages/napalm/nxos/nxos.py", line 721, in _get_command_table
    return self._get_reply_table(json_output, table_name, row_name)
  File "/opt/py3.6/lib/python3.6/site-packages/napalm/nxos/nxos.py", line 717, in _get_reply_table
    return self._get_table_rows(result, table_name, row_name)
  File "/opt/py3.6/lib/python3.6/site-packages/napalm/nxos/nxos.py", line 706, in _get_table_rows
    _table = parent_table.get(table_name)
AttributeError: 'NoneType' object has no attribute 'get'

* Remove extensive argument from junos_iface_table (#929)

Fixes #928

* Add GitHub issue template, as we used to have before (#961)

When we used to maintain separare NAPALM drivers, we had an issue template
looking like this:
napalm-automation/napalm-junos@110fec4#diff-faa36bc26a21ed93c8de974753b71507.

I was looking today through the issues we currently have open, and
I found some of them a bit chaotic, and hard to understand the context
/ environment the user runs. Additionally, some, e.g., #960, is really
hard to follow, and I've included a note to invite the user to check the
HitGub markdown manual.

* NXOS_SSH get_route_to (updated) (#914)

* Add MTU support to get_interface (#940)

* Feature/ios get bgp config (#897)

* support n9k ipv6 ints for interfaces_ip getter (#969)

* support catalyst vss for mac_address getter (#968)

* support getting auto-negotiated speed on junos (#967)

* [IOS] Raise exception if BGP neighbor info requested and BGP not running (#970)

* Implement nxos_ssh get_environment (#973)

* Switch Docker image to Python 3 and reduce the number of layers and size (#980)

* Better handling of connection closing upon exceptions in __enter__ (#994)

* Fix incorrect get_interfaces_ip parsing on n9k with IPv6 addresses (#997)

* Modernize docs for FreeBSD installation (#993)

* Fix nxos and nxos_ssh hostname change handling (#999)

* Update link location in the docs (#1002)

* Hostname fixes for NXOS and IOS (#1007)

* Clean up the documentation contribution section (#1004)

* <exception>.message is no longer a thing in Python3 (#1016)

* Added option to show run all (#1029)

* Update ISSUE_TEMPLATE

Removing the space between the brackets, as it seems like it's confusing the users.

* junos add optional arg for DB config selection (#1035)

* fix junos issue #1028 (#1032)

* fix junos issue #1028

* junos add test case for get_network_instances

* Incorrectly taken serial number in NXOS. (#1025)

* The serial number is taken incorrectly, in particular,
the "Processor Board ID" is displayed,
and you need a Chassis -> serialnum:

* Additional safety net for the lack of a serial number in the output.

* black test

* mov function _get_table_rows, _get_reply_table and _get_command_table
from class  NXOSDriver to NXOSDriverBase, because used in NXOSSSHDriver.

* Added verification and conversion from string to json

* Implemented  lock_disable for EOS based on Junos. (#1042)

To fix(?) issue #1041 - #1041
On branch eos-lock-disable-flag
Changes to be committed:
    modified:   napalm/eos/eos.py

* #1025 Work around NXAPI double quoting (#1048)

* #1025 Work around NXAPI double quoting

The NXAPI on the Nexus 9000 platform seems to be double-quoting the name of inventory items.

Amend the check for the inventory item name to take this into account.

* the output of the N9000 has extra quotes:

show inventory | json
{"TABLE_inv": {"ROW_inv": [{"name": "\"Chassis\"",
"desc": "\"Nexus9000 C92160YC-X chassis\"",.......

* #1046 Use new dictionary key to fetch OS version (#1047)

Some Cisco Nexus equipment doesn’t have `sys_ver_str`, but has `rr_sys_ver` instead. Use this as a backup.

* Add get_environment support for NXOS driver (#1054)

* napalm.nxos.traceroute - VRF traces and handle AS in hops (#989)

* Adding traceroute from a specific VRF

* Combination of source and vrf command

* On some devices running BGP, an AS number will appear after the IP address of the hop

* E261 at least two spaces before inline comment [pep8]

* Fix extra line in show ip int brief on IOS (#986)

* keep nxos consistent with ios for rollback of failed merge (#860)

* IOS: add support for VRF for get_arp_table func (#937)

Simply takes into account the vrf function arg and exec
the expected ios command.

* ios get_bgp_neighbors vrf and safi aware (#768)

* get_bgp_neighbors vrf support

* afi string contains afi modifier

* mocked data, minor changes

* afi string with afi modifier

* supported afis

* mocked data

* comments

* typo

* show arp vrf ios test

* black reformated

* Check if temperature sensor on Cisco device is not supported (#1055)

* Check if temperature sensor on Cisco device is not supported

Some older Cisco devices like models from the 2960 platform have no temperature sensor built-in. In that case the get_environment function will throw on exception. That case will now be handeled.

* Correct if check

* Fixes get_environment memory collection on ios-xe devices (#1053)

* fixes issue #1052
* add tests for get_environment on ios-xe devices

* Pin PyEZ to 2.2.1 (#1061)

* get_route_to implementation for IOS (#750)

* 1st functional config

* bgp protocol attributes added

* linting, minor changes

* test_get_route_to mocked_data

* linting errors fix

* comments, minor changes in bgp procesing

* bgp processing separated

* bgp support 7200 old

* new bgp processing

* mocked data global routing table

* comments, _get_vrfs update

* mocked data c7200

* bug in regex

* connected, next-hop regex changed,..

* community + ext.community, comments

* linting

* RE_RDB1 regex fixed

* asr_pe test

* typo

* typo

* typo in mocked data - vrf Test -> TEST

* longer parameter added (PR735)

* rollback to pass test_method_signatures ...

* bgp_time_conversion duplicity fixed

* community regex fixed

* code optimization

* module constant, variables renaming

* black reformated

* sh arp vrf test

* When asPathType is Internal (IBGP), as_path is empty and the remote-as is the local_as (#1064)

* Pin Netmiko to version 2.4.2 (#1066)

* Release 2.5.0 (#1063)
ExaneServerTeam pushed a commit to ExaneServerTeam/napalm that referenced this pull request Mar 6, 2020
bharath-ravindranath pushed a commit to bharath-ravindranath/napalm that referenced this pull request Apr 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants