aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJake Hunsaker <jhunsake@redhat.com>2021-09-27 12:28:27 -0400
committerJake Hunsaker <jhunsake@redhat.com>2021-10-18 21:05:22 -0400
commit07d96d52ef69b9f8fe1ef32a1b88089d31c33fe8 (patch)
tree724a4a830a90c6dce6b9262af9e36cabf4bf7401
parente869bc84c714bfc2249bbcb84e14908049ee42c4 (diff)
downloadsos-07d96d52ef69b9f8fe1ef32a1b88089d31c33fe8.tar.gz
[plugins] Update plugins to use new os.path.join wrapper
Updates plugins to use the new `self.path_join()` wrapper for `os.path.join()` so that these plugins now account for non-/ sysroots for their collections. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
-rw-r--r--sos/report/plugins/__init__.py2
-rw-r--r--sos/report/plugins/azure.py4
-rw-r--r--sos/report/plugins/collectd.py2
-rw-r--r--sos/report/plugins/container_log.py2
-rw-r--r--sos/report/plugins/corosync.py2
-rw-r--r--sos/report/plugins/docker_distribution.py5
-rw-r--r--sos/report/plugins/ds.py3
-rw-r--r--sos/report/plugins/elastic.py4
-rw-r--r--sos/report/plugins/etcd.py2
-rw-r--r--sos/report/plugins/gluster.py3
-rw-r--r--sos/report/plugins/jars.py2
-rw-r--r--sos/report/plugins/kdump.py4
-rw-r--r--sos/report/plugins/libvirt.py2
-rw-r--r--sos/report/plugins/logs.py8
-rw-r--r--sos/report/plugins/manageiq.py12
-rw-r--r--sos/report/plugins/numa.py9
-rw-r--r--sos/report/plugins/openstack_instack.py2
-rw-r--r--sos/report/plugins/openstack_nova.py2
-rw-r--r--sos/report/plugins/openvswitch.py13
-rw-r--r--sos/report/plugins/origin.py28
-rw-r--r--sos/report/plugins/ovirt.py2
-rw-r--r--sos/report/plugins/ovirt_engine_backup.py5
-rw-r--r--sos/report/plugins/ovn_central.py26
-rw-r--r--sos/report/plugins/ovn_host.py4
-rw-r--r--sos/report/plugins/pacemaker.py4
-rw-r--r--sos/report/plugins/pcp.py32
-rw-r--r--sos/report/plugins/postfix.py2
-rw-r--r--sos/report/plugins/postgresql.py2
-rw-r--r--sos/report/plugins/powerpc.py2
-rw-r--r--sos/report/plugins/processor.py3
-rw-r--r--sos/report/plugins/python.py4
-rw-r--r--sos/report/plugins/sar.py5
-rw-r--r--sos/report/plugins/sos_extras.py2
-rw-r--r--sos/report/plugins/ssh.py7
-rw-r--r--sos/report/plugins/unpackaged.py4
-rw-r--r--sos/report/plugins/watchdog.py13
-rw-r--r--sos/report/plugins/yum.py2
37 files changed, 115 insertions, 115 deletions
diff --git a/sos/report/plugins/__init__.py b/sos/report/plugins/__init__.py
index 1f84bca4..ec138f83 100644
--- a/sos/report/plugins/__init__.py
+++ b/sos/report/plugins/__init__.py
@@ -2897,7 +2897,7 @@ class Plugin():
try:
cmd_line_paths = glob.glob(cmd_line_glob)
for path in cmd_line_paths:
- f = open(path, 'r')
+ f = open(self.path_join(path), 'r')
cmd_line = f.read().strip()
if process in cmd_line:
status = True
diff --git a/sos/report/plugins/azure.py b/sos/report/plugins/azure.py
index 45971a61..90999b3f 100644
--- a/sos/report/plugins/azure.py
+++ b/sos/report/plugins/azure.py
@@ -8,8 +8,8 @@
#
# See the LICENSE file in the source distribution for further information.
-import os
from sos.report.plugins import Plugin, UbuntuPlugin, RedHatPlugin
+import os
class Azure(Plugin, UbuntuPlugin):
@@ -38,7 +38,7 @@ class Azure(Plugin, UbuntuPlugin):
for path, subdirs, files in os.walk("/var/log/azure"):
for name in files:
- self.add_copy_spec(os.path.join(path, name), sizelimit=limit)
+ self.add_copy_spec(self.path_join(path, name), sizelimit=limit)
self.add_cmd_output((
'curl -s -H Metadata:true '
diff --git a/sos/report/plugins/collectd.py b/sos/report/plugins/collectd.py
index 80d4b00a..8584adf9 100644
--- a/sos/report/plugins/collectd.py
+++ b/sos/report/plugins/collectd.py
@@ -33,7 +33,7 @@ class Collectd(Plugin, IndependentPlugin):
p = re.compile('^LoadPlugin.*')
try:
- with open("/etc/collectd.conf") as f:
+ with open(self.path_join("/etc/collectd.conf"), 'r') as f:
for line in f:
if p.match(line):
self.add_alert("Active Plugin found: %s" %
diff --git a/sos/report/plugins/container_log.py b/sos/report/plugins/container_log.py
index 14e0b7d8..e8dedad2 100644
--- a/sos/report/plugins/container_log.py
+++ b/sos/report/plugins/container_log.py
@@ -29,6 +29,6 @@ class ContainerLog(Plugin, IndependentPlugin):
"""Collect *.log files from subdirs of passed root path
"""
for dirName, _, _ in os.walk(root):
- self.add_copy_spec(os.path.join(dirName, '*.log'))
+ self.add_copy_spec(self.path_join(dirName, '*.log'))
# vim: set et ts=4 sw=4 :
diff --git a/sos/report/plugins/corosync.py b/sos/report/plugins/corosync.py
index d74086e3..10e096c6 100644
--- a/sos/report/plugins/corosync.py
+++ b/sos/report/plugins/corosync.py
@@ -47,7 +47,7 @@ class Corosync(Plugin):
# (it isnt precise but sufficient)
pattern = r'^\s*(logging.)?logfile:\s*(\S+)$'
try:
- with open("/etc/corosync/corosync.conf") as f:
+ with open(self.path_join("/etc/corosync/corosync.conf"), 'r') as f:
for line in f:
if re.match(pattern, line):
self.add_copy_spec(re.search(pattern, line).group(2))
diff --git a/sos/report/plugins/docker_distribution.py b/sos/report/plugins/docker_distribution.py
index 84222ff7..e760f252 100644
--- a/sos/report/plugins/docker_distribution.py
+++ b/sos/report/plugins/docker_distribution.py
@@ -19,8 +19,9 @@ class DockerDistribution(Plugin):
def setup(self):
self.add_copy_spec('/etc/docker-distribution/')
self.add_journal('docker-distribution')
- if self.path_exists('/etc/docker-distribution/registry/config.yml'):
- with open('/etc/docker-distribution/registry/config.yml') as f:
+ conf = self.path_join('/etc/docker-distribution/registry/config.yml')
+ if self.path_exists(conf):
+ with open(conf) as f:
for line in f:
if 'rootdirectory' in line:
loc = line.split()[1]
diff --git a/sos/report/plugins/ds.py b/sos/report/plugins/ds.py
index addf49e1..43feb21e 100644
--- a/sos/report/plugins/ds.py
+++ b/sos/report/plugins/ds.py
@@ -11,7 +11,6 @@
# See the LICENSE file in the source distribution for further information.
from sos.report.plugins import Plugin, RedHatPlugin
-import os
class DirectoryServer(Plugin, RedHatPlugin):
@@ -47,7 +46,7 @@ class DirectoryServer(Plugin, RedHatPlugin):
try:
for d in self.listdir("/etc/dirsrv"):
if d[0:5] == 'slapd':
- certpath = os.path.join("/etc/dirsrv", d)
+ certpath = self.path_join("/etc/dirsrv", d)
self.add_cmd_output("certutil -L -d %s" % certpath)
self.add_cmd_output("dsctl %s healthcheck" % d)
except OSError:
diff --git a/sos/report/plugins/elastic.py b/sos/report/plugins/elastic.py
index ad9a06ff..da2662bc 100644
--- a/sos/report/plugins/elastic.py
+++ b/sos/report/plugins/elastic.py
@@ -39,7 +39,9 @@ class Elastic(Plugin, IndependentPlugin):
return hostname, port
def setup(self):
- els_config_file = "/etc/elasticsearch/elasticsearch.yml"
+ els_config_file = self.path_join(
+ "/etc/elasticsearch/elasticsearch.yml"
+ )
self.add_copy_spec(els_config_file)
if self.get_option("all_logs"):
diff --git a/sos/report/plugins/etcd.py b/sos/report/plugins/etcd.py
index fd4f67eb..fe017e9f 100644
--- a/sos/report/plugins/etcd.py
+++ b/sos/report/plugins/etcd.py
@@ -62,7 +62,7 @@ class etcd(Plugin, RedHatPlugin):
def get_etcd_url(self):
try:
- with open('/etc/etcd/etcd.conf', 'r') as ef:
+ with open(self.path_join('/etc/etcd/etcd.conf'), 'r') as ef:
for line in ef:
if line.startswith('ETCD_LISTEN_CLIENT_URLS'):
return line.split('=')[1].replace('"', '').strip()
diff --git a/sos/report/plugins/gluster.py b/sos/report/plugins/gluster.py
index a44ffeb7..e518e3d3 100644
--- a/sos/report/plugins/gluster.py
+++ b/sos/report/plugins/gluster.py
@@ -35,9 +35,10 @@ class Gluster(Plugin, RedHatPlugin):
]
for statedump_file in statedump_entries:
statedumps_present = statedumps_present+1
+ _spath = self.path_join(name_dir, statedump_file)
ret = -1
while ret == -1:
- with open(name_dir + '/' + statedump_file, 'r') as sfile:
+ with open(_spath, 'r') as sfile:
last_line = sfile.readlines()[-1]
ret = string.count(last_line, 'DUMP_END_TIME')
diff --git a/sos/report/plugins/jars.py b/sos/report/plugins/jars.py
index 0d3cf37e..4b98684e 100644
--- a/sos/report/plugins/jars.py
+++ b/sos/report/plugins/jars.py
@@ -63,7 +63,7 @@ class Jars(Plugin, RedHatPlugin):
for location in locations:
for dirpath, _, filenames in os.walk(location):
for filename in filenames:
- path = os.path.join(dirpath, filename)
+ path = self.path_join(dirpath, filename)
if Jars.is_jar(path):
jar_paths.append(path)
diff --git a/sos/report/plugins/kdump.py b/sos/report/plugins/kdump.py
index 757c2736..66565664 100644
--- a/sos/report/plugins/kdump.py
+++ b/sos/report/plugins/kdump.py
@@ -40,7 +40,7 @@ class RedHatKDump(KDump, RedHatPlugin):
packages = ('kexec-tools',)
def fstab_parse_fs(self, device):
- with open('/etc/fstab', 'r') as fp:
+ with open(self.path_join('/etc/fstab'), 'r') as fp:
for line in fp:
if line.startswith((device)):
return line.split()[1].rstrip('/')
@@ -50,7 +50,7 @@ class RedHatKDump(KDump, RedHatPlugin):
fs = ""
path = "/var/crash"
- with open('/etc/kdump.conf', 'r') as fp:
+ with open(self.path_join('/etc/kdump.conf'), 'r') as fp:
for line in fp:
if line.startswith("path"):
path = line.split()[1]
diff --git a/sos/report/plugins/libvirt.py b/sos/report/plugins/libvirt.py
index be8120ff..5caa5802 100644
--- a/sos/report/plugins/libvirt.py
+++ b/sos/report/plugins/libvirt.py
@@ -55,7 +55,7 @@ class Libvirt(Plugin, IndependentPlugin):
else:
self.add_copy_spec("/var/log/libvirt")
- if self.path_exists(self.join_sysroot(libvirt_keytab)):
+ if self.path_exists(self.path_join(libvirt_keytab)):
self.add_cmd_output("klist -ket %s" % libvirt_keytab)
self.add_cmd_output("ls -lR /var/lib/libvirt/qemu")
diff --git a/sos/report/plugins/logs.py b/sos/report/plugins/logs.py
index ee6bb98d..606e574a 100644
--- a/sos/report/plugins/logs.py
+++ b/sos/report/plugins/logs.py
@@ -24,15 +24,15 @@ class Logs(Plugin, IndependentPlugin):
since = self.get_option("since")
if self.path_exists('/etc/rsyslog.conf'):
- with open('/etc/rsyslog.conf', 'r') as conf:
+ with open(self.path_join('/etc/rsyslog.conf'), 'r') as conf:
for line in conf.readlines():
if line.startswith('$IncludeConfig'):
confs += glob.glob(line.split()[1])
for conf in confs:
- if not self.path_exists(conf):
+ if not self.path_exists(self.path_join(conf)):
continue
- config = self.join_sysroot(conf)
+ config = self.path_join(conf)
logs += self.do_regex_find_all(r"^\S+\s+(-?\/.*$)\s+", config)
for i in logs:
@@ -60,7 +60,7 @@ class Logs(Plugin, IndependentPlugin):
# - there is some data present, either persistent or runtime only
# - systemd-journald service exists
# otherwise fallback to collecting few well known logfiles directly
- journal = any([self.path_exists(p + "/log/journal/")
+ journal = any([self.path_exists(self.path_join(p, "log/journal/"))
for p in ["/var", "/run"]])
if journal and self.is_service("systemd-journald"):
self.add_journal(since=since, tags='journal_full', priority=100)
diff --git a/sos/report/plugins/manageiq.py b/sos/report/plugins/manageiq.py
index 27ad6ef4..e20c4a2a 100644
--- a/sos/report/plugins/manageiq.py
+++ b/sos/report/plugins/manageiq.py
@@ -58,7 +58,7 @@ class ManageIQ(Plugin, RedHatPlugin):
# Log files to collect from miq_dir/log/
miq_log_dir = os.path.join(miq_dir, "log")
- miq_main_log_files = [
+ miq_main_logs = [
'ansible_tower.log',
'top_output.log',
'evm.log',
@@ -81,16 +81,16 @@ class ManageIQ(Plugin, RedHatPlugin):
self.add_copy_spec(list(self.files))
self.add_copy_spec([
- os.path.join(self.miq_conf_dir, x) for x in self.miq_conf_files
+ self.path_join(self.miq_conf_dir, x) for x in self.miq_conf_files
])
# Collect main log files without size limit.
self.add_copy_spec([
- os.path.join(self.miq_log_dir, x) for x in self.miq_main_log_files
+ self.path_join(self.miq_log_dir, x) for x in self.miq_main_logs
], sizelimit=0)
self.add_copy_spec([
- os.path.join(self.miq_log_dir, x) for x in self.miq_log_files
+ self.path_join(self.miq_log_dir, x) for x in self.miq_log_files
])
self.add_copy_spec([
@@ -101,8 +101,8 @@ class ManageIQ(Plugin, RedHatPlugin):
if environ.get("APPLIANCE_PG_DATA"):
pg_dir = environ.get("APPLIANCE_PG_DATA")
self.add_copy_spec([
- os.path.join(pg_dir, 'pg_log'),
- os.path.join(pg_dir, 'postgresql.conf')
+ self.path_join(pg_dir, 'pg_log'),
+ self.path_join(pg_dir, 'postgresql.conf')
])
# vim: set et ts=4 sw=4 :
diff --git a/sos/report/plugins/numa.py b/sos/report/plugins/numa.py
index 0faef8d2..9094baef 100644
--- a/sos/report/plugins/numa.py
+++ b/sos/report/plugins/numa.py
@@ -9,7 +9,6 @@
# See the LICENSE file in the source distribution for further information.
from sos.report.plugins import Plugin, IndependentPlugin
-import os.path
class Numa(Plugin, IndependentPlugin):
@@ -42,10 +41,10 @@ class Numa(Plugin, IndependentPlugin):
])
self.add_copy_spec([
- os.path.join(numa_path, "node*/meminfo"),
- os.path.join(numa_path, "node*/cpulist"),
- os.path.join(numa_path, "node*/distance"),
- os.path.join(numa_path, "node*/hugepages/hugepages-*/*")
+ self.path_join(numa_path, "node*/meminfo"),
+ self.path_join(numa_path, "node*/cpulist"),
+ self.path_join(numa_path, "node*/distance"),
+ self.path_join(numa_path, "node*/hugepages/hugepages-*/*")
])
# vim: set et ts=4 sw=4 :
diff --git a/sos/report/plugins/openstack_instack.py b/sos/report/plugins/openstack_instack.py
index 7c56c162..5b4f7d41 100644
--- a/sos/report/plugins/openstack_instack.py
+++ b/sos/report/plugins/openstack_instack.py
@@ -68,7 +68,7 @@ class OpenStackInstack(Plugin):
p = uc_config.get(opt)
if p:
if not os.path.isabs(p):
- p = os.path.join('/home/stack', p)
+ p = self.path_join('/home/stack', p)
self.add_copy_spec(p)
except Exception:
pass
diff --git a/sos/report/plugins/openstack_nova.py b/sos/report/plugins/openstack_nova.py
index 53210c48..f840081e 100644
--- a/sos/report/plugins/openstack_nova.py
+++ b/sos/report/plugins/openstack_nova.py
@@ -103,7 +103,7 @@ class OpenStackNova(Plugin):
"nova-scheduler.log*"
]
for novalog in novalogs:
- self.add_copy_spec(os.path.join(novadir, novalog))
+ self.add_copy_spec(self.path_join(novadir, novalog))
self.add_copy_spec([
"/etc/nova/",
diff --git a/sos/report/plugins/openvswitch.py b/sos/report/plugins/openvswitch.py
index 003596c6..179d1532 100644
--- a/sos/report/plugins/openvswitch.py
+++ b/sos/report/plugins/openvswitch.py
@@ -10,7 +10,6 @@
from sos.report.plugins import Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin
-from os.path import join as path_join
from os import environ
import re
@@ -65,7 +64,9 @@ class OpenVSwitch(Plugin):
log_dirs.append(environ.get('OVS_LOGDIR'))
if not all_logs:
- self.add_copy_spec([path_join(ld, '*.log') for ld in log_dirs])
+ self.add_copy_spec([
+ self.path_join(ld, '*.log') for ld in log_dirs
+ ])
else:
self.add_copy_spec(log_dirs)
@@ -76,13 +77,13 @@ class OpenVSwitch(Plugin):
])
self.add_copy_spec([
- path_join('/usr/local/etc/openvswitch', 'conf.db'),
- path_join('/etc/openvswitch', 'conf.db'),
- path_join('/var/lib/openvswitch', 'conf.db'),
+ self.path_join('/usr/local/etc/openvswitch', 'conf.db'),
+ self.path_join('/etc/openvswitch', 'conf.db'),
+ self.path_join('/var/lib/openvswitch', 'conf.db'),
])
ovs_dbdir = environ.get('OVS_DBDIR')
if ovs_dbdir:
- self.add_copy_spec(path_join(ovs_dbdir, 'conf.db'))
+ self.add_copy_spec(self.path_join(ovs_dbdir, 'conf.db'))
self.add_cmd_output([
# The '-t 5' adds an upper bound on how long to wait to connect
diff --git a/sos/report/plugins/origin.py b/sos/report/plugins/origin.py
index f9cc32c1..7df9c019 100644
--- a/sos/report/plugins/origin.py
+++ b/sos/report/plugins/origin.py
@@ -69,20 +69,21 @@ class OpenShiftOrigin(Plugin):
def is_static_etcd(self):
"""Determine if we are on a node running etcd"""
- return self.path_exists(os.path.join(self.static_pod_dir, "etcd.yaml"))
+ return self.path_exists(self.path_join(self.static_pod_dir,
+ "etcd.yaml"))
def is_static_pod_compatible(self):
"""Determine if a node is running static pods"""
return self.path_exists(self.static_pod_dir)
def setup(self):
- bstrap_node_cfg = os.path.join(self.node_base_dir,
- "bootstrap-" + self.node_cfg_file)
- bstrap_kubeconfig = os.path.join(self.node_base_dir,
- "bootstrap.kubeconfig")
- node_certs = os.path.join(self.node_base_dir, "certs", "*")
- node_client_ca = os.path.join(self.node_base_dir, "client-ca.crt")
- admin_cfg = os.path.join(self.master_base_dir, "admin.kubeconfig")
+ bstrap_node_cfg = self.path_join(self.node_base_dir,
+ "bootstrap-" + self.node_cfg_file)
+ bstrap_kubeconfig = self.path_join(self.node_base_dir,
+ "bootstrap.kubeconfig")
+ node_certs = self.path_join(self.node_base_dir, "certs", "*")
+ node_client_ca = self.path_join(self.node_base_dir, "client-ca.crt")
+ admin_cfg = self.path_join(self.master_base_dir, "admin.kubeconfig")
oc_cmd_admin = "%s --config=%s" % ("oc", admin_cfg)
static_pod_logs_cmd = "master-logs"
@@ -92,11 +93,12 @@ class OpenShiftOrigin(Plugin):
self.add_copy_spec([
self.master_cfg,
self.master_env,
- os.path.join(self.master_base_dir, "*.crt"),
+ self.path_join(self.master_base_dir, "*.crt"),
])
if self.is_static_pod_compatible():
- self.add_copy_spec(os.path.join(self.static_pod_dir, "*.yaml"))
+ self.add_copy_spec(self.path_join(self.static_pod_dir,
+ "*.yaml"))
self.add_cmd_output([
"%s api api" % static_pod_logs_cmd,
"%s controllers controllers" % static_pod_logs_cmd,
@@ -177,9 +179,9 @@ class OpenShiftOrigin(Plugin):
node_client_ca,
bstrap_node_cfg,
bstrap_kubeconfig,
- os.path.join(self.node_base_dir, "*.crt"),
- os.path.join(self.node_base_dir, "resolv.conf"),
- os.path.join(self.node_base_dir, "node-dnsmasq.conf"),
+ self.path_join(self.node_base_dir, "*.crt"),
+ self.path_join(self.node_base_dir, "resolv.conf"),
+ self.path_join(self.node_base_dir, "node-dnsmasq.conf"),
])
self.add_journal(units="atomic-openshift-node")
diff --git a/sos/report/plugins/ovirt.py b/sos/report/plugins/ovirt.py
index 1de606be..09647bf1 100644
--- a/sos/report/plugins/ovirt.py
+++ b/sos/report/plugins/ovirt.py
@@ -216,7 +216,7 @@ class Ovirt(Plugin, RedHatPlugin):
"isouploader.conf"
]
for conf_file in passwd_files:
- conf_path = os.path.join("/etc/ovirt-engine", conf_file)
+ conf_path = self.path_join("/etc/ovirt-engine", conf_file)
self.do_file_sub(
conf_path,
r"passwd=(.*)",
diff --git a/sos/report/plugins/ovirt_engine_backup.py b/sos/report/plugins/ovirt_engine_backup.py
index 676e419e..7fb6a5c7 100644
--- a/sos/report/plugins/ovirt_engine_backup.py
+++ b/sos/report/plugins/ovirt_engine_backup.py
@@ -8,7 +8,6 @@
#
# See the LICENSE file in the source distribution for further information.
-import os
from sos.report.plugins import Plugin, RedHatPlugin, PluginOpt
from datetime import datetime
@@ -29,11 +28,11 @@ class oVirtEngineBackup(Plugin, RedHatPlugin):
def setup(self):
now = datetime.now().strftime("%Y%m%d%H%M%S")
- backup_filename = os.path.join(
+ backup_filename = self.path_join(
self.get_option("backupdir"),
"engine-db-backup-%s.tar.gz" % (now)
)
- log_filename = os.path.join(
+ log_filename = self.path_join(
self.get_option("backupdir"),
"engine-db-backup-%s.log" % (now)
)
diff --git a/sos/report/plugins/ovn_central.py b/sos/report/plugins/ovn_central.py
index d6647aad..914eda60 100644
--- a/sos/report/plugins/ovn_central.py
+++ b/sos/report/plugins/ovn_central.py
@@ -42,7 +42,7 @@ class OVNCentral(Plugin):
return
else:
try:
- with open(filename, 'r') as f:
+ with open(self.path_join(filename), 'r') as f:
try:
db = json.load(f)
except Exception:
@@ -71,13 +71,13 @@ class OVNCentral(Plugin):
ovs_rundir = os.environ.get('OVS_RUNDIR')
for pidfile in ['ovnnb_db.pid', 'ovnsb_db.pid', 'ovn-northd.pid']:
self.add_copy_spec([
- os.path.join('/var/lib/openvswitch/ovn', pidfile),
- os.path.join('/usr/local/var/run/openvswitch', pidfile),
- os.path.join('/run/openvswitch/', pidfile),
+ self.path_join('/var/lib/openvswitch/ovn', pidfile),
+ self.path_join('/usr/local/var/run/openvswitch', pidfile),
+ self.path_join('/run/openvswitch/', pidfile),
])
if ovs_rundir:
- self.add_copy_spec(os.path.join(ovs_rundir, pidfile))
+ self.add_copy_spec(self.path_join(ovs_rundir, pidfile))
if self.get_option("all_logs"):
self.add_copy_spec("/var/log/ovn/")
@@ -104,7 +104,7 @@ class OVNCentral(Plugin):
schema_dir = '/usr/share/openvswitch'
- nb_tables = self.get_tables_from_schema(os.path.join(
+ nb_tables = self.get_tables_from_schema(self.path_join(
schema_dir, 'ovn-nb.ovsschema'))
self.add_database_output(nb_tables, nbctl_cmds, 'ovn-nbctl')
@@ -116,7 +116,7 @@ class OVNCentral(Plugin):
format(self.ovn_sbdb_sock_path),
"output": "Leader: self"}
if self.test_predicate(self, pred=SoSPredicate(self, cmd_outputs=co)):
- sb_tables = self.get_tables_from_schema(os.path.join(
+ sb_tables = self.get_tables_from_schema(self.path_join(
schema_dir, 'ovn-sb.ovsschema'), ['Logical_Flow'])
self.add_database_output(sb_tables, sbctl_cmds, 'ovn-sbctl')
cmds += sbctl_cmds
@@ -134,14 +134,14 @@ class OVNCentral(Plugin):
ovs_dbdir = os.environ.get('OVS_DBDIR')
for dbfile in ['ovnnb_db.db', 'ovnsb_db.db']:
self.add_copy_spec([
- os.path.join('/var/lib/openvswitch/ovn', dbfile),
- os.path.join('/usr/local/etc/openvswitch', dbfile),
- os.path.join('/etc/openvswitch', dbfile),
- os.path.join('/var/lib/openvswitch', dbfile),
- os.path.join('/var/lib/ovn/etc', dbfile),
+ self.path_join('/var/lib/openvswitch/ovn', dbfile),
+ self.path_join('/usr/local/etc/openvswitch', dbfile),
+ self.path_join('/etc/openvswitch', dbfile),
+ self.path_join('/var/lib/openvswitch', dbfile),
+ self.path_join('/var/lib/ovn/etc', dbfile)
])
if ovs_dbdir:
- self.add_copy_spec(os.path.join(ovs_dbdir, dbfile))
+ self.add_copy_spec(self.path_join(ovs_dbdir, dbfile))
self.add_journal(units="ovn-northd")
diff --git a/sos/report/plugins/ovn_host.py b/sos/report/plugins/ovn_host.py
index 3742c49f..78604a15 100644
--- a/sos/report/plugins/ovn_host.py
+++ b/sos/report/plugins/ovn_host.py
@@ -35,7 +35,7 @@ class OVNHost(Plugin):
else:
self.add_copy_spec("/var/log/ovn/*.log")
- self.add_copy_spec([os.path.join(pp, pidfile) for pp in pid_paths])
+ self.add_copy_spec([self.path_join(pp, pidfile) for pp in pid_paths])
self.add_copy_spec('/etc/sysconfig/ovn-controller')
@@ -49,7 +49,7 @@ class OVNHost(Plugin):
def check_enabled(self):
return (any([self.path_isfile(
- os.path.join(pp, pidfile)) for pp in pid_paths]) or
+ self.path_join(pp, pidfile)) for pp in pid_paths]) or
super(OVNHost, self).check_enabled())
diff --git a/sos/report/plugins/pacemaker.py b/sos/report/plugins/pacemaker.py
index 497807ff..6ce80881 100644
--- a/sos/report/plugins/pacemaker.py
+++ b/sos/report/plugins/pacemaker.py
@@ -129,7 +129,7 @@ class Pacemaker(Plugin):
class DebianPacemaker(Pacemaker, DebianPlugin, UbuntuPlugin):
def setup(self):
- self.envfile = "/etc/default/pacemaker"
+ self.envfile = self.path_join("/etc/default/pacemaker")
self.setup_crm_shell()
self.setup_pcs()
super(DebianPacemaker, self).setup()
@@ -141,7 +141,7 @@ class DebianPacemaker(Pacemaker, DebianPlugin, UbuntuPlugin):
class RedHatPacemaker(Pacemaker, RedHatPlugin):
def setup(self):
- self.envfile = "/etc/sysconfig/pacemaker"
+ self.envfile = self.path_join("/etc/sysconfig/pacemaker")
self.setup_pcs()
self.add_copy_spec("/etc/sysconfig/sbd")
super(RedHatPacemaker, self).setup()
diff --git a/sos/report/plugins/pcp.py b/sos/report/plugins/pcp.py
index 9707d7a9..ad902332 100644
--- a/sos/report/plugins/pcp.py
+++ b/sos/report/plugins/pcp.py
@@ -41,7 +41,7 @@ class Pcp(Plugin, RedHatPlugin, DebianPlugin):
total_size = 0
for dirpath, dirnames, filenames in os.walk(path):
for f in filenames:
- fp = os.path.join(dirpath, f)
+ fp = self.path_join(dirpath, f)
total_size += os.path.getsize(fp)
return total_size
@@ -86,7 +86,7 @@ class Pcp(Plugin, RedHatPlugin, DebianPlugin):
# unconditionally. Obviously if someone messes up their /etc/pcp.conf
# in a ridiculous way (i.e. setting PCP_SYSCONF_DIR to '/') this will
# break badly.
- var_conf_dir = os.path.join(self.pcp_var_dir, 'config')
+ var_conf_dir = self.path_join(self.pcp_var_dir, 'config')
self.add_copy_spec([
self.pcp_sysconf_dir,
self.pcp_conffile,
@@ -98,10 +98,10 @@ class Pcp(Plugin, RedHatPlugin, DebianPlugin):
# rpms. It does not make up for a lot of size but it contains many
# files
self.add_forbidden_path([
- os.path.join(var_conf_dir, 'pmchart'),
- os.path.join(var_conf_dir, 'pmlogconf'),
- os.path.join(var_conf_dir, 'pmieconf'),
- os.path.join(var_conf_dir, 'pmlogrewrite')
+ self.path_join(var_conf_dir, 'pmchart'),
+ self.path_join(var_conf_dir, 'pmlogconf'),
+ self.path_join(var_conf_dir, 'pmieconf'),
+ self.path_join(var_conf_dir, 'pmlogrewrite')
])
# Take PCP_LOG_DIR/pmlogger/`hostname` + PCP_LOG_DIR/pmmgr/`hostname`
@@ -121,13 +121,13 @@ class Pcp(Plugin, RedHatPlugin, DebianPlugin):
# we would collect everything
if self.pcp_hostname != '':
# collect pmmgr logs up to 'pmmgrlogs' size limit
- path = os.path.join(self.pcp_log_dir, 'pmmgr',
- self.pcp_hostname, '*')
+ path = self.path_join(self.pcp_log_dir, 'pmmgr',
+ self.pcp_hostname, '*')
self.add_copy_spec(path, sizelimit=self.sizelimit, tailit=False)
# collect newest pmlogger logs up to 'pmloggerfiles' count
files_collected = 0
- path = os.path.join(self.pcp_log_dir, 'pmlogger',
- self.pcp_hostname, '*')
+ path = self.path_join(self.pcp_log_dir, 'pmlogger',
+ self.pcp_hostname, '*')
pmlogger_ls = self.exec_cmd("ls -t1 %s" % path)
if pmlogger_ls['status'] == 0:
for line in pmlogger_ls['output'].splitlines():
@@ -138,15 +138,15 @@ class Pcp(Plugin, RedHatPlugin, DebianPlugin):
self.add_copy_spec([
# Collect PCP_LOG_DIR/pmcd and PCP_LOG_DIR/NOTICES
- os.path.join(self.pcp_log_dir, 'pmcd'),
- os.path.join(self.pcp_log_dir, 'NOTICES*'),
+ self.path_join(self.pcp_log_dir, 'pmcd'),
+ self.path_join(self.pcp_log_dir, 'NOTICES*'),
# Collect PCP_VAR_DIR/pmns
- os.path.join(self.pcp_var_dir, 'pmns'),
+ self.path_join(self.pcp_var_dir, 'pmns'),
# Also collect any other log and config files
# (as suggested by fche)
- os.path.join(self.pcp_log_dir, '*/*.log*'),
- os.path.join(self.pcp_log_dir, '*/*/*.log*'),
- os.path.join(self.pcp_log_dir, '*/*/config*')
+ self.path_join(self.pcp_log_dir, '*/*.log*'),
+ self.path_join(self.pcp_log_dir, '*/*/*.log*'),
+ self.path_join(self.pcp_log_dir, '*/*/config*')
])
# Collect a summary for the current day
diff --git a/sos/report/plugins/postfix.py b/sos/report/plugins/postfix.py
index 8f584430..3ca0c4ad 100644
--- a/sos/report/plugins/postfix.py
+++ b/sos/report/plugins/postfix.py
@@ -41,7 +41,7 @@ class Postfix(Plugin):
]
fp = []
try:
- with open('/etc/postfix/main.cf', 'r') as cffile:
+ with open(self.path_join('/etc/postfix/main.cf'), 'r') as cffile:
for line in cffile.readlines():
# ignore comments and take the first word after '='
if line.startswith('#'):
diff --git a/sos/report/plugins/postgresql.py b/sos/report/plugins/postgresql.py
index bec0b019..00824db7 100644
--- a/sos/report/plugins/postgresql.py
+++ b/sos/report/plugins/postgresql.py
@@ -124,7 +124,7 @@ class RedHatPostgreSQL(PostgreSQL, SCLPlugin):
# copy PG_VERSION and postmaster.opts
for f in ["PG_VERSION", "postmaster.opts"]:
- self.add_copy_spec(os.path.join(_dir, "data", f))
+ self.add_copy_spec(self.path_join(_dir, "data", f))
class DebianPostgreSQL(PostgreSQL, DebianPlugin, UbuntuPlugin):
diff --git a/sos/report/plugins/powerpc.py b/sos/report/plugins/powerpc.py
index 4fb4f87c..50f88650 100644
--- a/sos/report/plugins/powerpc.py
+++ b/sos/report/plugins/powerpc.py
@@ -22,7 +22,7 @@ class PowerPC(Plugin, IndependentPlugin):
def setup(self):
try:
- with open('/proc/cpuinfo', 'r') as fp:
+ with open(self.path_join('/proc/cpuinfo'), 'r') as fp:
contents = fp.read()
ispSeries = "pSeries" in contents
isPowerNV = "PowerNV" in contents
diff --git a/sos/report/plugins/processor.py b/sos/report/plugins/processor.py
index 2df2dc9a..c3d8930c 100644
--- a/sos/report/plugins/processor.py
+++ b/sos/report/plugins/processor.py
@@ -7,7 +7,6 @@
# See the LICENSE file in the source distribution for further information.
from sos.report.plugins import Plugin, IndependentPlugin
-import os
class Processor(Plugin, IndependentPlugin):
@@ -41,7 +40,7 @@ class Processor(Plugin, IndependentPlugin):
# cumulative directory size exceeds 25MB or even 100MB.
cdirs = self.listdir('/sys/devices/system/cpu')
self.add_copy_spec([
- os.path.join('/sys/devices/system/cpu', cdir) for cdir in cdirs
+ self.path_join('/sys/devices/system/cpu', cdir) for cdir in cdirs
])
self.add_cmd_output([
diff --git a/sos/report/plugins/python.py b/sos/report/plugins/python.py
index e2ab39ab..a8ec0cd8 100644
--- a/sos/report/plugins/python.py
+++ b/sos/report/plugins/python.py
@@ -68,9 +68,9 @@ class RedHatPython(Python, RedHatPlugin):
]
for py_path in py_paths:
- for root, _, files in os.walk(py_path):
+ for root, _, files in os.walk(self.path_join(py_path)):
for file_ in files:
- filepath = os.path.join(root, file_)
+ filepath = self.path_join(root, file_)
if filepath.endswith('.py'):
try:
with open(filepath, 'rb') as f:
diff --git a/sos/report/plugins/sar.py b/sos/report/plugins/sar.py
index 669f5d7b..b60005b1 100644
--- a/sos/report/plugins/sar.py
+++ b/sos/report/plugins/sar.py
@@ -8,7 +8,6 @@
from sos.report.plugins import (Plugin, RedHatPlugin, DebianPlugin,
UbuntuPlugin, PluginOpt)
-import os
import re
@@ -27,7 +26,7 @@ class Sar(Plugin,):
]
def setup(self):
- self.add_copy_spec(os.path.join(self.sa_path, '*'),
+ self.add_copy_spec(self.path_join(self.sa_path, '*'),
sizelimit=0 if self.get_option("all_sar") else None,
tailit=False)
@@ -44,7 +43,7 @@ class Sar(Plugin,):
# as option for sadc
for fname in dir_list:
if sa_regex.match(fname):
- sa_data_path = os.path.join(self.sa_path, fname)
+ sa_data_path = self.path_join(self.sa_path, fname)
sar_filename = 'sar' + fname[2:]
if sar_filename not in dir_list:
sar_cmd = 'sh -c "sar -A -f %s"' % sa_data_path
diff --git a/sos/report/plugins/sos_extras.py b/sos/report/plugins/sos_extras.py
index ffde4138..55bc4dc0 100644
--- a/sos/report/plugins/sos_extras.py
+++ b/sos/report/plugins/sos_extras.py
@@ -58,7 +58,7 @@ class SosExtras(Plugin, IndependentPlugin):
for path, dirlist, filelist in os.walk(self.extras_dir):
for f in filelist:
- _file = os.path.join(path, f)
+ _file = self.path_join(path, f)
self._log_warn("Collecting data from extras file %s" % _file)
try:
for line in open(_file).read().splitlines():
diff --git a/sos/report/plugins/ssh.py b/sos/report/plugins/ssh.py
index 971cda8b..9ac9dec0 100644
--- a/sos/report/plugins/ssh.py
+++ b/sos/report/plugins/ssh.py
@@ -9,7 +9,6 @@
# See the LICENSE file in the source distribution for further information.
from sos.report.plugins import Plugin, IndependentPlugin
-import os.path
class Ssh(Plugin, IndependentPlugin):
@@ -42,7 +41,7 @@ class Ssh(Plugin, IndependentPlugin):
try:
for sshcfg in sshcfgs:
tag = sshcfg.split('/')[-1]
- with open(sshcfg, 'r') as cfgfile:
+ with open(self.path_join(sshcfg), 'r') as cfgfile:
for line in cfgfile:
# skip empty lines and comments
if len(line.split()) == 0 or line.startswith('#'):
@@ -65,7 +64,7 @@ class Ssh(Plugin, IndependentPlugin):
if users_data['status']:
# If getent fails, fallback to just reading /etc/passwd
try:
- with open('/etc/passwd') as passwd_file:
+ with open(self.path_join('/etc/passwd')) as passwd_file:
users_data_lines = passwd_file.readlines()
except Exception:
# If we can't read /etc/passwd, then there's something wrong.
@@ -77,7 +76,7 @@ class Ssh(Plugin, IndependentPlugin):
# Read the home paths of users in the system and check the ~/.ssh dirs
for usr_line in users_data_lines:
try:
- home_dir = os.path.join(usr_line.split(':')[5], '.ssh')
+ home_dir = self.path_join(usr_line.split(':')[5], '.ssh')
if self.path_isdir(home_dir):
self.add_cmd_output('ls -laZ {}'.format(home_dir))
except IndexError:
diff --git a/sos/report/plugins/unpackaged.py b/sos/report/plugins/unpackaged.py
index 9205e53f..772b1d1f 100644
--- a/sos/report/plugins/unpackaged.py
+++ b/sos/report/plugins/unpackaged.py
@@ -40,7 +40,7 @@ class Unpackaged(Plugin, RedHatPlugin):
for e in exclude:
dirs[:] = [d for d in dirs if d not in e]
for name in files:
- path = os.path.join(root, name)
+ path = self.path_join(root, name)
try:
if stat.S_ISLNK(os.lstat(path).st_mode):
path = Path(path).resolve()
@@ -49,7 +49,7 @@ class Unpackaged(Plugin, RedHatPlugin):
file_list.append(os.path.realpath(path))
for name in dirs:
file_list.append(os.path.realpath(
- os.path.join(root, name)))
+ self.path_join(root, name)))
return file_list
diff --git a/sos/report/plugins/watchdog.py b/sos/report/plugins/watchdog.py
index 1bf3f4cb..bf2dc9cb 100644
--- a/sos/report/plugins/watchdog.py
+++ b/sos/report/plugins/watchdog.py
@@ -11,7 +11,6 @@
from sos.report.plugins import Plugin, RedHatPlugin, PluginOpt
from glob import glob
-import os
class Watchdog(Plugin, RedHatPlugin):
@@ -56,8 +55,8 @@ class Watchdog(Plugin, RedHatPlugin):
Collect configuration files, custom executables for test-binary
and repair-binary, and stdout/stderr logs.
"""
- conf_file = self.get_option('conf_file')
- log_dir = '/var/log/watchdog'
+ conf_file = self.path_join(self.get_option('conf_file'))
+ log_dir = self.path_join('/var/log/watchdog')
# Get service configuration and sysconfig files
self.add_copy_spec([
@@ -80,15 +79,15 @@ class Watchdog(Plugin, RedHatPlugin):
self._log_warn("Could not read %s: %s" % (conf_file, ex))
if self.get_option('all_logs'):
- log_files = glob(os.path.join(log_dir, '*'))
+ log_files = glob(self.path_join(log_dir, '*'))
else:
- log_files = (glob(os.path.join(log_dir, '*.stdout')) +
- glob(os.path.join(log_dir, '*.stderr')))
+ log_files = (glob(self.path_join(log_dir, '*.stdout')) +
+ glob(self.path_join(log_dir, '*.stderr')))
self.add_copy_spec(log_files)
# Get output of "wdctl <device>" for each /dev/watchdog*
- for dev in glob('/dev/watchdog*'):
+ for dev in glob(self.path_join('/dev/watchdog*')):
self.add_cmd_output("wdctl %s" % dev)
# vim: set et ts=4 sw=4 :
diff --git a/sos/report/plugins/yum.py b/sos/report/plugins/yum.py
index 148464cb..e5256642 100644
--- a/sos/report/plugins/yum.py
+++ b/sos/report/plugins/yum.py
@@ -61,7 +61,7 @@ class Yum(Plugin, RedHatPlugin):
if not p.endswith(".py"):
continue
plugins = plugins + " " if len(plugins) else ""
- plugins = plugins + os.path.join(YUM_PLUGIN_PATH, p)
+ plugins = plugins + self.path_join(YUM_PLUGIN_PATH, p)
if len(plugins):
self.add_cmd_output("rpm -qf %s" % plugins,
suggest_filename="plugin-packages")