diff options
author | Jaghathiswari Rankappagounder Natarajan <jaghu@google.com> | 2019-02-12 13:22:55 -0800 |
---|---|---|
committer | Jaghathiswari Rankappagounder Natarajan <jaghu@google.com> | 2019-02-15 21:48:56 +0000 |
commit | 9c11894eb919034fb7841520aea3f476783a85c6 (patch) | |
tree | 7d3b244ea082418317608fad7877de59bb549bb1 /scripts/entity_gen.py | |
parent | 0780df105bdd00184de29f48e9946bebfc5b5fb2 (diff) | |
download | phosphor-host-ipmid-9c11894eb919034fb7841520aea3f476783a85c6.tar.gz phosphor-host-ipmid-9c11894eb919034fb7841520aea3f476783a85c6.zip |
Add support for Entity Association Record
Adding support for Entity Association Record (SDR type - 0x08h)
This patch includes:
1) Entity Association Record yaml file example
2) Entity Assocation Record related script and mako file changes
3) Adding Entity Association Record in get_sdr IPMI command response
From the host, tested that entity association records can be fetched
Change-Id: I9cf598e5d27d2e8c6751bbaae2176e7c976974b1
Tested: Yes
Signed-off-by: Jaghathiswari Rankappagounder Natarajan <jaghu@google.com>
Diffstat (limited to 'scripts/entity_gen.py')
-rwxr-xr-x | scripts/entity_gen.py | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/scripts/entity_gen.py b/scripts/entity_gen.py new file mode 100755 index 0000000..057821b --- /dev/null +++ b/scripts/entity_gen.py @@ -0,0 +1,60 @@ +#!/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() |