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)
--- /dev/null
+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()
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()
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()
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'
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':