]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cepahdm: add various touch points to enable smb service
authorJohn Mulligan <jmulligan@redhat.com>
Thu, 4 Jan 2024 21:38:08 +0000 (16:38 -0500)
committerAdam King <adking@redhat.com>
Mon, 15 Apr 2024 15:01:30 +0000 (11:01 -0400)
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 <jmulligan@redhat.com>
(cherry picked from commit c5e4912fd5fd43e21525952ca1d295dac10e2bbe)

src/pybind/mgr/cephadm/module.py
src/pybind/mgr/cephadm/utils.py
src/pybind/mgr/orchestrator/_interface.py
src/pybind/mgr/orchestrator/module.py

index 3362a6780eb0439bb8e9e616b183c52e73eccc12..b8af6638a5cd4003f5c55c93f07766a5af3a106b 100644 (file)
@@ -74,6 +74,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
@@ -685,6 +686,7 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule,
             PromtailService,
             RbdMirrorService,
             RgwService,
+            SMBService,
             SNMPGatewayService,
         ]
 
@@ -3230,7 +3232,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 \
@@ -3360,6 +3363,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)
index 1ba3e48454a209be6525edb7db39577f7b50b199..3673fbf621cb9e70324fde3ea02a62064ccec20e 100644 (file)
@@ -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)
index 055fba316a88bd714f31798f971901c57cad8772..04883c1a6eedca645ebabc601271eb53485e3e95 100644 (file)
@@ -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
@@ -811,6 +813,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()
@@ -909,7 +915,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]
 
@@ -943,7 +950,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]
 
index 178498fc457504b38e8ea64e8519f880bfbff4f5..9a8984b9ccadb80a969c6dd94efa7ea267c7b270 100644 (file)
@@ -44,6 +44,7 @@ from ._interface import (
     OrchestratorError,
     OrchestratorValidationError,
     RGWSpec,
+    SMBSpec,
     SNMPGatewaySpec,
     ServiceDescription,
     TunedProfileSpec,
@@ -1808,6 +1809,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"""