summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad Bishop <bradleyb@fuzziesquirrel.com>2017-01-21 23:44:28 -0500
committerBrad Bishop <bradleyb@fuzziesquirrel.com>2017-02-01 16:17:55 -0500
commitdb92c28ac9f354833753b451e4fba081c75d2564 (patch)
treedbdaac8ce6c81ef7dbd378bbffd56942b3ee51c9
parent90c30bc515bfe0d16da44c723a5d91f72a4d1a41 (diff)
downloadphosphor-inventory-manager-db92c28ac9f354833753b451e4fba081c75d2564.tar.gz
phosphor-inventory-manager-db92c28ac9f354833753b451e4fba081c75d2564.zip
Add support for rendering createObjects
Change-Id: Ic7412430ad223e8237ab0a1d1f26183486c22518 Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
-rw-r--r--README.md6
-rwxr-xr-xpimgen.py35
2 files changed, 41 insertions, 0 deletions
diff --git a/README.md b/README.md
index c7c64a1..81929d4 100644
--- a/README.md
+++ b/README.md
@@ -108,6 +108,12 @@ Supported arguments for the setProperty action are:
* path - The object hosting the property to be set.
* value - The value to set.
+----
+**createObjects**
+
+Supported arguments for the createObjects action are:
+* objs - A dictionary of objects to create.
+
----
diff --git a/pimgen.py b/pimgen.py
index 6835258..242edda 100755
--- a/pimgen.py
+++ b/pimgen.py
@@ -242,6 +242,40 @@ class Action(Wrapper):
super(Action, self).__init__(**kw)
+class CreateObjects(Action):
+ '''Assemble a createObjects action.'''
+
+ def __init__(self, **kw):
+ objs = []
+
+ for path, interfaces in kw.pop('objs').iteritems():
+ key_o = TrivialArgument(
+ value=path,
+ type='string',
+ decorators=[Literal('string')])
+ value_i = []
+
+ for interface, properties, in interfaces.iteritems():
+ key_i = TrivialArgument(value=interface, type='string')
+ value_p = []
+
+ for prop, value in properties.iteritems():
+ key_p = TrivialArgument(value=prop, type='string')
+ value_v = TrivialArgument(
+ decorators=[Literal(value.get('type', None))],
+ **value)
+ value_p.append(InitializerList(values=[key_p, value_v]))
+
+ value_p = InitializerList(values=value_p)
+ value_i.append(InitializerList(values=[key_i, value_p]))
+
+ value_i = InitializerList(values=value_i)
+ objs.append(InitializerList(values=[key_o, value_i]))
+
+ kw['args'] = [InitializerList(values=objs)]
+ super(CreateObjects, self).__init__(**kw)
+
+
class DestroyObjects(Action):
'''Assemble a destroyObject action.'''
@@ -322,6 +356,7 @@ class Event(MethodCall):
action_map = {
'destroyObjects': DestroyObjects,
+ 'createObjects': CreateObjects,
'setProperty': SetProperty,
}
OpenPOWER on IntegriCloud