diff options
author | yanzhangi <51999930+yanzhangi@users.noreply.github.com> | 2019-10-12 03:35:35 +0800 |
---|---|---|
committer | Toshio Kuratomi <a.badger@gmail.com> | 2019-10-12 09:17:09 -0700 |
commit | 7e6c9c88e4b5128a581305a221940f4f0845cf23 (patch) | |
tree | 2d360e80c4d20fb9778452ec291b764419b7c592 | |
parent | d05831fbd4ab3f75e2644cb2cd3a0c11d0c429f9 (diff) | |
download | ansible-7e6c9c88e4b5128a581305a221940f4f0845cf23.tar.gz |
[Backport/2.9/60634]Update ce_bgp_neighbor to fix bugs (#62698)
* Update ce_bgp_neighbor modified information
* Update ce_bgp_neighbor to fix bugs
(cherry picked from commit dc5f127086c82bbc3b66f33e1e5dc6a6db8c46ce)
-rw-r--r-- | changelogs/fragments/60634-ce_bgp_neighbor-to-fix-bugs.yml | 2 | ||||
-rw-r--r-- | lib/ansible/modules/network/cloudengine/ce_bgp_neighbor.py | 25 |
2 files changed, 19 insertions, 8 deletions
diff --git a/changelogs/fragments/60634-ce_bgp_neighbor-to-fix-bugs.yml b/changelogs/fragments/60634-ce_bgp_neighbor-to-fix-bugs.yml new file mode 100644 index 0000000000..4f1775e54d --- /dev/null +++ b/changelogs/fragments/60634-ce_bgp_neighbor-to-fix-bugs.yml @@ -0,0 +1,2 @@ +bugfixes: +- ce_bgp_neighbor - update to fix some bugs - Add some update statements. (https://github.com/ansible/ansible/pull/60934) diff --git a/lib/ansible/modules/network/cloudengine/ce_bgp_neighbor.py b/lib/ansible/modules/network/cloudengine/ce_bgp_neighbor.py index 796bb109bb..48bdd0466d 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) + \ "<dualAs></dualAs>" + 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) + \ "<prependGlobalAs></prependGlobalAs>" + 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) + \ "<prependFakeAs></prependFakeAs>" + 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 += "<localIfName>%s</localIfName>" % 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 += "<mplsLocalIfnetDisable>%s</mplsLocalIfnetDisable>" % 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 += "<prependGlobalAs>%s</prependGlobalAs>" % 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 += "<prependFakeAs>%s</prependFakeAs>" % 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 |