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

Confirmed commit fails with TypeError in IOS XR netconf plugin (for 2.9.9) #74

Closed
kmtenhouse opened this issue Aug 15, 2020 · 3 comments · Fixed by #76
Closed

Confirmed commit fails with TypeError in IOS XR netconf plugin (for 2.9.9) #74

kmtenhouse opened this issue Aug 15, 2020 · 3 comments · Fixed by #76
Assignees

Comments

@kmtenhouse
Copy link

SUMMARY

Hitting a TypeError when attempting to use the confirmed commit capability with the IOX XR netconf plugin (Ansible 2.9.9). (Ansible module seems to want type=int for the timeout operation; underlying ncclient seems to need bytes or unicode.)

ISSUE TYPE
  • Bug Report
COMPONENT NAME

Netconf plugin for IOS XR:
plugins/netconf/iosxr.py

Note: I did see that this code is part of the main Ansible stable-2.9 branch. However, it was recommended that I instead open the issue here, as this will be the ongoing place for this plugin.

ANSIBLE VERSION
ansible 2.9.9
python version = 2.7.5 
CONFIGURATION
(no output was shown)
OS / ENVIRONMENT

Cisco IOS XR

STEPS TO REPRODUCE

Attempt to perform a task with a confirmed commit, ex:

- name: use lookup filter to provide xml configuration to be applied via netconf
connection: netconf
netconf_config:
target: "{{ netconf_target | default('candidate') }}"
error_option: "{{ netconf_error_option | default('rollback-on-error') }}"
commit: yes
confirm: 10
default_operation: "merge"
content: |
<nc:config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
<cdp xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-cdp-cfg">
<enable>true</enable>
</cdp>
</nc:config>
register: result
vars:
ansible_persistent_log_messages: True
EXPECTED RESULTS

Expected not to receive a type error.

ACTUAL RESULTS

TypeError is received when trying to perform the confirmed commit.

Additionally, setting confirm='10' does not help, although a team mate was able to do the following with Python:
m.commit(confirmed=True, timeout='40', persist='100') succeeds.
m.commit(confirmed=True, timeout=40, persist='100') fails with the same TypeError.

Example error message is below:

  File "/usr/lib/python2.7/site-packages/ansible/utils/jsonrpc.py", line 45, in handle_request
    result = rpc_method(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/ansible/plugins/netconf/iosxr.py", line 185, in commit
    resp = self.m.commit(confirmed=confirmed, timeout=timeout, persist=persist)
  File "/usr/lib/python2.7/site-packages/ncclient/manager.py", line 231, in execute
    huge_tree=self._huge_tree).request(*args, **kwds)
  File "/usr/lib/python2.7/site-packages/ncclient/operations/edit.py", line 158, in request
    sub_ele(node, "confirm-timeout").text = timeout
  File "src/lxml/etree.pyx", line 1024, in lxml.etree._Element.text.__set__
  File "src/lxml/apihelpers.pxi", line 747, in lxml.etree._setNodeText
  File "src/lxml/apihelpers.pxi", line 735, in lxml.etree._createTextNode
  File "src/lxml/apihelpers.pxi", line 1538, in lxml.etree._utf8
TypeError: Argument must be bytes or unicode, got 'int'
@ikhan2010
Copy link
Member

Thanks for raising the issue. cc @trishnaguha @ganeshrn
We will backport this bugfix to 2.9 stable branch.

ganeshrn added a commit to ganeshrn/ansible that referenced this issue Aug 15, 2020
Fixes ansible-collections/cisco.iosxr#74

*  ncclient API expects commit timeout value in either unicode
   or bytes format, hence convert the timeout value explicitly
   to string type.
ganeshrn added a commit to ganeshrn/ansible that referenced this issue Aug 15, 2020
*  ncclient API expects commit timeout value in either unicode
   or bytes format, hence convert the timeout value explicitly
   to string type.
ganeshrn added a commit to ganeshrn/iosxr that referenced this issue Aug 15, 2020
Fixes ansible-collections#74

*  ncclient API expects commit timeout value in either unicode
   or bytes format, hence convert the timeout value explicitly
   to string type.
@ganeshrn
Copy link
Member

@kmtenhouse Please check if PR ansible/ansible#71291 (on stable-2.9) fixes the issue.

Also raised PR on 2.10 and individual collections
stable-2.10: ansible/ansible#71292
cisco.iosxr: #76
ansible.netcommon: ansible-collections/ansible.netcommon#124 (testcase only)

@ganeshrn ganeshrn self-assigned this Aug 15, 2020
@kmtenhouse
Copy link
Author

Wow, thank you so much for your prompt response! We will check and let you know.

relrod pushed a commit to ansible/ansible that referenced this issue Aug 27, 2020
Fixes ansible-collections/cisco.iosxr#74

*  ncclient API expects commit timeout value in either unicode
   or bytes format, hence convert the timeout value explicitly
   to string type.
relrod pushed a commit to ansible/ansible that referenced this issue Aug 27, 2020
*  ncclient API expects commit timeout value in either unicode
   or bytes format, hence convert the timeout value explicitly
   to string type.
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Sep 8, 2020
v2.9.13
=======

Minor Changes
-------------
- Updated network integration auth timeout to 90 secs.
- ansible-test - Remove ``pytest < 6.0.0`` constraint for managed installations on Python 3.x now that pytest 6 is supported.
- known_hosts - fix reference to non-existent parameter in example (ansible/ansible#71417)

Security Fixes
--------------
- The fix for CVE-2020-1736 has been reverted. Users are encouraged to specify a ``mode`` parameter in their file-based tasks when the files being manipulated contain sensitive data.
- dnf - Previously, regardless of the ``disable_gpg_check`` option, packages were not GPG validated. They are now. (CVE-2020-14365)

Bugfixes
--------
- Confirmed commit fails with TypeError in IOS XR netconf plugin (ansible-collections/cisco.iosxr#74)
- Fix an exit code for a non-failing playbook (ansible/ansible#71306)
- Fix execution of the meta tasks 'clear_facts', 'clear_host_errors', 'end_play', 'end_host', and 'reset_connection' when the CLI flag '--flush-cache' is provided.
- Fix statistics reporting when rescue block contains another block (issue ansible/ansible#61253).
- Fixed Ansible reporting validate not supported by netconf server when enabled in netconf - (ansible-collections/ansible.netcommon#119).
- TOML inventory - Ensure we register dump functions for ``AnsibleUnsafe`` to support dumping unsafe values. Note that the TOML format has no functionality to mark that the data is unsafe for re-consumption. (ansible/ansible#71307)
- ansible-test units - fixed collection location code to work under pytest >= 6.0.0
- aws_acm_info - fix `KeyError` failure when retrieving keys with a `Failed` status (ansible-collections/community.aws#198)
- cron - cron file should not be empty after adding var (ansible/ansible#71207)
- mongodb_replicaset - fixes authentication to determine replicaset name (ansible-collections/community.mongodb#136).
- powershell - fix escaping of strings that broken modules like fetch when dealing with special chars - ansible/ansible#62781
- powershell - fix the CLIXML parser when it contains nested CLIXML objects - ansible/ansible#69550
- psrp - Use native PSRP mechanism when copying files to support custom endpoints
- setup - Add a null check for ``Win32_Bios.ReleaseData`` to avoid a failure when that value is not set - ansible/ansible#69736
- strftime filter - Input epoch is allowed to be a float (ansible/ansible#71257)
- systemd - fixed chroot usage on new versions of systemd, that broke because of upstream changes in systemctl output
- systemd - made the systemd module work correctly when the SYSTEMD_OFFLINE environment variable is set
- zabbix_host - fixed inventory_mode key error, which occurs with Zabbix 4.4.1 or more (ansible/ansible#65304).
- zabbix_proxy - fixed support for Zabbix 5.0
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 a pull request may close this issue.

3 participants