Created
December 5, 2013 01:37
-
-
Save jctanner/7798778 to your computer and use it in GitHub Desktop.
accelerate connection tracking
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/ansible/runner/__init__.py b/lib/ansible/runner/__init__.py | |
index 8fec285..cda5b77 100644 | |
--- a/lib/ansible/runner/__init__.py | |
+++ b/lib/ansible/runner/__init__.py | |
@@ -188,6 +188,10 @@ class Runner(object): | |
self.callbacks.runner = self | |
self.original_transport = self.transport | |
+ # PATCH | |
+ import uuid | |
+ self.uuid = str(uuid.uuid4())[0:8] + "-" + "runner" | |
+ | |
if self.transport == 'smart': | |
# if the transport is 'smart' see if SSH can support ControlPersist if not use paramiko | |
# 'smart' is the default since 1.2.1/1.3 | |
@@ -669,6 +673,11 @@ class Runner(object): | |
result = dict(failed=True, msg="FAILED: %s" % str(e)) | |
return ReturnData(host=host, comm_ok=False, result=result) | |
+ if self.accelerate: | |
+ # HOW DO I STORE FIRST SUCCESS? | |
+ open("/tmp/awx.log", "a").write("%s: %s\n" % (self.uuid, host)) | |
+ #import epdb; epdb.st() | |
+ | |
tmp = '' | |
# all modules get a tempdir, action plugins get one unless they have NEEDS_TMPPATH set to False | |
if getattr(handler, 'NEEDS_TMPPATH', True): | |
diff --git a/lib/ansible/runner/connection_plugins/accelerate.py b/lib/ansible/runner/connection_plugins/accelerate. | |
index 085c166..cf24f61 100644 | |
--- a/lib/ansible/runner/connection_plugins/accelerate.py | |
+++ b/lib/ansible/runner/connection_plugins/accelerate.py | |
@@ -38,7 +38,7 @@ CHUNK_SIZE=1044*20 | |
class Connection(object): | |
''' raw socket accelerated connection ''' | |
- def __init__(self, runner, host, port, user, password, private_key_file, *args, **kwargs): | |
+ def __init__(self, runner, host, port, user, password, private_key_file, valid=False, *args, **kwargs): | |
self.runner = runner | |
self.host = host | |
@@ -50,6 +50,11 @@ class Connection(object): | |
self.accport = port[1] | |
self.is_connected = False | |
+ # PATCH | |
+ import uuid | |
+ self.uuid = str(uuid.uuid4())[0:8] + "-" + str(self.host) | |
+ self.decryption_succeeded = valid | |
+ | |
if not self.port: | |
self.port = constants.DEFAULT_REMOTE_PORT | |
elif not isinstance(self.port, int): | |
@@ -95,9 +100,46 @@ class Connection(object): | |
tmp_path = self.runner._make_tmp_path(self.ssh) | |
return self.runner._execute_module(self.ssh, tmp_path, 'accelerate', args, inject=inject) | |
+ def _teardown(self): | |
+ open("/tmp/awx.log", "a").write("%s: teardown\n" % self.uuid) | |
+ args = 'rm -f /root/.accelerate.pid ; ps aux | egrep *python.*accelerate$ | awk \'{print $2}\' | xargs kill | |
+ inject = dict(password=self.key) | |
+ if getattr(self.runner, 'accelerate_inventory_host', False): | |
+ inject = utils.combine_vars(inject, | |
+ self.runner.inventory.get_variables(self.runner.accelerate_inventory_host)) | |
+ else: | |
+ inject = utils.combine_vars(inject, self.runner.inventory.get_variables(self.host)) | |
+ vvvv("attempting to kill the accelerate daemon...") | |
+ self.ssh.connect() | |
+ tmp_path = self.runner._make_tmp_path(self.ssh) | |
+ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment