From 98725b25f7aa8f0ed1ee4c0bd6ed2a4ad856d717 Mon Sep 17 00:00:00 2001
From: YuandongXu <786018072@qq.com>
Date: Sat, 29 Jun 2019 04:14:28 +0800
Subject: [PATCH] update to fix a bug (#58227)
(cherry picked from commit e0f3e404c95716e59e84568e7d84c416856adb9b)
---
.../modules/network/cloudengine/ce_evpn_bd_vni.py | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/lib/ansible/modules/network/cloudengine/ce_evpn_bd_vni.py b/lib/ansible/modules/network/cloudengine/ce_evpn_bd_vni.py
index 21f23b02bb8..ac30b8cc866 100644
--- a/lib/ansible/modules/network/cloudengine/ce_evpn_bd_vni.py
+++ b/lib/ansible/modules/network/cloudengine/ce_evpn_bd_vni.py
@@ -248,6 +248,7 @@ changed:
sample: true
'''
+import re
import copy
from xml.etree import ElementTree
from ansible.module_utils.basic import AnsibleModule
@@ -260,7 +261,7 @@ CE_NC_GET_VNI_BD = """
- %s
+
@@ -552,7 +553,7 @@ class EvpnBd(object):
replace('xmlns="http://www.huawei.com/netconf/vrp"', "")
root = ElementTree.fromstring(xml_str)
- evpn_inst = root.find("data/evpn/evpnInstances/evpnInstance")
+ evpn_inst = root.find("evpn/evpnInstances/evpnInstance")
if evpn_inst:
for eles in evpn_inst:
if eles.tag in ["evpnAutoRD", "evpnRD", "evpnRTs", "evpnAutoRTs"]:
@@ -1006,9 +1007,9 @@ class EvpnBd(object):
def check_vni_bd(self):
"""Check whether vxlan vni is configured in BD view"""
- xml_str = CE_NC_GET_VNI_BD % self.bridge_domain_id
+ xml_str = CE_NC_GET_VNI_BD
xml_str = get_nc_config(self.module, xml_str)
- if "" in xml_str:
+ if "" in xml_str or not re.findall(r'\S+\s+%s' % self.bridge_domain_id, xml_str):
self.module.fail_json(
msg='Error: The vxlan vni is not configured or the bridge domain id is invalid.')