Skip to content

Commit 3154cd2

Browse files
cephadm: add get_container_stats to container_types
We're in the process of trying to remove get_container_types from cephadm.py. Most of the generic logic has been moved to container_engines.py. However, the remaining parts of the current get_container_stats rely on classes from container_types.py so add a future replacement for the existing get_container_types to container_types.py. Signed-off-by: John Mulligan <[email protected]>
1 parent cc087cf commit 3154cd2

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/cephadm/cephadmlib/container_types.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@
1010
from .call_wrappers import call, call_throws, CallVerbosity
1111
from .constants import DEFAULT_TIMEOUT
1212
from ceph.cephadm.images import DefaultImages
13-
from .container_engines import Docker, Podman
13+
from .container_engines import (
14+
ContainerInfo,
15+
Docker,
16+
Podman,
17+
parsed_container_stats,
18+
)
1419
from .context import CephadmContext
1520
from .daemon_identity import DaemonIdentity, DaemonSubIdentity
1621
from .exceptions import Error
@@ -670,3 +675,15 @@ def get_mgr_images() -> dict:
670675
f'{mgr_prefix}{image.key}': image.image_ref for image in DefaultImages
671676
}
672677
return mgr_images
678+
679+
680+
def get_container_stats(
681+
ctx: CephadmContext, identity: DaemonIdentity, *, container_path: str = ''
682+
) -> Optional[ContainerInfo]:
683+
"""returns container id, image name, image id, created time, and ceph version if available"""
684+
c = CephContainer.for_daemon(ctx, identity, 'bash')
685+
for name in (c.cname, c.old_cname):
686+
ci = parsed_container_stats(ctx, name, container_path=container_path)
687+
if ci is not None:
688+
return ci
689+
return None

0 commit comments

Comments
 (0)