mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
updates netconf to use persistent socket (#21307)
This commit is contained in:
parent
b8f138cabb
commit
92aa92ebd2
3 changed files with 9 additions and 18 deletions
|
@ -4,7 +4,7 @@
|
|||
# still belong to the author of the module, and may assign their own license
|
||||
# to the complete work.
|
||||
#
|
||||
# (c) 2016 Red Hat Inc.
|
||||
# (c) 2017 Red Hat Inc.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
|
@ -29,9 +29,11 @@ from contextlib import contextmanager
|
|||
|
||||
from ncclient.xml_ import new_ele, sub_ele, to_xml, to_ele
|
||||
|
||||
from ansible.module_utils.connection import exec_command
|
||||
|
||||
def send_request(module, obj, check_rc=True):
|
||||
request = to_xml(obj)
|
||||
rc, out, err = module.exec_command(request)
|
||||
rc, out, err = exec_command(module, request)
|
||||
if rc != 0:
|
||||
if check_rc:
|
||||
module.fail_json(msg=str(err))
|
||||
|
|
|
@ -44,11 +44,10 @@ except ImportError:
|
|||
display = Display()
|
||||
|
||||
class Connection(ConnectionBase):
|
||||
''' NetConf base connections '''
|
||||
''' NetConf connections '''
|
||||
|
||||
transport = 'netconf'
|
||||
has_pipelining = False
|
||||
action_handler = 'network'
|
||||
|
||||
def __init__(self, play_context, new_stdin, *args, **kwargs):
|
||||
super(Connection, self).__init__(play_context, new_stdin, *args, **kwargs)
|
||||
|
@ -113,9 +112,11 @@ class Connection(ConnectionBase):
|
|||
|
||||
return (0, reply.data_xml, '')
|
||||
|
||||
def fetch_file(self):
|
||||
def put_file(self, in_path, out_path):
|
||||
"""Transfer a file from local to remote"""
|
||||
pass
|
||||
|
||||
def put_file(self):
|
||||
def fetch_file(self, in_path, out_path):
|
||||
"""Fetch a file from remote to local"""
|
||||
pass
|
||||
|
||||
|
|
|
@ -118,16 +118,4 @@ class TestNetconfConnectionClass(unittest.TestCase):
|
|||
self.assertEqual('', out)
|
||||
self.assertEqual('unable to parse request', err)
|
||||
|
||||
def test_fetch_file(self):
|
||||
pc = PlayContext()
|
||||
new_stdin = StringIO()
|
||||
conn = netconf.Connection(pc, new_stdin)
|
||||
self.assertIsNone(conn.fetch_file())
|
||||
|
||||
def test_put_file(self):
|
||||
pc = PlayContext()
|
||||
new_stdin = StringIO()
|
||||
conn = netconf.Connection(pc, new_stdin)
|
||||
self.assertIsNone(conn.put_file())
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue