]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm/smb: Determine samba version within container 58585/head
authorAnoop C S <anoopcs@cryptolab.net>
Mon, 15 Jul 2024 07:07:59 +0000 (12:37 +0530)
committerAnoop C S <anoopcs@cryptolab.net>
Tue, 16 Jul 2024 06:03:29 +0000 (11:33 +0530)
Implement a `get_version()` method to figure out the version of samba
running inside the container using smbd. This will help us to avoid
reporting version as "<unknown>" while listing the daemons via `ceph
orch ps`.

Signed-off-by: Anoop C S <anoopcs@cryptolab.net>
src/cephadm/cephadm.py
src/cephadm/cephadmlib/daemons/smb.py

index 5deaec55949c8bf1c29d0174f407a06a556b9664..ecac9afa16d0ea00c853b974cfee954b5bf801ce 100755 (executable)
@@ -3528,6 +3528,8 @@ def list_daemons(
                                 version = CephIscsi.get_version(ctx, container_id)
                             if daemon_type == CephNvmeof.daemon_type:
                                 version = CephNvmeof.get_version(ctx, container_id)
+                            if daemon_type == SMB.daemon_type:
+                                version = SMB.get_version(ctx, container_id)
                             elif not version:
                                 if daemon_type in ceph_daemons():
                                     out, err, code = call(ctx,
index e90329787c7e7afb89e10b3ce2a3d4b5e92cfd83..272566238905ee79bddb2282a305142f7f05947e 100644 (file)
@@ -2,6 +2,7 @@ import enum
 import json
 import logging
 import pathlib
+import re
 import socket
 
 from typing import List, Dict, Tuple, Optional, Any
@@ -11,6 +12,7 @@ from .. import daemon_form
 from .. import data_utils
 from .. import deployment_utils
 from .. import file_utils
+from ..call_wrappers import call, CallVerbosity
 from ..constants import DEFAULT_SMB_IMAGE
 from ..container_daemon_form import ContainerDaemonForm, daemon_to_container
 from ..container_engines import Podman
@@ -220,6 +222,7 @@ class SMB(ContainerDaemonForm):
     """Provides a form for SMB containers."""
 
     daemon_type = 'smb'
+    daemon_base = '/usr/sbin/smbd'
     default_image = DEFAULT_SMB_IMAGE
 
     @classmethod
@@ -237,6 +240,27 @@ class SMB(ContainerDaemonForm):
         self.smb_port = 445
         logger.debug('Created SMB ContainerDaemonForm instance')
 
+    @staticmethod
+    def get_version(ctx: CephadmContext, container_id: str) -> Optional[str]:
+        version = None
+        out, _, ret = call(
+            ctx,
+            [
+                ctx.container_engine.path,
+                'exec',
+                container_id,
+                SMB.daemon_base,
+                '-V',
+            ],
+            verbosity=CallVerbosity.QUIET,
+        )
+
+        if ret == 0:
+            match = re.search(r'Version\s*([\d.]+)', out)
+            if match:
+                version = match.group(1)
+        return version
+
     def validate(self) -> None:
         if self._instance_cfg is not None:
             return