aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Jaggars <jhjaggars@gmail.com>2012-01-10 10:13:41 -0600
committerJesse Jaggars <jhjaggars@gmail.com>2012-01-10 10:17:17 -0600
commit68c4d5d38ed39241b8414442a36a570324ba3531 (patch)
tree189d561519c0311848f8865c2d32561c619faf1c
parent2f1baf7b83ecdef7f189dd4a1fff190180816d9d (diff)
downloadsos-68c4d5d38ed39241b8414442a36a570324ba3531.tar.gz
Adding a generic policy for fallback
-rw-r--r--sos/policies/__init__.py11
-rw-r--r--sos/policies/redhat.py2
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