From 9bf0e696010c9fe9853946d983865a5d85a7e1af Mon Sep 17 00:00:00 2001
From: yanzhangi <51999930+yanzhangi@users.noreply.github.com>
Date: Wed, 18 Sep 2019 12:05:56 +0800
Subject: [PATCH] Update ce_bgp_neighbor to fix bugs (#60634)
---
.../network/cloudengine/ce_bgp_neighbor.py | 25 +++++++++++++------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/lib/ansible/modules/network/cloudengine/ce_bgp_neighbor.py b/lib/ansible/modules/network/cloudengine/ce_bgp_neighbor.py
index 796bb109bbd..48bdd0466d5 100644
--- a/lib/ansible/modules/network/cloudengine/ce_bgp_neighbor.py
+++ b/lib/ansible/modules/network/cloudengine/ce_bgp_neighbor.py
@@ -529,7 +529,8 @@ class BgpNeighbor(object):
dual_as = module.params['dual_as']
if dual_as != 'no_use':
-
+ if not fake_as:
+ module.fail_json(msg='fake_as must exist.')
conf_str = CE_GET_BGP_PEER_HEADER % (vrf_name, peerip) + \
"" + CE_GET_BGP_PEER_TAIL
recv_xml = self.netconf_get_config(module=module, conf_str=conf_str)
@@ -938,7 +939,8 @@ class BgpNeighbor(object):
prepend_global_as = module.params['prepend_global_as']
if prepend_global_as != 'no_use':
-
+ if not fake_as:
+ module.fail_json(msg='fake_as must exist.')
conf_str = CE_GET_BGP_PEER_HEADER % (vrf_name, peerip) + \
"" + CE_GET_BGP_PEER_TAIL
recv_xml = self.netconf_get_config(module=module, conf_str=conf_str)
@@ -958,7 +960,8 @@ class BgpNeighbor(object):
prepend_fake_as = module.params['prepend_fake_as']
if prepend_fake_as != 'no_use':
-
+ if not fake_as:
+ module.fail_json(msg='fake_as must exist.')
conf_str = CE_GET_BGP_PEER_HEADER % (vrf_name, peerip) + \
"" + CE_GET_BGP_PEER_TAIL
recv_xml = self.netconf_get_config(module=module, conf_str=conf_str)
@@ -1473,7 +1476,7 @@ class BgpNeighbor(object):
if local_if_name:
conf_str += "%s" % local_if_name
- cmd = "peer %s connect-interface local_if_name" % peer_addr
+ cmd = "peer %s connect-interface %s" % (peer_addr, local_if_name)
cmds.append(cmd)
ebgp_max_hop = module.params['ebgp_max_hop']
@@ -1580,14 +1583,20 @@ class BgpNeighbor(object):
if mpls_local_ifnet_disable != 'no_use':
conf_str += "%s" % mpls_local_ifnet_disable
+ if mpls_local_ifnet_disable == "false":
+ cmd = "undo peer %s mpls-local-ifnet disable" % peer_addr
+ else:
+ cmd = "peer %s mpls-local-ifnet disable" % peer_addr
+ cmds.append(cmd)
+
prepend_global_as = module.params['prepend_global_as']
if prepend_global_as != 'no_use':
conf_str += "%s" % prepend_global_as
if prepend_global_as == "true":
- cmd = "peer %s public-as-only" % peer_addr
+ cmd = "peer %s local-as %s prepend-global-as" % (peer_addr, fake_as)
else:
- cmd = "undo peer %s public-as-only" % peer_addr
+ cmd = "undo peer %s local-as %s prepend-global-as" % (peer_addr, fake_as)
cmds.append(cmd)
prepend_fake_as = module.params['prepend_fake_as']
@@ -1595,9 +1604,9 @@ class BgpNeighbor(object):
conf_str += "%s" % prepend_fake_as
if prepend_fake_as == "true":
- cmd = "peer %s prepend-local-as" % peer_addr
+ cmd = "peer %s local-as %s prepend-local-as" % (peer_addr, fake_as)
else:
- cmd = "undo peer %s prepend-local-as" % peer_addr
+ cmd = "undo peer %s local-as %s prepend-local-as" % (peer_addr, fake_as)
cmds.append(cmd)
conf_str += CE_MERGE_BGP_PEER_TAIL