summaryrefslogtreecommitdiff
path: root/test/integration/targets/junos_system
diff options
context:
space:
mode:
authorGanesh Nalawade <ganesh634@gmail.com>2017-06-22 09:34:50 +0530
committerGitHub <noreply@github.com>2017-06-22 09:34:50 +0530
commitb2f46753ecf7bae8ad20086bb9c8ebe4b67df533 (patch)
tree4665e82e37f260da708550da4fe7be670a63b3c4 /test/integration/targets/junos_system
parentdd07d11ae51755d5f383c34ebb5378611d9aa18c (diff)
downloadansible-b2f46753ecf7bae8ad20086bb9c8ebe4b67df533.tar.gz
Add junos_system declartive module and other related change (#25859)
* Add junos_system declartive module and other related change * junos_system declartive module * integration test for junos_system * integration test for net_system (junos platform) * pep8 fixes for junos modules * move to lxml from elementree for xml parsing as it support complete set of xpath api's * other minor changes * Fix CI and doc changes * Fix unit test failures * Fix typo in import * Fix import issue for py2.6 * Add missed Element in import
Diffstat (limited to 'test/integration/targets/junos_system')
-rw-r--r--test/integration/targets/junos_system/aliases1
-rw-r--r--test/integration/targets/junos_system/defaults/main.yaml2
-rw-r--r--test/integration/targets/junos_system/tasks/main.yaml2
-rw-r--r--test/integration/targets/junos_system/tasks/netconf.yaml16
-rw-r--r--test/integration/targets/junos_system/tests/netconf/basic.yaml308
5 files changed, 329 insertions, 0 deletions
diff --git a/test/integration/targets/junos_system/aliases b/test/integration/targets/junos_system/aliases
new file mode 100644
index 0000000000..93151a8d9d
--- /dev/null
+++ b/test/integration/targets/junos_system/aliases
@@ -0,0 +1 @@
+network/ci
diff --git a/test/integration/targets/junos_system/defaults/main.yaml b/test/integration/targets/junos_system/defaults/main.yaml
new file mode 100644
index 0000000000..5f709c5aac
--- /dev/null
+++ b/test/integration/targets/junos_system/defaults/main.yaml
@@ -0,0 +1,2 @@
+---
+testcase: "*"
diff --git a/test/integration/targets/junos_system/tasks/main.yaml b/test/integration/targets/junos_system/tasks/main.yaml
new file mode 100644
index 0000000000..cc27f174fd
--- /dev/null
+++ b/test/integration/targets/junos_system/tasks/main.yaml
@@ -0,0 +1,2 @@
+---
+- { include: netconf.yaml, tags: ['netconf'] }
diff --git a/test/integration/targets/junos_system/tasks/netconf.yaml b/test/integration/targets/junos_system/tasks/netconf.yaml
new file mode 100644
index 0000000000..1286b35422
--- /dev/null
+++ b/test/integration/targets/junos_system/tasks/netconf.yaml
@@ -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
diff --git a/test/integration/targets/junos_system/tests/netconf/basic.yaml b/test/integration/targets/junos_system/tests/netconf/basic.yaml
new file mode 100644
index 0000000000..090a76467c
--- /dev/null
+++ b/test/integration/targets/junos_system/tests/netconf/basic.yaml
@@ -0,0 +1,308 @@
+---
+- debug: msg="START junos_system netconf/basic.yaml"
+
+- name: setup - remove hostname
+ junos_system:
+ hostname: vsrx01
+ state: absent
+ provider: "{{ netconf }}"
+
+- name: Set hostname
+ junos_system:
+ hostname: vsrx01
+ state: present
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'<host-name>vsrx01</host-name>' in result.rpc"
+
+- name: Set hostname (idempotent)
+ junos_system:
+ hostname: vsrx01
+ state: present
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: Deactivate hostname configuration
+ junos_system:
+ hostname: vsrx01
+ state: suspend
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'<host-name inactive=\"inactive\" />' in result.rpc"
+
+- name: Activate hostname configuration
+ junos_system:
+ hostname: vsrx01
+ state: active
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'<host-name active=\"active\" />' in result.rpc"
+
+- name: Delete hostname configuration
+ junos_system:
+ hostname: vsrx01
+ state: absent
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'<host-name delete=\"delete\" />' in result.rpc"
+
+- name: Teardown - set hostname
+ junos_system:
+ hostname: vsrx01
+ state: present
+ provider: "{{ netconf }}"
+
+- name: setup - remove domain name
+ junos_system:
+ domain_name: ansible.com
+ state: absent
+ provider: "{{ netconf }}"
+
+- name: Set domain name
+ junos_system:
+ domain_name: ansible.com
+ state: present
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'<domain-name>ansible.com</domain-name>' in result.rpc"
+
+- name: Set domain name (idempotent)
+ junos_system:
+ domain_name: ansible.com
+ state: present
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: Deactivate domain name
+ junos_system:
+ domain_name: ansible.com
+ state: suspend
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'<domain-name inactive=\"inactive\" />' in result.rpc"
+
+- name: Activate domain name
+ junos_system:
+ domain_name: ansible.com
+ state: active
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'<domain-name active=\"active\" />' in result.rpc"
+
+- name: Delete domain name
+ junos_system:
+ domain_name: ansible.com
+ state: absent
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'<domain-name delete=\"delete\" />' in result.rpc"
+
+- name: Teardown - set domain name
+ junos_system:
+ domain_name: ansible.com
+ state: present
+ provider: "{{ netconf }}"
+
+- name: Setup - delete domain search
+ junos_system:
+ domain_search:
+ - test.com
+ - sample.com
+ state: absent
+ provider: "{{ netconf }}"
+ register: result
+
+- name: Set domain search
+ junos_system:
+ domain_search:
+ - test.com
+ - sample.com
+ state: present
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'<domain-search>test.com</domain-search>' in result.rpc"
+ - "'<domain-search>sample.com</domain-search>' in result.rpc"
+
+- name: Set domain search
+ junos_system:
+ domain_search:
+ - test.com
+ - sample.com
+ state: present
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: Deactivate domain search
+ junos_system:
+ domain_search:
+ - test.com
+ - sample.com
+ state: suspend
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'<domain-search inactive=\"inactive\">test.com</domain-search>' in result.rpc"
+ - "'<domain-search inactive=\"inactive\">sample.com</domain-search>' in result.rpc"
+
+- name: Activate domain search
+ junos_system:
+ domain_search:
+ - test.com
+ - sample.com
+ state: active
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'<domain-search active=\"active\">test.com</domain-search>' in result.rpc"
+ - "'<domain-search active=\"active\">sample.com</domain-search>' in result.rpc"
+
+- name: Delete domain search
+ junos_system:
+ domain_search:
+ - test.com
+ - sample.com
+ state: absent
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'<domain-search delete=\"delete\">test.com</domain-search>' in result.rpc"
+ - "'<domain-search delete=\"delete\">sample.com</domain-search>' in result.rpc"
+
+- name: Setup - delete name servers
+ junos_system:
+ name_servers:
+ - 8.8.8.8
+ - 8.8.4.4
+ state: absent
+ provider: "{{ netconf }}"
+ register: result
+
+- name: Set name servers
+ junos_system:
+ name_servers:
+ - 8.8.8.8
+ - 8.8.4.4
+ state: present
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'<name-server><name>8.8.8.8</name></name-server>' in result.rpc"
+ - "'<name-server><name>8.8.4.4</name></name-server>' in result.rpc"
+
+- name: Set name servers (idempotent)
+ junos_system:
+ name_servers:
+ - 8.8.8.8
+ - 8.8.4.4
+ state: present
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == false"
+
+- name: Deactivate name servers
+ junos_system:
+ name_servers:
+ - 8.8.8.8
+ - 8.8.4.4
+ state: suspend
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'<name-server inactive=\"inactive\"><name>8.8.8.8</name></name-server>' in result.rpc"
+ - "'<name-server inactive=\"inactive\"><name>8.8.4.4</name></name-server>' in result.rpc"
+
+- name: Activate name servers
+ junos_system:
+ name_servers:
+ - 8.8.8.8
+ - 8.8.4.4
+ state: active
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'<name-server active=\"active\"><name>8.8.8.8</name></name-server>' in result.rpc"
+ - "'<name-server active=\"active\"><name>8.8.4.4</name></name-server>' in result.rpc"
+
+- name: Delete name servers
+ junos_system:
+ name_servers:
+ - 8.8.8.8
+ - 8.8.4.4
+ state: absent
+ provider: "{{ netconf }}"
+ register: result
+
+- assert:
+ that:
+ - "result.changed == true"
+ - "'<name-server delete=\"delete\"><name>8.8.8.8</name></name-server>' in result.rpc"
+ - "'<name-server delete=\"delete\"><name>8.8.4.4</name></name-server>' in result.rpc"