Implementation of junos_static_route module (#26501)

* Implementation of junos_static_route module

*  junos implementation of net_static_route
*  integration test for junos_static_route
*  integration test for junos net_static_route

* Minor change

* Doc change

* Fix CI issue
This commit is contained in:
Ganesh Nalawade 2017-07-07 13:25:14 +05:30 committed by GitHub
parent 63f4aa3069
commit ba60ac04fc
10 changed files with 479 additions and 1 deletions

View file

@ -99,8 +99,15 @@
rescue:
- set_fact: test_failed=true
- block:
- include_role:
name: junos_static_route
when: "limit_to in ['*', 'junos_static_route']"
rescue:
- set_fact: test_failed=true
###########
- name: Has any previous test failed?
fail:
msg: "One or more tests failed, check log for details"
when: test_failed
when: test_failed

View file

@ -0,0 +1,2 @@
---
testcase: "*"

View file

@ -0,0 +1,2 @@
---
- { include: netconf.yaml, tags: ['netconf'] }

View file

@ -0,0 +1,16 @@
---
- name: collect all netconf test cases
find:
paths: "{{ role_path }}/tests/netconf"
patterns: "{{ testcase }}.yaml"
register: test_cases
delegate_to: localhost
- 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

View file

@ -0,0 +1,142 @@
---
- debug: msg="START junos_static_route netconf/basic.yaml"
- name: setup - remove static route
junos_static_route:
address: 1.1.1.0/24
state: absent
provider: "{{ netconf }}"
- name: Confgiure static route
junos_static_route:
address: 1.1.1.0/24
next_hop: 3.3.3.3
preference: 10
qualified_next_hop: 5.5.5.5
qualified_preference: 30
state: present
provider: "{{ netconf }}"
register: result
- name: Get running configuration
junos_rpc:
rpc: get-configuration
provider: "{{ netconf }}"
register: config
- assert:
that:
- "result.changed == true"
- "'<name>1.1.1.0/24</name>' in config.xml"
- "'<next-hop>3.3.3.3</next-hop>' in config.xml"
- "'<qualified-next-hop>' in config.xml"
- "'<name>5.5.5.5</name>' in config.xml"
- "'<preference>30</preference>' in config.xml"
- "'<metric-value>10</metric-value>' in config.xml"
- name: Confgiure static route (idempotent)
junos_static_route:
address: 1.1.1.0/24
next_hop: 3.3.3.3
preference: 10
qualified_next_hop: 5.5.5.5
qualified_preference: 30
state: present
provider: "{{ netconf }}"
register: result
- assert:
that:
- "result.changed == false"
- name: Deactivate static route
junos_static_route:
address: 1.1.1.0/24
next_hop: 3.3.3.3
preference: 10
qualified_next_hop: 5.5.5.5
qualified_preference: 30
state: present
active: False
provider: "{{ netconf }}"
register: result
- name: Get running configuration
junos_rpc:
rpc: get-configuration
provider: "{{ netconf }}"
register: config
- assert:
that:
- "result.changed == true"
- "'<route inactive=\"inactive\">' in config.xml"
- "'inactive: route 1.1.1.0/24' in result.diff"
- name: Activate static route
junos_static_route:
address: 1.1.1.0/24
next_hop: 3.3.3.3
preference: 10
qualified_next_hop: 5.5.5.5
qualified_preference: 30
state: present
active: True
provider: "{{ netconf }}"
register: result
- name: Get running configuration
junos_rpc:
rpc: get-configuration
provider: "{{ netconf }}"
register: config
- assert:
that:
- "result.changed == true"
- "'<name>1.1.1.0/24</name>' in config.xml"
- "'<next-hop>3.3.3.3</next-hop>' in config.xml"
- "'<qualified-next-hop>' in config.xml"
- "'<name>5.5.5.5</name>' in config.xml"
- "'<preference>30</preference>' in config.xml"
- "'<metric-value>10</metric-value>' in config.xml"
- "'inactive: route 1.1.1.0/24' not in result.diff"
- name: Delete static route
junos_static_route:
address: 1.1.1.0/24
next_hop: 3.3.3.3
preference: 10
qualified_next_hop: 5.5.5.5
qualified_preference: 30
state: absent
active: True
provider: "{{ netconf }}"
register: result
- name: Get running configuration
junos_rpc:
rpc: get-configuration
provider: "{{ netconf }}"
register: config
- assert:
that:
- "result.changed == true"
- "'<name>1.1.1.0/24</name>' not in config.xml"
- name: Delete static route (idempotent)
junos_static_route:
address: 1.1.1.0/24
next_hop: 3.3.3.3
preference: 10
qualified_next_hop: 5.5.5.5
qualified_preference: 30
state: absent
active: True
provider: "{{ netconf }}"
register: result
- assert:
that:
- "result.changed == false"

View file

@ -1,2 +1,3 @@
---
- { include: cli.yaml, tags: ['cli'] }
- { include: netconf.yaml, tags: ['netconf'] }

View file

@ -0,0 +1,16 @@
---
- name: collect all netconf test cases
find:
paths: "{{ role_path }}/tests/netconf"
patterns: "{{ testcase }}.yaml"
register: test_cases
delegate_to: localhost
- 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

View file

@ -0,0 +1,71 @@
---
- debug: msg="START net_static_route junos/basic.yaml"
- name: setup - remove static route
net_static_route:
address: 1.1.1.0/24
state: absent
provider: "{{ netconf }}"
- name: Confgiure static route
net_static_route:
prefix: 1.1.1.0/24
next_hop: 3.3.3.3
admin_distance: 10
state: present
provider: "{{ netconf }}"
register: result
- name: Get running configuration
junos_rpc:
rpc: get-configuration
provider: "{{ netconf }}"
register: config
- assert:
that:
- "result.changed == true"
- "'<name>1.1.1.0/24</name>' in config.xml"
- "'<next-hop>3.3.3.3</next-hop>' in config.xml"
- name: Confgiure static route (idempotent)
net_static_route:
prefix: 1.1.1.0/24
next_hop: 3.3.3.3
admin_distance: 10
state: present
provider: "{{ netconf }}"
register: result
- assert:
that:
- "result.changed == false"
- name: Delete static route
net_static_route:
prefix: 1.1.1.0/24
state: absent
provider: "{{ netconf }}"
register: result
- name: Get running configuration
junos_rpc:
rpc: get-configuration
provider: "{{ netconf }}"
register: config
- assert:
that:
- "result.changed == true"
- "'<name>1.1.1.0/24</name>' not in config.xml"
- name: Delete static route (idempotent)
net_static_route:
prefix: 1.1.1.0/24
state: absent
provider: "{{ netconf }}"
register: result
- assert:
that:
- "result.changed == false"

View file

@ -0,0 +1,3 @@
---
- include: "{{ role_path }}/tests/junos/basic.yaml"
when: hostvars[inventory_hostname]['ansible_network_os'] == 'junos'