summaryrefslogtreecommitdiffstats
path: root/control
diff options
context:
space:
mode:
authorMatthew Barth <msbarth@us.ibm.com>2018-01-23 15:32:26 -0600
committerMatthew Barth <msbarth@linux.vnet.ibm.com>2018-01-29 15:28:14 +0000
commit9a5b6994c745480a78ef658148cfd96dd3e12bdb (patch)
tree6df88f21a2f7f4f18c5acf5f501e6d0c4de1cf4e /control
parent7f7df319f500b5dac983e2159e7a6f12565d7358 (diff)
downloadphosphor-fan-presence-9a5b6994c745480a78ef658148cfd96dd3e12bdb.tar.gz
phosphor-fan-presence-9a5b6994c745480a78ef658148cfd96dd3e12bdb.zip
Support properties of type string
Properties used within set speed events may be of type string to trigger an action. These should be handled where the defined type attribute is given as 'std::string' and a parsed value is an instance of python str type. Resolves openbmc/openbmc#292 Change-Id: Ib188e7abc212062a1c61950abaa28434a4726521 Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
Diffstat (limited to 'control')
-rwxr-xr-xcontrol/gen-fan-zone-defs.py36
-rw-r--r--control/types.hpp4
2 files changed, 32 insertions, 8 deletions
diff --git a/control/gen-fan-zone-defs.py b/control/gen-fan-zone-defs.py
index c071aea..1568137 100755
--- a/control/gen-fan-zone-defs.py
+++ b/control/gen-fan-zone-defs.py
@@ -243,6 +243,7 @@ def convertToMap(listOfDict):
"""
Converts a list of dictionary entries to a std::map initialization list.
"""
+ listOfDict = listOfDict.replace('\'', '\"')
listOfDict = listOfDict.replace('[', '{')
listOfDict = listOfDict.replace(']', '}')
listOfDict = listOfDict.replace(':', ',')
@@ -285,9 +286,15 @@ def getActions(edata, actions, events):
param += "),"
param += "}"
elif p == 'property':
- param += (
- str(edata['property']['type']).lower() +
- ">(" + str(eActions[p]).lower() + ")")
+ if isinstance(eActions[p], str) or \
+ "string" in str(edata['property']['type']).lower():
+ param += (
+ str(edata['property']['type']).lower() +
+ ">(\"" + str(eActions[p]) + "\")")
+ else:
+ param += (
+ str(edata['property']['type']).lower() +
+ ">(" + str(eActions[p]).lower() + ")")
else:
# Default type to 'size_t' when not given
param += ("size_t>(" + str(eActions[p]).lower() + ")")
@@ -301,7 +308,13 @@ def getActions(edata, actions, events):
else:
param += (str(eActions[p]['type']).lower() + ">(")
if p != 'map':
- param += str(eActions[p]['value']).lower() + ")"
+ if isinstance(eActions[p]['value'], str) or \
+ "string" in str(eActions[p]['type']).lower():
+ param += \
+ "\"" + str(eActions[p]['value']) + "\")"
+ else:
+ param += \
+ str(eActions[p]['value']).lower() + ")"
else:
param += (
str(eActions[p]['type']).lower() +
@@ -458,7 +471,11 @@ def addPrecondition(zNum, zCond, event, events_data):
members['interface'] = grp['interface']
members['property'] = grp['property']['name']
members['type'] = grp['property']['type']
- members['value'] = grp['property']['value']
+ if isinstance(grp['property']['value'], str) or \
+ "string" in str(members['type']).lower():
+ members['value'] = "\"" + grp['property']['value'] + "\""
+ else:
+ members['value'] = grp['property']['value']
group.append(members)
precond['pcgrp'] = group
@@ -484,8 +501,13 @@ def addPrecondition(zNum, zCond, event, events_data):
str(pcgrp['interface']) + "\",\"" +
str(pcgrp['property']) + "\"," +
"static_cast<" +
- str(pcgrp['type']).lower() + ">" +
- "(" + str(pcgrp['value']).lower() + ")}")
+ str(pcgrp['type']).lower() + ">")
+ if isinstance(pcgrp['value'], str) or \
+ "string" in str(pcgrp['type']).lower():
+ value['value'] += ("(" + str(pcgrp['value']) + ")}")
+ else:
+ value['value'] += \
+ ("(" + str(pcgrp['value']).lower() + ")}")
values.append(value)
param['values'] = values
params.append(param)
diff --git a/control/types.hpp b/control/types.hpp
index b0b84f3..f7b75aa 100644
--- a/control/types.hpp
+++ b/control/types.hpp
@@ -30,7 +30,9 @@ constexpr auto conditionPropertyListPos = 1;
using Condition = std::tuple<std::string,
std::vector<ConditionProperty>>;
-using PropertyVariantType = sdbusplus::message::variant<bool, int64_t>;
+using PropertyVariantType = sdbusplus::message::variant<bool,
+ int64_t,
+ std::string>;
constexpr auto fanNamePos = 0;
constexpr auto sensorListPos = 1;
OpenPOWER on IntegriCloud