From: Michael Fritch Date: Mon, 27 Apr 2020 17:42:11 +0000 (-0600) Subject: mgr/cephadm: get service_name from DaemonDescription X-Git-Tag: wip-pdonnell-testing-20200918.022351~1358^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=01604b6e43b57e0f5ff93fe316da1eb75ed156f3;p=ceph-ci.git mgr/cephadm: get service_name from DaemonDescription use the shared logic in the DaemonDescription class Signed-off-by: Michael Fritch --- diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index 89af9d14b04..9fc306f65b3 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 @@ -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: