|
|
@ -18,9 +18,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
################################################
|
|
|
|
################################################
|
|
|
|
|
|
|
|
|
|
|
|
import local
|
|
|
|
from ansible import utils
|
|
|
|
import paramiko_ssh
|
|
|
|
from ansible.errors import AnsibleError
|
|
|
|
import ssh
|
|
|
|
|
|
|
|
|
|
|
|
import os.path
|
|
|
|
|
|
|
|
dirname = os.path.dirname(__file__)
|
|
|
|
|
|
|
|
modules = utils.import_plugins(os.path.join(dirname, 'connections'))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# rename this module
|
|
|
|
|
|
|
|
modules['paramiko'] = modules['paramiko_ssh']
|
|
|
|
|
|
|
|
del modules['paramiko_ssh']
|
|
|
|
|
|
|
|
|
|
|
|
class Connection(object):
|
|
|
|
class Connection(object):
|
|
|
|
''' Handles abstract connections to remote hosts '''
|
|
|
|
''' Handles abstract connections to remote hosts '''
|
|
|
@ -31,13 +38,9 @@ class Connection(object):
|
|
|
|
def connect(self, host, port=None):
|
|
|
|
def connect(self, host, port=None):
|
|
|
|
conn = None
|
|
|
|
conn = None
|
|
|
|
transport = self.runner.transport
|
|
|
|
transport = self.runner.transport
|
|
|
|
if transport == 'local':
|
|
|
|
module = modules.get(transport, None)
|
|
|
|
conn = local.LocalConnection(self.runner, host)
|
|
|
|
if module is None:
|
|
|
|
elif transport == 'paramiko':
|
|
|
|
raise AnsibleError("unsupported connection type: %s" % transport)
|
|
|
|
conn = paramiko_ssh.ParamikoConnection(self.runner, host, port)
|
|
|
|
conn = module.Connection(self.runner, host, port)
|
|
|
|
elif transport == 'ssh':
|
|
|
|
|
|
|
|
conn = ssh.SSHConnection(self.runner, host, port)
|
|
|
|
|
|
|
|
if conn is None:
|
|
|
|
|
|
|
|
raise Exception("unsupported connection type")
|
|
|
|
|
|
|
|
return conn.connect()
|
|
|
|
return conn.connect()
|
|
|
|
|
|
|
|
|