summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--[-rwxr-xr-x]scripts/entity-example.md (renamed from scripts/entity-example.yaml)26
-rwxr-xr-xscripts/entity_gen.py60
-rwxr-xr-xscripts/fru_gen.py4
-rw-r--r--[-rwxr-xr-x]scripts/inventory-sensor-example.yaml0
-rwxr-xr-xscripts/inventory-sensor.py4
-rw-r--r--[-rwxr-xr-x]scripts/sensor-example.yaml38
-rwxr-xr-xscripts/sensor_gen.py4
-rw-r--r--scripts/writeentity.mako.cpp34
-rw-r--r--scripts/writesensor.mako.cpp82
9 files changed, 114 insertions, 138 deletions
diff --git a/scripts/entity-example.yaml b/scripts/entity-example.md
index 2db14cc..98dbade 100755..100644
--- a/scripts/entity-example.yaml
+++ b/scripts/entity-example.md
@@ -1,3 +1,28 @@
+If your platform requires the entity container map, you can provide a json file of the format:
+
+```
+[
+ {
+ "id" : 1,
+ "containerEntityId" : 2,
+ "containerEntityInstance" : 3,
+ "isList" : false,
+ "isLinked" : false,
+ "entities" : [
+ {"id" : 1, "instance" : 2},
+ {"id" : 1, "instance" : 3},
+ {"id" : 1, "instance" : 4},
+ {"id" : 1, "instance" : 5}
+ ]
+ }
+]
+```
+
+as part of your `phosphor-ipmi-config`
+
+The above json is identical to the original YAML documented below:
+
+```
# This record has:
# Container Entity Id and Container Entity Instance = (0x13, 0x81)
# Contained Entity Id and Contained Entity Instance = (0x0A, 0x1),
@@ -125,3 +150,4 @@
entityInstance3: 0xD
entityId4: 0x20
entityInstance4: 0xF
+```
diff --git a/scripts/entity_gen.py b/scripts/entity_gen.py
deleted file mode 100755
index 057821b..0000000
--- a/scripts/entity_gen.py
+++ /dev/null
@@ -1,60 +0,0 @@
-#!/usr/bin/env python
-
-import os
-import sys
-import yaml
-import argparse
-from mako.template import Template
-
-
-def generate_cpp(entity_yaml, output_dir):
- with open(os.path.join(script_dir, entity_yaml), 'r') as f:
- ifile = yaml.safe_load(f)
- if not isinstance(ifile, dict):
- ifile = {}
-
- # Render the mako template
-
- t = Template(filename=os.path.join(
- script_dir,
- "writeentity.mako.cpp"))
-
- output_cpp = os.path.join(output_dir, "entity-gen.cpp")
- with open(output_cpp, 'w') as fd:
- fd.write(t.render(entityDict=ifile))
-
-
-def main():
-
- valid_commands = {
- 'generate-cpp': generate_cpp
- }
- parser = argparse.ArgumentParser(
- description="IPMI Entity record parser and code generator")
-
- parser.add_argument(
- '-i', '--entity_yaml', dest='entity_yaml',
- default='example.yaml', help='input entity yaml file to parse')
-
- parser.add_argument(
- "-o", "--output-dir", dest="outputdir",
- default=".",
- help="output directory")
-
- parser.add_argument(
- 'command', metavar='COMMAND', type=str,
- choices=valid_commands.keys(),
- help='Command to run.')
-
- args = parser.parse_args()
-
- if (not (os.path.isfile(os.path.join(script_dir, args.entity_yaml)))):
- sys.exit("Can not find input yaml file " + args.entity_yaml)
-
- function = valid_commands[args.command]
- function(args.entity_yaml, args.outputdir)
-
-
-if __name__ == '__main__':
- script_dir = os.path.dirname(os.path.realpath(__file__))
- main()
diff --git a/scripts/fru_gen.py b/scripts/fru_gen.py
index f6111b7..a8d148a 100755
--- a/scripts/fru_gen.py
+++ b/scripts/fru_gen.py
@@ -8,7 +8,7 @@ from mako.template import Template
def generate_cpp(inventory_yaml, output_dir):
- with open(os.path.join(script_dir, inventory_yaml), 'r') as f:
+ with open(inventory_yaml, 'r') as f:
ifile = yaml.safe_load(f)
if not isinstance(ifile, dict):
ifile = {}
@@ -48,7 +48,7 @@ def main():
args = parser.parse_args()
- if (not (os.path.isfile(os.path.join(script_dir, args.inventory_yaml)))):
+ if (not (os.path.isfile(args.inventory_yaml))):
sys.exit("Can not find input yaml file " + args.inventory_yaml)
function = valid_commands[args.command]
diff --git a/scripts/inventory-sensor-example.yaml b/scripts/inventory-sensor-example.yaml
index 7ff78fb..7ff78fb 100755..100644
--- a/scripts/inventory-sensor-example.yaml
+++ b/scripts/inventory-sensor-example.yaml
diff --git a/scripts/inventory-sensor.py b/scripts/inventory-sensor.py
index 77222f5..2dd1e8d 100755
--- a/scripts/inventory-sensor.py
+++ b/scripts/inventory-sensor.py
@@ -8,7 +8,7 @@ from mako.template import Template
def generate_cpp(sensor_yaml, output_dir):
- with open(os.path.join(script_dir, sensor_yaml), 'r') as f:
+ with open(sensor_yaml, 'r') as f:
ifile = yaml.safe_load(f)
if not isinstance(ifile, dict):
ifile = {}
@@ -48,7 +48,7 @@ def main():
args = parser.parse_args()
- if (not (os.path.isfile(os.path.join(script_dir, args.sensor_yaml)))):
+ if (not (os.path.isfile(args.sensor_yaml))):
sys.exit("Can not find input yaml file " + args.sensor_yaml)
function = valid_commands[args.command]
diff --git a/scripts/sensor-example.yaml b/scripts/sensor-example.yaml
index 4a1472d..c0fbe1e 100755..100644
--- a/scripts/sensor-example.yaml
+++ b/scripts/sensor-example.yaml
@@ -154,3 +154,41 @@
#the update will be skipped.
skipOn: deassert
type: bool
+
+0xC5:
+ sensorType: 0x17
+ path: /system/chassis/motherboard/gv100card0
+ sensorReadingType: 1
+ serviceInterface: xyz.openbmc_project.Inventory.Manager
+ readingType: assertion
+ mutability: Mutability::Write|Mutability::Read
+ sensorNamePattern: nameLeaf
+ interfaces:
+ xyz.openbmc_project.Inventory.Decorator.Replaceable:
+ FieldReplaceable:
+ Offsets:
+ 7:
+ assert: true
+ deassert: true
+ type: bool
+ xyz.openbmc_project.Inventory.Item:
+ Present:
+ Offsets:
+ 7:
+ assert: true
+ deassert: false
+ type: bool
+ # Example of an interface with no attached properties
+ xyz.openbmc_project.Inventory.Item.Accelerator:
+ xyz.openbmc_project.State.Decorator.OperationalStatus:
+ Functional:
+ Offsets:
+ 8:
+ assert: false
+ deassert: true
+ type: bool
+ Prereqs:
+ 7:
+ assert: true
+ deassert: false
+ type: bool
diff --git a/scripts/sensor_gen.py b/scripts/sensor_gen.py
index 822a00a..6f59021 100755
--- a/scripts/sensor_gen.py
+++ b/scripts/sensor_gen.py
@@ -8,7 +8,7 @@ from mako.template import Template
def generate_cpp(sensor_yaml, output_dir):
- with open(os.path.join(script_dir, sensor_yaml), 'r') as f:
+ with open(sensor_yaml, 'r') as f:
ifile = yaml.safe_load(f)
if not isinstance(ifile, dict):
ifile = {}
@@ -48,7 +48,7 @@ def main():
args = parser.parse_args()
- if (not (os.path.isfile(os.path.join(script_dir, args.sensor_yaml)))):
+ if (not (os.path.isfile(args.sensor_yaml))):
sys.exit("Can not find input yaml file " + args.sensor_yaml)
function = valid_commands[args.command]
diff --git a/scripts/writeentity.mako.cpp b/scripts/writeentity.mako.cpp
deleted file mode 100644
index 4cfc82b..0000000
--- a/scripts/writeentity.mako.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
-## This file is a template. The comment below is emitted
-## into the rendered file; feel free to edit this file.
-// !!! WARNING: This is a GENERATED Code..Please do NOT Edit !!!
-
-#include <ipmid/types.hpp>
-using namespace ipmi::sensor;
-
-extern const EntityInfoMap entities = {
-% for key in entityDict.iterkeys():
-{${key},{
-<%
- entity = entityDict[key]
- containerEntityId = entity["containerEntityId"]
- containerEntityInstance = entity["containerEntityInstance"]
- isList = entity["isList"]
- isLinked = entity["isLinked"]
- entityId1 = entity["entityId1"]
- entityInstance1 = entity["entityInstance1"]
- entityId2 = entity["entityId2"]
- entityInstance2 = entity["entityInstance2"]
- entityId3 = entity["entityId3"]
- entityInstance3 = entity["entityInstance3"]
- entityId4 = entity["entityId4"]
- entityInstance4 = entity["entityInstance4"]
-%>
- ${containerEntityId},${containerEntityInstance},${isList},${isLinked},{
- std::make_pair(${entityId1}, ${entityInstance1}),
- std::make_pair(${entityId2}, ${entityInstance2}),
- std::make_pair(${entityId3}, ${entityInstance3}),
- std::make_pair(${entityId4}, ${entityInstance4}) }
-
-}},
-% endfor
-};
diff --git a/scripts/writesensor.mako.cpp b/scripts/writesensor.mako.cpp
index 559f0f9..c740f6f 100644
--- a/scripts/writesensor.mako.cpp
+++ b/scripts/writesensor.mako.cpp
@@ -27,7 +27,9 @@ interfaceDict = {}
#include "sensordatahandler.hpp"
#include <ipmid/types.hpp>
-using namespace ipmi::sensor;
+
+namespace ipmi {
+namespace sensor {
extern const IdInfoMap sensors = {
% for key in sensorDict.iterkeys():
@@ -74,67 +76,69 @@ extern const IdInfoMap sensors = {
${updateFunc},${getFunc},Mutability(${mutability}),${sensorNameFunc},{
% for interface,properties in interfaces.items():
{"${interface}",{
- % for dbus_property,property_value in properties.items():
- {"${dbus_property}",{
+ % if properties:
+ % for dbus_property,property_value in properties.items():
+ {"${dbus_property}",{
<%
try:
preReq = property_value["Prereqs"]
except KeyError, e:
preReq = dict()
%>\
- {
- % for preOffset,preValues in preReq.items():
- { ${preOffset},{
- % for name,value in preValues.items():
- % if name == "type":
+ {
+ % for preOffset,preValues in preReq.items():
+ { ${preOffset},{
+ % for name,value in preValues.items():
+ % if name == "type":
<% continue %>\
- % endif
+ % endif
<% value = str(value).lower() %>\
- ${value},
+ ${value},
+ % endfor
+ }
+ },
% endfor
- }
},
- % endfor
- },
- {
- % for offset,values in property_value["Offsets"].items():
- { ${offset},{
- % if offset == 0xFF:
- }},
+ {
+ % for offset,values in property_value["Offsets"].items():
+ { ${offset},{
+ % if offset == 0xFF:
+ }},
<% continue %>\
- % endif
+ % endif
<% valueType = values["type"] %>\
<%
try:
skip = values["skipOn"]
if skip == "assert":
- skipVal = "SkipAssertion::ASSERT"
+ skipVal = "SkipAssertion::ASSERT"
elif skip == "deassert":
- skipVal = "SkipAssertion::DEASSERT"
+ skipVal = "SkipAssertion::DEASSERT"
else:
- assert "Unknown skip value " + str(skip)
+ assert "Unknown skip value " + str(skip)
except KeyError, e:
skipVal = "SkipAssertion::NONE"
%>\
- ${skipVal},
- % for name,value in values.items():
- % if name == "type" or name == "skipOn":
+ ${skipVal},
+ % for name,value in values.items():
+ % if name == "type" or name == "skipOn":
<% continue %>\
- % endif
- % if valueType == "string":
- std::string("${value}"),
- % elif valueType == "bool":
+ % endif
+ % if valueType == "string":
+ std::string("${value}"),
+ % elif valueType == "bool":
<% value = str(value).lower() %>\
- ${value},
- % else:
- ${value},
- % endif
- % endfor
- }
- },
+ ${value},
+ % else:
+ ${value},
+ % endif
+ % endfor
+ }
+ },
+ % endfor
+ }}},
% endfor
- }}},
- % endfor
+ % endif
}},
% endfor
},
@@ -143,3 +147,5 @@ except KeyError, e:
% endfor
};
+} // namespace sensor
+} // namespace ipmi
OpenPOWER on IntegriCloud