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
diff --git a/Makefile.am b/Makefile.am
index bcac808..cd0b64e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -25,8 +25,7 @@
 libipmi20_BUILT_LIST = \
 	sensor-gen.cpp \
 	inventory-sensor-gen.cpp \
-	fru-read-gen.cpp \
-	entity-gen.cpp
+	fru-read-gen.cpp
 
 BUILT_SOURCES = \
 	ipmiwhitelist.cpp \
@@ -79,9 +78,6 @@
 fru-read-gen.cpp: scripts/readfru.mako.cpp scripts/fru_gen.py @FRU_YAML_GEN@
 	$(AM_V_GEN)@FRUGEN@ -o $(top_builddir) generate-cpp
 
-entity-gen.cpp: scripts/writeentity.mako.cpp scripts/entity_gen.py @ENTITY_YAML_GEN@
-	$(AM_V_GEN)@ENTITYGEN@ -o $(top_builddir) generate-cpp
-
 providers_LTLIBRARIES += libipmi20.la
 libipmi20_la_SOURCES = \
 	app/channel.cpp \
diff --git a/entity_map_json.cpp b/entity_map_json.cpp
index c0b836c..7b4e0bf 100644
--- a/entity_map_json.cpp
+++ b/entity_map_json.cpp
@@ -13,8 +13,6 @@
 namespace sensor
 {
 
-extern const EntityInfoMap entities;
-
 EntityInfoMapContainer* EntityInfoMapContainer::getContainer()
 {
     static std::unique_ptr<EntityInfoMapContainer> instance;
@@ -25,16 +23,8 @@
          * the first thread to hit it would set it up.
          */
         EntityInfoMap builtEntityMap = buildEntityMapFromFile();
-        if (!builtEntityMap.empty())
-        {
-            instance = std::unique_ptr<EntityInfoMapContainer>(
-                new EntityInfoMapContainer(builtEntityMap));
-        }
-        else
-        {
-            instance = std::unique_ptr<EntityInfoMapContainer>(
-                new EntityInfoMapContainer(entities));
-        }
+        instance = std::unique_ptr<EntityInfoMapContainer>(
+            new EntityInfoMapContainer(builtEntityMap));
     }
 
     return instance.get();
diff --git a/scripts/entity-example.yaml b/scripts/entity-example.md
similarity index 87%
rename from scripts/entity-example.yaml
rename to 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
diff --git a/test/Makefile.am b/test/Makefile.am
index 7d3d6fc..e4ff261 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -27,7 +27,7 @@
 TESTS = $(check_PROGRAMS)
 
 entitymap_json_unittest_SOURCES = entitymap_json_unittest.cpp
-entitymap_json_unittest_LDADD = $(top_builddir)/entity_map_json.o -lgmock $(top_builddir)/entity-gen.o
+entitymap_json_unittest_LDADD = $(top_builddir)/entity_map_json.o -lgmock
 
 check_PROGRAMS += entitymap_json_unittest