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

* 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

(cherry picked from commit da8ec327cc)
pull/65015/head^2
Xu Yuandong 5 years ago committed by Matt Davis
parent a4e055e0cd
commit b816e7c82e

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

@ -54,14 +54,26 @@ class Netconf(NetconfBase):
def get_device_info(self): def get_device_info(self):
device_info = dict() device_info = dict()
device_info['network_os'] = 'ce' device_info['network_os'] = 'ce'
ele = new_ele('get-software-information') filter_xml = '''<filter type="subtree">
data = self.execute_rpc(to_xml(ele)) <system xmlns="http://www.huawei.com/netconf/vrp" content-version="1.0" format-version="1.0">
reply = to_ele(to_bytes(data, errors='surrogate_or_strict')) <systemInfo>
sw_info = reply.find('.//software-information') <sysName></sysName>
<sysContact></sysContact>
device_info['network_os_version'] = self.get_text(sw_info, 'ce-version') <productVer></productVer>
device_info['network_os_hostname'] = self.get_text(sw_info, 'host-name') <platformVer></platformVer>
device_info['network_os_model'] = self.get_text(sw_info, 'product-model') <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, '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 return device_info

Loading…
Cancel
Save