Skip to content

Commit 08d9859

Browse files
committed
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 <[email protected]>
1 parent f890abb commit 08d9859

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/cephadm/cephadm.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3528,6 +3528,8 @@ def list_daemons(
35283528
version = CephIscsi.get_version(ctx, container_id)
35293529
if daemon_type == CephNvmeof.daemon_type:
35303530
version = CephNvmeof.get_version(ctx, container_id)
3531+
if daemon_type == SMB.daemon_type:
3532+
version = SMB.get_version(ctx, container_id)
35313533
elif not version:
35323534
if daemon_type in ceph_daemons():
35333535
out, err, code = call(ctx,

src/cephadm/cephadmlib/daemons/smb.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import json
33
import logging
44
import pathlib
5+
import re
56
import socket
67

78
from typing import List, Dict, Tuple, Optional, Any
@@ -11,6 +12,7 @@
1112
from .. import data_utils
1213
from .. import deployment_utils
1314
from .. import file_utils
15+
from ..call_wrappers import call, CallVerbosity
1416
from ..constants import DEFAULT_SMB_IMAGE
1517
from ..container_daemon_form import ContainerDaemonForm, daemon_to_container
1618
from ..container_engines import Podman
@@ -220,6 +222,7 @@ class SMB(ContainerDaemonForm):
220222
"""Provides a form for SMB containers."""
221223

222224
daemon_type = 'smb'
225+
daemon_base = '/usr/sbin/smbd'
223226
default_image = DEFAULT_SMB_IMAGE
224227

225228
@classmethod
@@ -237,6 +240,27 @@ def __init__(self, ctx: CephadmContext, ident: DaemonIdentity):
237240
self.smb_port = 445
238241
logger.debug('Created SMB ContainerDaemonForm instance')
239242

243+
@staticmethod
244+
def get_version(ctx: CephadmContext, container_id: str) -> Optional[str]:
245+
version = None
246+
out, _, ret = call(
247+
ctx,
248+
[
249+
ctx.container_engine.path,
250+
'exec',
251+
container_id,
252+
SMB.daemon_base,
253+
'-V',
254+
],
255+
verbosity=CallVerbosity.QUIET,
256+
)
257+
258+
if ret == 0:
259+
match = re.search(r'Version\s*([\d.]+)', out)
260+
if match:
261+
version = match.group(1)
262+
return version
263+
240264
def validate(self) -> None:
241265
if self._instance_cfg is not None:
242266
return

0 commit comments

Comments
 (0)