Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added handling for printing array properties with 'null' entries where allowed #159

Merged
merged 2 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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