summaryrefslogtreecommitdiffstats
path: root/presence/gen-fan-detect-defs.py
diff options
context:
space:
mode:
Diffstat (limited to 'presence/gen-fan-detect-defs.py')
-rwxr-xr-xpresence/gen-fan-detect-defs.py59
1 files changed, 0 insertions, 59 deletions
diff --git a/presence/gen-fan-detect-defs.py b/presence/gen-fan-detect-defs.py
deleted file mode 100755
index 842bbeb..0000000
--- a/presence/gen-fan-detect-defs.py
+++ /dev/null
@@ -1,59 +0,0 @@
-#!/usr/bin/env python
-
-"""
-This script parses the given fan presence definition yaml file and generates
-a header file based on the defined methods for determining when a fan is
-present.
-"""
-
-import os
-import sys
-import yaml
-from argparse import ArgumentParser
-from mako.template import Template
-
-tmpl = '''/* This is a generated file. */
-#include "fan_detect_defs.hpp"
-
-const std::map<std::string, std::set<phosphor::fan::Properties>>
-fanDetectMap = {
-%for methods in presence:
- %for method in methods:
- <% m = method.lower() %> \
- {"${m}", {
- %for fan in methods[method]:
- std::make_tuple("${fan['Inventory']}",
- "${fan['PrettyName']}",
- std::vector<std::string>{
- %for s in fan['Sensors']:
- "${s}",
- %endfor
- }),
- %endfor
- %endfor
- }},
-%endfor
-};
-'''
-
-
-if __name__ == '__main__':
- parser = ArgumentParser()
- # Input yaml containing how each fan's presence detection should be done
- parser.add_argument("-y", "--yaml", dest="pres_yaml",
- default=
- "example/fan-detect.yaml",
- help=
- "Input fan presences definition yaml file to parse")
- args = parser.parse_args(sys.argv[1:])
-
- # Verify given yaml file exists
- yaml_file = os.path.abspath(args.pres_yaml)
- if not os.path.isfile(yaml_file):
- print "Unable to find input yaml file " + yaml_file
- exit(1)
-
- with open(yaml_file, 'r') as yaml_input:
- presence_data = yaml.safe_load(yaml_input) or {}
-
- sys.stdout.write(Template(tmpl).render(presence=presence_data))
OpenPOWER on IntegriCloud