diff options
author | Patrick Venture <venture@google.com> | 2019-08-19 12:25:54 -0700 |
---|---|---|
committer | Patrick Venture <venture@google.com> | 2019-09-19 10:20:47 -0700 |
commit | 1ad9da8a7882a643ca28fedbdc614f1855e3669a (patch) | |
tree | 2533fde8f95d730e2090fce01f32590dc3d611a5 /scripts | |
parent | 87fd2cd13314a2b0b8cbc6441e724a4fea57e20c (diff) | |
download | phosphor-host-ipmid-1ad9da8a7882a643ca28fedbdc614f1855e3669a.tar.gz phosphor-host-ipmid-1ad9da8a7882a643ca28fedbdc614f1855e3669a.zip |
drop entity YAML in favor of json provided file
Step 5 of moving from entity map from YAML to JSON drops support for a
built-in YAML mapping of the entity containers.
Tested: Not tested. No platform upstream updates this YAML file in
their builds.
Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: Ic2918f568f5a6f4a9f9135990889b3bb84a0c81d
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/entity-example.md (renamed from scripts/entity-example.yaml) | 26 | ||||
-rwxr-xr-x | scripts/entity_gen.py | 60 | ||||
-rw-r--r-- | scripts/writeentity.mako.cpp | 40 |
3 files changed, 26 insertions, 100 deletions
diff --git a/scripts/entity-example.yaml b/scripts/entity-example.md index 2db14cc..98dbade 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 b558a44..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(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(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/writeentity.mako.cpp b/scripts/writeentity.mako.cpp deleted file mode 100644 index 04ea87c..0000000 --- a/scripts/writeentity.mako.cpp +++ /dev/null @@ -1,40 +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> -#include <utility> - -namespace ipmi { -namespace 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 -}; - -} // namespace sensor -} // namespace ipmi |