summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad Bishop <bradleyb@fuzziesquirrel.com>2016-11-12 12:51:26 -0500
committerBrad Bishop <bradleyb@fuzziesquirrel.com>2016-11-21 11:28:33 -0500
commit14a9fe5e15c588e82efa002faaac8d38a087b779 (patch)
tree5c873e10bc94d87f306a9c80d1eefa28d50bc0cc
parentf4666f595797910fec3c8b314d1219215e425f6d (diff)
downloadphosphor-inventory-manager-14a9fe5e15c588e82efa002faaac8d38a087b779.tar.gz
phosphor-inventory-manager-14a9fe5e15c588e82efa002faaac8d38a087b779.zip
pimgen: Add list-interfaces command option
list-interfaces simply prints out all the interfaces found in interfaces.d. This intended user is configure. Change-Id: I5e2c6b59ae4addb04f2e82b084122a948e46d29f Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
-rwxr-xr-xpimgen.py34
1 files changed, 23 insertions, 11 deletions
diff --git a/pimgen.py b/pimgen.py
index 187e6e7..072f7d6 100755
--- a/pimgen.py
+++ b/pimgen.py
@@ -20,6 +20,25 @@ def parse_event(e):
return e
+def get_interfaces(args):
+ interfaces_dir = os.path.join(args.inputdir, 'interfaces.d')
+ yaml_files = filter(
+ lambda x: x.endswith('.yaml'),
+ os.listdir(interfaces_dir))
+
+ interfaces = []
+ for x in yaml_files:
+ with open(os.path.join(interfaces_dir, x), 'r') as fd:
+ for i in yaml.load(fd.read()):
+ interfaces.append(i)
+
+ return interfaces
+
+
+def list_interfaces(args):
+ print ' '.join(get_interfaces(args))
+
+
def generate_cpp(args):
# Aggregate all the event YAML in the events.d directory
# into a single list of events.
@@ -39,16 +58,7 @@ def generate_cpp(args):
template = os.path.join(script_dir, 'generated.mako.cpp')
t = Template(filename=template)
- interfaces_dir = os.path.join(args.inputdir, 'interfaces.d')
- yaml_files = filter(
- lambda x: x.endswith('.yaml'),
- os.listdir(interfaces_dir))
-
- interfaces = []
- for x in yaml_files:
- with open(os.path.join(interfaces_dir, x), 'r') as fd:
- for i in yaml.load(fd.read()):
- interfaces.append(i)
+ interfaces = get_interfaces(args)
# Render the template with the provided events and interfaces.
template = os.path.join(script_dir, 'generated.mako.cpp')
@@ -104,7 +114,9 @@ def generate_cpp(args):
if __name__ == '__main__':
script_dir = os.path.dirname(os.path.realpath(__file__))
- valid_commands = {'generate-cpp': 'generate_cpp'}
+ valid_commands = {
+ 'generate-cpp': 'generate_cpp',
+ 'list-interfaces': 'list_interfaces'}
parser = argparse.ArgumentParser(
description='Phosphor Inventory Manager (PIM) YAML '
OpenPOWER on IntegriCloud