mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 12:50:22 -07:00
network_put and network_get modules (#39592)
* Initial commit * Socket Timeout and dest file handler * sftp handling * module name change as per review * multiple thread tmp file overwite problem * Integration test suite for network_put * add additional testcase for dest argument * fix pylint/pep8/modules warnings * add socket timeout for get_file * network_get module * pep8 issue on network_get * Review comments
This commit is contained in:
parent
05c4f5997e
commit
86c945a628
12 changed files with 543 additions and 5 deletions
2
test/integration/targets/ios_file/defaults/main.yaml
Normal file
2
test/integration/targets/ios_file/defaults/main.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
testcase: "*"
|
3
test/integration/targets/ios_file/ios1.cfg
Normal file
3
test/integration/targets/ios_file/ios1.cfg
Normal file
|
@ -0,0 +1,3 @@
|
|||
vlan 3
|
||||
name ank_vlan3
|
||||
!
|
16
test/integration/targets/ios_file/tasks/cli.yaml
Normal file
16
test/integration/targets/ios_file/tasks/cli.yaml
Normal file
|
@ -0,0 +1,16 @@
|
|||
---
|
||||
- name: collect all cli test cases
|
||||
find:
|
||||
paths: "{{ role_path }}/tests/cli"
|
||||
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 cases (connection=network_cli)
|
||||
include: "{{ test_case_to_run }}"
|
||||
with_items: "{{ test_items }}"
|
||||
loop_control:
|
||||
loop_var: test_case_to_run
|
2
test/integration/targets/ios_file/tasks/main.yaml
Normal file
2
test/integration/targets/ios_file/tasks/main.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
- { include: cli.yaml, tags: ['cli'] }
|
43
test/integration/targets/ios_file/tests/cli/network_get.yaml
Normal file
43
test/integration/targets/ios_file/tests/cli/network_get.yaml
Normal file
|
@ -0,0 +1,43 @@
|
|||
---
|
||||
- debug: msg="START ios cli/network_get.yaml on connection={{ ansible_connection }}"
|
||||
|
||||
# Add minimal testcase to check args are passed correctly to
|
||||
# implementation module and module run is successful.
|
||||
|
||||
- name: setup
|
||||
ios_config:
|
||||
lines:
|
||||
- ip ssh version 2
|
||||
- ip scp server enable
|
||||
- username {{ ansible_ssh_user }} privilege 15
|
||||
match: none
|
||||
|
||||
- name: setup (copy file to be fetched from device)
|
||||
network_put:
|
||||
src: ios1.cfg
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result.changed == true
|
||||
|
||||
- name: get the file from device with dest unspecified
|
||||
network_get:
|
||||
src: ios1.cfg
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result.changed == true
|
||||
|
||||
- name: get the file from device with relative destination
|
||||
network_get:
|
||||
src: ios1.cfg
|
||||
dest: 'ios_{{ ansible_host }}.cfg'
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result.changed == true
|
||||
|
||||
- debug: msg="END ios cli/network_get.yaml on connection={{ ansible_connection }}"
|
34
test/integration/targets/ios_file/tests/cli/network_put.yaml
Normal file
34
test/integration/targets/ios_file/tests/cli/network_put.yaml
Normal file
|
@ -0,0 +1,34 @@
|
|||
---
|
||||
- debug: msg="START ios cli/network_put.yaml on connection={{ ansible_connection }}"
|
||||
|
||||
# Add minimal testcase to check args are passed correctly to
|
||||
# implementation module and module run is successful.
|
||||
|
||||
- name: setup
|
||||
ios_config:
|
||||
lines:
|
||||
- ip ssh version 2
|
||||
- ip scp server enable
|
||||
- username {{ ansible_ssh_user }} privilege 15
|
||||
match: none
|
||||
|
||||
- name: copy file from controller to ios + scp (Default)
|
||||
network_put:
|
||||
src: ios1.cfg
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result.changed == true
|
||||
|
||||
- name: copy file from controller to ios + dest specified
|
||||
network_put:
|
||||
src: ios1.cfg
|
||||
dest: ios.cfg
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result.changed == true
|
||||
|
||||
- debug: msg="END ios cli/network_put.yaml on connection={{ ansible_connection }}"
|
Loading…
Add table
Add a link
Reference in a new issue