Skip to content

Commit 530a81a

Browse files
cephadm: use parsed_container_cpu_perc in cephadm.py
Replace the use of _parse_cpu_perc and related command calls with parsed_container_mem_usage. This needs no additional test updates because the test updates in the previous patch that added parsed_container_mem_usage covered all of that already. Signed-off-by: John Mulligan <[email protected]>
1 parent 1834881 commit 530a81a

File tree

1 file changed

+2
-23
lines changed

1 file changed

+2
-23
lines changed

src/cephadm/cephadm.py

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
check_container_engine,
9090
find_container_engine,
9191
parsed_container_mem_usage,
92+
parsed_container_cpu_perc,
9293
pull_command,
9394
registry_login,
9495
)
@@ -3448,13 +3449,7 @@ def list_daemons(
34483449
seen_memusage = {} # type: Dict[str, int]
34493450
seen_cpuperc = {} # type: Dict[str, str]
34503451
seen_memusage_cid_len, seen_memusage = parsed_container_mem_usage(ctx)
3451-
3452-
out, err, code = call(
3453-
ctx,
3454-
[container_path, 'stats', '--format', '{{.ID}},{{.CPUPerc}}', '--no-stream'],
3455-
verbosity=CallVerbosity.QUIET
3456-
)
3457-
seen_cpuperc_cid_len, seen_cpuperc = _parse_cpu_perc(code, out)
3452+
seen_cpuperc_cid_len, seen_cpuperc = parsed_container_cpu_perc(ctx)
34583453

34593454
# /var/lib/ceph
34603455
if os.path.exists(data_dir):
@@ -3657,22 +3652,6 @@ def list_daemons(
36573652
return ls
36583653

36593654

3660-
def _parse_cpu_perc(code: int, out: str) -> Tuple[int, Dict[str, str]]:
3661-
seen_cpuperc = {}
3662-
seen_cpuperc_cid_len = 0
3663-
if not code:
3664-
for line in out.splitlines():
3665-
(cid, cpuperc) = line.split(',')
3666-
try:
3667-
seen_cpuperc[cid] = cpuperc
3668-
if not seen_cpuperc_cid_len:
3669-
seen_cpuperc_cid_len = len(cid)
3670-
except ValueError:
3671-
logger.info('unable to parse cpu percentage line\n>{}'.format(line))
3672-
pass
3673-
return seen_cpuperc_cid_len, seen_cpuperc
3674-
3675-
36763655
def get_daemon_description(ctx, fsid, name, detail=False, legacy_dir=None):
36773656
# type: (CephadmContext, str, str, bool, Optional[str]) -> Dict[str, str]
36783657

0 commit comments

Comments
 (0)