From: Michael Fritch Date: Mon, 27 Apr 2020 17:42:11 +0000 (-0600) Subject: mgr/cephadm: get service_name from DaemonDescription X-Git-Tag: v15.2.4~73^2~84 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c86a31bfed03f3fc7ccdce658e74862ea8d15c12;p=ceph.git mgr/cephadm: get service_name from DaemonDescription use the shared logic in the DaemonDescription class Signed-off-by: Michael Fritch (cherry picked from commit 01604b6e43b57e0f5ff93fe316da1eb75ed156f3) --- diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index 3f81c0b457b8..0edd76de4e39 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -23,7 +23,6 @@ import os import random import tempfile import multiprocessing.pool -import re import shutil import subprocess import uuid @@ -1240,15 +1239,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)) @@ -2933,8 +2923,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: