From 2645c43a2b1e8f01144e580b49835473727b4376 Mon Sep 17 00:00:00 2001 From: YuandongXu <786018072@qq.com> Date: Sat, 15 Jun 2019 10:21:41 +0800 Subject: [PATCH] backport/2.8/57270 update vrf to fix bugs (#57270) (#57757) * update vrf to fix bugs (#57270) * update vrf * update vrf (cherry picked from commit 76e06fa7c2156cbed5726cf0d0d8e12100fe7424) * add changelog fragment fot PR 57757. --- changelogs/fragments/57757-update-vrf-to-fix-bugs.yml | 2 ++ lib/ansible/modules/network/cloudengine/ce_vrf.py | 2 +- lib/ansible/modules/network/cloudengine/ce_vrf_af.py | 2 +- .../modules/network/cloudengine/ce_vrf_interface.py | 7 +++---- 4 files changed, 7 insertions(+), 6 deletions(-) create mode 100644 changelogs/fragments/57757-update-vrf-to-fix-bugs.yml diff --git a/changelogs/fragments/57757-update-vrf-to-fix-bugs.yml b/changelogs/fragments/57757-update-vrf-to-fix-bugs.yml new file mode 100644 index 00000000000..18775e3f375 --- /dev/null +++ b/changelogs/fragments/57757-update-vrf-to-fix-bugs.yml @@ -0,0 +1,2 @@ +bugfixes: + - update vrf to fix bugs.(https://github.com/ansible/ansible/pull/57270 ) diff --git a/lib/ansible/modules/network/cloudengine/ce_vrf.py b/lib/ansible/modules/network/cloudengine/ce_vrf.py index b6f6a90b8e0..9daad302e0e 100644 --- a/lib/ansible/modules/network/cloudengine/ce_vrf.py +++ b/lib/ansible/modules/network/cloudengine/ce_vrf.py @@ -214,7 +214,7 @@ class Vrf(object): root = ElementTree.fromstring(xml_str) vpn_instances = root.findall( - "data/l3vpn/l3vpncomm/l3vpnInstances/l3vpnInstance") + "l3vpn/l3vpncomm/l3vpnInstances/l3vpnInstance") if vpn_instances: for vpn_instance in vpn_instances: if vpn_instance.find('vrfName').text == self.vrf: diff --git a/lib/ansible/modules/network/cloudengine/ce_vrf_af.py b/lib/ansible/modules/network/cloudengine/ce_vrf_af.py index f6de1e6f630..c019e1af8db 100644 --- a/lib/ansible/modules/network/cloudengine/ce_vrf_af.py +++ b/lib/ansible/modules/network/cloudengine/ce_vrf_af.py @@ -568,7 +568,7 @@ class VrfAf(object): # get the vpn address family and RD text vrf_addr_types = root.findall( - "data/l3vpn/l3vpncomm/l3vpnInstances/l3vpnInstance/vpnInstAFs/vpnInstAF") + "l3vpn/l3vpncomm/l3vpnInstances/l3vpnInstance/vpnInstAFs/vpnInstAF") if vrf_addr_types: for vrf_addr_type in vrf_addr_types: vrf_af_info = dict() diff --git a/lib/ansible/modules/network/cloudengine/ce_vrf_interface.py b/lib/ansible/modules/network/cloudengine/ce_vrf_interface.py index bed004c0d98..681e9934e41 100644 --- a/lib/ansible/modules/network/cloudengine/ce_vrf_interface.py +++ b/lib/ansible/modules/network/cloudengine/ce_vrf_interface.py @@ -353,7 +353,7 @@ class VrfInterface(object): for l3vpn_ifinfo in l3vpn_if: for ele in l3vpn_ifinfo: if ele.tag in ['ifName']: - if ele.text == self.vpn_interface: + if ele.text.lower() == self.vpn_interface.lower(): self.intf_info['vrfName'] = vpn_name def get_interface_vpn(self): @@ -371,14 +371,13 @@ class VrfInterface(object): # get global vrf interface info root = ElementTree.fromstring(xml_str) vpns = root.findall( - "data/l3vpn/l3vpncomm/l3vpnInstances/l3vpnInstance") + "l3vpn/l3vpncomm/l3vpnInstances/l3vpnInstance") if vpns: for vpnele in vpns: vpn_name = None for vpninfo in vpnele: if vpninfo.tag == 'vrfName': vpn_name = vpninfo.text - if vpninfo.tag == 'l3vpnIfs': self.get_interface_vpn_name(vpninfo, vpn_name) @@ -408,7 +407,7 @@ class VrfInterface(object): replace('xmlns="http://www.huawei.com/netconf/vrp"', "") root = ElementTree.fromstring(xml_str) - interface = root.find("data/ifm/interfaces/interface") + interface = root.find("ifm/interfaces/interface") if interface: for eles in interface: if eles.tag in ["isL2SwitchPort"]: