ansible/test/integration/targets/netconf_rpc/tests/sros/basic.yaml
wiso 387a23c3d1 New ansible module netconf_rpc (#40358)
* New ansible module netconf_rpc

* add integration test for module netconf_rpc

* pep8/meta-data corrections

* usage of jxmlease for all XML processing
separation of attributes "rpc" and "content"

* removed unused imports
improved error handling

* fixed pep8

* usage of ast.literal_eval instead of eval
added description to SROS integration test for cases commented out
2018-05-24 15:25:02 +05:30

188 lines
4.5 KiB
YAML

---
- debug: msg="START netconf_rpc sros/basic.yaml on connection={{ ansible_connection }}"
- name: lock candidate (content is dict)
netconf_rpc:
rpc: lock
content:
target:
candidate:
register: result
connection: netconf
- name: discard changes (w/o content)
netconf_rpc:
rpc: discard-changes
display: xml
register: result
connection: netconf
- name: unlock candidate (content is dict as json)
netconf_rpc:
rpc: unlock
xmlns: "urn:ietf:params:xml:ns:netconf:base:1.0"
content: "{'target': {'candidate': None}}"
display: json
register: result
connection: netconf
- assert:
that:
- "{{ result['output']['rpc-reply'] is defined}}"
- "{{ result['output']['rpc-reply']['ok'] is defined}}"
- name: validate candidate (content is single line of XML)
netconf_rpc:
rpc: validate
content: "<source><candidate/></source>"
display: json
register: result
connection: netconf
- assert:
that:
- "{{ result['output']['rpc-reply'] is defined}}"
- "{{ result['output']['rpc-reply']['ok'] is defined}}"
- name: copy running to startup
netconf_rpc:
rpc: copy-config
content:
source:
running:
target:
startup:
register: result
connection: netconf
- name: get schema list (content is multiple lines of XML)
netconf_rpc:
rpc: get
content: |
<filter>
<netconf-state xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring">
<schemas/>
</netconf-state>
</filter>
display: json
register: result
connection: netconf
- assert:
that:
- "{{ result['output']['data'] is defined}}"
- "{{ result['output']['data']['netconf-state'] is defined}}"
- "{{ result['output']['data']['netconf-state']['schemas'] is defined}}"
- "{{ result['output']['data']['netconf-state']['schemas']['schema'] is defined}}"
# The following two test-cases have been validated against a pre-release implementation.
# To make this playbook work with the regular Nokia SROS 16.0 release, those test-cases
# have been commented out. As soon the <get-schema> operation is supported by SROS
# those test-cases shall be included.
#- name: get-schema
# netconf_rpc:
# rpc: get-schema
# xmlns: urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring
# content:
# identifier: ietf-netconf
# version: "2011-06-01"
# register: result
# connection: netconf
#- name: get schema using XML request
# netconf_rpc:
# rpc: "get-schema"
# xmlns: "urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring"
# content: |
# <identifier>ietf-netconf-monitoring</identifier>
# <version>2010-10-04</version>
# display: pretty
# register: result
# connection: netconf
- name: Failure scenario, unsupported content (xpath value)
netconf_rpc:
rpc: get
content: schemas/schema[identifier=ietf-netconf-monitoring]
register: result
connection: netconf
ignore_errors: True
- assert:
that:
- "'unsupported content value' in result.msg"
- name: Failure scenario, unsupported content type (list)
netconf_rpc:
rpc: get
content:
- value1
- value2
register: result
connection: netconf
ignore_errors: True
- assert:
that:
- "'unsupported content data-type' in result.msg"
- name: Failure scenario, RPC is close-session
netconf_rpc:
rpc: close-session
register: result
connection: netconf
ignore_errors: True
- assert:
that:
- "'unsupported operation' in result.msg"
- name: Failure scenario, attribute rpc missing
netconf_rpc:
display: json
register: result
connection: netconf
ignore_errors: True
- assert:
that:
- "'missing required arguments' in result.msg"
- name: Failure scenario, attribute rpc is None
netconf_rpc:
rpc:
display: json
register: result
connection: netconf
ignore_errors: True
- assert:
that:
- "'must not be None' in result.msg"
- name: Failure scenario, attribute rpc is zero-length string
netconf_rpc:
rpc: ""
display: json
register: result
connection: netconf
ignore_errors: True
- assert:
that:
- "'must not be empty' in result.msg"
- name: Failure scenario, attribute rpc only contains white-spaces
netconf_rpc:
rpc: " "
display: json
register: result
connection: netconf
ignore_errors: True
- assert:
that:
- "'must not be empty' in result.msg"
- debug: msg="END netconf_rpc sros/basic.yaml on connection={{ ansible_connection }}"