Skip to content

Commit

Permalink
config_file and pyez_conn issue Juniper#671
Browse files Browse the repository at this point in the history
  • Loading branch information
chidanandpujar committed Jul 29, 2024
1 parent b1aa8c4 commit 009734c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
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

0 comments on commit 009734c

Please sign in to comment.