return super(HandleCommandResult, cls).__new__(cls, retval, stdout, stderr)
+class MonCommandFailed(RuntimeError): pass
+
+
class OSDMap(ceph_module.BasePyOSDMap):
def get_epoch(self):
return self._get_epoch()
"""
return self._ceph_get_daemon_status(svc_type, svc_id)
+ def check_mon_command(self, cmd_dict: dict) -> HandleCommandResult:
+ """
+ Wrapper around :func:`~mgr_module.MgrModule.mon_command`, but raises,
+ if ``retval != 0``.
+ """
+
+ r = HandleCommandResult(*self.mon_command(cmd_dict))
+ if r.retval:
+ raise MonCommandFailed(f'{cmd_dict["prefix"]} failed: {r.stderr} retval: {r.retval}')
+ return r
+
def mon_command(self, cmd_dict):
"""
Helper for modules that do simple, synchronous mon command
schema = self.get_perf_schema(service['type'], service['id'])
if not schema:
- self.log.warn("No perf counter schema for {0}.{1}".format(
+ self.log.warning("No perf counter schema for {0}.{1}".format(
service['type'], service['id']
))
continue