Skip to content

Commit 9f33410

Browse files
committed
node-proxy: do not fail when empty data is received
If for some reason the redfish returns empty data, node-proxy fails because it can't access non-existing keys in `_sys` dict. It basically throws a KeyError exception. Fixes: https://tracker.ceph.com/issues/65395 Signed-off-by: Guillaume Abrioux <[email protected]>
1 parent 41c5137 commit 9f33410

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/ceph-node-proxy/ceph_node_proxy/redfishdellsystem.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,31 +45,31 @@ def build_chassis_data(self,
4545
return normalize_dict(result)
4646

4747
def get_sn(self) -> str:
48-
return self._sys['SKU']
48+
return self._sys.get('SKU', '')
4949

5050
def get_status(self) -> Dict[str, Dict[str, Dict]]:
51-
return self._sys['status']
51+
return self._sys.get('status', {})
5252

5353
def get_memory(self) -> Dict[str, Dict[str, Dict]]:
54-
return self._sys['memory']
54+
return self._sys.get('memory', {})
5555

5656
def get_processors(self) -> Dict[str, Dict[str, Dict]]:
57-
return self._sys['processors']
57+
return self._sys.get('processors', {})
5858

5959
def get_network(self) -> Dict[str, Dict[str, Dict]]:
60-
return self._sys['network']
60+
return self._sys.get('network', {})
6161

6262
def get_storage(self) -> Dict[str, Dict[str, Dict]]:
63-
return self._sys['storage']
63+
return self._sys.get('storage', {})
6464

6565
def get_firmwares(self) -> Dict[str, Dict[str, Dict]]:
66-
return self._sys['firmwares']
66+
return self._sys.get('firmwares', {})
6767

6868
def get_power(self) -> Dict[str, Dict[str, Dict]]:
69-
return self._sys['power']
69+
return self._sys.get('power', {})
7070

7171
def get_fans(self) -> Dict[str, Dict[str, Dict]]:
72-
return self._sys['fans']
72+
return self._sys.get('fans', {})
7373

7474
def _update_network(self) -> None:
7575
fields = ['Description', 'Name', 'SpeedMbps', 'Status']

0 commit comments

Comments
 (0)