return f"Host {host} failed to login to {url} as {username} with given password"
return
- def _check_host(self, host):
- if host not in self.inventory:
- return
- self.log.debug(' checking %s' % host)
- try:
- out, err, code = self._run_cephadm(
- host, cephadmNoImage, 'check-host', [],
- error_ok=True, no_fsid=True)
- self.cache.update_last_host_check(host)
- self.cache.save_host(host)
- if code:
- self.log.debug(' host %s failed check' % host)
- if self.warn_on_failed_host_check:
- return 'host %s failed check: %s' % (host, err)
- else:
- self.log.debug(' host %s ok' % host)
- except Exception as e:
- self.log.debug(' host %s failed check' % host)
- return 'host %s failed check: %s' % (host, e)
-
def _check_for_strays(self):
self.log.debug('_check_for_strays')
for k in ['CEPHADM_STRAY_HOST',
self._reconfig_ssh()
host = self.cache.get_hosts()[0]
- r = self._check_host(host)
+ r = CephadmServe(self)._check_host(host)
if r is not None:
# connection failed reset user
self.set_store('ssh_user', current_user)
import logging
from typing import TYPE_CHECKING
-from cephadm.utils import forall_hosts
+from cephadm.utils import forall_hosts, cephadmNoImage
from orchestrator import OrchestratorError
if TYPE_CHECKING:
@forall_hosts
def refresh(host):
if self.mgr.cache.host_needs_check(host):
- r = self.mgr._check_host(host)
+ r = self._check_host(host)
if r is not None:
bad_hosts.append(r)
if self.mgr.cache.host_needs_daemon_refresh(host):
health_changed = True
if health_changed:
self.mgr.set_health_checks(self.mgr.health_checks)
+
+ def _check_host(self, host):
+ if host not in self.mgr.inventory:
+ return
+ self.log.debug(' checking %s' % host)
+ try:
+ out, err, code = self.mgr._run_cephadm(
+ host, cephadmNoImage, 'check-host', [],
+ error_ok=True, no_fsid=True)
+ self.mgr.cache.update_last_host_check(host)
+ self.mgr.cache.save_host(host)
+ if code:
+ self.log.debug(' host %s failed check' % host)
+ if self.mgr.warn_on_failed_host_check:
+ return 'host %s failed check: %s' % (host, err)
+ else:
+ self.log.debug(' host %s ok' % host)
+ except Exception as e:
+ self.log.debug(' host %s failed check' % host)
+ return 'host %s failed check: %s' % (host, e)
assert out == HostSpec('test', 'test', status='Offline').to_json()
_get_connection.side_effect = None
- assert cephadm_module._check_host('test') is None
+ assert CephadmServe(cephadm_module)._check_host('test') is None
out = wait(cephadm_module, cephadm_module.get_hosts())[0].to_json()
assert out == HostSpec('test', 'test').to_json()