# start the process
self._kick_serve_loop()
- def is_paused(self) -> bool:
- return self.paused
-
def pause(self) -> None:
if not self.paused:
self.log.info('Paused')
return False, "loading remoto library:{}".format(
remoto_import_error)
- def available(self) -> Tuple[bool, str]:
+ def available(self) -> Tuple[bool, str, Dict[str, Any]]:
"""
The cephadm orchestrator is always available.
"""
ok, err = self.can_run()
if not ok:
- return ok, err
+ return ok, err, {}
if not self.ssh_key or not self.ssh_pub:
- return False, 'SSH keys not set. Use `ceph cephadm set-priv-key` and `ceph cephadm set-pub-key` or `ceph cephadm generate-key`'
+ return False, 'SSH keys not set. Use `ceph cephadm set-priv-key` and `ceph cephadm set-pub-key` or `ceph cephadm generate-key`', {}
+
+ # mypy is unable to determine type for _processes since it's private
+ worker_count: int = self._worker_pool._processes # type: ignore
+ ret = {
+ "workers": worker_count,
+ "paused": self.paused,
+ }
- return True, str(self._worker_pool._processes) # type: ignore
+ return True, err, ret
def process(self, completions: List[CephadmCompletion]) -> None: # type: ignore
"""
return True
@_hide_in_features
- def available(self) -> Tuple[bool, str]:
+ def available(self) -> Tuple[bool, str, Dict[str, Any]]:
"""
Report whether we can talk to the orchestrator. This is the
place to give the user a meaningful message if the orchestrator
... if OrchestratorClientMixin().available()[0]: # wrong.
... OrchestratorClientMixin().get_hosts()
- :return: two-tuple of boolean, string
+ :return: boolean representing whether the module is available/usable
+ :return: string describing any error
+ :return: dict containing any module specific information
"""
raise NotImplementedError()
def resume(self) -> None:
raise NotImplementedError()
- def is_paused(self) -> bool:
- raise NotImplementedError()
-
def add_host(self, host_spec: HostSpec) -> Completion[str]:
"""
Add a host to the orchestrator inventory.
if o is None:
raise NoOrchestrator()
- avail, msg = self.available()
+ avail, why, module_details = self.available()
result: Dict[str, Any] = {
+ "available": avail,
"backend": o,
- "paused": self.is_paused(),
}
- if avail is not None:
- result['available'] = avail
- if avail:
- if o == "cephadm" and detail:
- result['workers'] = msg
- else:
- result['reason'] = msg
+ if avail:
+ result.update(module_details)
+ else:
+ result['reason'] = why
if format != Format.plain:
output = to_format(result, format, many=False, cls=None)
else:
output = "Backend: {0}".format(result['backend'])
- if 'available' in result:
- output += f"\nAvailable: {'Yes' if result['available'] else 'No'}"
- if 'reason' in result:
- output += ' ({0})'.format(result['reason'])
- output += f"\nPaused: {'Yes' if result['paused'] else 'No'}"
- if 'workers' in result:
+ output += f"\nAvailable: {'Yes' if result['available'] else 'No'}"
+ if 'reason' in result:
+ output += ' ({0})'.format(result['reason'])
+ if 'paused' in result:
+ output += f"\nPaused: {'Yes' if result['paused'] else 'No'}"
+ if 'workers' in result and detail:
output += f"\nHost Parallelism: {result['workers']}"
return HandleCommandResult(stdout=output)
return False, "Rook version unsupported."
return True, ''
- def available(self) -> Tuple[bool, str]:
+ def available(self) -> Tuple[bool, str, Dict[str, Any]]:
if not kubernetes_imported:
- return False, "`kubernetes` python module not found"
+ return False, "`kubernetes` python module not found", {}
elif not self._rook_env.has_namespace():
- return False, "ceph-mgr not running in Rook cluster"
+ return False, "ceph-mgr not running in Rook cluster", {}
try:
self.k8s.list_namespaced_pod(self._rook_env.namespace)
except ApiException as e:
- return False, "Cannot reach Kubernetes API: {}".format(e)
+ return False, "Cannot reach Kubernetes API: {}".format(e), {}
else:
- return True, ""
+ return True, "", {}
def __init__(self, *args: Any, **kwargs: Any) -> None:
super(RookOrchestrator, self).__init__(*args, **kwargs)