From 36bf1e6b7e9567ca755f2667fc43b168d1b38780 Mon Sep 17 00:00:00 2001 From: Adrian Likins Date: Fri, 29 Jul 2016 16:19:38 -0400 Subject: [PATCH] Fix funcd to at least import without errors. (#16288) This plugin was using very old api, so was updated to newer api. Also misc style/pep8 cleanups. --- lib/ansible/plugins/connection/funcd.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/lib/ansible/plugins/connection/funcd.py b/lib/ansible/plugins/connection/funcd.py index 4c9e09be65..49b2499778 100644 --- a/lib/ansible/plugins/connection/funcd.py +++ b/lib/ansible/plugins/connection/funcd.py @@ -24,19 +24,24 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type -HAVE_FUNC=False +HAVE_FUNC = False try: import func.overlord.client as fc - HAVE_FUNC=True + HAVE_FUNC = True except ImportError: pass import os -from ansible.callbacks import vvv -from ansible import errors import tempfile import shutil +from ansible.errors import AnsibleError + +try: + from __main__ import display +except ImportError: + from ansible.utils.display import Display + display = Display() class Connection(object): ''' Func-based connections ''' @@ -50,7 +55,7 @@ class Connection(object): def connect(self, port=None): if not HAVE_FUNC: - raise errors.AnsibleError("func is not installed") + raise AnsibleError("func is not installed") self.client = fc.Client(self.host) return self @@ -60,10 +65,10 @@ class Connection(object): ''' run a command on the remote minion ''' if in_data: - raise errors.AnsibleError("Internal Error: this module does not support optimized module pipelining") + raise AnsibleError("Internal Error: this module does not support optimized module pipelining") # totally ignores privlege escalation - vvv("EXEC %s" % (cmd), host=self.host) + display.vvv("EXEC %s" % (cmd), host=self.host) p = self.client.command.run(cmd)[self.host] return (p[0], p[1], p[2]) @@ -77,14 +82,14 @@ class Connection(object): ''' transfer a file from local to remote ''' out_path = self._normalize_path(out_path, '/') - vvv("PUT %s TO %s" % (in_path, out_path), host=self.host) + display.vvv("PUT %s TO %s" % (in_path, out_path), host=self.host) self.client.local.copyfile.send(in_path, out_path) def fetch_file(self, in_path, out_path): ''' fetch a file from remote to local ''' in_path = self._normalize_path(in_path, '/') - vvv("FETCH %s TO %s" % (in_path, out_path), host=self.host) + display.vvv("FETCH %s TO %s" % (in_path, out_path), host=self.host) # need to use a tmp dir due to difference of semantic for getfile # ( who take a # directory as destination) and fetch_file, who # take a file directly