diff --git a/plugins/module_utils/network/iosxr/rm_templates/route_maps.py b/plugins/module_utils/network/iosxr/rm_templates/route_maps.py index 0653446e5..7c841c8c3 100644 --- a/plugins/module_utils/network/iosxr/rm_templates/route_maps.py +++ b/plugins/module_utils/network/iosxr/rm_templates/route_maps.py @@ -333,13 +333,13 @@ def __init__(self, lines=None, module=None): "getval": re.compile( r""" \s*set\scommunity - (\s(?P.*))? + (\s(?P(.*?)))? (\s(?Padditive))? $""", re.VERBOSE, ), "setval": "set community" "{{ (' ' + set.community.community_name ) if set.community.community_name is defined else '' }}" - "{{ (' additive' ) if set.community.additive is defined else '' }}", + "{{ (' additive') if set.community.additive|d(False) else '' }}", "result": { "policies": { "set": { diff --git a/tests/integration/targets/iosxr_l2_interfaces/tests/cli/_remove_config.yaml b/tests/integration/targets/iosxr_l2_interfaces/tests/cli/_remove_config.yaml index d8205e5ac..aeb543e83 100644 --- a/tests/integration/targets/iosxr_l2_interfaces/tests/cli/_remove_config.yaml +++ b/tests/integration/targets/iosxr_l2_interfaces/tests/cli/_remove_config.yaml @@ -8,6 +8,7 @@ - GigabitEthernet 0/0/0/3.900 - GigabitEthernet 0/0/0/4 - GigabitEthernet0/0/0/4.1 + - GigabitEthernet0/0/0/5 ignore_errors: true cisco.iosxr.iosxr_config: lines: diff --git a/tests/integration/targets/iosxr_l2_interfaces/tests/cli/replaced.yaml b/tests/integration/targets/iosxr_l2_interfaces/tests/cli/replaced.yaml index dfae20d54..c95c9f541 100644 --- a/tests/integration/targets/iosxr_l2_interfaces/tests/cli/replaced.yaml +++ b/tests/integration/targets/iosxr_l2_interfaces/tests/cli/replaced.yaml @@ -11,7 +11,7 @@ register: result cisco.iosxr.iosxr_l2_interfaces: &id001 config: - - name: GigabitEthernet0/0/0/1 + - name: GigabitEthernet0/0/0/4 l2transport: true l2protocol: - cpsv: drop diff --git a/tests/integration/targets/iosxr_l2_interfaces/vars/main.yaml b/tests/integration/targets/iosxr_l2_interfaces/vars/main.yaml index e8d60bbe9..b5dfc87d7 100644 --- a/tests/integration/targets/iosxr_l2_interfaces/vars/main.yaml +++ b/tests/integration/targets/iosxr_l2_interfaces/vars/main.yaml @@ -55,7 +55,7 @@ replaced: l2transport: true name: GigabitEthernet0/0/0/4 commands: - - interface GigabitEthernet0/0/0/1 + - interface GigabitEthernet0/0/0/4 - no l2transport - l2transport l2protocol cpsv drop after: @@ -63,15 +63,16 @@ replaced: - name: Loopback999 - name: MgmtEth0/RP0/CPU0/0 - l2protocol: - - cpsv: drop + - cpsv: tunnel l2transport: true + propagate: true name: GigabitEthernet0/0/0/1 - name: GigabitEthernet0/0/0/3.900 encapsulation: dot1q: 40 second_dot1q: 60 - l2protocol: - - cpsv: tunnel + - cpsv: drop l2transport: true name: GigabitEthernet0/0/0/4 @@ -140,3 +141,4 @@ deleted: - name: Loopback999 - name: MgmtEth0/RP0/CPU0/0 - name: GigabitEthernet0/0/0/3.900 + - name: GigabitEthernet0/0/0/4 diff --git a/tests/integration/targets/iosxr_lacp_interfaces/tests/cli/gathered.yaml b/tests/integration/targets/iosxr_lacp_interfaces/tests/cli/gathered.yaml index 527c3c0da..231b5ef9d 100644 --- a/tests/integration/targets/iosxr_lacp_interfaces/tests/cli/gathered.yaml +++ b/tests/integration/targets/iosxr_lacp_interfaces/tests/cli/gathered.yaml @@ -19,7 +19,7 @@ mac: 00c2.4c00.bd15 - name: GigabitEthernet0/0/0/1 - period: 100 + period: 200 state: merged - name: Gather interfaces facts using gathered state diff --git a/tests/integration/targets/iosxr_lacp_interfaces/tests/cli/merged.yaml b/tests/integration/targets/iosxr_lacp_interfaces/tests/cli/merged.yaml index 4ca41988e..fedf432fc 100644 --- a/tests/integration/targets/iosxr_lacp_interfaces/tests/cli/merged.yaml +++ b/tests/integration/targets/iosxr_lacp_interfaces/tests/cli/merged.yaml @@ -19,7 +19,7 @@ mac: 00c2.4c00.bd15 - name: GigabitEthernet0/0/0/1 - period: 100 + period: 200 state: merged - name: Assert that before dicts were correctly generated diff --git a/tests/integration/targets/iosxr_lacp_interfaces/vars/main.yaml b/tests/integration/targets/iosxr_lacp_interfaces/vars/main.yaml index a57a4e412..e3496f4dc 100644 --- a/tests/integration/targets/iosxr_lacp_interfaces/vars/main.yaml +++ b/tests/integration/targets/iosxr_lacp_interfaces/vars/main.yaml @@ -11,7 +11,7 @@ merged: - interface Bundle-Ether11 - lacp system mac 00c2.4c00.bd15 - interface GigabitEthernet0/0/0/1 - - lacp period 100 + - lacp period 200 after: - name: Bundle-Ether10 churn_logging: actor @@ -22,7 +22,7 @@ merged: mac: 00c2.4c00.bd15 - name: GigabitEthernet0/0/0/0 - name: GigabitEthernet0/0/0/1 - period: 100 + period: 200 populate: - name: Bundle-Ether10 churn_logging: actor diff --git a/tests/integration/targets/iosxr_route_maps/tests/common/_parsed.cfg b/tests/integration/targets/iosxr_route_maps/tests/common/_parsed.cfg index a6d4ff88d..9a4cea6d4 100644 --- a/tests/integration/targets/iosxr_route_maps/tests/common/_parsed.cfg +++ b/tests/integration/targets/iosxr_route_maps/tests/common/_parsed.cfg @@ -1,3 +1,8 @@ +route-policy POLICY_TWO_PARAMS($SPECIFICITY, $GEO_LOCATION) + set community (64496:100, 64496:$SPECIFICITY, 64496:$GEO_LOCATION, 65012:174) + set local-preference 150 +end-policy +! route-policy COMPLEX_ROUTE_POLICY if destination in A_RANDOM_POLICY_DUMMY then drop diff --git a/tests/integration/targets/iosxr_route_maps/tests/common/merged.yaml b/tests/integration/targets/iosxr_route_maps/tests/common/merged.yaml index 94e2efa62..731f6e8d8 100644 --- a/tests/integration/targets/iosxr_route_maps/tests/common/merged.yaml +++ b/tests/integration/targets/iosxr_route_maps/tests/common/merged.yaml @@ -54,6 +54,13 @@ condition: community matches-any (9119:1001) or community matches-any (11100:1001) drop: true name: COMPLEX_CONDITION_ROUTE_POLICY + - global: + set: + community: + community_name: (64496:100, 64496:$SPECIFICITY, 64496:$GEO_LOCATION, 65012:174) + local_preference: + - metric_number: 150 + name: POLICY_TWO_PARAMS($SPECIFICITY, $GEO_LOCATION) register: result - name: Assert that before dicts were correctly generated diff --git a/tests/integration/targets/iosxr_route_maps/vars/main.yaml b/tests/integration/targets/iosxr_route_maps/vars/main.yaml index f7557764c..b2b965b47 100644 --- a/tests/integration/targets/iosxr_route_maps/vars/main.yaml +++ b/tests/integration/targets/iosxr_route_maps/vars/main.yaml @@ -9,6 +9,10 @@ merged: - "set extcommunity rt 65000:100 additive" - "set weight 20000" - "end-policy" + - "route-policy POLICY_TWO_PARAMS($SPECIFICITY, $GEO_LOCATION)" + - "set community (64496:100, 64496:$SPECIFICITY, 64496:$GEO_LOCATION, 65012:174)" + - "set local-preference 150\n" + - "end-policy" - "route-policy SIMPLE_CONDITION_ROUTE_POLICY" - "if destination in SIMPLE_CONDITION_ROUTE_POLICY then" - "pass" @@ -34,27 +38,34 @@ merged: - "endif" - "end-policy" after: + - global: + set: + community: + community_name: "(64496:100, 64496:$SPECIFICITY, 64496:$GEO_LOCATION, 65012:174)" + local_preference: + - metric_number: 150 + name: "POLICY_TWO_PARAMS($SPECIFICITY, $GEO_LOCATION)" - else_section: else_section: drop: true if_section: - condition: destination in A_RANDOM_POLICY + condition: "destination in A_RANDOM_POLICY" pass: true if_section: - condition: destination in A_RANDOM_POLICY_DUMMY + condition: "destination in A_RANDOM_POLICY_DUMMY" drop: true - name: COMPLEX_ROUTE_POLICY + name: "COMPLEX_ROUTE_POLICY" - global: apply: - - route_policy: A_NEW_ROUTE_POLICY + - route_policy: "A_NEW_ROUTE_POLICY" set: community: additive: true - community_name: (11011:1001) + community_name: "(11011:1001)" med: value: 100 extcommunity: - rt: 65000:100 + rt: "65000:100" additive: true weight: 20000 local_preference: @@ -64,21 +75,21 @@ merged: metric_number: 200 - multiply: true metric_number: 300 - name: SIMPLE_GLOBAL_ROUTE_POLICY + name: "SIMPLE_GLOBAL_ROUTE_POLICY" - else_section: global: drop: true if_section: - condition: destination in SIMPLE_CONDITION_ROUTE_POLICY + condition: "destination in SIMPLE_CONDITION_ROUTE_POLICY" pass: true - name: SIMPLE_CONDITION_ROUTE_POLICY + name: "SIMPLE_CONDITION_ROUTE_POLICY" - else_section: global: pass: true if_section: - condition: community matches-any (9119:1001) or community matches-any (11100:1001) + condition: "community matches-any (9119:1001) or community matches-any (11100:1001)" drop: true - name: COMPLEX_CONDITION_ROUTE_POLICY + name: "COMPLEX_CONDITION_ROUTE_POLICY" overridden: commands: @@ -100,6 +111,7 @@ overridden: - endif - endif - end-policy + - no route-policy POLICY_TWO_PARAMS($SPECIFICITY, $GEO_LOCATION) - no route-policy COMPLEX_ROUTE_POLICY - no route-policy SIMPLE_GLOBAL_ROUTE_POLICY - no route-policy SIMPLE_CONDITION_ROUTE_POLICY @@ -134,6 +146,13 @@ overridden: metric_number: 300 name: SIMPLE_GLOBAL_ROUTE_POLICY_overridden before: + - global: + set: + community: + community_name: (64496:100, 64496:$SPECIFICITY, 64496:$GEO_LOCATION, 65012:174) + local_preference: + - metric_number: 150 + name: POLICY_TWO_PARAMS($SPECIFICITY, $GEO_LOCATION) - else_section: else_section: drop: true @@ -216,6 +235,13 @@ rendered: deleted: after: + - global: + set: + community: + community_name: "(64496:100, 64496:$SPECIFICITY, 64496:$GEO_LOCATION, 65012:174)" + local_preference: + - metric_number: 150 + name: POLICY_TWO_PARAMS($SPECIFICITY, $GEO_LOCATION) - global: apply: - route_policy: A_NEW_ROUTE_POLICY diff --git a/tests/integration/targets/iosxr_smoke/tests/cli/caching.yaml b/tests/integration/targets/iosxr_smoke/tests/cli/caching.yaml index 3ff359ca8..4067f50fc 100644 --- a/tests/integration/targets/iosxr_smoke/tests/cli/caching.yaml +++ b/tests/integration/targets/iosxr_smoke/tests/cli/caching.yaml @@ -30,7 +30,7 @@ register: result cisco.iosxr.iosxr_interfaces: &merged config: - - name: GigabitEthernet0/0/0/1 + - name: GigabitEthernet0/0/0/3 description: Configured by Ansible mtu: 110 enabled: true @@ -46,7 +46,7 @@ - ansible.builtin.assert: that: - - '"interface GigabitEthernet0/0/0/1" in result.commands' + - '"interface GigabitEthernet0/0/0/3" in result.commands' - '"description Configured by Ansible" in result.commands' - '"mtu 110" in result.commands' - '"duplex half" in result.commands' @@ -70,7 +70,7 @@ register: result cisco.iosxr.iosxr_l2_interfaces: &mergedl2 config: - - name: GigabitEthernet0/0/0/1 + - name: GigabitEthernet0/0/0/5 l2transport: true l2protocol: - cpsv: drop @@ -85,7 +85,7 @@ - ansible.builtin.assert: that: - - '"interface GigabitEthernet0/0/0/1" in result.commands' + - '"interface GigabitEthernet0/0/0/5" in result.commands' - '"l2transport l2protocol cpsv drop" in result.commands' - '"l2transport propagate remote-status" in result.commands' - '"interface GigabitEthernet0/0/0/4.1" in result.commands' diff --git a/tests/integration/targets/iosxr_vrf_interfaces/vars/main.yaml b/tests/integration/targets/iosxr_vrf_interfaces/vars/main.yaml index 6695f4e8e..362e7cf3a 100644 --- a/tests/integration/targets/iosxr_vrf_interfaces/vars/main.yaml +++ b/tests/integration/targets/iosxr_vrf_interfaces/vars/main.yaml @@ -9,6 +9,8 @@ gathered: vrf_name: vrf_A - name: GigabitEthernet0/0/0/2 vrf_name: vrf_B + - name: GigabitEthernet0/0/0/3 + - name: GigabitEthernet0/0/0/5 merged: commands: @@ -25,6 +27,8 @@ merged: vrf_name: vrf_C - name: GigabitEthernet0/0/0/2 vrf_name: vrf_D + - name: GigabitEthernet0/0/0/3 + - name: GigabitEthernet0/0/0/5 overridden: commands: @@ -40,6 +44,8 @@ overridden: - name: GigabitEthernet0/0/0/1 vrf_name: vrf_C - name: GigabitEthernet0/0/0/2 + - name: GigabitEthernet0/0/0/3 + - name: GigabitEthernet0/0/0/5 before: - name: Loopback888 - name: Loopback999 @@ -49,6 +55,8 @@ overridden: vrf_name: vrf_A - name: GigabitEthernet0/0/0/2 vrf_name: vrf_B + - name: GigabitEthernet0/0/0/3 + - name: GigabitEthernet0/0/0/5 parsed: result: - name: Loopback888 diff --git a/tests/integration/targets/prepare_iosxr_tests/tasks/main.yml b/tests/integration/targets/prepare_iosxr_tests/tasks/main.yml index d93230f9e..b7403bc85 100644 --- a/tests/integration/targets/prepare_iosxr_tests/tasks/main.yml +++ b/tests/integration/targets/prepare_iosxr_tests/tasks/main.yml @@ -1,16 +1,19 @@ --- - name: Ensure we have loopback 888 for testing - connection: ansible.netcommon.network_cli cisco.iosxr.iosxr_config: src: config.j2 + vars: + ansible_connection: ansible.netcommon.network_cli - name: Enable netconf service - connection: ansible.netcommon.network_cli - tags: netconf cisco.iosxr.iosxr_netconf: netconf_port: 830 netconf_vrf: default state: present + vars: + ansible_connection: ansible.netcommon.network_cli + tags: + - netconf - name: Set facts ansible.builtin.set_fact: diff --git a/tests/unit/modules/network/iosxr/test_iosxr_route_maps.py b/tests/unit/modules/network/iosxr/test_iosxr_route_maps.py index e51c0feaa..1641b30e9 100644 --- a/tests/unit/modules/network/iosxr/test_iosxr_route_maps.py +++ b/tests/unit/modules/network/iosxr/test_iosxr_route_maps.py @@ -1456,4 +1456,4 @@ def test_iosxr_routemap_multiple_params_gathered(self): }, ] result = self.execute_module(changed=False) - self.assertEqual(gathered, result["gathered"]) + self.assertEqual(sorted(gathered), sorted(result["gathered"]))