MCPcopy Create free account
hub / github.com/ceph/ceph / tool_exec

Method tool_exec

src/pybind/mgr/mgr_module.py:1994–2020  ·  view source on GitHub ↗
(
        self,
        args: List[str],
        timeout: int = 10,
        stdin: Optional[bytes] = None
    )

Source from the content-addressed store, hash-verified

1992 self._ceph_send_command(result, svc_type, svc_id, command, tag, inbuf, one_shot=one_shot)
1993
1994 def tool_exec(
1995 self,
1996 args: List[str],
1997 timeout: int = 10,
1998 stdin: Optional[bytes] = None
1999 ) -> Tuple[int, str, str]:
2000 try:
2001 tool = args.pop(0)
2002 cmd = [
2003 tool,
2004 '-k', str(self.get_ceph_option('keyring')),
2005 '-n', f'mgr.{self.get_mgr_id()}',
2006 ] + args
2007 self.log.debug('exec: ' + ' '.join(cmd))
2008 p = subprocess.run(
2009 cmd,
2010 input=stdin,
2011 stdout=subprocess.PIPE,
2012 stderr=subprocess.PIPE,
2013 timeout=timeout,
2014 )
2015 except subprocess.TimeoutExpired as ex:
2016 self.log.error(ex)
2017 return -errno.ETIMEDOUT, '', str(ex)
2018 if p.returncode:
2019 self.log.error(f'Non-zero return from {cmd}: {p.stderr.decode()}')
2020 return p.returncode, p.stdout.decode(), p.stderr.decode()
2021
2022 def set_health_checks(self, checks: HealthChecksT) -> None:
2023 """

Callers

nothing calls this directly

Calls 8

get_ceph_optionMethod · 0.95
get_mgr_idMethod · 0.95
popMethod · 0.45
debugMethod · 0.45
joinMethod · 0.45
runMethod · 0.45
errorMethod · 0.45
decodeMethod · 0.45

Tested by

no test coverage detected