diff --git a/changelogs/fragments/65065-plugins-netconf-ce-fix.yaml b/changelogs/fragments/65065-plugins-netconf-ce-fix.yaml new file mode 100644 index 00000000000..591fb38b179 --- /dev/null +++ b/changelogs/fragments/65065-plugins-netconf-ce-fix.yaml @@ -0,0 +1,3 @@ +--- +bugfixes: + - plugins-netconf-ce - Fix failed to get version information. diff --git a/lib/ansible/plugins/netconf/ce.py b/lib/ansible/plugins/netconf/ce.py index 3d58f71a717..46b3bc2725d 100644 --- a/lib/ansible/plugins/netconf/ce.py +++ b/lib/ansible/plugins/netconf/ce.py @@ -54,14 +54,26 @@ class Netconf(NetconfBase): def get_device_info(self): device_info = dict() device_info['network_os'] = 'ce' - ele = new_ele('get-software-information') - data = self.execute_rpc(to_xml(ele)) - reply = to_ele(to_bytes(data, errors='surrogate_or_strict')) - sw_info = reply.find('.//software-information') - - device_info['network_os_version'] = self.get_text(sw_info, 'ce-version') - device_info['network_os_hostname'] = self.get_text(sw_info, 'host-name') - device_info['network_os_model'] = self.get_text(sw_info, 'product-model') + filter_xml = ''' + + + + + + + + + + ''' + data = self.get(filter_xml) + data = re.sub(r'xmlns=".+?"', r'', data) + reply = fromstring(to_bytes(data, errors='surrogate_or_strict')) + sw_info = reply.find('.//systemInfo') + + device_info['network_os_version'] = self.get_text(sw_info, 'productVer') + device_info['network_os_hostname'] = self.get_text(sw_info, 'sysName') + device_info['network_os_platform_version'] = self.get_text(sw_info, 'platformVer') + device_info['network_os_platform'] = self.get_text(sw_info, 'productName') return device_info