Update ce_evpn_bgp_rr to fix bugs (#61168)

This commit is contained in:
yanzhangi 2019-09-18 10:08:12 +08:00 committed by ansibot
parent 8eec5d2ab2
commit 1a8c1c7365

View file

@ -169,7 +169,7 @@ changed:
import re
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.network.cloudengine.ce import get_config, load_config, ce_argument_spec
from ansible.module_utils.network.cloudengine.ce import exec_command, load_config, ce_argument_spec
def is_config_exist(cmp_cfg, test_cfg):
@ -259,19 +259,17 @@ class EvpnBgpRr(object):
def get_config_in_bgp_view(self):
"""Get configuration in BGP view"""
flags = list()
exp = " | section include"
cmd = "display current-configuration | section include"
if self.as_number:
if self.bgp_instance:
exp += " bgp %s instance %s" % (self.as_number,
cmd += " bgp %s instance %s" % (self.as_number,
self.bgp_instance)
else:
exp += " bgp %s" % self.as_number
flags.append(exp)
config = get_config(self.module, flags)
cmd = 'display current-configuration ' + exp
config = config.strip() if config else ""
cmd += " bgp %s" % self.as_number
rc, out, err = exec_command(self.module, cmd)
if rc != 0:
self.module.fail_json(msg=err)
config = out.strip() if out else ""
if cmd == config:
return ''
@ -423,27 +421,27 @@ class EvpnBgpRr(object):
self.cli_add_command(view_cmd)
if self.bgp_evpn_enable == 'disable':
self.cli_add_command(" undo l2vpn-family evpn")
self.cli_add_command("undo l2vpn-family evpn")
else:
self.cli_add_command(" l2vpn-family evpn")
self.cli_add_command("l2vpn-family evpn")
if self.reflect_client and self.reflect_client != self.cur_config['reflect_client']:
if self.reflect_client == 'enable':
self.cli_add_command(" peer %s enable" % self.peer)
self.cli_add_command("peer %s enable" % self.peer)
self.cli_add_command(
" peer %s reflect-client" % self.peer)
"peer %s reflect-client" % self.peer)
else:
self.cli_add_command(
" undo peer %s reflect-client" % self.peer)
self.cli_add_command(" undo peer %s enable" % self.peer)
"undo peer %s reflect-client" % self.peer)
self.cli_add_command("undo peer %s enable" % self.peer)
if self.cur_config['bgp_evpn_enable'] == 'enable':
if self.policy_vpn_target and self.policy_vpn_target != self.cur_config['policy_vpn_target']:
if self.policy_vpn_target == 'enable':
self.cli_add_command(" policy vpn-target")
self.cli_add_command("policy vpn-target")
else:
self.cli_add_command(" undo policy vpn-target")
self.cli_add_command("undo policy vpn-target")
else:
if self.policy_vpn_target and self.policy_vpn_target == 'disable':
self.cli_add_command(" undo policy vpn-target")
self.cli_add_command("undo policy vpn-target")
if self.commands:
self.cli_load_config(self.commands)