Fan control dump utility
Changes:
- Add code to dump and get attributes from
fan config JSON file generated dump.
- Add python function to walk the nested dictionary
to find the matched key.
Tested:
- Test on sandbox with sample test code calling it.
Robot code example:
${holds_data}= Get Fan Attribute Value target_holds
Should Be Empty ${holds_data}
${locks_data}= Get Fan Attribute Value target_locks
Should Be Empty ${locks_data}
Change-Id: Idae5f1d06331cd20f2d689a910efcea9251544a2
Signed-off-by: George Keishing <gkeishin@in.ibm.com>
diff --git a/lib/utilities.py b/lib/utilities.py
index 96421e8..403164b 100755
--- a/lib/utilities.py
+++ b/lib/utilities.py
@@ -307,3 +307,20 @@
for item in data_list:
prefix_string += prefix + item + " "
return prefix_string.strip()
+
+
+def get_value_from_nested_dict(key, nested_dict):
+ r"""
+ Returns the key value from the nested dictionary.
+
+ key Key value of the dictionary to look up.
+ nested_dict Dictionary data.
+ """
+ result = []
+ for k, v in nested_dict.items():
+ if k == key:
+ result.append(v)
+ elif isinstance(v, dict) and k != key:
+ result += get_value_from_nested_dict(key, v)
+
+ return result