summaryrefslogtreecommitdiffstats
path: root/src/cephadm
diff options
context:
space:
mode:
authorAnoop C S <anoopcs@cryptolab.net>2024-07-15 09:07:59 +0200
committerAnoop C S <anoopcs@cryptolab.net>2024-07-16 08:03:29 +0200
commit08d985933c529216c6e9aacc89fa1b03a0cdcc56 (patch)
tree2f85a3581cc4f2a2d7fce8074d434bd2d0c8f0f2 /src/cephadm
parentMerge pull request #58596 from batrick/superuser-doc (diff)
downloadceph-08d985933c529216c6e9aacc89fa1b03a0cdcc56.tar.xz
ceph-08d985933c529216c6e9aacc89fa1b03a0cdcc56.zip
cephadm/smb: Determine samba version within container
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>
Diffstat (limited to 'src/cephadm')
-rwxr-xr-xsrc/cephadm/cephadm.py2
-rw-r--r--src/cephadm/cephadmlib/daemons/smb.py24
2 files changed, 26 insertions, 0 deletions
diff --git a/src/cephadm/cephadm.py b/src/cephadm/cephadm.py
index 5deaec55949..ecac9afa16d 100755
--- a/src/cephadm/cephadm.py
+++ b/src/cephadm/cephadm.py
@@ -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,
diff --git a/src/cephadm/cephadmlib/daemons/smb.py b/src/cephadm/cephadmlib/daemons/smb.py
index e90329787c7..27256623890 100644
--- a/src/cephadm/cephadmlib/daemons/smb.py
+++ b/src/cephadm/cephadmlib/daemons/smb.py
@@ -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