summaryrefslogtreecommitdiffstats
path: root/control/gen-fan-zone-defs.py
diff options
context:
space:
mode:
authorGunnar Mills <gmills@us.ibm.com>2017-06-06 15:14:11 -0500
committerPatrick Williams <patrick@stwcx.xyz>2017-06-26 02:06:05 +0000
commitb751f32d06cb8804bdd4344f3868ca284c0c9e68 (patch)
treed7a47bcf7c7d44ee424ca03fe19ad5e10574b85c /control/gen-fan-zone-defs.py
parent63605cd3b7c66f2fbfeb40f85a1fb3ce1ab87424 (diff)
downloadphosphor-fan-presence-b751f32d06cb8804bdd4344f3868ca284c0c9e68.tar.gz
phosphor-fan-presence-b751f32d06cb8804bdd4344f3868ca284c0c9e68.zip
Check for zone number and condition
Only add events to the zone if the conditions and zone number are correct. Resolves openbmc/openbmc#1500 Change-Id: Ia040fcbdd9093d25d4ed1773d5fea0ed8a95ba2b Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
Diffstat (limited to 'control/gen-fan-zone-defs.py')
-rwxr-xr-xcontrol/gen-fan-zone-defs.py23
1 files changed, 17 insertions, 6 deletions
diff --git a/control/gen-fan-zone-defs.py b/control/gen-fan-zone-defs.py
index 293bb02..694477b 100755
--- a/control/gen-fan-zone-defs.py
+++ b/control/gen-fan-zone-defs.py
@@ -113,7 +113,7 @@ const std::vector<ZoneGroup> Manager::_zoneLayouts
'''
-def getEventsInZone(zone_num, events_data):
+def getEventsInZone(zone_num, zone_conditions, events_data):
"""
Constructs the event entries defined for each zone using the events yaml
provided.
@@ -122,9 +122,19 @@ def getEventsInZone(zone_num, events_data):
if 'events' in events_data:
for e in events_data['events']:
- for z in e['zone_conditions']:
- if zone_num not in z['zones']:
- continue
+
+ # Zone numbers are optional in the events yaml but skip if this
+ # zone's zone number is not in the event's zone numbers
+ if all('zones' in z and z['zones'] is not None and
+ zone_num not in z['zones'] for z in e['zone_conditions']):
+ continue
+
+ # Zone conditions are optional in the events yaml but skip if this
+ # event's condition is not in this zone's conditions
+ if all('name' in z and z['name'] is not None and
+ not any(c['name'] == z['name'] for c in zone_conditions)
+ for z in e['zone_conditions']):
+ continue
event = {}
# Add set speed event group
@@ -257,7 +267,7 @@ def buildZoneData(zone_data, fan_data, events_data, zone_conditions_data):
for c in group['zone_conditions']:
if not zone_conditions_data:
- sys.exit("No zone_conditions YAML file but" +
+ sys.exit("No zone_conditions YAML file but " +
"zone_conditions used in zone YAML")
condition = getConditionInZoneConditions(c['name'],
@@ -291,7 +301,8 @@ def buildZoneData(zone_data, fan_data, events_data, zone_conditions_data):
profiles = z['cooling_profiles']
fans = getFansInZone(z['zone'], profiles, fan_data)
- events = getEventsInZone(z['zone'], events_data)
+ events = getEventsInZone(z['zone'], group['zone_conditions'],
+ events_data)
if len(fans) == 0:
sys.exit("Didn't find any fans in zone " + str(zone['num']))
OpenPOWER on IntegriCloud