aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sos/collector/sosnode.py20
-rw-r--r--sos/policies/__init__.py9
2 files changed, 15 insertions, 14 deletions
diff --git a/sos/collector/sosnode.py b/sos/collector/sosnode.py
index 5f86f656..c603e556 100644
--- a/sos/collector/sosnode.py
+++ b/sos/collector/sosnode.py
@@ -18,6 +18,7 @@ import shutil
from distutils.version import LooseVersion
from pipes import quote
+from sos.policies import load, InitSystem
from sos.collector.exceptions import *
@@ -63,7 +64,7 @@ class SosNode():
self.connected = True
self.local = True
if self.connected and load_facts:
- self.host = self.determine_host()
+ self.host = self.determine_host_policy()
if not self.host:
self.connected = False
self.close_ssh_session()
@@ -71,8 +72,6 @@ class SosNode():
if self.local:
if self.check_in_container():
self.host.containerized = False
- self.log_debug("Host facts found to be %s" %
- self.host.report_facts())
self.get_hostname()
if self.host.containerized:
self.create_sos_container()
@@ -291,17 +290,16 @@ class SosNode():
self.log_error("Exception while reading %s: %s" % (to_read, err))
return ''
- def determine_host(self):
+ def determine_host_policy(self):
'''Attempts to identify the host installation against supported
distributions
'''
- for host_type in self.host_types:
- host = self.host_types[host_type](self.address)
- rel_string = self.read_file(host.release_file)
- if host._check_enabled(rel_string):
- self.log_debug("Host installation found to be %s" %
- host.distribution)
- return host
+ host = load(cache={}, sysroot=self.opts.sysroot, init=InitSystem(),
+ probe_runtime=False, remote_exec=self.ssh_cmd,
+ remote_check=self.read_file('/etc/os-release'))
+ if host:
+ self.log_debug("loaded policy %s for host" % host.distro)
+ return host
self.log_error('Unable to determine host installation. Ignoring node')
raise UnsupportedHostException
diff --git a/sos/policies/__init__.py b/sos/policies/__init__.py
index 7ab1477c..97624052 100644
--- a/sos/policies/__init__.py
+++ b/sos/policies/__init__.py
@@ -48,7 +48,8 @@ def import_policy(name):
return None
-def load(cache={}, sysroot=None):
+def load(cache={}, sysroot=None, init=None, probe_runtime=True,
+ remote_exec=None, remote_check=''):
if 'policy' in cache:
return cache.get('policy')
@@ -56,8 +57,10 @@ def load(cache={}, sysroot=None):
helper = ImporterHelper(sos.policies)
for module in helper.get_modules():
for policy in import_policy(module):
- if policy.check():
- cache['policy'] = policy(sysroot=sysroot)
+ if policy.check(remote=remote_check):
+ cache['policy'] = policy(sysroot=sysroot, init=init,
+ probe_runtime=probe_runtime,
+ remote_exec=remote_exec)
if 'policy' not in cache:
cache['policy'] = GenericPolicy()