From: Joseph Sawaya Date: Mon, 28 Jun 2021 15:47:01 +0000 (-0400) Subject: mgr/rook: add CustomObjectsApi to RookCluster X-Git-Tag: v17.1.0~1144^2~13 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2c5893e75edf0e3f6ea1fe31f2627179420c431b;p=ceph.git mgr/rook: add CustomObjectsApi to RookCluster This commit adds the CustomObjectsApi to the RookCluster class to be able to fetch Custom Resource objects. Signed-off-by: Joseph Sawaya --- diff --git a/src/pybind/mgr/rook/module.py b/src/pybind/mgr/rook/module.py index 6b2fc08b0cda..edb81a5189e1 100644 --- a/src/pybind/mgr/rook/module.py +++ b/src/pybind/mgr/rook/module.py @@ -102,6 +102,7 @@ class RookOrchestrator(MgrModule, orchestrator.Orchestrator): self._initialized = threading.Event() self._k8s_CoreV1_api: Optional[client.CoreV1Api] = None self._k8s_BatchV1_api: Optional[client.BatchV1Api] = None + self._k8s_CustomObjects_api: Optional[client.CustomObjectsApi] = None self._rook_cluster: Optional[RookCluster] = None self._rook_env = RookEnv() @@ -141,6 +142,7 @@ class RookOrchestrator(MgrModule, orchestrator.Orchestrator): self._k8s_CoreV1_api = client.CoreV1Api() self._k8s_BatchV1_api = client.BatchV1Api() + self._k8s_CustomObjects_api = client.CustomObjectsApi() try: # XXX mystery hack -- I need to do an API call from @@ -155,6 +157,7 @@ class RookOrchestrator(MgrModule, orchestrator.Orchestrator): self._rook_cluster = RookCluster( self._k8s_CoreV1_api, self._k8s_BatchV1_api, + self._k8s_CustomObjects_api, self._rook_env) self._initialized.set() diff --git a/src/pybind/mgr/rook/rook_cluster.py b/src/pybind/mgr/rook/rook_cluster.py index 5d0a9884d390..7b30b62f44d5 100644 --- a/src/pybind/mgr/rook/rook_cluster.py +++ b/src/pybind/mgr/rook/rook_cluster.py @@ -191,10 +191,11 @@ class KubernetesResource(Generic[T]): class RookCluster(object): # import of client.CoreV1Api must be optional at import time. # Instead allow mgr/rook to be imported anyway. - def __init__(self, coreV1_api: 'client.CoreV1Api', batchV1_api: 'client.BatchV1Api', rook_env: 'RookEnv'): + def __init__(self, coreV1_api: 'client.CoreV1Api', batchV1_api: 'client.BatchV1Api', customObjects_api: 'client.CustomObjectsApi', rook_env: 'RookEnv'): self.rook_env = rook_env # type: RookEnv self.coreV1_api = coreV1_api # client.CoreV1Api self.batchV1_api = batchV1_api + self.customObjects_api = customObjects_api # TODO: replace direct k8s calls with Rook API calls # when they're implemented