executable_path))
return executable_path
+ @contextmanager
+ def _remote_connection(self,
+ host: str,
+ addr: Optional[str]=None,
+ ) -> Iterator[Tuple["BaseConnection", Any]]:
+ if not addr and host in self.inventory:
+ addr = self.inventory.get_addr(host)
+
+ self.offline_hosts_remove(host)
+
+ try:
+ try:
+ conn, connr = self._get_connection(addr)
+ except OSError as e:
+ self._reset_con(host)
+ msg = f"Can't communicate with remote host `{addr}`, possibly because python3 is not installed there: {str(e)}"
+ raise execnet.gateway_bootstrap.HostNotFound(msg)
+
+ yield (conn, connr)
+
+ except execnet.gateway_bootstrap.HostNotFound as e:
+ # this is a misleading exception as it seems to be thrown for
+ # any sort of connection failure, even those having nothing to
+ # do with "host not found" (e.g., ssh key permission denied).
+ self.offline_hosts.add(host)
+ self._reset_con(host)
+
+ user = 'root' if self.mode == 'root' else 'cephadm'
+ msg = f'''Failed to connect to {host} ({addr}).
+ Check that the host is reachable and accepts connections using the cephadm SSH key
+
+ you may want to run:
+ > ceph cephadm get-ssh-config > ssh_config
+ > ceph config-key get mgr/cephadm/ssh_identity_key > key
+ > ssh -F ssh_config -i key {user}@{host}'''
+ raise OrchestratorError(msg) from e
+ except Exception as ex:
+ self.log.exception(ex)
+ raise
+
def _run_cephadm(self,
host: str,
- entity: Optional[str],
+ entity: str,
command: str,
args: List[str],
- addr: Optional[str] = None,
- stdin: Optional[str] = None,
- no_fsid=False,
- error_ok=False,
- image: Optional[str] = None,
- env_vars: Optional[List[str]] = None,
+ addr: Optional[str] = "",
+ stdin: Optional[str] = "",
+ no_fsid: Optional[bool] = False,
+ error_ok: Optional[bool] = False,
+ image: Optional[str] = "",
+ env_vars: Optional[List[str]]= None,
) -> Tuple[List[str], List[str], int]:
"""
Run cephadm on the remote host with the given command + args