mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 05:10:22 -07:00
Add net_vrf implementation for junos (#27055)
* junos_vrf implementation * junos_vrf integration test * net_vrf integration test for junos
This commit is contained in:
parent
13e7e00706
commit
5ab8d30d10
10 changed files with 625 additions and 0 deletions
3
test/integration/targets/junos_vrf/defaults/main.yaml
Normal file
3
test/integration/targets/junos_vrf/defaults/main.yaml
Normal file
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
testcase: "*"
|
||||
test_items: []
|
2
test/integration/targets/junos_vrf/tasks/main.yaml
Normal file
2
test/integration/targets/junos_vrf/tasks/main.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
- { include: netconf.yaml, tags: ['netconf'] }
|
14
test/integration/targets/junos_vrf/tasks/netconf.yaml
Normal file
14
test/integration/targets/junos_vrf/tasks/netconf.yaml
Normal file
|
@ -0,0 +1,14 @@
|
|||
- name: collect netconf test cases
|
||||
find:
|
||||
paths: "{{ role_path }}/tests/netconf"
|
||||
patterns: "{{ testcase }}.yaml"
|
||||
register: test_cases
|
||||
|
||||
- name: set test_items
|
||||
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
|
||||
|
||||
- name: run test case
|
||||
include: "{{ test_case_to_run }}"
|
||||
with_items: "{{ test_items }}"
|
||||
loop_control:
|
||||
loop_var: test_case_to_run
|
171
test/integration/targets/junos_vrf/tests/netconf/basic.yaml
Normal file
171
test/integration/targets/junos_vrf/tests/netconf/basic.yaml
Normal file
|
@ -0,0 +1,171 @@
|
|||
---
|
||||
- debug: msg="START junos_vrf netconf/basic.yaml"
|
||||
|
||||
- name: setup - remove vrf
|
||||
junos_vrf:
|
||||
name: test-1
|
||||
state: absent
|
||||
provider: "{{ netconf }}"
|
||||
|
||||
- name: Configure vrf and its parameter
|
||||
junos_vrf:
|
||||
name: test-1
|
||||
description: test-vrf-1
|
||||
interfaces:
|
||||
- ge-0/0/6
|
||||
- ge-0/0/5
|
||||
rd: 3.3.3.3:10
|
||||
target: target:65513:111
|
||||
state: present
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'+ test-1' in result.diff.prepared"
|
||||
- "'+ description test-vrf-1;' in result.diff.prepared"
|
||||
- "'+ instance-type vrf;' in result.diff.prepared"
|
||||
- "'+ interface ge-0/0/5.0;' in result.diff.prepared"
|
||||
- "'+ interface ge-0/0/6.0;' in result.diff.prepared"
|
||||
- "'+ route-distinguisher 3.3.3.3:10;' in result.diff.prepared"
|
||||
- "'+ vrf-target target:65513:111;' in result.diff.prepared"
|
||||
|
||||
- name: Configure vrf and its parameter (idempotent)
|
||||
junos_vrf:
|
||||
name: test-1
|
||||
description: test-vrf-1
|
||||
interfaces:
|
||||
- ge-0/0/6
|
||||
- ge-0/0/5
|
||||
rd: 3.3.3.3:10
|
||||
target: target:65513:111
|
||||
state: present
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: Change vrf parameter
|
||||
junos_vrf:
|
||||
name: test-1
|
||||
description: test-vrf-1
|
||||
interfaces:
|
||||
- ge-0/0/3
|
||||
- ge-0/0/2
|
||||
rd: 1.1.1.1:10
|
||||
target: target:65514:113
|
||||
state: present
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'[edit routing-instances test-1]' in result.diff.prepared"
|
||||
- "'+ interface ge-0/0/2.0;' in result.diff.prepared"
|
||||
- "'+ interface ge-0/0/3.0;' in result.diff.prepared"
|
||||
- "'- interface ge-0/0/5.0;' in result.diff.prepared"
|
||||
- "'- interface ge-0/0/6.0;' in result.diff.prepared"
|
||||
- "'[edit routing-instances test-1]' in result.diff.prepared"
|
||||
- "'- route-distinguisher 3.3.3.3:10;' in result.diff.prepared"
|
||||
- "'+ route-distinguisher 1.1.1.1:10;' in result.diff.prepared"
|
||||
- "'- vrf-target target:65513:111;' in result.diff.prepared"
|
||||
- "'+ vrf-target target:65514:113;' in result.diff.prepared"
|
||||
|
||||
|
||||
- name: Deactivate vrf
|
||||
junos_vrf:
|
||||
name: test-1
|
||||
description: test-vrf-1
|
||||
interfaces:
|
||||
- ge-0/0/3
|
||||
- ge-0/0/2
|
||||
rd: 1.1.1.1:10
|
||||
target: target:65514:113
|
||||
state: present
|
||||
active: False
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'[edit routing-instances]' in result.diff.prepared"
|
||||
- "'! inactive: test-1' in result.diff.prepared"
|
||||
- "'[edit routing-instances test-1]' in result.diff.prepared"
|
||||
- "'! inactive: interface ge-0/0/2.0' in result.diff.prepared"
|
||||
- "'! inactive: interface ge-0/0/3.0' in result.diff.prepared"
|
||||
- "'[edit routing-instances test-1]' in result.diff.prepared"
|
||||
- "'! inactive: route-distinguisher' in result.diff.prepared"
|
||||
- "'! inactive: vrf-target' in result.diff.prepared"
|
||||
|
||||
- name: Activate vrf
|
||||
junos_vrf:
|
||||
name: test-1
|
||||
description: test-vrf-1
|
||||
interfaces:
|
||||
- ge-0/0/3
|
||||
- ge-0/0/2
|
||||
rd: 1.1.1.1:10
|
||||
target: target:65514:113
|
||||
state: present
|
||||
active: True
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'[edit routing-instances]' in result.diff.prepared"
|
||||
- "'! active: test-1' in result.diff.prepared"
|
||||
- "'[edit routing-instances test-1]' in result.diff.prepared"
|
||||
- "'! active: interface ge-0/0/2.0' in result.diff.prepared"
|
||||
- "'! active: interface ge-0/0/3.0' in result.diff.prepared"
|
||||
- "'[edit routing-instances test-1]' in result.diff.prepared"
|
||||
- "'! active: route-distinguisher' in result.diff.prepared"
|
||||
- "'! active: vrf-target' in result.diff.prepared"
|
||||
|
||||
- name: Delete vrf
|
||||
junos_vrf:
|
||||
name: test-1
|
||||
description: test-vrf-1
|
||||
interfaces:
|
||||
- ge-0/0/3
|
||||
- ge-0/0/2
|
||||
rd: 1.1.1.1:10
|
||||
target: target:65514:113
|
||||
state: absent
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'[edit routing-instances]' in result.diff.prepared"
|
||||
- "'- test-1' in result.diff.prepared"
|
||||
- "'- description test-vrf-1;' in result.diff.prepared"
|
||||
- "'- instance-type vrf;' in result.diff.prepared"
|
||||
- "'- interface ge-0/0/2.0;' in result.diff.prepared"
|
||||
- "'- interface ge-0/0/3.0;' in result.diff.prepared"
|
||||
- "'- route-distinguisher 1.1.1.1:10;' in result.diff.prepared"
|
||||
- "'- vrf-target target:65514:113;' in result.diff.prepared"
|
||||
|
||||
- name: Delete vrf (idempotent)
|
||||
junos_vrf:
|
||||
name: test-1
|
||||
description: test-vrf-1
|
||||
interfaces:
|
||||
- ge-0/0/3
|
||||
- ge-0/0/2
|
||||
rd: 1.1.1.1:10
|
||||
target: target:65514:113
|
||||
state: absent
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
Loading…
Add table
Add a link
Reference in a new issue