Created
August 9, 2013 20:21
-
-
Save jimi-c/6196856 to your computer and use it in GitHub Desktop.
This file contains 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
class SSHConnection(...) | |
""" initiates an ssh connection """ | |
... | |
class Connection(SSHConnection): | |
def __init__(self, runner, host, port, user, password, private_key_file, *args, **kwargs): | |
super(Connection,self).__init__( | |
runner=runner, | |
host=host, | |
port=port, | |
user=user, | |
password=password, | |
private_key_file=private_key_file | |
) | |
self.host = host | |
self.context = None | |
self.conn = None | |
self.key = utils.key_for_hostname(host) | |
self.fbport = 50994 | |
def _execute_fb_module(self, conn): | |
args = "password=%s port=%s" % (self.key,str(self.fbport)) | |
return self.runner._execute_module(conn, "/tmp", 'fireball2', args, inject={}) | |
def connect(self, allow_ssh=True): | |
''' activates the connection object over a socket ''' | |
try: | |
self.conn = socket.socket() | |
self.conn.connect((self.host,self.fbport)) | |
except: | |
if allow_ssh: | |
print "Falling back to ssh to startup accelerated mode" | |
c = super(Connection,self).connect() | |
self._execute_fb_module(c) | |
return self.connect(allow_ssh=False) | |
else: | |
raise errors.Error("Failed to connect to %s:%s" % (self.host,self.fbport)) | |
return self | |
def exec_command(self, cmd): | |
""" runs a command on the remote system """ | |
... |
Author
jimi-c
commented
Aug 9, 2013
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment