return rv
def rexec(command, host, user,
- port = None,
+ port = None,
+ gwuser = None,
+ gw = None,
agent = True,
sudo = False,
identity = None,
"""
tmp_known_hosts = None
- hostip = gethostbyname(host)
+ if not gw:
+ hostip = gethostbyname(host)
+ else: hostip = None
args = ['ssh', '-C',
# Don't bother with localhost. Makes test easier
'-o', 'ConnectionAttempts=3',
'-o', 'ServerAliveInterval=30',
'-o', 'TCPKeepAlive=yes',
+ '-o', 'Batchmode=yes',
'-l', user, hostip or host]
if persistent and openssh_has_persist():
# Do not check for Host key. Unsafe.
args.extend(['-o', 'StrictHostKeyChecking=no'])
+ if gw:
+ if gwuser:
+ proxycommand = 'ProxyCommand=ssh %s@%s -W %%h:%%p' % (gwuser, gw)
+ else:
+ proxycommand = 'ProxyCommand=ssh %%r@%s -W %%h:%%p' % gw
+ args.extend(['-o', proxycommand])
+
if agent:
args.append('-A')
args.append('-p%d' % port)
if identity:
+ identity = os.path.expanduser(identity)
args.extend(('-i', identity))
if tty:
blocking = blocking)
def rcopy(source, dest,
- port = None,
+ port = None,
+ gwuser = None,
+ gw = None,
agent = True,
recursive = False,
identity = None,
Source and destination should have the user and host encoded
as per scp specs.
- Source can be a list of files to copy to a single destination,
- in which case it is advised that the destination be a folder.
+ Source can be a list of files to copy to a single destination,
+ (in which case it is advised that the destination be a folder),
+ a single file in a string or a semi-colon separated list of files
+ in a string.
"""
-
+
# Parse destination as <user>@<server>:<path>
- if isinstance(dest, basestring) and ':' in dest:
+ if isinstance(dest, str) and ':' in dest:
remspec, path = dest.split(':',1)
- elif isinstance(source, basestring) and ':' in source:
+ elif isinstance(source, str) and ':' in source:
remspec, path = source.split(':',1)
else:
raise ValueError, "Both endpoints cannot be local"
if port:
args.append('-P%d' % port)
+ if gw:
+ if gwuser:
+ proxycommand = 'ProxyCommand=ssh %s@%s -W %%h:%%p' % (gwuser, gw)
+ else:
+ proxycommand = 'ProxyCommand=ssh %%r@%s -W %%h:%%p' % gw
+ args.extend(['-o', proxycommand])
+
if recursive:
args.append('-r')
if identity:
+ identity = os.path.expanduser(identity)
args.extend(('-i', identity))
if server_key:
if not strict_host_checking:
# Do not check for Host key. Unsafe.
args.extend(['-o', 'StrictHostKeyChecking=no'])
-
+
if isinstance(source, list):
args.extend(source)
else:
host = None,
port = None,
user = None,
+ gwuser = None,
+ gw = None,
agent = None,
identity = None,
server_key = None,
host = host,
port = port,
user = user,
+ gwuser = gwuser,
+ gw = gw,
agent = agent,
identity = identity,
server_key = server_key,
host = None,
port = None,
user = None,
+ gwuser = None,
+ gw = None,
agent = None,
identity = None,
server_key = None):
host = host,
port = port,
user = user,
+ gwuser = gwuser,
+ gw = gw,
agent = agent,
identity = identity,
server_key = server_key
host = None,
port = None,
user = None,
+ gwuser = None,
+ gw = None,
agent = None,
identity = None,
server_key = None):
host = host,
port = port,
user = user,
+ gwuser = gwuser,
+ gw = gw,
agent = agent,
identity = identity,
server_key = server_key
host = None,
port = None,
user = None,
+ gwuser = None,
+ gw = None,
agent = None,
sudo = False,
identity = None,
host = host,
port = port,
user = user,
+ gwuser = gwuser,
+ gw = gw,
agent = agent,
identity = identity,
server_key = server_key
return ((out, err), proc)
-