config: error on invalid configuration
Since the default led priority is no longer 'Blink', the priority now
has to be explicitly defined when using either group priority or led
priority.
If a configuration does not define the priority, the configuration is
invalid and in the yaml case, phosphor-led-manager should fail to build,
in the json case, the process should exit due to the configuration
error.
The config validation has been extracted into it's own file and made
separate from json config parsing.
So every config will go through the same validation even if its been
created via yaml.
Change-Id: Ifda65942b0768d6c0d3b25076f7a1236b46b3d9f
Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>
diff --git a/test/config/led-group-config-malformed.json b/test/config/led-group-config-malformed.json
deleted file mode 100644
index 3e7d668..0000000
--- a/test/config/led-group-config-malformed.json
+++ /dev/null
@@ -1,40 +0,0 @@
-{
- "leds": [
- {
- "group": "bmc_booted"
- "members": [
- {
- "Name": "heartbeat",
- "Action": "On"
- }
- ]
- },
- {
- "group": "power_on",
- "members": [
- {
- "Name": "power",
- "Action": "On",
- "Priority": "On"
- }
- ]
- },
- {
- "group": "enclosure_identify",
- "members": [
- {
- "Name": "front_id",
- "Action": "Blink",
- "DutyOn": 50,
- "Period": 1000
- },
- {
- "Name": "rear_id",
- "Action": "Blink",
- "DutyOn": 50,
- "Period": 1000
- }
- ]
- }
- ]
-}
\ No newline at end of file
diff --git a/test/config/led-group-config.json b/test/config/led-group-config.json
index 0a4ccb9..f2ce5d7 100644
--- a/test/config/led-group-config.json
+++ b/test/config/led-group-config.json
@@ -5,7 +5,8 @@
"members": [
{
"Name": "heartbeat",
- "Action": "On"
+ "Action": "On",
+ "Priority": "Blink"
}
]
},
@@ -36,13 +37,15 @@
"Name": "front_id",
"Action": "Blink",
"DutyOn": 50,
- "Period": 1000
+ "Period": 1000,
+ "Priority": "Blink"
},
{
"Name": "rear_id",
"Action": "Blink",
"DutyOn": 50,
- "Period": 1000
+ "Period": 1000,
+ "Priority": "Blink"
}
]
}
diff --git a/test/config/test-group-priority.yaml b/test/config/test-group-priority.yaml
index ca5005f..1acfbb6 100644
--- a/test/config/test-group-priority.yaml
+++ b/test/config/test-group-priority.yaml
@@ -1,10 +1,13 @@
group1:
+ Priority: 1
led1:
Action: "On"
group2:
+ Priority: 2
led1:
Action: "Off"
group3:
+ Priority: 3
led1:
Action: "Blink"
DutyOn: 50