# -*- coding: utf-8 -*-
from enum import Enum
-from typing import List, Optional, Set, no_type_check
+from typing import Dict, List, Optional, Set, no_type_check
import cherrypy
from mgr_module import CLICommand, Option
+from mgr_util import CLIWarning
from ..controllers.cephfs import CephFS
from ..controllers.iscsi import Iscsi, IscsiTarget
NFS = 'nfs'
DASHBOARD = 'dashboard'
+ # if we want to add any custom warning message when enabling a feature
+ # we can add it here as key-value pair in warn_msg.
+ # eg: Features.ISCSI.value: 'iscsi warning message'
+ @property
+ def warning(self):
+ warn_msg: Dict[str, str] = {}
+ return warn_msg.get(self.value, None)
+
PREDISABLED_FEATURES = set() # type: Set[str]
mgr.set_module_option(
self.OPTION_FMT.format(feature),
action == Actions.ENABLE)
+ if action == Actions.ENABLE and feature.warning:
+ msg += [CLIWarning(feature.warning)]
msg += ["Feature '{.value}': {}".format(
feature,
'enabled' if action == Actions.ENABLE else
pass
+# helper function for showing a warning text in
+# the terminal
+class CLIWarning(str):
+ def __new__(cls, content: str) -> "CLIWarning":
+ return super().__new__(cls, f"WARNING: {content}")
+
+
class CephfsConnectionException(Exception):
def __init__(self, error_code: int, error_message: str):
self.errno = error_code