Skip to content

Commit 64d5042

Browse files
committed
Simplification to property checks
Signed-off-by: Mike Raineri <[email protected]>
1 parent e1f6b39 commit 64d5042

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

scripts/rf_discover.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,14 @@
3838
groups = re.search(r"^(.+)\/redfish\/v1\/?$", services[service])
3939
url = groups.group(1)
4040
redfish_obj = redfish.redfish_client(base_url=url, timeout=15, max_retry=3)
41-
product = "N/A"
42-
if "Product" in redfish_obj.root:
43-
product = redfish_obj.root["Product"]
44-
identification = "N/A"
45-
if "ServiceIdentification" in redfish_obj.root:
46-
identification = redfish_obj.root["ServiceIdentification"]
47-
print("{}: {} ({}, {})".format(service, services[service], product, identification))
41+
print(
42+
"{}: {} ({}, {})".format(
43+
service,
44+
services[service],
45+
redfish_obj.root.get("Product", "N/A"),
46+
redfish_obj.root.get("ServiceIdentification", "N/A"),
47+
)
48+
)
4849
except Exception:
4950
print("{}: {}".format(service, services[service]))
5051

0 commit comments

Comments
 (0)