Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config_file and pyez_conn issue #671 #680

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
14 changes: 9 additions & 5 deletions ansible_collections/juniper/device/plugins/connection/pyez.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ def set_chassis_cluster_disable(self):
return self.dev.rpc.set_chassis_cluster_disable(
reboot=True, normalize=True)

def invoke_jsnapy(self, data, action):
def invoke_jsnapy(self, data, action, folder=None):
"""invoke jsnapy for persistent connection.
"""
try:
Expand All @@ -549,19 +549,23 @@ def invoke_jsnapy(self, data, action):
responses = jsa.check(data=data,
dev=self.dev,
pre_file='PRE',
post_file='POST')
post_file='POST',
folder=folder)
elif action == 'snapcheck':
responses = jsa.snapcheck(data=data,
dev=self.dev,
pre_file='PRE')
pre_file='PRE',
folder=folder)
elif action == 'snap_pre':
responses = jsa.snap(data=data,
dev=self.dev,
file_name='PRE')
file_name='PRE',
folder=folder)
elif action == 'snap_post':
responses = jsa.snap(data=data,
dev=self.dev,
file_name='POST')
file_name='POST',
folder=folder)
else:
raise AnsibleError("Unexpected action: %s." % (action))
self.queue_message("vvvv", 'The %s action executed successfully' % action)
Expand Down
24 changes: 16 additions & 8 deletions ansible_collections/juniper/device/plugins/modules/jsnapy.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,36 +285,44 @@ def main():
if action == 'check':
if junos_module.conn_type != "local":
responses = junos_module._pyez_conn.invoke_jsnapy(data=data,
action='check')
action='check',
folder=dir)
else:
responses = jsa.check(data=data,
dev=junos_module.dev,
pre_file='PRE',
post_file='POST')
post_file='POST',
folder=dir)
elif action == 'snapcheck':
if junos_module.conn_type != "local":
responses = junos_module._pyez_conn.invoke_jsnapy(data=data,
action='snapcheck')
action='snapcheck',
folder=dir)
else:
responses = jsa.snapcheck(data=data,
dev=junos_module.dev,
pre_file='PRE')
pre_file='PRE',
folder=dir)
elif action == 'snap_pre':
if junos_module.conn_type != "local":
responses = junos_module._pyez_conn.invoke_jsnapy(data=data,
action='snap_pre')
action='snap_pre',
folder=dir)
else:
responses = jsa.snap(data=data,
dev=junos_module.dev,
file_name='PRE')
file_name='PRE',
folder=dir)
elif action == 'snap_post':
if junos_module.conn_type != "local":
responses = junos_module._pyez_conn.invoke_jsnapy(data=data,
action='snap_post')
action='snap_post',
folder=dir)
else:
responses = jsa.snap(data=data,
dev=junos_module.dev,
file_name='POST')
file_name='POST',
folder=dir)
else:
junos_module.fail_json(msg="Unexpected action: %s." % (action))
junos_module.logger.debug('The %s action executed successfully.',
Expand Down