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:
Deepak Agrawal 2018-05-16 14:38:43 +05:30 committed by GitHub
commit 86c945a628
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 543 additions and 5 deletions

View file

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

View file

@ -0,0 +1,3 @@
vlan 3
name ank_vlan3
!

View 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

View file

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

View 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 }}"

View 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 }}"