From 68c4d5d38ed39241b8414442a36a570324ba3531 Mon Sep 17 00:00:00 2001 From: Jesse Jaggars Date: Tue, 10 Jan 2012 10:13:41 -0600 Subject: Adding a generic policy for fallback --- sos/policies/__init__.py | 11 ++++++++++- sos/policies/redhat.py | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/sos/policies/__init__.py b/sos/policies/__init__.py index 07c75f64..a2234016 100644 --- a/sos/policies/__init__.py +++ b/sos/policies/__init__.py @@ -25,7 +25,7 @@ def load(cache={}): if policy.check(): cache['policy'] = policy() return policy() - raise Exception("No policy could be loaded.") + return GenericPolicy() class PackageManager(object): @@ -133,6 +133,7 @@ No changes will be made to your system. def _parse_uname(self): (system, node, release, version, machine, processor) = platform.uname() + self.system = system self.hostname = node self.release = release self.smp = version.split()[1] == "SMP" @@ -274,3 +275,11 @@ No changes will be made to your system. text will be substituted accordingly. You can also override this method to do something more complicated.""" return self.msg % {'distro': self.distro} + + +class GenericPolicy(Policy): + """This Policy will be returned if no other policy can be loaded. This + should allow for IndependentPlugins to be executed on any system""" + + def get_msg(self): + return self.msg % {'distro': self.system} diff --git a/sos/policies/redhat.py b/sos/policies/redhat.py index cfd31ef2..398514e1 100644 --- a/sos/policies/redhat.py +++ b/sos/policies/redhat.py @@ -98,7 +98,7 @@ class RHELPolicy(Policy): @classmethod def check(self): "This method checks to see if we are running on RHEL. It returns True or False." - return os.path.isfile('/etc/redhat-release') + return os.path.isfile('/etc/redhat-release') or os.path.isfile('/etc/fedora-release') def preferedArchive(self): from sos.utilities import TarFileArchive -- cgit