From: John Mulligan Date: Thu, 30 Jan 2025 22:54:22 +0000 (-0500) Subject: cephadm: move ContainerInfo class to container_engines.py X-Git-Tag: v20.0.0~205^2~5 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=bc61710baed4a0ef3ca6d7161e14eaad96659c56;p=ceph.git cephadm: move ContainerInfo class to container_engines.py Move the ContainerInfo class, which has basically no dependencies, to container engines module which is the current home for generic *low-level* container things. Signed-off-by: John Mulligan --- diff --git a/src/cephadm/cephadm.py b/src/cephadm/cephadm.py index 4be352bfae089..cf7531f76389a 100755 --- a/src/cephadm/cephadm.py +++ b/src/cephadm/cephadm.py @@ -85,6 +85,7 @@ from cephadmlib.call_wrappers import ( concurrent_tasks, ) from cephadmlib.container_engines import ( + ContainerInfo, Podman, check_container_engine, find_container_engine, @@ -200,30 +201,6 @@ logger = logging.getLogger() ################################## -class ContainerInfo: - def __init__(self, container_id: str, - image_name: str, - image_id: str, - start: str, - version: str) -> None: - self.container_id = container_id - self.image_name = image_name - self.image_id = image_id - self.start = start - self.version = version - - def __eq__(self, other: Any) -> bool: - if not isinstance(other, ContainerInfo): - return NotImplemented - return (self.container_id == other.container_id - and self.image_name == other.image_name - and self.image_id == other.image_id - and self.start == other.start - and self.version == other.version) - -################################## - - def get_supported_daemons(): # type: () -> List[str] supported_daemons = ceph_daemons() diff --git a/src/cephadm/cephadmlib/container_engines.py b/src/cephadm/cephadmlib/container_engines.py index af094ecbd54c2..9eb2f622b8f17 100644 --- a/src/cephadm/cephadmlib/container_engines.py +++ b/src/cephadm/cephadmlib/container_engines.py @@ -3,7 +3,7 @@ import os import logging -from typing import Tuple, List, Optional, Dict +from typing import Tuple, List, Optional, Dict, Any from .call_wrappers import call_throws, call, CallVerbosity from .context import CephadmContext @@ -302,3 +302,30 @@ def parsed_container_cpu_perc( ctx, container_path=container_path, verbosity=verbosity ) return _parse_cpu_perc(code, out) + + +class ContainerInfo: + def __init__( + self, + container_id: str, + image_name: str, + image_id: str, + start: str, + version: str, + ) -> None: + self.container_id = container_id + self.image_name = image_name + self.image_id = image_id + self.start = start + self.version = version + + def __eq__(self, other: Any) -> bool: + if not isinstance(other, ContainerInfo): + return NotImplemented + return ( + self.container_id == other.container_id + and self.image_name == other.image_name + and self.image_id == other.image_id + and self.start == other.start + and self.version == other.version + )