From fb897c3f486f56bbb01a74f4c9331c6ef76c0ae9 Mon Sep 17 00:00:00 2001
From: yanzhangi <51999930+yanzhangi@users.noreply.github.com>
Date: Sat, 12 Oct 2019 23:44:21 +0800
Subject: [PATCH] [Backport/2.9/62589]update ce_bgp_af to fix bugs (#62652)
* update ce_bgp_af to fix bugs (#62589)
* update to fix bugs
* update to fix bugs
(cherry picked from commit 2a206f0e4c8cfdb431bd2b5f98992cb839e4a975)
* Update ce_bgp_af modified information
---
.../fragments/62589-ce_bgp_af-to-fix-bugs.yml | 2 ++
.../modules/network/cloudengine/ce_bgp_af.py | 20 +++++++++++--------
2 files changed, 14 insertions(+), 8 deletions(-)
create mode 100644 changelogs/fragments/62589-ce_bgp_af-to-fix-bugs.yml
diff --git a/changelogs/fragments/62589-ce_bgp_af-to-fix-bugs.yml b/changelogs/fragments/62589-ce_bgp_af-to-fix-bugs.yml
new file mode 100644
index 00000000000..e0f5314630a
--- /dev/null
+++ b/changelogs/fragments/62589-ce_bgp_af-to-fix-bugs.yml
@@ -0,0 +1,2 @@
+bugfixes:
+- ce_bgp_af - update to fix some bugs - Add some update statements. (https://github.com/ansible/ansible/pull/62589)
diff --git a/lib/ansible/modules/network/cloudengine/ce_bgp_af.py b/lib/ansible/modules/network/cloudengine/ce_bgp_af.py
index c0918996593..80d3584e550 100644
--- a/lib/ansible/modules/network/cloudengine/ce_bgp_af.py
+++ b/lib/ansible/modules/network/cloudengine/ce_bgp_af.py
@@ -2555,15 +2555,15 @@ class BgpAf(object):
cmds.append(cmd)
preference_external = module.params['preference_external']
- if preference_external:
- conf_str += "%s" % preference_external
-
preference_internal = module.params['preference_internal']
- if preference_internal:
- conf_str += "%s" % preference_internal
-
preference_local = module.params['preference_local']
- if preference_local:
+ if any([preference_external, preference_internal, preference_local]):
+ preference_external = preference_external or "255"
+ preference_internal = preference_internal or "255"
+ preference_local = preference_local or "255"
+
+ conf_str += "%s" % preference_external
+ conf_str += "%s" % preference_internal
conf_str += "%s" % preference_local
cmd = "preference %s %s %s" % (
@@ -2808,6 +2808,8 @@ class BgpAf(object):
cmds = []
cmd = "import-route %s %s" % (import_protocol, import_process_id)
+ if import_protocol == "direct" or import_protocol == "static":
+ cmd = "import-route %s" % import_protocol
cmds.append(cmd)
return cmds
@@ -2836,7 +2838,7 @@ class BgpAf(object):
cmds = []
cmd = "import-route %s %s" % (import_protocol, import_process_id)
- if import_process_id == "0":
+ if import_protocol == "direct" or import_protocol == "static":
cmd = "import-route %s" % import_protocol
cmds.append(cmd)
@@ -2866,6 +2868,8 @@ class BgpAf(object):
cmds = []
cmd = "undo import-route %s %s" % (import_protocol, import_process_id)
+ if import_protocol == "direct" or import_protocol == "static":
+ cmd = "undo import-route %s" % import_protocol
cmds.append(cmd)
return cmds