update vrf to fix bugs (#57270)

* update vrf

* update vrf
This commit is contained in:
xuxiaowei0512 2019-06-08 01:03:54 +08:00 committed by Nathaniel Case
parent 4dc6faea59
commit 76e06fa7c2
3 changed files with 5 additions and 6 deletions

View file

@ -214,7 +214,7 @@ class Vrf(object):
root = ElementTree.fromstring(xml_str) root = ElementTree.fromstring(xml_str)
vpn_instances = root.findall( vpn_instances = root.findall(
"data/l3vpn/l3vpncomm/l3vpnInstances/l3vpnInstance") "l3vpn/l3vpncomm/l3vpnInstances/l3vpnInstance")
if vpn_instances: if vpn_instances:
for vpn_instance in vpn_instances: for vpn_instance in vpn_instances:
if vpn_instance.find('vrfName').text == self.vrf: if vpn_instance.find('vrfName').text == self.vrf:

View file

@ -568,7 +568,7 @@ class VrfAf(object):
# get the vpn address family and RD text # get the vpn address family and RD text
vrf_addr_types = root.findall( vrf_addr_types = root.findall(
"data/l3vpn/l3vpncomm/l3vpnInstances/l3vpnInstance/vpnInstAFs/vpnInstAF") "l3vpn/l3vpncomm/l3vpnInstances/l3vpnInstance/vpnInstAFs/vpnInstAF")
if vrf_addr_types: if vrf_addr_types:
for vrf_addr_type in vrf_addr_types: for vrf_addr_type in vrf_addr_types:
vrf_af_info = dict() vrf_af_info = dict()

View file

@ -353,7 +353,7 @@ class VrfInterface(object):
for l3vpn_ifinfo in l3vpn_if: for l3vpn_ifinfo in l3vpn_if:
for ele in l3vpn_ifinfo: for ele in l3vpn_ifinfo:
if ele.tag in ['ifName']: 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 self.intf_info['vrfName'] = vpn_name
def get_interface_vpn(self): def get_interface_vpn(self):
@ -371,14 +371,13 @@ class VrfInterface(object):
# get global vrf interface info # get global vrf interface info
root = ElementTree.fromstring(xml_str) root = ElementTree.fromstring(xml_str)
vpns = root.findall( vpns = root.findall(
"data/l3vpn/l3vpncomm/l3vpnInstances/l3vpnInstance") "l3vpn/l3vpncomm/l3vpnInstances/l3vpnInstance")
if vpns: if vpns:
for vpnele in vpns: for vpnele in vpns:
vpn_name = None vpn_name = None
for vpninfo in vpnele: for vpninfo in vpnele:
if vpninfo.tag == 'vrfName': if vpninfo.tag == 'vrfName':
vpn_name = vpninfo.text vpn_name = vpninfo.text
if vpninfo.tag == 'l3vpnIfs': if vpninfo.tag == 'l3vpnIfs':
self.get_interface_vpn_name(vpninfo, vpn_name) self.get_interface_vpn_name(vpninfo, vpn_name)
@ -408,7 +407,7 @@ class VrfInterface(object):
replace('xmlns="http://www.huawei.com/netconf/vrp"', "") replace('xmlns="http://www.huawei.com/netconf/vrp"', "")
root = ElementTree.fromstring(xml_str) root = ElementTree.fromstring(xml_str)
interface = root.find("data/ifm/interfaces/interface") interface = root.find("ifm/interfaces/interface")
if interface: if interface:
for eles in interface: for eles in interface:
if eles.tag in ["isL2SwitchPort"]: if eles.tag in ["isL2SwitchPort"]: