aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJake Hunsaker <jhunsake@redhat.com>2021-09-01 15:54:55 -0400
committerJake Hunsaker <jhunsake@redhat.com>2021-09-13 10:47:04 -0400
commitf3f3e763d7c31b7b7cafdf8dd4dab87056fb7696 (patch)
treefe15b2373e542e0331068a4437eafae636849238
parent9b119f860eaec089f7ef884ff39c42589a662994 (diff)
downloadsos-f3f3e763d7c31b7b7cafdf8dd4dab87056fb7696.tar.gz
[cleaner] Add support for Insights client archives
Adds a new type of `SoSObfuscationArchive` to add support for obfuscating archives generated by the Insights project. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
-rw-r--r--man/en/sos-clean.11
-rw-r--r--sos/cleaner/__init__.py4
-rw-r--r--sos/cleaner/archives/insights.py42
3 files changed, 46 insertions, 1 deletions
diff --git a/man/en/sos-clean.1 b/man/en/sos-clean.1
index 54026713..358ec0cb 100644
--- a/man/en/sos-clean.1
+++ b/man/en/sos-clean.1
@@ -105,6 +105,7 @@ The following are accepted values for this option:
\fBauto\fR Automatically detect the archive type
\fBreport\fR An archive generated by \fBsos report\fR
\fBcollect\fR An archive generated by \fBsos collect\fR
+ \fBinsights\fR An archive generated by the \fBinsights-client\fR package
The following may also be used, however note that these do not attempt to pre-load
any information from the archives into the parsers. This means that, among other limitations,
diff --git a/sos/cleaner/__init__.py b/sos/cleaner/__init__.py
index 6d2eb483..3e08aa28 100644
--- a/sos/cleaner/__init__.py
+++ b/sos/cleaner/__init__.py
@@ -29,6 +29,7 @@ from sos.cleaner.archives.sos import (SoSReportArchive, SoSReportDirectory,
SoSCollectorArchive,
SoSCollectorDirectory)
from sos.cleaner.archives.generic import DataDirArchive, TarballArchive
+from sos.cleaner.archives.insights import InsightsArchive
from sos.utilities import get_human_readable
from textwrap import fill
@@ -100,6 +101,7 @@ class SoSCleaner(SoSComponent):
SoSReportArchive,
SoSCollectorDirectory,
SoSCollectorArchive,
+ InsightsArchive,
# make sure these two are always last as they are fallbacks
DataDirArchive,
TarballArchive
@@ -194,7 +196,7 @@ third party.
help='The directory or archive to obfuscate')
clean_grp.add_argument('--archive-type', default='auto',
choices=['auto', 'report', 'collect',
- 'data-dir', 'tarball'],
+ 'insights', 'data-dir', 'tarball'],
help=('Specify what kind of archive the target '
'was generated as'))
clean_grp.add_argument('--domains', action='extend', default=[],
diff --git a/sos/cleaner/archives/insights.py b/sos/cleaner/archives/insights.py
new file mode 100644
index 00000000..dab48b16
--- /dev/null
+++ b/sos/cleaner/archives/insights.py
@@ -0,0 +1,42 @@
+# Copyright 2021 Red Hat, Inc. Jake Hunsaker <jhunsake@redhat.com>
+
+# This file is part of the sos project: https://github.com/sosreport/sos
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions of
+# version 2 of the GNU General Public License.
+#
+# See the LICENSE file in the source distribution for further information.
+
+
+from sos.cleaner.archives import SoSObfuscationArchive
+
+import tarfile
+
+
+class InsightsArchive(SoSObfuscationArchive):
+ """This class represents archives generated by the insights-client utility
+ for RHEL systems.
+ """
+
+ type_name = 'insights'
+ description = 'insights-client archive'
+
+ prep_files = {
+ 'hostname': 'data/insights_commands/hostname_-f',
+ 'ip': 'data/insights_commands/ip_addr',
+ 'mac': 'data/insights_commands/ip_addr'
+ }
+
+ @classmethod
+ def check_is_type(cls, arc_path):
+ try:
+ return tarfile.is_tarfile(arc_path) and 'insights-' in arc_path
+ except Exception:
+ return False
+
+ def get_archive_root(self):
+ top = self.archive_path.split('/')[-1].split('.tar')[0]
+ if self.tarobj.firstmember.name == '.':
+ top = './' + top
+ return top