Build component data from Redfish endpoints. Returns dict sys_id -> member_id -> data.
(
endpoints: EndpointMgr,
collection: str,
path: str,
fields: List[str],
log: Any,
attribute: Optional[str] = None,
)
| 275 | |
| 276 | |
| 277 | def get_component_data( |
| 278 | endpoints: EndpointMgr, |
| 279 | collection: str, |
| 280 | path: str, |
| 281 | fields: List[str], |
| 282 | log: Any, |
| 283 | attribute: Optional[str] = None, |
| 284 | ) -> Dict[str, Any]: |
| 285 | """Build component data from Redfish endpoints. Returns dict sys_id -> member_id -> data.""" |
| 286 | members: List[str] = endpoints[collection].get_members_names() |
| 287 | result: Dict[str, Any] = {} |
| 288 | if not members: |
| 289 | ep = _resolve_path(endpoints[collection], path) |
| 290 | data = ep.get_members_data() |
| 291 | result = build_data(data=data, fields=fields, log=log, attribute=attribute) |
| 292 | else: |
| 293 | for member in members: |
| 294 | try: |
| 295 | ep = _resolve_path(endpoints[collection][member], path) |
| 296 | if attribute is None: |
| 297 | data = ep.get_members_data() |
| 298 | else: |
| 299 | data = ep.data |
| 300 | result[member] = build_data( |
| 301 | data=data, fields=fields, log=log, attribute=attribute |
| 302 | ) |
| 303 | except HTTPError as e: |
| 304 | log.error(f"Error while updating {path}: {e}") |
| 305 | continue |
| 306 | return result |
| 307 | |
| 308 | |
| 309 | def update_component( |
no test coverage detected