summaryrefslogtreecommitdiffstats
path: root/src/pdmgen.py
diff options
context:
space:
mode:
authorBrad Bishop <bradleyb@fuzziesquirrel.com>2017-05-20 21:42:38 -0400
committerBrad Bishop <bradleyb@fuzziesquirrel.com>2017-06-19 16:26:44 -0400
commitc1283ae8472dbd4e2c3593b76b7600ac72640b80 (patch)
tree1e45c148d19a59a561df430a1f4ba3728196d910 /src/pdmgen.py
parent893b348890781dba2603ead61cf6f724350d0b47 (diff)
downloadphosphor-dbus-monitor-c1283ae8472dbd4e2c3593b76b7600ac72640b80.tar.gz
phosphor-dbus-monitor-c1283ae8472dbd4e2c3593b76b7600ac72640b80.zip
Add support for callbacks
Callbacks are the response in the PDM 'trigger->response' model. Add general support for implementing callbacks and implement a log to systemd journal using that framework. Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com> Change-Id: I8bead5368ee5472a02b47e8bba9e9df3a1f346bc
Diffstat (limited to 'src/pdmgen.py')
-rwxr-xr-xsrc/pdmgen.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/pdmgen.py b/src/pdmgen.py
index 070c118..e4a97e7 100755
--- a/src/pdmgen.py
+++ b/src/pdmgen.py
@@ -413,6 +413,29 @@ class PropertyWatch(HasPropertyIndex):
super(PropertyWatch, self).__init__(**kw)
+class Callback(HasPropertyIndex):
+ '''Interface and common logic for callbacks.'''
+
+ def __init__(self, *a, **kw):
+ super(Callback, self).__init__(**kw)
+
+
+class Journal(Callback, Renderer):
+ '''Handle the journal callback config file directive.'''
+
+ def __init__(self, *a, **kw):
+ self.severity = kw.pop('severity')
+ self.message = kw.pop('message')
+ super(Journal, self).__init__(**kw)
+
+ def construct(self, loader, indent):
+ return self.render(
+ loader,
+ 'journal.mako.cpp',
+ c=self,
+ indent=indent)
+
+
class Everything(Renderer):
'''Parse/render entry point.'''
@@ -440,6 +463,9 @@ class Everything(Renderer):
'instance': {
'element': Instance,
},
+ 'callback': {
+ 'journal': Journal,
+ },
}
if cls not in class_map:
@@ -529,6 +555,7 @@ class Everything(Renderer):
self.instances = kw.pop('instance', [])
self.instancegroups = kw.pop('instancegroup', [])
self.watches = kw.pop('watch', [])
+ self.callbacks = kw.pop('callback', [])
super(Everything, self).__init__(**kw)
@@ -550,6 +577,7 @@ class Everything(Renderer):
instances=self.instances,
watches=self.watches,
instancegroups=self.instancegroups,
+ callbacks=self.callbacks,
indent=Indent()))
if __name__ == '__main__':
OpenPOWER on IntegriCloud