diff options
author | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2017-01-21 23:44:28 -0500 |
---|---|---|
committer | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2017-02-01 16:17:55 -0500 |
commit | db92c28ac9f354833753b451e4fba081c75d2564 (patch) | |
tree | dbdaac8ce6c81ef7dbd378bbffd56942b3ee51c9 | |
parent | 90c30bc515bfe0d16da44c723a5d91f72a4d1a41 (diff) | |
download | phosphor-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.md | 6 | ||||
-rwxr-xr-x | pimgen.py | 35 |
2 files changed, 41 insertions, 0 deletions
@@ -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. + ---- @@ -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, } |