diff options
author | Anoop C S <anoopcs@cryptolab.net> | 2024-07-15 09:07:59 +0200 |
---|---|---|
committer | Anoop C S <anoopcs@cryptolab.net> | 2024-07-16 08:03:29 +0200 |
commit | 08d985933c529216c6e9aacc89fa1b03a0cdcc56 (patch) | |
tree | 2f85a3581cc4f2a2d7fce8074d434bd2d0c8f0f2 /src/cephadm | |
parent | Merge pull request #58596 from batrick/superuser-doc (diff) | |
download | ceph-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-x | src/cephadm/cephadm.py | 2 | ||||
-rw-r--r-- | src/cephadm/cephadmlib/daemons/smb.py | 24 |
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 |