]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
node-proxy: RedfishClient class refactor
authorGuillaume Abrioux <gabrioux@ibm.com>
Fri, 16 Jun 2023 11:09:48 +0000 (13:09 +0200)
committerGuillaume Abrioux <gabrioux@ibm.com>
Thu, 25 Jan 2024 14:52:24 +0000 (14:52 +0000)
This implements BaseClient class and make RedfishClient inherit from it.
Same logic as BaseSystem / RedfishSystem given that any other backend could
need to implement a new client for collecting the data.

Signed-off-by: Guillaume Abrioux <gabrioux@ibm.com>
(cherry picked from commit 5cd39211401fcbbcb8a8e3441fd42043b45238dd)

src/cephadm/node-proxy/baseclient.py [new file with mode: 0644]
src/cephadm/node-proxy/basesystem.py
src/cephadm/node-proxy/redfish_client.py

diff --git a/src/cephadm/node-proxy/baseclient.py b/src/cephadm/node-proxy/baseclient.py
new file mode 100644 (file)
index 0000000..735dd11
--- /dev/null
@@ -0,0 +1,20 @@
+from typing import Dict
+
+
+class BaseClient:
+    def __init__(self,
+                 host: str,
+                 username: str,
+                 password: str) -> None:
+        self.host = host
+        self.username = username
+        self.password = password
+
+    def login(self) -> None:
+        raise NotImplementedError()
+
+    def logout(self) -> None:
+        raise NotImplementedError()
+
+    def get_path(self, path: str) -> Dict:
+        raise NotImplementedError()
index 8dcdecbc3a74050806b058c5ede63de97254d086..1ec6998add22aa88a47d1e106aaaa3f155843158 100644 (file)
@@ -1,11 +1,13 @@
 from util import Config
 from typing import Dict, Any
+from baseclient import BaseClient
 
 
 class BaseSystem:
     def __init__(self, **kw: Any) -> None:
         self._system: Dict = {}
         self.config: Config = kw['config']
+        self.client: BaseClient
 
     def get_system(self) -> Dict[str, Dict[str, Dict]]:
         raise NotImplementedError()
@@ -30,3 +32,12 @@ class BaseSystem:
 
     def get_storage(self) -> Dict[str, Dict[str, Dict]]:
         raise NotImplementedError()
+
+    def start_update_loop(self) -> None:
+        raise NotImplementedError()
+
+    def stop_update_loop(self) -> None:
+        raise NotImplementedError()
+
+    def start_client(self) -> None:
+        raise NotImplementedError()
index 6a3e384893d2e3a00507f069f3fae4da9afcb08a..77353cd4781986df7cd290783dcd6dbee0b043e2 100644 (file)
@@ -4,12 +4,13 @@ from redfish.rest.v1 import ServerDownOrUnreachableError, \
 import redfish
 import sys
 from util import Logger
+from baseclient import BaseClient
 from typing import Dict
 
 log = Logger(__name__)
 
 
-class RedFishClient:
+class RedFishClient(BaseClient):
 
     PREFIX = '/redfish/v1'
 
@@ -18,9 +19,7 @@ class RedFishClient:
                  username: str,
                  password: str) -> None:
         log.logger.info("redfish client initialization...")
-        self.host = host
-        self.username = username
-        self.password = password
+        super().__init__(host, username, password)
         self.redfish_obj: 'redfish.redfish_client' = None
 
     def login(self) -> 'redfish.redfish_client':