From 92aa92ebd2848d3f61e507dbc979ec9b4af51265 Mon Sep 17 00:00:00 2001 From: Peter Sprygada Date: Sun, 12 Feb 2017 09:05:23 -0500 Subject: [PATCH] updates netconf to use persistent socket (#21307) --- lib/ansible/module_utils/netconf.py | 6 ++++-- lib/ansible/plugins/connection/netconf.py | 9 +++++---- test/units/plugins/connection/test_netconf.py | 12 ------------ 3 files changed, 9 insertions(+), 18 deletions(-) diff --git a/lib/ansible/module_utils/netconf.py b/lib/ansible/module_utils/netconf.py index cf49019766b..ff3d54806eb 100644 --- a/lib/ansible/module_utils/netconf.py +++ b/lib/ansible/module_utils/netconf.py @@ -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)) diff --git a/lib/ansible/plugins/connection/netconf.py b/lib/ansible/plugins/connection/netconf.py index 30648767442..edc1c8b4ac1 100644 --- a/lib/ansible/plugins/connection/netconf.py +++ b/lib/ansible/plugins/connection/netconf.py @@ -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 diff --git a/test/units/plugins/connection/test_netconf.py b/test/units/plugins/connection/test_netconf.py index 2b4985603fc..21913584897 100644 --- a/test/units/plugins/connection/test_netconf.py +++ b/test/units/plugins/connection/test_netconf.py @@ -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()) -