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

Function send_command

src/pybind/ceph_argparse.py:1573–1670  ·  view source on GitHub ↗

Send a command to a daemon using librados's mon_command, osd_command, mgr_command, or pg_command. Any bulk input data comes in inbuf. Returns (ret, outbuf, outs); ret is the return code, outbuf is the outbl "bulk useful output" buffer, and outs is any status or error messa

(cluster,
                 target: Tuple[str, Optional[str]] = ('mon', ''),
                 cmd: Optional[str] = None,
                 inbuf: Optional[bytes] = b'',
                 timeout: Optional[int] = 0,
                 verbose: Optional[bool] = False)

Source from the content-addressed store, hash-verified

1571
1572
1573def send_command(cluster,
1574 target: Tuple[str, Optional[str]] = ('mon', ''),
1575 cmd: Optional[str] = None,
1576 inbuf: Optional[bytes] = b'',
1577 timeout: Optional[int] = 0,
1578 verbose: Optional[bool] = False) -> Tuple[int, bytes, str]:
1579 """
1580 Send a command to a daemon using librados's
1581 mon_command, osd_command, mgr_command, or pg_command. Any bulk input data
1582 comes in inbuf.
1583
1584 Returns (ret, outbuf, outs); ret is the return code, outbuf is
1585 the outbl "bulk useful output" buffer, and outs is any status
1586 or error message (intended for stderr).
1587
1588 If target is osd.N, send command to that osd (except for pgid cmds)
1589 """
1590 try:
1591 if target[0] == 'osd':
1592 osdid = target[1]
1593 assert osdid is not None
1594
1595 if verbose:
1596 print('submit {0} to osd.{1}'.format(cmd, osdid),
1597 file=sys.stderr)
1598 ret, outbuf, outs = run_in_thread(
1599 cluster.osd_command, int(osdid), cmd, inbuf, timeout=timeout)
1600
1601 elif target[0] == 'mgr':
1602 name = '' # non-None empty string means "current active mgr"
1603 if len(target) > 1 and target[1] is not None:
1604 name = target[1]
1605 if verbose:
1606 print('submit {0} to {1} name {2}'.format(cmd, target[0], name),
1607 file=sys.stderr)
1608 ret, outbuf, outs = run_in_thread(
1609 cluster.mgr_command, cmd, inbuf, timeout=timeout, target=name)
1610
1611 elif target[0] == 'mon-mgr':
1612 if verbose:
1613 print('submit {0} to {1}'.format(cmd, target[0]),
1614 file=sys.stderr)
1615 ret, outbuf, outs = run_in_thread(
1616 cluster.mgr_command, cmd, inbuf, timeout=timeout)
1617
1618 elif target[0] == 'pg':
1619 pgid = target[1]
1620 # pgid will already be in the command for the pg <pgid>
1621 # form, but for tell <pgid>, we need to put it in
1622 if cmd:
1623 cmddict = json.loads(cmd)
1624 cmddict['pgid'] = pgid
1625 else:
1626 cmddict = dict(pgid=pgid)
1627 cmd = json.dumps(cmddict)
1628 if verbose:
1629 print('submit {0} for pgid {1}'.format(cmd, pgid),
1630 file=sys.stderr)

Callers 1

send_command_retryFunction · 0.85

Calls 7

printFunction · 0.85
run_in_threadFunction · 0.85
ArgumentValidClass · 0.85
mds_commandMethod · 0.80
formatMethod · 0.45
initMethod · 0.45
shutdownMethod · 0.45

Tested by

no test coverage detected