return None
-def check_container_engine(ctx):
- # type: (CephadmContext) -> None
+def check_container_engine(ctx: CephadmContext) -> ContainerEngine:
engine = ctx.container_engine
if not isinstance(engine, CONTAINER_PREFERENCE):
# See https://github.com/python/mypy/issues/8993
engine.get_version(ctx)
if engine.version < MIN_PODMAN_VERSION:
raise Error('podman version %d.%d.%d or later is required' % MIN_PODMAN_VERSION)
+ return engine
def get_unit_name(fsid, daemon_type, daemon_id=None):
def command_check_host(ctx: CephadmContext) -> None:
- container_path = ctx.container_engine.path
-
errors = []
commands = ['systemctl', 'lvcreate']
try:
- check_container_engine(ctx)
- logger.info('podman|docker (%s) is present' % container_path)
+ engine = check_container_engine(ctx)
+ logger.info('podman|docker (%s) is present' % engine.path)
except Error as e:
errors.append(str(e))
assert c.old_cname == 'ceph-9b9d7609-f4d5-4aba-94c8-effa764d96c9-iscsi.something'
+class TestCheckHost:
+ @mock.patch('cephadm.find_executable', return_value='foo')
+ def test_container_engine(self, find_executable):
+ cmd = ['check-host']
+
+ ctx = cd.CephadmContext()
+ ctx.container_engine = None
+
+ err = r'No container engine binary found'
+ with pytest.raises(cd.Error, match=err):
+ cd.command_check_host(ctx)
+
+ ctx.container_engine = mock_podman()
+ cd.command_check_host(ctx)
+
+ ctx.container_engine = mock_docker()
+ cd.command_check_host(ctx)