]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/tasks: add a cephadm samba container helper func independent of AD DC
authorJohn Mulligan <jmulligan@redhat.com>
Fri, 15 Mar 2024 17:48:35 +0000 (13:48 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Thu, 21 Mar 2024 22:31:16 +0000 (18:31 -0400)
To have the standalone (non-AD) server test function similarly to the AD
member server test we need to set a variable for samba client container
command similar to how the AD setup command does it.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
qa/tasks/cephadm.py

index 66d51aff2f5486cf894c909b3c492eec46ddb98c..008d8c94d55bbe2ad16a5a09173632f81dfbb439 100644 (file)
@@ -1962,6 +1962,44 @@ def _samba_ad_dc_conf(ctx, remote, cengine):
     ]
 
 
+@contextlib.contextmanager
+def configure_samba_client_container(ctx, config):
+    # TODO: deduplicate logic between this task and deploy_samba_ad_dc
+    role = config.get('role')
+    samba_client_image = config.get(
+        'samba_client_image', 'quay.io/samba.org/samba-client:latest'
+    )
+    if not role:
+        raise ConfigError(
+            "you must specify a role to discover container engine / pull image"
+        )
+    (remote,) = ctx.cluster.only(role).remotes.keys()
+    cengine = 'podman'
+    try:
+        log.info("Testing if podman is available")
+        remote.run(args=['sudo', cengine, '--help'])
+    except CommandFailedError:
+        log.info("Failed to find podman. Using docker")
+        cengine = 'docker'
+
+    remote.run(args=['sudo', cengine, 'pull', samba_client_image])
+    samba_client_container_cmd = [
+        'sudo',
+        cengine,
+        'run',
+        '--rm',
+        '--net=host',
+        '-eKRB5_CONFIG=/dev/null',
+        samba_client_image,
+    ]
+
+    setattr(ctx, 'samba_client_container_cmd', samba_client_container_cmd)
+    try:
+        yield
+    finally:
+        setattr(ctx, 'samba_client_container_cmd', None)
+
+
 @contextlib.contextmanager
 def deploy_samba_ad_dc(ctx, config):
     role = config.get('role')