diff options
author | Joel Andres Granados <jgranado@redhat.com> | 2008-10-22 18:50:13 +0200 |
---|---|---|
committer | Joel Andres Granados <jgranado@redhat.com> | 2008-10-24 15:01:04 +0200 |
commit | 1615b70e2fdd6e36d4050ee9c55aaf15a0501a6f (patch) | |
tree | a3279e24a0caf46016a724bac033befc37fa54c1 /plugins | |
parent | ac73d062f903c69b7475b124ee1549d6062aab25 (diff) | |
download | firstaidkit-1615b70e2fdd6e36d4050ee9c55aaf15a0501a6f.tar.gz firstaidkit-1615b70e2fdd6e36d4050ee9c55aaf15a0501a6f.tar.xz firstaidkit-1615b70e2fdd6e36d4050ee9c55aaf15a0501a6f.zip |
Add the revert functionality to firstaidkit.
This introduces new requirements to the plugins.
1. If a plugin wants to be revertable it must implement the revert function.
This function will be accessible from the plugins top most namespace. The
same place where get_plugin is.
2. For the plugin's backend directory to be easily found, the plugin must
give the backend its module name as an id. In this way when the user
specifies in the revert command line plugin 'x', the revert class will
go to the backup directory in search for a directory called the same
way as the module of 'x'.
3. If the plugin developer does not want to use the system of backup dir
naming, there is a second way how to specify the backup dir. The
plugin must specify a function getBackupId(), that will return the id
of the backup space that can be used for the backup dir search.
Backup spaces that fail to comply with these directive will be ignored.
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/grub/grub.py | 11 | ||||
-rw-r--r-- | plugins/grub/grubUtils.py | 8 |
2 files changed, 12 insertions, 7 deletions
diff --git a/plugins/grub/grub.py b/plugins/grub/grub.py index feafaf5..7fcb586 100644 --- a/plugins/grub/grub.py +++ b/plugins/grub/grub.py @@ -39,6 +39,10 @@ class Grub(Plugin): def getDeps(cls): return set(["root", "experimental", "filesystem"]) + @classmethod + def revert(cls, backup, report): + report.info("Executing revert", origin = Grub) + def __init__(self, *args, **kwargs): Plugin.__init__(self, *args, **kwargs) @@ -61,10 +65,11 @@ class Grub(Plugin): self.issue_grub_image = SimpleIssue(self.name, "Bad grub stage1 image.") # Initialize the backup space. - self.backupSpace = self._backups.getBackup(str(self), persistent = True) + self.backupSpace = self._backups.getBackup( \ + self.__module__.split('.')[-1:][0], persistent = True) # Parce the parameters passed to the plugin. - self.args = gurbUtils.get_grub_opts(self._args) + self.args = grubUtils.get_grub_opts(self._args) def prepare(self): self._reporting.info("Initializing the search for all the grub " \ @@ -146,7 +151,7 @@ class Grub(Plugin): # Now we see if we can install in the partitions. for part in parts: if grubUtils.other_bootloader_present(Dname(part)): - self._reporting.info("Found no other bootloader in " \ + self._reporting.info("Found no other bootloader in " \ "%s partition." % Dname.asPath(part), \ origin = self) self.install_grub_parts.append(Dname(part)) diff --git a/plugins/grub/grubUtils.py b/plugins/grub/grubUtils.py index 949730f..1519d72 100644 --- a/plugins/grub/grubUtils.py +++ b/plugins/grub/grubUtils.py @@ -252,7 +252,7 @@ def other_bootloader_present(dev): return False # We will have the list of all the tests in the tests variable. - tests = {none_grub} + tests = [none_grub] for test in tests: if test(dev): @@ -357,13 +357,13 @@ def get_grub_opts(args): # Create the object with the argument decision. class grub_args: - install_all = Flase + install_all = False install_to = [] retval = grub_args() # Parse the args string optsstr = "" - longotps = ["install-all", "install-to="] + longopts = ["install-all", "install-to="] try: (opts, vals) = getopt.getopt( args.split(), optsstr, longopts ) except: @@ -477,7 +477,7 @@ class Dname: openpar = "" closepar = "" - # Create the gurb device string. + # Create the grub device string. if partnum == None: return "%shd%s%s"%(openpar, devnum, closepar) else: |