summaryrefslogtreecommitdiffstats
path: root/pyfirstaidkit/plugins.py
diff options
context:
space:
mode:
authorMartin Sivak <msivak@redhat.com>2008-02-28 16:08:09 +0100
committerMartin Sivak <msivak@redhat.com>2008-02-28 16:08:09 +0100
commitb2c3417bb9704b8afab1a0053f100c252a4c8ed5 (patch)
treed62f0b964d488ac081e435f026ffce37ebd404fd /pyfirstaidkit/plugins.py
parent70efb5c67c477c8b9a801686878f158b0cbdb262 (diff)
downloadfirstaidkit-b2c3417bb9704b8afab1a0053f100c252a4c8ed5.tar.gz
firstaidkit-b2c3417bb9704b8afab1a0053f100c252a4c8ed5.tar.xz
firstaidkit-b2c3417bb9704b8afab1a0053f100c252a4c8ed5.zip
Modify the plugins, tasker and cli launcher to provide means to split the flows into diagnostics and fixes.
So when the user launches ./firstaidkit -a it runs only diagnostics. For fixing use ./firstaidkit -a fix
Diffstat (limited to 'pyfirstaidkit/plugins.py')
-rw-r--r--pyfirstaidkit/plugins.py44
1 files changed, 27 insertions, 17 deletions
diff --git a/pyfirstaidkit/plugins.py b/pyfirstaidkit/plugins.py
index 49386ae..d8fe14b 100644
--- a/pyfirstaidkit/plugins.py
+++ b/pyfirstaidkit/plugins.py
@@ -53,9 +53,9 @@ class Plugin(object):
# Dictionary that holds all the flows. The keys for each flow is its
# name. The flow will be addressed by this name. The plugin developer
# Can add as many flows as he wants. The developer must use the instance.
- # obj._flows["name"] = SomeFlow. Be aware that you can overwirhte
- # previously added flows. This class attribute has to be overriden by
- # each plugin.
+ # flows["name"] = SomeFlow. Be aware that you can overwirhte
+ # previously added flows. This class attribute has to be initialized by
+ # each plugin using flows = Flow.init(ParentClass)
#
flows = {}
@@ -68,17 +68,21 @@ class Plugin(object):
final = 1
#
- # The flow to use with the automated repair mode
- #
-
- default_flow = "defflow"
-
- #
# This is the default flow that all classes deriving from plugin must
# have. As the initial state has no return value it will be indexed
# with the parent of all Return classes.
#
- flows["defflow"] = Flow({
+ # The flow to use with the automated repair mode
+ # has to have name "fix". The flow for diagnose mode
+ # has to be named "diagnose"
+ #
+ flows["diagnose"] = Flow({
+ initial : {Return: "prepare"},
+ "prepare" : {ReturnSuccess: "diagnose"},
+ "diagnose" : {ReturnSuccess: "clean", ReturnFailure: "clean"},
+ "clean" : {ReturnSuccess: final, ReturnFailure: final}
+ }, description="The default, fully automated, diagnose sequence")
+ flows["fix"] = Flow({
initial : {Return: "prepare"},
"prepare" : {ReturnSuccess: "diagnose"},
"diagnose" : {ReturnSuccess: "clean", ReturnFailure: "backup"},
@@ -88,6 +92,12 @@ class Plugin(object):
"clean" : {ReturnSuccess: final, ReturnFailure: final}
}, description="The default, fully automated, fixing sequence")
+ # By default, when no other parameters are passed, we use the diagnose flow as
+ # the default flow to run. You can change this, BUT it MUST always be a non-changing
+ # non-destructive and safe flow, which does the diagnostics
+
+ default_flow = "diagnose"
+
def __init__(self, flow, reporting, dependencies):
""" Initialize the instance.
@@ -299,21 +309,21 @@ class FlagTrackerPlugin(Plugin):
return set([x+"?" for x in cls.flag_list])
#
- # The flow to use with the automated repair mode
- #
-
- default_flow = "deflogic"
-
- #
# This is the default flow that all classes deriving from plugin must
# have. As the initial state has no return value it will be indexed
# with the parent of all Return classes.
#
+ # The flow to use with the automated repair mode
+ # has to have name "fix". The flow for diagnose mode
+ # has to be named "diagnose"
+ #
+
flows = Flow.init(Plugin)
- flows["deflogic"] = Flow({
+ flows["diagnose"] = Flow({
Plugin.initial : {Return: "decide"},
"decide" : {Return: Plugin.final}
}, description="The default, fully automated, deciding sequence")
+ flows["fix"] = flows["diagnose"]
def decide(self):
"""Decide about state of higher level flags."""