]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/rook: add CustomObjectsApi to RookCluster
authorJoseph Sawaya <jsawaya@redhat.com>
Mon, 28 Jun 2021 15:47:01 +0000 (11:47 -0400)
committerJoseph Sawaya <jsawaya@redhat.com>
Tue, 13 Jul 2021 17:55:05 +0000 (13:55 -0400)
This commit adds the CustomObjectsApi to the RookCluster class to be
able to fetch Custom Resource objects.

Signed-off-by: Joseph Sawaya <jsawaya@redhat.com>
src/pybind/mgr/rook/module.py
src/pybind/mgr/rook/rook_cluster.py

index 6b2fc08b0cda327c0bbb8d1db0a800635299959d..edb81a5189e14469b52642d521f82df6a4fb7294 100644 (file)
@@ -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()
index 5d0a9884d3909d2c08a80c9b004c04289cfb3dd1..7b30b62f44d57a43879d51edb1ed9d6c2e0b4ef1 100644 (file)
@@ -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