logger=self.log.getChild(n),
ssh_options=self._ssh_options)
- conn.import_module(remotes)
+ r = conn.import_module(remotes)
- return conn
+ return conn, r
def _executable_path(self, conn, executable):
"""
"""
Run cephadm on the remote host with the given command + args
"""
- conn = self._get_connection(host)
+ conn, connr = self._get_connection(host)
try:
if not image:
final_args += args
if self.mode == 'root':
- self.log.debug('args: %s' % final_args)
+ self.log.debug('args: %s' % (' '.join(final_args)))
self.log.debug('stdin: %s' % stdin)
script = 'injected_argv = ' + json.dumps(final_args) + '\n'
if stdin:
script += 'injected_stdin = ' + json.dumps(stdin) + '\n'
script += self._cephadm
- out, err, code = remoto.process.check(
- conn,
- ['/usr/bin/python', '-u'],
- stdin=script.encode('utf-8'))
+ python = connr.choose_python()
+ if not python:
+ raise RuntimeError(
+ 'unable to find python on %s (tried %s in %s)' % (
+ host, remotes.PYTHONS, remotes.PATH))
+ try:
+ out, err, code = remoto.process.check(
+ conn,
+ [python, '-u'],
+ stdin=script.encode('utf-8'))
+ except RuntimeError as e:
+ if error_ok:
+ return '', str(e), 1
+ raise
elif self.mode == 'cephadm-package':
- out, err, code = remoto.process.check(
- conn,
- ['sudo', '/usr/bin/cephadm'] + final_args,
- stdin=stdin)
- self.log.debug('exit code %s out %s err %s' % (code, out, err))
+ try:
+ out, err, code = remoto.process.check(
+ conn,
+ ['sudo', '/usr/bin/cephadm'] + final_args,
+ stdin=stdin)
+ except RuntimeError as e:
+ if error_ok:
+ return '', str(e), 1
+ raise
if code and not error_ok:
raise RuntimeError(
'cephadm exited with an error code: %d, stderr:%s' % (