mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-25 11:51:26 -07:00
Netconf bytes fixes (#41607)
* Solve some bytes issues on iosxr * Solve some bytes issues in junos * Do the correct thing with tostring based on lxml or not
This commit is contained in:
parent
c144adc9de
commit
9aa8c652ba
23 changed files with 54 additions and 113 deletions
|
@ -26,7 +26,7 @@ import collections
|
|||
|
||||
from ansible import constants as C
|
||||
from ansible.module_utils.network.common.netconf import remove_namespaces
|
||||
from ansible.module_utils.network.iosxr.iosxr import build_xml
|
||||
from ansible.module_utils.network.iosxr.iosxr import build_xml, etree_find
|
||||
from ansible.errors import AnsibleConnectionFailure, AnsibleError
|
||||
from ansible.plugins.netconf import NetconfBase
|
||||
from ansible.plugins.netconf import ensure_connected
|
||||
|
@ -64,10 +64,10 @@ class Netconf(NetconfBase):
|
|||
install_filter = build_xml('install', install_meta, opcode='filter')
|
||||
|
||||
reply = self.get(install_filter)
|
||||
ele_boot_variable = etree.fromstring(reply).find('.//boot-variable/boot-variable')
|
||||
ele_boot_variable = etree_find(reply, 'boot-variable/boot-variable')
|
||||
if ele_boot_variable is not None:
|
||||
device_info['network_os_image'] = re.split('[:|,]', ele_boot_variable.text)[1]
|
||||
ele_package_name = etree.fromstring(reply).find('.//package-name')
|
||||
ele_package_name = etree_find(reply, 'package-name')
|
||||
if ele_package_name is not None:
|
||||
device_info['network_os_package'] = ele_package_name.text
|
||||
device_info['network_os_version'] = re.split('-', ele_package_name.text)[-1]
|
||||
|
@ -75,7 +75,7 @@ class Netconf(NetconfBase):
|
|||
hostname_filter = build_xml('host-names', opcode='filter')
|
||||
|
||||
reply = self.get(hostname_filter)
|
||||
hostname_ele = etree.fromstring(reply).find('.//host-name')
|
||||
hostname_ele = etree_find(reply, 'host-name')
|
||||
device_info['network_os_hostname'] = hostname_ele.text if hostname_ele is not None else None
|
||||
|
||||
return device_info
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue