From: John Mulligan Date: Wed, 1 Apr 2026 22:22:54 +0000 (-0400) Subject: python-common/ceph/smb: add file with basic config classes X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=cebdc1ed1284165589ecabe898ba98ff2c088934;p=ceph.git python-common/ceph/smb: add file with basic config classes Add a file with the basic configuration classes and functions needed to set up a connection with the remote-control grpc server for SMB. Signed-off-by: John Mulligan --- diff --git a/src/python-common/ceph/smb/ctl/config.py b/src/python-common/ceph/smb/ctl/config.py new file mode 100644 index 00000000000..5d7147de772 --- /dev/null +++ b/src/python-common/ceph/smb/ctl/config.py @@ -0,0 +1,58 @@ +"""Ceph SMB client config library""" + +import typing + +import abc +import dataclasses +import enum +import pathlib + +from ._typing import Self + + +class ChannelType(str, enum.Enum): + SECURE = 'secure' + INSECURE = 'insecure' + + +class TLSLoader(abc.ABC): + def load(self) -> bytes: + raise NotImplementedError() + + +@dataclasses.dataclass +class TLSInline(TLSLoader): + """Configure TLS with inline cert data. Mainly for testing.""" + + data: typing.Union[str, bytes] + + def load(self) -> bytes: + if isinstance(self.data, str): + return self.data.encode() + return self.data + + +@dataclasses.dataclass +class TLSPath(TLSLoader): + """Configure TLS using a path to cert data.""" + + path: pathlib.Path + + @classmethod + def create(cls, path: typing.Union[str, pathlib.Path]) -> Self: + return cls(pathlib.Path(path)) + + def load(self) -> bytes: + with open(self.path, 'rb') as fh: + data = fh.read() + return data + + +@dataclasses.dataclass +class Config: + address: str + channel_type: ChannelType + tls_cert: typing.Optional[TLSLoader] = None + tls_key: typing.Optional[TLSLoader] = None + tls_ca_cert: typing.Optional[TLSLoader] = None + headers: typing.Optional[typing.Dict[str, str]] = None