Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cephx auth config module #41

Merged
merged 3 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading