summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVishwanatha Subbanna <vishwa@linux.vnet.ibm.com>2017-06-15 13:46:05 +0530
committerVishwanatha Subbanna <vishwa@linux.vnet.ibm.com>2017-06-19 13:10:24 +0530
commit1da8eb71390b49ee82f16bd89d859ea28144eb2f (patch)
tree85ca1d1012570cb1a51be2d226c5ebc1ac91bf03
parent4b000d8d84253f97cfe5695b4798e75092509706 (diff)
downloadphosphor-led-manager-1da8eb71390b49ee82f16bd89d859ea28144eb2f.zip
phosphor-led-manager-1da8eb71390b49ee82f16bd89d859ea28144eb2f.tar.gz
Throw error if priority of any LED is not same across all groups
An LED can be part of any number of groups. It is a requirement that the priority of that particular LED is same in all the groups where that LED is a member. If the input yaml file does not conform to this requirement, compilation should fail. Change-Id: I187730e835521d14564495cbe52eb139fc1bd264 Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
-rwxr-xr-xparse_led.py24
1 files changed, 20 insertions, 4 deletions
diff --git a/parse_led.py b/parse_led.py
index 5392e97..608fa92 100755
--- a/parse_led.py
+++ b/parse_led.py
@@ -37,6 +37,9 @@ if __name__ == '__main__':
with open(yaml_file, 'r') as f:
ifile = yaml.safe_load(f)
+ # Dictionary having [Name:Priority]
+ priority_dict = {}
+
with open(os.path.join(args.outputdir, 'led-gen.hpp'), 'w') as ofile:
ofile.write('/* !!! WARNING: This is a GENERATED Code..')
ofile.write('Please do NOT Edit !!! */\n\n')
@@ -47,7 +50,7 @@ if __name__ == '__main__':
for group in ifile.keys():
# This section generates an std::map of LedGroupNames to std::set
# of LEDs containing the name and properties
- ledset = ifile[group]
+ led_dict = ifile[group]
ofile.write(
' {\"' +
"/xyz/openbmc_project/led/groups/" +
@@ -55,12 +58,25 @@ if __name__ == '__main__':
'\",{\n')
# Some LED groups could be empty
- if not ledset:
+ if not led_dict:
ofile.write(' }},\n')
continue
- for led_dict, list_dict in ledset.items():
- ofile.write(' {\"' + underscore(led_dict) + '\",')
+ for led_name, list_dict in led_dict.items():
+ value = list_dict.get('Priority')
+ if led_name in priority_dict:
+ if value != priority_dict[led_name]:
+ # Priority for a particular LED needs to stay SAME
+ # across all groups
+ ofile.close()
+ os.remove(ofile.name)
+ raise ValueError("Priority for [" +
+ led_name +
+ "] is NOT same across all groups")
+ else:
+ priority_dict[led_name] = value
+
+ ofile.write(' {\"' + underscore(led_name) + '\",')
ofile.write('phosphor::led::Layout::' +
str(list_dict.get('Action', 'Off')) + ',')
ofile.write(str(list_dict.get('DutyOn', 50)) + ',')
OpenPOWER on IntegriCloud