From: John Mulligan Date: Fri, 20 Oct 2023 18:22:40 +0000 (-0400) Subject: cephadm: convert get_container_binds to use class based approach X-Git-Tag: v19.0.0~110^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f04c4b6c6f2b047260a003f5b47cb6b81a998d93;p=ceph.git cephadm: convert get_container_binds to use class based approach Since all types affected by get_container_binds now have the common customize_container_binds, use a generic class-based approach by creating an instance of ContainerDaemonForm and calling the method. All other classes have a customize_container_binds that is a no-op. Signed-off-by: John Mulligan --- diff --git a/src/cephadm/cephadm.py b/src/cephadm/cephadm.py index 03887b46e6b..9a1989a3c95 100755 --- a/src/cephadm/cephadm.py +++ b/src/cephadm/cephadm.py @@ -2561,17 +2561,9 @@ def get_container_binds( ctx: CephadmContext, ident: 'DaemonIdentity' ) -> List[List[str]]: binds: List[List[str]] = list() - - if ident.daemon_type == CephIscsi.daemon_type: - iscsi = CephIscsi.create(ctx, ident) - iscsi.customize_container_binds(ctx, binds) - if ident.daemon_type == CephNvmeof.daemon_type: - nvmeof = CephNvmeof.create(ctx, ident) - nvmeof.customize_container_binds(ctx, binds) - elif ident.daemon_type == CustomContainer.daemon_type: - cc = CustomContainer.create(ctx, ident) - cc.customize_container_binds(ctx, binds) - + daemon = daemon_form_create(ctx, ident) + assert isinstance(daemon, ContainerDaemonForm) + daemon.customize_container_binds(ctx, binds) return binds diff --git a/src/cephadm/tests/test_cephadm.py b/src/cephadm/tests/test_cephadm.py index 3f6ed70a39c..8db8edd0c1b 100644 --- a/src/cephadm/tests/test_cephadm.py +++ b/src/cephadm/tests/test_cephadm.py @@ -1575,7 +1575,7 @@ class TestShell(object): retval = _cephadm.command_shell(ctx) assert retval == 0 - cmd = ['shell', '--name', 'foo.bar'] + cmd = ['shell', '--name', 'mgr.bar'] with with_cephadm_ctx(cmd) as ctx: err = r'must pass --fsid' with pytest.raises(_cephadm.Error, match=err): @@ -1583,7 +1583,7 @@ class TestShell(object): assert retval == 1 fsid = '00000000-0000-0000-0000-0000deadbeef' - cmd = ['shell', '--name', 'foo.bar', '--fsid', fsid] + cmd = ['shell', '--name', 'mgr.bar', '--fsid', fsid] with with_cephadm_ctx(cmd) as ctx: retval = _cephadm.command_shell(ctx) assert retval == 0