|
|
|
@ -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
|
|
|
|
|