Skip to content

Commit

Permalink
Merge pull request #159 from DMTF/Fix158-Handle-null-Values
Browse files Browse the repository at this point in the history
 Added handling for printing array properties with 'null' entries where allowed
  • Loading branch information
mraineri authored Jun 7, 2024
2 parents b903f29 + 299fc24 commit b7164ae
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
12 changes: 5 additions & 7 deletions redfish_utilities/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def print_manager(manager):
if property in manager.dict:
prop_val = manager.dict[property]
if isinstance(prop_val, list):
prop_val = ", ".join(prop_val)
prop_val = ", ".join([i for i in prop_val if i is not None])
elif property == "Status":
prop_val = "State: {}, Health: {}".format(prop_val.get("State", "N/A"), prop_val.get("Health", "N/A"))
print(manager_line_format.format(property, prop_val))
Expand Down Expand Up @@ -514,11 +514,9 @@ def print_manager_network_protocol(network_protocol):
if property == "NTP":
# For NTP, extract the servers; need to skip "empty" slots potentially
if "NTPServers" in network_protocol.dict[property]:
other_str = []
for server in network_protocol.dict[property]["NTPServers"]:
if isinstance(server, str):
other_str.append(server)
other_str = "NTP Servers: " + ", ".join(other_str)
other_str = "NTP Servers: " + ", ".join(
[i for i in network_protocol.dict[property]["NTPServers"] if i is not None]
)
print(
network_protocol_line_format.format(
property,
Expand Down Expand Up @@ -690,7 +688,7 @@ def print_manager_ethernet_interface(interface):
if property in interface.dict:
prop_val = interface.dict[property]
if isinstance(prop_val, list):
prop_val = ", ".join(prop_val)
prop_val = ", ".join([i for i in prop_val if i is not None])
elif property == "Status":
prop_val = "State: {}, Health: {}".format(prop_val.get("State", "N/A"), prop_val.get("Health", "N/A"))
print(interface_line_format.format(property, prop_val))
Expand Down
4 changes: 2 additions & 2 deletions redfish_utilities/power_equipment.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ def print_power_equipment(power_equipment):
if property in power_equipment["Info"].dict:
prop_val = power_equipment["Info"].dict[property]
if isinstance(prop_val, list):
prop_val = ", ".join(prop_val)
prop_val = ", ".join([i for i in prop_val if i is not None])
elif property == "Status":
prop_val = "State: {}, Health: {}".format(prop_val.get("State", "N/A"), prop_val.get("Health", "N/A"))
print(power_equipment_line_format.format(property, prop_val))
Expand Down Expand Up @@ -534,7 +534,7 @@ def print_power_equipment_electrical(electrical):
if property in electrical.dict:
prop_val = electrical.dict[property]
if isinstance(prop_val, list):
prop_val = ", ".join(prop_val)
prop_val = ", ".join([i for i in prop_val if i is not None])
elif property == "PhaseWiringType":
prop_val = str(phase_wiring_type_strings.get(prop_val, prop_val))
elif property == "NominalVoltage":
Expand Down
2 changes: 1 addition & 1 deletion redfish_utilities/systems.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ def print_virtual_media(virtual_media_list):
if property in virtual_media:
prop_val = virtual_media[property]
if isinstance(prop_val, list):
prop_val = ", ".join(prop_val)
prop_val = ", ".join([i for i in prop_val if i is not None])
print(virtual_media_line_format.format("", property, prop_val))
print("")

Expand Down

0 comments on commit b7164ae

Please sign in to comment.