From: Guillaume Abrioux Date: Fri, 16 Jun 2023 11:09:48 +0000 (+0200) Subject: node-proxy: RedfishClient class refactor X-Git-Tag: v18.2.4~314^2~83 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=55539d1fe5ee45f22a40e61e0d4a32f38d6592ff;p=ceph.git node-proxy: RedfishClient class refactor 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 (cherry picked from commit 5cd39211401fcbbcb8a8e3441fd42043b45238dd) --- diff --git a/src/cephadm/node-proxy/baseclient.py b/src/cephadm/node-proxy/baseclient.py new file mode 100644 index 0000000000000..735dd11e96d94 --- /dev/null +++ b/src/cephadm/node-proxy/baseclient.py @@ -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() diff --git a/src/cephadm/node-proxy/basesystem.py b/src/cephadm/node-proxy/basesystem.py index 8dcdecbc3a740..1ec6998add22a 100644 --- a/src/cephadm/node-proxy/basesystem.py +++ b/src/cephadm/node-proxy/basesystem.py @@ -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() diff --git a/src/cephadm/node-proxy/redfish_client.py b/src/cephadm/node-proxy/redfish_client.py index 6a3e384893d2e..77353cd478198 100644 --- a/src/cephadm/node-proxy/redfish_client.py +++ b/src/cephadm/node-proxy/redfish_client.py @@ -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':