summaryrefslogtreecommitdiffstats
path: root/plugins/plugin_rpm_lowlevel
diff options
context:
space:
mode:
authorJoel Andres Granados <jgranado@redhat.com>2008-07-15 13:31:26 +0200
committerJoel Andres Granados <jgranado@redhat.com>2008-07-15 13:31:26 +0200
commitafa753016f8d43ce2c886e146093470cd5877f7f (patch)
tree1ba29171802c712cf36bf0b643fc05c7fe049b68 /plugins/plugin_rpm_lowlevel
parentb52801801b20a7ddc65918fdafdfdb1ff7eacc98 (diff)
Standarize and simplify plugin names.
- The file names are the ones the the user will be using to reference each plugin. Having a long name will not help the user. - Also, to signify that they are plugins we will use the "p_" at the beginning of each name. - plugin_examples is left like that because it is not a plugin in itself, but a directory that contains plugins. Please follow these naming standards when you name you plugins.
Diffstat (limited to 'plugins/plugin_rpm_lowlevel')
-rw-r--r--plugins/plugin_rpm_lowlevel/__init__.py71
-rw-r--r--plugins/plugin_rpm_lowlevel/issue_locks.py73
-rw-r--r--plugins/plugin_rpm_lowlevel/issue_packages.py81
3 files changed, 0 insertions, 225 deletions
diff --git a/plugins/plugin_rpm_lowlevel/__init__.py b/plugins/plugin_rpm_lowlevel/__init__.py
deleted file mode 100644
index b4daef9..0000000
--- a/plugins/plugin_rpm_lowlevel/__init__.py
+++ /dev/null
@@ -1,71 +0,0 @@
-# First Aid Kit - diagnostic and repair tool for Linux
-# Copyright (C) 2007 Martin Sivak <msivak@redhat.com>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-from pyfirstaidkit.plugins import IssuesPlugin,Flow
-from pyfirstaidkit.returns import *
-from pyfirstaidkit.utils import *
-from pyfirstaidkit.reporting import PLUGIN,TASK
-from pyfirstaidkit import Config
-
-from issue_packages import Packages
-from issue_locks import Locks
-
-import os.path
-
-class RPMLowlevelPlugin(IssuesPlugin):
- """This plugin provides lowlevel checks for RPM database."""
- #
- # Additional flow defprepareion.
- #
- flows = Flow.init(IssuesPlugin)
-
- name = "RPM lowlevel structure plugin"
- version = "0.0.1"
- author = "Martin Sivak"
-
- issue_tests = [Packages, Locks]
- set_flags = ["rpm_lowlevel"]
-
- @classmethod
- def getDeps(cls):
- return set(["root", "experimental", "filesystem"])
-
- def __init__(self, *args, **kwargs):
- IssuesPlugin.__init__(self, *args, **kwargs)
- self.rpm = None
-
- def prepare(self):
- self.backup = self._backups.getBackup(self.__class__.__name__+" -- "+self.name)
- IssuesPlugin.prepare(self)
-
- def backup(self):
- IssuesPlugin.backup(self)
- self.backup.backupPath(path = os.path.join(Config.system.root,"/var/lib/rpm"), name="rpm")
- self._result=ReturnSuccess
-
- def restore(self):
- self.backup.restorePath(path = os.path.join(Config.system.root,"/var/lib/rpm"), name="rpm")
- IssuesPlugin.restore(self)
- self._result=ReturnSuccess
-
- def clean(self):
- self._backups.closeBackup(self.backup._id)
- IssuesPlugin.clean(self)
- self._result=ReturnSuccess
-
-def get_plugin():
- return RPMLowlevelPlugin
diff --git a/plugins/plugin_rpm_lowlevel/issue_locks.py b/plugins/plugin_rpm_lowlevel/issue_locks.py
deleted file mode 100644
index d64c3f7..0000000
--- a/plugins/plugin_rpm_lowlevel/issue_locks.py
+++ /dev/null
@@ -1,73 +0,0 @@
-# File name: issue_filesystem.py
-# Date: 2008/03/14
-# Author: Martin Sivak <msivak at redhat dot com>
-#
-# Copyright (C) Red Hat 2008
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License as
-# published by the Free Software Foundation; either version 2 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# in a file called COPYING along with this program; if not, write to
-# the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA
-# 02139, USA.
-
-from pyfirstaidkit.issue import Issue
-from pyfirstaidkit.reporting import TASK
-from pyfirstaidkit.utils import spawnvch
-from pyfirstaidkit.configuration import Config
-import os.path
-import re
-
-class Locks(Issue):
- name = "Staled RPM locks"
- description = "The database is still locked, but it shouldn't be. Probably a result of some unexpectedly aborted rpm operation."
-
- def __init__(self, *args, **kwargs):
- Issue.__init__(self, *args, **kwargs)
-
- def detect(self):
- result = Issue.detect(self)
- if result is not None:
- return result
-
- path = os.path.join(Config.system.root,"/var/lib/rpm/")
- self.locks = []
-
- def walkfunc(arg, dirname, fnames):
- for f in fnames:
- if f[:4]=="__db" and os.path.isfile(os.path.join(dirname, f)):
- arg.append(os.path.join(dirname, f))
-
- os.path.walk(path, walkfunc, self.locks)
-
- if len(self.locks)==0:
- self._happened = False
- else:
- self._happened = True
-
- self._checked = True
- return True
-
- def fix(self):
- result = Issue.fix(self)
- if result is not None:
- return result
-
- for f in self.locks:
- os.unlink(f)
-
- self._fixed = True
- return True
-
- def reset(self):
- Issue.reset(self)
- self.locks = []
-
diff --git a/plugins/plugin_rpm_lowlevel/issue_packages.py b/plugins/plugin_rpm_lowlevel/issue_packages.py
deleted file mode 100644
index 34bac91..0000000
--- a/plugins/plugin_rpm_lowlevel/issue_packages.py
+++ /dev/null
@@ -1,81 +0,0 @@
-# File name: issue_filesystem.py
-# Date: 2008/03/14
-# Author: Martin Sivak <msivak at redhat dot com>
-#
-# Copyright (C) Red Hat 2008
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License as
-# published by the Free Software Foundation; either version 2 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# in a file called COPYING along with this program; if not, write to
-# the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA
-# 02139, USA.
-
-from pyfirstaidkit.issue import Issue
-from pyfirstaidkit.reporting import TASK
-from pyfirstaidkit.utils import spawnvch
-from pyfirstaidkit.configuration import Config
-import os, os.path
-
-
-class Packages(Issue):
- name = "Required Packages database"
- description = "The file containing the rpm database of packages is missing or corrupted"
-
- def detect(self):
- result = Issue.detect(self)
- if result is not None:
- return result
-
- dbname = os.path.join(Config.system.root, "/var/lib/rpm/Packages")
- self._happened = False
-
- if not os.path.isfile(os.path.realpath(dbname)):
- self._db_missing = True
- self._happened = True
- self._checked = True
- return True
-
- #verify the Package database
- rpm_verify = spawnvch(executable = "/usr/lib/rpm/rpmdb_verify", args = ["/usr/lib/rpm/rpmdb_verify", dbname], chroot = Config.system.root)
- err = rpm_verify.wait()
- if err!=0:
- return False
-
- if len(rpm_verify.stdout.read())>0:
- self._happened = True
- if len(rpm_verify.stderr.read())>0:
- self._happened = True
-
- self._checked = True
- return True
-
- def fix(self):
- result = Issue.fix(self)
- if result is not None:
- return result
-
- dbname = os.path.join(Config.system.root,"/var/lib/rpm/Packages")
-
- if not self._db_missing:
- #dump&load the database
- os.rename(dbname, dbname+".orig")
- err = spawnvch(executable = "/bin/sh", args = ["sh", "-c", "/usr/lib/rpm/rpmdb_dump /var/lib/rpm/Packages.orig | /usr/lib/rpm/rpmdb_load /var/lib/rpm/Packages"], chroot = Config.system.root).wait()
- if rpm.returncode!=0:
- os.rename(dbname+".orig", dbname)
- return False
-
- #rebuild the indexes
- rpm = spawnvch(executable = "/bin/rpm", args = ["rpm", "--rebuilddb"], chroot = Config.system.root).wait()
- if rpm.returncode==0:
- self._fixed = True
- return True
-