Fix junos integration zuul CI failures (#57309)

This commit is contained in:
Ganesh Nalawade 2019-06-10 07:10:58 -07:00 committed by Daniel Mellado Area
commit a867ced4de
9 changed files with 318 additions and 234 deletions

View file

@ -223,9 +223,9 @@ class NetconfBase(AnsiblePlugin):
""" """
if rpc_command is None: if rpc_command is None:
raise ValueError('rpc_command value must be provided') raise ValueError('rpc_command value must be provided')
req = fromstring(rpc_command)
resp = self.m.dispatch(req, source=source, filter=filter) resp = self.m.dispatch(fromstring(rpc_command), source=source, filter=filter)
return resp.data_xml if resp.data_ele else resp.xml return resp.data_xml if hasattr(resp, 'data_xml') else resp.xml
@ensure_connected @ensure_connected
def lock(self, target="candidate"): def lock(self, target="candidate"):

View file

@ -50,7 +50,7 @@
- assert: - assert:
that: that:
- "result.failed == true" - "result.failed == true"
- "result.msg == 'Subset must be one of [config, default, hardware, interfaces, ofacts], got test'" - "'Subset must be one of' in result.msg"
- name: Collect config facts from device in set format - name: Collect config facts from device in set format
junos_facts: junos_facts:

View file

@ -1,6 +1,23 @@
--- ---
- debug: msg="START junos_lldp netconf/basic.yaml on connection={{ ansible_connection }}" - debug: msg="START junos_lldp netconf/basic.yaml on connection={{ ansible_connection }}"
- name: get supported protocols
junos_command:
commands: show lldp
register: result
ignore_errors: yes
- name: lldp supported
set_fact:
lldp_supported: True
when: not result.failed
- name: lldp not supported
set_fact:
lldp_supported: False
when: result.failed
- block:
- name: setup - Disable lldp and remove it's configuration - name: setup - Disable lldp and remove it's configuration
junos_lldp: junos_lldp:
state: absent state: absent
@ -116,4 +133,6 @@
that: that:
- "result.changed == false" - "result.changed == false"
when: lldp_supported
- debug: msg="END junos_lldp netconf/basic.yaml on connection={{ ansible_connection }}" - debug: msg="END junos_lldp netconf/basic.yaml on connection={{ ansible_connection }}"

View file

@ -3,7 +3,23 @@
# Add minimal testcase to check args are passed correctly to # Add minimal testcase to check args are passed correctly to
# implementation module and module run is successful. # implementation module and module run is successful.
- name: get supported protocols
junos_command:
commands: show lldp
register: result
ignore_errors: yes
- name: lldp supported
set_fact:
lldp_supported: True
when: not result.failed
- name: lldp not supported
set_fact:
lldp_supported: False
when: result.failed
- block:
- name: setup - Disable lldp - setup - name: setup - Disable lldp - setup
net_lldp: net_lldp:
state: absent state: absent
@ -23,5 +39,6 @@
net_lldp: net_lldp:
state: absent state: absent
provider: "{{ netconf }}" provider: "{{ netconf }}"
when: lldp_supported
- debug: msg="START junos netconf/net_lldp.yaml on connection={{ ansible_connection }}" - debug: msg="START junos netconf/net_lldp.yaml on connection={{ ansible_connection }}"

View file

@ -1,6 +1,23 @@
--- ---
- debug: msg="START junos_lldp_interface netconf/basic.yaml on connection={{ ansible_connection }}" - debug: msg="START junos_lldp_interface netconf/basic.yaml on connection={{ ansible_connection }}"
- name: get supported protocols
junos_command:
commands: show lldp
register: result
ignore_errors: yes
- name: lldp supported
set_fact:
lldp_supported: True
when: not result.failed
- name: lldp not supported
set_fact:
lldp_supported: False
when: result.failed
- block:
- name: setup - Remove lldp interface configuration - name: setup - Remove lldp interface configuration
junos_lldp_interface: junos_lldp_interface:
name: ge-0/0/5 name: ge-0/0/5
@ -102,5 +119,6 @@
- assert: - assert:
that: that:
- "result.changed == false" - "result.changed == false"
when: lldp_supported
- debug: msg="END junos_lldp_interface netconf/basic.yaml on connection={{ ansible_connection }}" - debug: msg="END junos_lldp_interface netconf/basic.yaml on connection={{ ansible_connection }}"

View file

@ -4,6 +4,23 @@
# Add minimal testcase to check args are passed correctly to # Add minimal testcase to check args are passed correctly to
# implementation module and module run is successful. # implementation module and module run is successful.
- name: get supported protocols
junos_command:
commands: show lldp
register: result
ignore_errors: yes
- name: lldp supported
set_fact:
lldp_supported: True
when: not result.failed
- name: lldp not supported
set_fact:
lldp_supported: False
when: result.failed
- block:
- name: setup - Remove lldp interface configuration - name: setup - Remove lldp interface configuration
net_lldp_interface: net_lldp_interface:
name: ge-0/0/5 name: ge-0/0/5
@ -27,5 +44,6 @@
name: ge-0/0/5 name: ge-0/0/5
state: absent state: absent
provider: "{{ netconf }}" provider: "{{ netconf }}"
when: lldp_supported
- debug: msg="END junos netconf/net_lldp_interface.yaml on connection={{ ansible_connection }}" - debug: msg="END junos netconf/net_lldp_interface.yaml on connection={{ ansible_connection }}"

View file

@ -10,14 +10,14 @@
- assert: - assert:
that: that:
- "result.changed == false" - "result.changed == false"
- "'<name>\nem0\n</name>' in result['xml']" - "'<interface-information' in result['xml']"
- "result.output is defined" - "result.output is defined"
- name: Execute RPC with args on device - name: Execute RPC with args on device
junos_rpc: junos_rpc:
rpc: get-interface-information rpc: get-interface-information
args: args:
interface-name: em0 interface-name: lo0
media: True media: True
provider: "{{ netconf }}" provider: "{{ netconf }}"
register: result register: result
@ -25,8 +25,9 @@
- assert: - assert:
that: that:
- "result.changed == false" - "result.changed == false"
- "'<name>\nem0\n</name>' in result['xml']" - "'<name>\nlo0\n</name>' in result['xml']"
- "'<name>\nlo0\n</name>' not in result['xml']" - "'<name>\nem0\n</name>' not in result['xml']"
- "'<name>\fxp0\n</name>' not in result['xml']"
- name: Execute RPC on device and get output in text format - name: Execute RPC on device and get output in text format
junos_rpc: junos_rpc:
@ -40,14 +41,14 @@
- "result.changed == false" - "result.changed == false"
- "result.output is defined" - "result.output is defined"
- "result.output_lines is defined" - "result.output_lines is defined"
- "'Physical interface: em0' in result['output']" - "'Physical interface' in result['output']"
- name: Execute RPC on device and get output in json format - name: Execute RPC on device and get output in json format
junos_rpc: junos_rpc:
rpc: get-interface-information rpc: get-interface-information
output: json output: json
args: args:
interface-name: em0 interface-name: lo0
media: True media: True
provider: "{{ netconf }}" provider: "{{ netconf }}"
register: result register: result
@ -56,7 +57,7 @@
that: that:
- "result.changed == false" - "result.changed == false"
- "result.output is defined" - "result.output is defined"
- "result['output']['interface-information'][0]['physical-interface'][0]['name'][0]['data'] == \"em0\"" - "result['output']['interface-information'][0]['physical-interface'][0]['name'][0]['data'] == \"lo0\""
- name: Execute invalid RPC - name: Execute invalid RPC
junos_rpc: junos_rpc:

View file

@ -27,11 +27,22 @@
that: that:
- "result.changed == false" - "result.changed == false"
- name: configure syslog file replace - name: replace default operation fail
netconf_config: netconf_config:
content: "{{ syslog_config_replace }}" content: "{{ syslog_config_replace }}"
default_operation: 'replace' default_operation: 'replace'
register: result register: result
ignore_errors: yes
- assert:
that:
- "result.failed == true"
- "'Missing mandatory statement' in result.msg"
- name: replace syslog config with operation key in content
netconf_config:
content: "{{ syslog_config_replace }}"
register: result
- assert: - assert:
that: that:

View file

@ -24,7 +24,7 @@ syslog_config_replace: |
<config xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0"> <config xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0">
<configuration> <configuration>
<system> <system>
<syslog> <syslog operation="replace">
<file> <file>
<name>test_netconf_config</name> <name>test_netconf_config</name>
<contents> <contents>