summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAshwini Mhatre <mashu97@gmail.com>2021-07-07 20:33:54 +0530
committerGitHub <noreply@github.com>2021-07-07 15:03:54 +0000
commit5c767d4266fe028cc0c11b05447e61ae89af9d45 (patch)
tree30e7bd1b330845f689009bc2bf5005a315259d1a
parente8e9cc5537c36a1f5eaf28cfc16b4101028f2013 (diff)
downloadvyos-ansible-old-5c767d4266fe028cc0c11b05447e61ae89af9d45.tar.gz
vyos-ansible-old-5c767d4266fe028cc0c11b05447e61ae89af9d45.zip
fix issue in route-maps facts code when route-maps facts are empty. (#182)
fix issue in route-maps facts code when route-maps facts are empty. SUMMARY fixes: #181 ISSUE TYPE Bugfix Pull Request COMPONENT NAME ADDITIONAL INFORMATION Reviewed-by: Rohit Thakur <rohitthakur2590@outlook.com>
-rw-r--r--changelogs/fragments/fix_issue_vyos_facts.yaml3
-rw-r--r--plugins/module_utils/network/vyos/config/route_maps/route_maps.py2
-rw-r--r--plugins/modules/vyos_route_maps.py4
-rw-r--r--tests/integration/targets/vyos_route_maps/tests/cli/deleted.yaml6
-rw-r--r--tests/integration/targets/vyos_route_maps/tests/cli/merged.yaml6
-rw-r--r--tests/integration/targets/vyos_route_maps/vars/main.yaml1
6 files changed, 19 insertions, 3 deletions
diff --git a/changelogs/fragments/fix_issue_vyos_facts.yaml b/changelogs/fragments/fix_issue_vyos_facts.yaml
new file mode 100644
index 0000000..81653a0
--- /dev/null
+++ b/changelogs/fragments/fix_issue_vyos_facts.yaml
@@ -0,0 +1,3 @@
+---
+bugfixes:
+ - fix issue in route-maps facts code when route-maps facts are empty.
diff --git a/plugins/module_utils/network/vyos/config/route_maps/route_maps.py b/plugins/module_utils/network/vyos/config/route_maps/route_maps.py
index 5e4bbea..467d782 100644
--- a/plugins/module_utils/network/vyos/config/route_maps/route_maps.py
+++ b/plugins/module_utils/network/vyos/config/route_maps/route_maps.py
@@ -40,7 +40,7 @@ class Route_maps(ResourceModule):
def __init__(self, module):
super(Route_maps, self).__init__(
- empty_fact_val={},
+ empty_fact_val=[],
facts_module=Facts(module),
module=module,
resource="route_maps",
diff --git a/plugins/modules/vyos_route_maps.py b/plugins/modules/vyos_route_maps.py
index c8e7352..27fac07 100644
--- a/plugins/modules/vyos_route_maps.py
+++ b/plugins/modules/vyos_route_maps.py
@@ -350,7 +350,7 @@ EXAMPLES = """
# "route_map": "test3"
# }
# ],
-# "before": {},
+# "before": [],
# "changed": true,
# "commands": [
# "set policy route-map test1 rule 1 description test",
@@ -558,7 +558,7 @@ EXAMPLES = """
#
# Module Execution:
#
-# "after": {},
+# "after": [],
# "before": [
# {
# "entries": [
diff --git a/tests/integration/targets/vyos_route_maps/tests/cli/deleted.yaml b/tests/integration/targets/vyos_route_maps/tests/cli/deleted.yaml
index c8b9e26..2999d63 100644
--- a/tests/integration/targets/vyos_route_maps/tests/cli/deleted.yaml
+++ b/tests/integration/targets/vyos_route_maps/tests/cli/deleted.yaml
@@ -21,6 +21,12 @@
- result.changed == true
- result.commands|symmetric_difference(deleted.commands) == []
+ - name: Assert that the after dicts were correctly generated
+ assert:
+ that:
+ - "{{ deleted['after'] | symmetric_difference(result['after']) |length\
+ \ == 0 }}"
+
- name: Delete the existing configuration with the provided running configuration
(IDEMPOTENT)
register: result
diff --git a/tests/integration/targets/vyos_route_maps/tests/cli/merged.yaml b/tests/integration/targets/vyos_route_maps/tests/cli/merged.yaml
index 56812e4..4b5ad4c 100644
--- a/tests/integration/targets/vyos_route_maps/tests/cli/merged.yaml
+++ b/tests/integration/targets/vyos_route_maps/tests/cli/merged.yaml
@@ -44,6 +44,12 @@
- result.commands|symmetric_difference(merged.commands) == []
- result.after|symmetric_difference(ansible_facts['network_resources']['route_maps']) == []
+ - name: Assert that before dicts were correctly generated
+ assert:
+ that:
+ - "{{ merged['before'] | symmetric_difference(result['before']) |length\
+ \ == 0 }}"
+
- name:
Merge the provided configuration with the existing running configuration
(IDEMPOTENT)
diff --git a/tests/integration/targets/vyos_route_maps/vars/main.yaml b/tests/integration/targets/vyos_route_maps/vars/main.yaml
index 5a0d027..47658f4 100644
--- a/tests/integration/targets/vyos_route_maps/vars/main.yaml
+++ b/tests/integration/targets/vyos_route_maps/vars/main.yaml
@@ -1,5 +1,6 @@
---
merged:
+ before: []
commands:
- set policy route-map test1 rule 1 description test
- set policy route-map test1 rule 1 action permit