Skip to content

Commit

Permalink
Add cephx auth config module
Browse files Browse the repository at this point in the history
Signed-off-by: Tobias Wolf <[email protected]>
  • Loading branch information
NotTheEvilOne authored May 6, 2024
1 parent 27aa23a commit 6aa972c
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/config.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ rook:
image: quay.io/ceph/ceph:v18.2.1

migration_modules:
- cephx_auth_config
- migrate_osds
- migrate_monitors
- example
10 changes: 10 additions & 0 deletions src/rookify/modules/cephx_auth_config/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# -*- coding: utf-8 -*-
# type: ignore

from .main import CephXAuthHandler

MODULE_NAME = "cephx_auth_config"
HANDLER_CLASS = CephXAuthHandler
REQUIRES = []
AFTER = []
PREFLIGHT_REQUIRES = []
16 changes: 16 additions & 0 deletions src/rookify/modules/cephx_auth_config/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-

from ..module import ModuleHandler
from typing import Any


class CephXAuthHandler(ModuleHandler):
def run(self) -> Any:
self.logger.debug("Reconfiguring Ceph to expect cephx auth")

self.ceph.conf_set("auth_cluster_required", "cephx")
self.ceph.conf_set("auth_service_required", "cephx")
self.ceph.conf_set("auth_client_required", "cephx")

self.logger.info("Reconfigured Ceph to expect cephx auth")
return {"reconfigured": True}
5 changes: 4 additions & 1 deletion src/rookify/modules/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ def __init__(self, config: Dict[str, Any]):
except rados.ObjectNotFound as err:
raise ModuleException(f"Could not connect to ceph: {err}")

def __getattr__(self, name: str) -> Any:
return getattr(self.__ceph, name)

def mon_command(
self, command: str, **kwargs: str
) -> Dict[str, Any] | List[Any]:
Expand Down Expand Up @@ -166,7 +169,7 @@ def __init__(self, config: Dict[str, Any], data: Dict[str, Any], module_path: st
self.__ssh: Optional[ModuleHandler.__SSH] = None
self.__logger = get_logger()

self.__logger.debug("Executing {0}", self.__class__.__name__)
self.__logger.debug("Executing {0}".format(self.__class__.__name__))

@abc.abstractmethod
def preflight(self) -> None:
Expand Down

0 comments on commit 6aa972c

Please sign in to comment.