]> git.proxmox.com Git - ceph.git/blame - ceph/src/pybind/mgr/dashboard/controllers/daemon.py
import quincy beta 17.1.0
[ceph.git] / ceph / src / pybind / mgr / dashboard / controllers / daemon.py
CommitLineData
20effc67
TL
1# -*- coding: utf-8 -*-
2
3from typing import Optional
4
5from ..exceptions import DashboardException
6from ..security import Scope
7from ..services.exception import handle_orchestrator_error
8from ..services.orchestrator import OrchClient, OrchFeature
9from . import APIDoc, APIRouter, RESTController
10from ._version import APIVersion
11from .orchestrator import raise_if_no_orchestrator
12
13
14@APIRouter('/daemon', Scope.HOSTS)
15@APIDoc("Perform actions on daemons", "Daemon")
16class Daemon(RESTController):
17 @raise_if_no_orchestrator([OrchFeature.DAEMON_ACTION])
18 @handle_orchestrator_error('daemon')
19 @RESTController.MethodMap(version=APIVersion.EXPERIMENTAL)
20 def set(self, daemon_name: str, action: str = '',
21 container_image: Optional[str] = None):
22
23 if action not in ['start', 'stop', 'restart', 'redeploy']:
24 raise DashboardException(
25 code='invalid_daemon_action',
26 msg=f'Daemon action "{action}" is either not valid or not supported.')
27 # non 'None' container_images change need a redeploy
28 if container_image == '' and action != 'redeploy':
29 container_image = None
30
31 orch = OrchClient.instance()
32 res = orch.daemons.action(action=action, daemon_name=daemon_name, image=container_image)
33 return res