Update plugins/netconf/ce.py to fix a bug(failed to get veriosn information via neocnf). ()

* fix version fail.

* add a changelog fragment.

* Update ce.py

* Rename plugins-netconf-ce-fix.yaml to 65065-plugins-netconf-ce-fix.yaml

* Update ce.py
This commit is contained in:
Xu Yuandong 2019-11-21 05:18:24 +08:00 committed by Felix Fontein
parent e16e6fac92
commit da8ec327cc
2 changed files with 22 additions and 7 deletions
changelogs/fragments
lib/ansible/plugins/netconf

View file

@ -0,0 +1,3 @@
---
bugfixes:
- plugins-netconf-ce - Fix failed to get version information.

View file

@ -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')
filter_xml = '''<filter type="subtree">
<system xmlns="http://www.huawei.com/netconf/vrp" content-version="1.0" format-version="1.0">
<systemInfo>
<sysName></sysName>
<sysContact></sysContact>
<productVer></productVer>
<platformVer></platformVer>
<productName></productName>
</systemInfo>
</system>
</filter>'''
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, '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')
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