]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: get service_name from DaemonDescription
authorMichael Fritch <mfritch@suse.com>
Mon, 27 Apr 2020 17:42:11 +0000 (11:42 -0600)
committerMichael Fritch <mfritch@suse.com>
Mon, 4 May 2020 21:35:53 +0000 (15:35 -0600)
use the shared logic in the DaemonDescription class

Signed-off-by: Michael Fritch <mfritch@suse.com>
src/pybind/mgr/cephadm/module.py

index 89af9d14b044bc3e4d125e15dc64447422698897..9fc306f65b32a635412c3d0a9f07e32e08d9702e 100644 (file)
@@ -23,7 +23,6 @@ import os
 import random
 import tempfile
 import multiprocessing.pool
-import re
 import shutil
 import subprocess
 import uuid
@@ -1242,15 +1241,6 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule):
                 continue
             return name
 
-    def get_service_name(self, daemon_type, daemon_id, host):
-        # type: (str, str, str) -> (str)
-        """
-        Returns the generic service name
-        """
-        p = re.compile(r'(.*)\.%s.*' % (host))
-        return '%s.%s' % (daemon_type, p.sub(r'\1', daemon_id))
-
-
     def _save_upgrade_state(self):
         self.set_store('upgrade_state', json.dumps(self.upgrade_state))
 
@@ -2917,8 +2907,14 @@ api_secure = {api_secure}
 
         # find the matching NFSServiceSpec
         # TODO: find the spec and pass via _create_daemon instead ??
-        service_name = self.get_service_name(daemon_type, daemon_id, host)
+        dd = orchestrator.DaemonDescription()
+        dd.daemon_type = daemon_type
+        dd.daemon_id = daemon_id
+        dd.hostname = host
+
+        service_name = dd.service_name()
         specs = self.spec_store.find(service_name)
+
         if not specs:
             raise OrchestratorError('Cannot find service spec %s' % (service_name))
         elif len(specs) > 1: