From c5e4912fd5fd43e21525952ca1d295dac10e2bbe Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Thu, 4 Jan 2024 16:38:08 -0500 Subject: [PATCH] mgr/cepahdm: add various touch points to enable smb service Add the smb service by name or by type to one of the many, many touch points in the orchestrator and cephadm packages needed to get the orchestrator aware of smb. Signed-off-by: John Mulligan --- src/pybind/mgr/cephadm/module.py | 9 +++++- src/pybind/mgr/cephadm/utils.py | 4 +-- src/pybind/mgr/orchestrator/_interface.py | 12 ++++++-- src/pybind/mgr/orchestrator/module.py | 37 +++++++++++++++++++++++ 4 files changed, 57 insertions(+), 5 deletions(-) diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index d30f2e5b5b6c2..8e81375917222 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -76,6 +76,7 @@ from .services.monitoring import GrafanaService, AlertmanagerService, Prometheus NodeExporterService, SNMPGatewayService, LokiService, PromtailService from .services.jaeger import ElasticSearchService, JaegerAgentService, JaegerCollectorService, JaegerQueryService from .services.node_proxy import NodeProxy +from .services.smb import SMBService from .schedule import HostAssignment from .inventory import Inventory, SpecStore, HostCache, AgentCache, EventStore, \ ClientKeyringStore, ClientKeyringSpec, TunedProfileStore, NodeProxyCache @@ -687,6 +688,7 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule, PromtailService, RbdMirrorService, RgwService, + SMBService, SNMPGatewayService, ] @@ -3275,7 +3277,8 @@ Then run the following: 'elasticsearch': PlacementSpec(count=1), 'jaeger-agent': PlacementSpec(host_pattern='*'), 'jaeger-collector': PlacementSpec(count=1), - 'jaeger-query': PlacementSpec(count=1) + 'jaeger-query': PlacementSpec(count=1), + SMBService.TYPE: PlacementSpec(count=1), } spec.placement = defaults[spec.service_type] elif spec.service_type in ['mon', 'mgr'] and \ @@ -3405,6 +3408,10 @@ Then run the following: def apply_snmp_gateway(self, spec: ServiceSpec) -> str: return self._apply(spec) + @handle_orch_error + def apply_smb(self, spec: ServiceSpec) -> str: + return self._apply(spec) + @handle_orch_error def set_unmanaged(self, service_name: str, value: bool) -> str: return self.spec_store.set_unmanaged(service_name, value) diff --git a/src/pybind/mgr/cephadm/utils.py b/src/pybind/mgr/cephadm/utils.py index 1ba3e48454a20..3673fbf621cb9 100644 --- a/src/pybind/mgr/cephadm/utils.py +++ b/src/pybind/mgr/cephadm/utils.py @@ -36,7 +36,7 @@ CEPH_IMAGE_TYPES = CEPH_TYPES + ['iscsi', 'nfs', 'node-proxy'] # these daemons do not use the ceph image. There are other daemons # that also don't use the ceph image, but we only care about those # that are part of the upgrade order here -NON_CEPH_IMAGE_TYPES = MONITORING_STACK_TYPES + ['nvmeof'] +NON_CEPH_IMAGE_TYPES = MONITORING_STACK_TYPES + ['nvmeof', 'smb'] # Used for _run_cephadm used for check-host etc that don't require an --image parameter cephadmNoImage = CephadmNoImage.token @@ -66,7 +66,7 @@ def name_to_config_section(name: str) -> ConfEntity: Map from daemon names to ceph entity names (as seen in config) """ daemon_type = name.split('.', 1)[0] - if daemon_type in ['rgw', 'rbd-mirror', 'nfs', 'crash', 'iscsi', 'ceph-exporter', 'nvmeof']: + if daemon_type in ['rgw', 'rbd-mirror', 'nfs', 'crash', 'iscsi', 'ceph-exporter', 'nvmeof', 'smb']: return ConfEntity('client.' + name) elif daemon_type in ['mon', 'osd', 'mds', 'mgr', 'client']: return ConfEntity(name) diff --git a/src/pybind/mgr/orchestrator/_interface.py b/src/pybind/mgr/orchestrator/_interface.py index 7e1b57466e3b9..f5ddbe6515b24 100644 --- a/src/pybind/mgr/orchestrator/_interface.py +++ b/src/pybind/mgr/orchestrator/_interface.py @@ -40,6 +40,7 @@ from ceph.deployment.service_spec import ( NFSServiceSpec, NvmeofServiceSpec, RGWSpec, + SMBSpec, SNMPGatewaySpec, ServiceSpec, TunedProfileSpec, @@ -582,6 +583,7 @@ class Orchestrator(object): 'ingress': self.apply_ingress, 'snmp-gateway': self.apply_snmp_gateway, 'host': self.add_host, + 'smb': self.apply_smb, } def merge(l: OrchResult[List[str]], r: OrchResult[str]) -> OrchResult[List[str]]: # noqa: E741 @@ -819,6 +821,10 @@ class Orchestrator(object): """Update an existing snmp gateway service""" raise NotImplementedError() + def apply_smb(self, spec: SMBSpec) -> OrchResult[str]: + """Update a smb gateway service""" + raise NotImplementedError() + def apply_tuned_profiles(self, specs: List[TunedProfileSpec], no_overwrite: bool) -> OrchResult[str]: """Add or update an existing tuned profile""" raise NotImplementedError() @@ -917,7 +923,8 @@ def daemon_type_to_service(dtype: str) -> str: 'elasticsearch': 'elasticsearch', 'jaeger-agent': 'jaeger-agent', 'jaeger-collector': 'jaeger-collector', - 'jaeger-query': 'jaeger-query' + 'jaeger-query': 'jaeger-query', + 'smb': 'smb', } return mapping[dtype] @@ -951,7 +958,8 @@ def service_to_daemon_types(stype: str) -> List[str]: 'jaeger-agent': ['jaeger-agent'], 'jaeger-collector': ['jaeger-collector'], 'jaeger-query': ['jaeger-query'], - 'jaeger-tracing': ['elasticsearch', 'jaeger-query', 'jaeger-collector', 'jaeger-agent'] + 'jaeger-tracing': ['elasticsearch', 'jaeger-query', 'jaeger-collector', 'jaeger-agent'], + 'smb': ['smb'], } return mapping[stype] diff --git a/src/pybind/mgr/orchestrator/module.py b/src/pybind/mgr/orchestrator/module.py index 3e80621ef8386..d1ba6ea867552 100644 --- a/src/pybind/mgr/orchestrator/module.py +++ b/src/pybind/mgr/orchestrator/module.py @@ -44,6 +44,7 @@ from ._interface import ( OrchestratorError, OrchestratorValidationError, RGWSpec, + SMBSpec, SNMPGatewaySpec, ServiceDescription, TunedProfileSpec, @@ -1820,6 +1821,42 @@ Usage: specs: List[ServiceSpec] = spec.get_tracing_specs() return self._apply_misc(specs, dry_run, format, no_overwrite) + @_cli_write_command('orch apply smb') + def _apply_smb( + self, + cluster_id: str, + config_uri: str, + features: str = '', + join_sources: Optional[List[str]] = None, + custom_dns: Optional[List[str]] = None, + include_ceph_users: Optional[List[str]] = None, + placement: Optional[str] = None, + unmanaged: bool = False, + dry_run: bool = False, + format: Format = Format.plain, + no_overwrite: bool = False, + ) -> HandleCommandResult: + """Apply an SMB network file system gateway service configuration.""" + + _features = features.replace(',', ' ').split() + spec = SMBSpec( + service_id=cluster_id, + placement=PlacementSpec.from_string(placement), + unmanaged=unmanaged, + preview_only=dry_run, + cluster_id=cluster_id, + features=_features, + config_uri=config_uri, + join_sources=join_sources, + custom_dns=custom_dns, + include_ceph_users=include_ceph_users, + ) + + spec.validate() # force any validation exceptions to be caught correctly + # The previous comment makes no sense to JJM. But when in rome. + + return self._apply_misc([spec], dry_run, format, no_overwrite) + @_cli_write_command('orch set-unmanaged') def _set_unmanaged(self, service_name: str) -> HandleCommandResult: """Set 'unmanaged: true' for the given service name""" -- 2.39.5