]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
node-proxy: fix mypy errors
authorGuillaume Abrioux <gabrioux@ibm.com>
Tue, 3 Feb 2026 13:41:13 +0000 (14:41 +0100)
committerGuillaume Abrioux <gabrioux@ibm.com>
Thu, 5 Feb 2026 09:09:20 +0000 (10:09 +0100)
this commit fixes mypy errors by adding explicit types for get_path
and get_* getters methods, extending SystemBackend with
start/shutdown and declaring _ca_temp_file on NodeProxyManager

Fixes: https://tracker.ceph.com/issues/74749
Signed-off-by: Guillaume Abrioux <gabrioux@ibm.com>
src/ceph-node-proxy/ceph_node_proxy/baseredfishsystem.py
src/ceph-node-proxy/ceph_node_proxy/main.py
src/ceph-node-proxy/ceph_node_proxy/protocols.py
src/ceph-node-proxy/ceph_node_proxy/redfish_client.py
src/ceph-node-proxy/ceph_node_proxy/util.py

index 50f5b01c9d5811f908311cc1331d8711d0b95860..8b6b7482b0ff129c81983ada081754b563f3a5b6 100644 (file)
@@ -166,31 +166,31 @@ class BaseRedfishSystem(BaseSystem):
         self._system[update_service_members.id] = update_service_members.data
 
     def get_sn(self) -> str:
-        return self._sys.get('SKU', '')
+        return str(self._sys.get('SKU', ''))
 
     def get_status(self) -> Dict[str, Dict[str, Dict]]:
-        return self._sys.get('status', {})
+        return dict(self._sys.get('status', {}))
 
     def get_memory(self) -> Dict[str, Dict[str, Dict]]:
-        return self._sys.get('memory', {})
+        return dict(self._sys.get('memory', {}))
 
     def get_processors(self) -> Dict[str, Dict[str, Dict]]:
-        return self._sys.get('processors', {})
+        return dict(self._sys.get('processors', {}))
 
     def get_network(self) -> Dict[str, Dict[str, Dict]]:
-        return self._sys.get('network', {})
+        return dict(self._sys.get('network', {}))
 
     def get_storage(self) -> Dict[str, Dict[str, Dict]]:
-        return self._sys.get('storage', {})
+        return dict(self._sys.get('storage', {}))
 
     def get_firmwares(self) -> Dict[str, Dict[str, Dict]]:
-        return self._sys.get('firmwares', {})
+        return dict(self._sys.get('firmwares', {}))
 
     def get_power(self) -> Dict[str, Dict[str, Dict]]:
-        return self._sys.get('power', {})
+        return dict(self._sys.get('power', {}))
 
     def get_fans(self) -> Dict[str, Dict[str, Dict]]:
-        return self._sys.get('fans', {})
+        return dict(self._sys.get('fans', {}))
 
     def get_component_spec_overrides(self) -> Dict[str, Dict[str, Any]]:
         return {}
index 5bd37d090fdc57ae5de3aaa05548be906a2f65b4..5b0dce045ce7e5e3bde7a253b423d298645f50b7 100644 (file)
@@ -4,6 +4,7 @@ from ceph_node_proxy.config import load_cephadm_config
 from ceph_node_proxy.registry import get_system_class
 from ceph_node_proxy.reporter import Reporter
 from ceph_node_proxy.util import Config, DEFAULTS, get_logger, http_req
+from tempfile import _TemporaryFileWrapper
 from urllib.error import HTTPError
 from typing import Dict, Any, Optional
 
@@ -59,6 +60,7 @@ class NodeProxyManager:
             self.config = Config(path, defaults=DEFAULTS)
         self.username: str = ''
         self.password: str = ''
+        self._ca_temp_file: Optional[_TemporaryFileWrapper[Any]] = None
 
     def run(self) -> None:
         self.init()
index f71d66561fc5fdc4aa56999cb5fc2396e983ff41..78a0fb36db81edd706d37b6c4eff28d1edbb964c 100644 (file)
@@ -58,6 +58,12 @@ class SystemBackend(Protocol):
     def flush(self) -> None:
         ...
 
+    def start(self) -> None:
+        ...
+
+    def shutdown(self) -> None:
+        ...
+
 
 @runtime_checkable
 class SystemForReporter(Protocol):
index d75d9a3cc8c8222f4a94e9b1cdb4a27a39978636..68e2fefb5b71ed38784ce60791a5b817ede5d04f 100644 (file)
@@ -104,7 +104,7 @@ class RedFishClient(BaseClient):
             path = f'{self.PREFIX}{path}'
         try:
             _, result, _status_code = self.query(endpoint=path)
-            result_json = json.loads(result)
+            result_json: Dict[str, Any] = json.loads(result)
             return result_json
         except URLError as e:
             self.log.error(f"Can't get path {path}:\n{e}")
index 15c20022b633a2e0a48be09f860593e314b5e899..9185858fa27748a56f1d24e8c94b92b66a6d7497 100644 (file)
@@ -149,9 +149,9 @@ def normalize_dict(test_dict: Dict) -> Dict:
     return res
 
 
-def retry(exceptions: Any = Exception, retries: int = 20, delay: int = 1) -> Callable:
-    def decorator(f: Callable) -> Callable:
-        def _retry(*args: str, **kwargs: Any) -> Callable:
+def retry(exceptions: Any = Exception, retries: int = 20, delay: int = 1) -> Callable[[Callable[..., Any]], Callable[..., Any]]:
+    def decorator(f: Callable[..., Any]) -> Callable[..., Any]:
+        def _retry(*args: Any, **kwargs: Any) -> Any:
             _tries = retries
             while _tries > 1:
                 try: