Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions ansible_collections/juniper/device/plugins/connection/pyez.py
Original file line number Diff line number Diff line change
Expand Up @@ -687,10 +687,10 @@ def rollback_configuration(self, id):
raise AnsibleError('Unable to load the rescue configuraton: '
'%s' % (str(ex)))
elif id >= 0 and id <= 49:
self.queue_message("log", "Loading rollback %d configuration.", id)
self.queue_message("log", "Loading rollback {} configuration.".format(id))
try:
self.config.rollback(rb_id=id)
self.queue_message("log", "Rollback %d configuration loaded.", id)
self.queue_message("log", "Rollback {} configuration loaded.".format(id))
except (self.pyez_exception.RpcError,
self.pyez_exception.ConnectError) as ex:
raise AnsibleError('Unable to load the rollback %d '
Expand Down Expand Up @@ -839,7 +839,7 @@ def software_api(self, install_params):
install_params.get('package') or
install_params.get('pkg_set'),
msg_ret)
self.queue_message("log", "%s" % msg)
self.queue_message("log",str(msg))
return msg
except (self.pyez_exception.ConnectError,
self.pyez_exception.RpcError) as ex:
Expand Down
7 changes: 7 additions & 0 deletions tests/inventory
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[junos]
local_connection_testcases ansible_host=x.x.x.x ansible_user=xxxx ansible_pass=xxxx ansible_port=22 ansible_connection=local ansible_command_timeout=300

pyez_connection_testcases ansible_host=x.x.x.x ansible_user=xxx ansible_ssh_pass=xxxx ansible_port=22 ansible_connection=juniper.device.pyez ansible_command_timeout=300

[all:vars]
ansible_python_interpreter=<python interpreter path>
5 changes: 2 additions & 3 deletions tests/pb.juniper_junos_command.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
- name: Test juniper.device.command module
hosts: all
connection: local
gather_facts: no
collections:
- juniper.device
Expand Down Expand Up @@ -111,7 +110,7 @@
command:
command:
- "show route"
- "show lldp neighbors"
- "show version"
dest: "./out/{{ inventory_hostname }}.commands.output"
register: test7

Expand All @@ -120,7 +119,7 @@
that:
- test7.results[0].command == "show route"
- test7.results[0].msg == "The command executed successfully."
- test7.results[1].command == "show lldp neighbors"
- test7.results[1].command == "show version"
- test7.results[1].msg == "The command executed successfully."

- name: TEST 8 - Multiple commands, save outputs, but don't return them
Expand Down
70 changes: 27 additions & 43 deletions tests/pb.juniper_junos_config.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
---
- name: Test juniper.device.config module
hosts: all
connection: local
gather_facts: no
collections:
- juniper.device
tasks:
#################
################
- name: Retrieve the committed configuration
config:
retrieve: 'committed'
Expand All @@ -21,7 +20,7 @@
assert:
that:
- test1.config
#################
################
- name: Append .foo to the hostname using private config mode.
config:
config_mode: 'private'
Expand All @@ -37,11 +36,11 @@
assert:
that:
- test2.diff_lines
#################
################
- name: Rollback to the previous config.
config:
config_mode: 'private'
rollback: "1"
rollback: 1
register: test3
ignore_errors: True
tags: [ test3 ]
Expand All @@ -51,46 +50,31 @@
that:
- test3.diff_lines
#################
- name: Creates directory
- name: Save rescue configuration
command:
commands: "request system configuration rescue save"


- name: Configure syslog configuration
config:
load: 'merge'
lines:
- "set system syslog file TEST any any"
comment: "Configured system services"

- name: Rollback to the rescue config.
config:
rollback: 'rescue'
register: test4
- name: Check TEST 4
assert:
that:
- test4.diff_lines
- name: Clean up TEST 4
file:
path: out
state: directory

# - name: Configure LLDP
# juniper_junos_config:
# load: 'merge'
# lines:
# - "set protocols lldp advertisement-interval 30"
# - "set protocols lldp transmit-delay 2"
# - "set protocols lldp hold-multiplier 4"
# - "set protocols lldp ptopo-configuration-trap-interval 30"
# - "set protocols lldp ptopo-configuration-maximum-hold-time 300"
# - "set protocols lldp lldp-configuration-notification-interval 30"
# - "set protocols lldp interface all disable"
# - "set protocols lldp interface ge-1/1/1"
# format: 'set'
# comment: 'Start LLDP with given options'
# dest_dir: './out'
# register: test4
# ignore_errors: True
# tags: [ test4 ]
#
# - name: Rollback to the rescue config.
# juniper_junos_config:
# rollback: 'rescue'
#
# - name: Check TEST 4
# assert:
# that:
# - stat_result_1.stat.exists == True
# - test4.diff_lines
# - "'+ interface ge-1/1/1;' in test4.diff_lines"
#
# - name: Clean up TEST 4
# file:
# path: out
# state: absent
################
state: absent
###############
- name: Configure system services.
config:
config_mode: 'private'
Expand Down