From 01604b6e43b57e0f5ff93fe316da1eb75ed156f3 Mon Sep 17 00:00:00 2001 From: Michael Fritch Date: Mon, 27 Apr 2020 11:42:11 -0600 Subject: [PATCH] mgr/cephadm: get service_name from DaemonDescription use the shared logic in the DaemonDescription class Signed-off-by: Michael Fritch --- src/pybind/mgr/cephadm/module.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index 89af9d14b044b..9fc306f65b32a 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: -- 2.39.5