From 90958b01c1c73d892a393e2cfabd5c59c2dcf53b Mon Sep 17 00:00:00 2001 From: yanzhangi <51999930+yanzhangi@users.noreply.github.com> Date: Wed, 18 Sep 2019 10:08:27 +0800 Subject: [PATCH] Update ce_evpn_bgp to fix bugs (#61136) --- .../network/cloudengine/ce_evpn_bgp.py | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/lib/ansible/modules/network/cloudengine/ce_evpn_bgp.py b/lib/ansible/modules/network/cloudengine/ce_evpn_bgp.py index 51c139afad4..3805375d63f 100644 --- a/lib/ansible/modules/network/cloudengine/ce_evpn_bgp.py +++ b/lib/ansible/modules/network/cloudengine/ce_evpn_bgp.py @@ -136,7 +136,7 @@ end_state: import re from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.network.cloudengine.ce import get_config, load_config +from ansible.module_utils.network.cloudengine.ce import exec_command, load_config from ansible.module_utils.network.cloudengine.ce import ce_argument_spec @@ -238,18 +238,20 @@ class EvpnBgp(object): def get_evpn_overlay_config(self): """get evpn-overlay enable configuration""" - flags = list() - exp = "| ignore-case include evpn-overlay enable" - flags.append(exp) - return get_config(self.module, flags) + cmd = "display current-configuration | include ^evpn-overlay enable" + rc, out, err = exec_command(self.module, cmd) + if rc != 0: + self.module.fail_json(msg=err) + return out def get_current_config(self): """get current configuration""" - flags = list() - exp = "| ignore-case section include bgp %s" % self.bgp_instance - flags.append(exp) - return get_config(self.module, flags) + cmd = "display current-configuration | section include bgp %s" % self.bgp_instance + rc, out, err = exec_command(self.module, cmd) + if rc != 0: + self.module.fail_json(msg=err) + return out def cli_add_command(self, command, undo=False): """add command to self.update_cmd and self.commands""" @@ -501,6 +503,10 @@ class EvpnBgp(object): if not self.config: return + self.config_list = self.config.split('l2vpn-family evpn') + if len(self.config_list) == 2: + self.l2vpn_evpn_exist = True + if self.bgp_instance: self.end_state["bgp_instance"] = self.bgp_instance