summaryrefslogtreecommitdiffstats
path: root/tasker/plugins.py
diff options
context:
space:
mode:
authorMartin Sivak <msivak@redhat.com>2007-12-19 13:28:18 +0100
committerMartin Sivak <msivak@redhat.com>2007-12-19 13:28:18 +0100
commita9d245e9ddf98c84825ee5accfffa43a23575c16 (patch)
tree61c67a63d0e0e4b98f376188b2622b35ffd51823 /tasker/plugins.py
parent9ab7cc7593030654a67f992ee7775243741baa58 (diff)
downloadfirstaidkit-a9d245e9ddf98c84825ee5accfffa43a23575c16.tar.gz
firstaidkit-a9d245e9ddf98c84825ee5accfffa43a23575c16.tar.xz
firstaidkit-a9d245e9ddf98c84825ee5accfffa43a23575c16.zip
- Make simple reporting thread in main
- Update reporting to support End-Of-Operations message - Update main and interpret to send the End-Of-Operations message - Subclass dict in plugins as Flow and add support for description - Update example plugins to use Flow instead of pure dictionary
Diffstat (limited to 'tasker/plugins.py')
-rw-r--r--tasker/plugins.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/tasker/plugins.py b/tasker/plugins.py
index 36b5a09..251cc43 100644
--- a/tasker/plugins.py
+++ b/tasker/plugins.py
@@ -27,6 +27,11 @@ import os
import subprocess
from cStringIO import StringIO
+class Flow(dict):
+ def __init__(self, rules, description="", *args, **kwargs):
+ self.description = description
+ dict.__init__(self, rules, *args, **kwargs)
+
class Plugin(object):
#
# Some information vars.
@@ -64,7 +69,7 @@ class Plugin(object):
# with the parent of all ReturnValue classes.
#
_defflows = {}
- _defflows["defflow"] = {
+ _defflows["defflow"] = Flow({
initial : {ReturnValue: "prepare"},
"prepare" : {ReturnValueTrue: "diagnose"},
"diagnose" : {ReturnValueTrue: "clean", ReturnValueFalse: "backup"},
@@ -72,7 +77,7 @@ class Plugin(object):
"fix" : {ReturnValueTrue: "clean", ReturnValueFalse: "restore"},
"restore" : {ReturnValueTrue: "clean", ReturnValueFalse: "clean"},
"clean" : {ReturnValueTrue: final}
- }
+ }, description="The default, fully automated, fixing sequence")
def __init__(self, flow, reporting):
""" Initialize the instance.
@@ -137,6 +142,14 @@ class Plugin(object):
fatherf = Plugin._defflows.keys()
pluginf = cls.flows.keys()
return set(fatherf+pluginf)
+
+ @classmethod
+ def getFlow(cls, name):
+ """Return a Flow object associated with provided name"""
+ if cls.flows.has_key(name):
+ return cls.flows[name]
+ else:
+ return Plugin._defflows[name]
#list of all actions provided
def actions(self):