from mgr_module import HandleCommandResult
from ceph.deployment.service_spec import IscsiServiceSpec
-from orchestrator import DaemonDescription, DaemonDescriptionStatus
+from orchestrator import DaemonDescription, DaemonDescriptionStatus, OrchestratorError
from .cephadmservice import CephadmDaemonDeploySpec, CephService
from .. import utils
"""
logger.debug(f'Post remove daemon {self.TYPE}.{daemon.daemon_id}')
- # remove config for dashboard iscsi gateways
ret, out, err = self.mgr.check_mon_command({
- 'prefix': 'dashboard iscsi-gateway-rm',
- 'name': daemon.hostname,
+ 'prefix': 'mgr module ls',
+ 'format': 'json',
})
- logger.info(f'{daemon.hostname} removed from iscsi gateways dashboard config')
+ try:
+ j = json.loads(out)
+ except ValueError:
+ msg = 'Failed to parse mgr module ls: Cannot decode JSON'
+ logger.exception('%s: \'%s\'' % (msg, out))
+ raise OrchestratorError('failed to parse mgr module ls')
+
+ if 'dashboard' in j['enabled_modules']:
+ # remove config for dashboard iscsi gateways
+ ret, out, err = self.mgr.check_mon_command({
+ 'prefix': 'dashboard iscsi-gateway-rm',
+ 'name': daemon.hostname,
+ })
+ logger.info(f'{daemon.hostname} removed from iscsi gateways dashboard config')
# needed to know if we have ssl stuff for iscsi in ceph config
iscsi_config_dict = {}
placement=ps)
unmanaged_spec = ServiceSpec.from_json(spec.to_json())
unmanaged_spec.unmanaged = True
+ cephadm_module._mon_command_mock_mgr_module_ls = lambda *args: json.dumps({'enabled_modules': []})
with with_service(cephadm_module, unmanaged_spec):
c = cephadm_module.add_daemon(spec)
@mock.patch("subprocess.run", mock.MagicMock())
def test_apply_save(self, spec: ServiceSpec, meth, cephadm_module: CephadmOrchestrator):
with with_host(cephadm_module, 'test'):
+ cephadm_module._mon_command_mock_mgr_module_ls = lambda *args: json.dumps({'enabled_modules': []})
with with_service(cephadm_module, spec, meth, 'test'):
pass