diff -Nru sosreport-4.5.3ubuntu2/.cirrus.yml sosreport-4.5.4ubuntu1/.cirrus.yml --- sosreport-4.5.3ubuntu2/.cirrus.yml 2023-04-28 22:46:21.000000000 +0530 +++ sosreport-4.5.4ubuntu1/.cirrus.yml 2023-05-26 22:32:49.000000000 +0530 @@ -3,7 +3,7 @@ # Main environment vars to set for all tasks env: - FEDORA_NAME: "fedora-38-beta" + FEDORA_NAME: "fedora-38" FEDORA_PRIOR_NAME: "fedora-37" DEBIAN_NAME: "debian-11" @@ -25,7 +25,7 @@ CENTOS_9_IMAGE_NAME: "centos-stream-9-v20221102" CENTOS_8_IMAGE_NAME: "centos-stream-8-v20230306" DEBIAN_IMAGE_NAME: "debian-11-bullseye-v20230306" - FEDORA_IMAGE_NAME: "fedora-cloud-base-gcp-38-beta-1-3-x86-64" + FEDORA_IMAGE_NAME: "fedora-cloud-base-gcp-38-1-6-x86-64" FEDORA_PRIOR_IMAGE_NAME: "fedora-cloud-base-gcp-37-1-7-x86-64" UBUNTU_IMAGE_NAME: "ubuntu-2204-jammy-v20230302" UBUNTU_PRIOR_IMAGE_NAME: "ubuntu-2004-focal-v20230302" diff -Nru sosreport-4.5.3ubuntu2/debian/changelog sosreport-4.5.4ubuntu1/debian/changelog --- sosreport-4.5.3ubuntu2/debian/changelog 2023-05-05 18:07:54.000000000 +0530 +++ sosreport-4.5.4ubuntu1/debian/changelog 2023-06-13 12:45:42.000000000 +0530 @@ -1,3 +1,21 @@ +sosreport (4.5.4ubuntu1) mantic; urgency=medium + + * New 4.5.4 upstream. (LP: #2022915) + + * For more details, full release note is available here: + - https://github.com/sosreport/sos/releases/tag/4.5.4 + + * d/rules: + - skip running unittests/policy_tests.py due to the avocado dependency + + * Remaining patches: + - d/p/0001-debian-change-tmp-dir-location.patch + + * New patches: + - d/p/0002-regex-flags.patch + + -- Nikhil Kshirsagar Tue, 13 Jun 2023 07:15:42 +0000 + sosreport (4.5.3ubuntu2) mantic; urgency=medium * d/control: diff -Nru sosreport-4.5.3ubuntu2/debian/patches/0002-regex-flags.patch sosreport-4.5.4ubuntu1/debian/patches/0002-regex-flags.patch --- sosreport-4.5.3ubuntu2/debian/patches/0002-regex-flags.patch 1970-01-01 05:30:00.000000000 +0530 +++ sosreport-4.5.4ubuntu1/debian/patches/0002-regex-flags.patch 2023-06-13 12:44:25.000000000 +0530 @@ -0,0 +1,35 @@ +Description: Fix do_file_private_sub() bug related to regex flags +Origin: upstream +Bug: https://github.com/sosreport/sos/issues/3261 +Applied-Upstream: https://github.com/sosreport/sos/pull/3263 +--- +This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ +Index: sos-4.5.4/sos/report/plugins/__init__.py +=================================================================== +--- sos-4.5.4.orig/sos/report/plugins/__init__.py ++++ sos-4.5.4/sos/report/plugins/__init__.py +@@ -1274,7 +1274,12 @@ class Plugin(): + """ + try: + path = self._get_dest_for_srcpath(srcpath) +- pattern = regexp.pattern if hasattr(regexp, "pattern") else regexp ++ if hasattr(regexp, "pattern"): ++ pattern = regexp.pattern ++ flags = regexp.flags | re.IGNORECASE ++ else: ++ pattern = regexp ++ flags = re.IGNORECASE + self._log_debug("substituting scrpath '%s'" % srcpath) + self._log_debug("substituting '%s' for '%s' in '%s'" + % (subst, pattern, path)) +@@ -1284,8 +1289,8 @@ class Plugin(): + content = readable.read() + if not isinstance(content, str): + content = content.decode('utf8', 'ignore') +- result, replacements = re.subn(regexp, subst, content, +- flags=re.IGNORECASE) ++ result, replacements = re.subn(pattern, subst, content, ++ flags=flags) + if replacements: + self.archive.add_string(result, srcpath) + else: diff -Nru sosreport-4.5.3ubuntu2/debian/patches/series sosreport-4.5.4ubuntu1/debian/patches/series --- sosreport-4.5.3ubuntu2/debian/patches/series 2022-08-17 14:08:08.000000000 +0530 +++ sosreport-4.5.4ubuntu1/debian/patches/series 2023-06-13 12:43:03.000000000 +0530 @@ -1 +1,2 @@ 0001-debian-change-tmp-dir-location.patch +0002-regex-flags.patch diff -Nru sosreport-4.5.3ubuntu2/debian/rules sosreport-4.5.4ubuntu1/debian/rules --- sosreport-4.5.3ubuntu2/debian/rules 2022-02-16 09:36:06.000000000 +0530 +++ sosreport-4.5.4ubuntu1/debian/rules 2023-06-13 12:45:42.000000000 +0530 @@ -12,4 +12,4 @@ rm -rf debian/sosreport/usr/config override_dh_auto_test: - nosetests3 -v --with-cover --cover-package=sos tests/unittests + nosetests3 -v --with-cover --cover-package=sos tests/unittests --ignore-files="policy_tests\.py" diff -Nru sosreport-4.5.3ubuntu2/docs/conf.py sosreport-4.5.4ubuntu1/docs/conf.py --- sosreport-4.5.3ubuntu2/docs/conf.py 2023-04-28 22:46:21.000000000 +0530 +++ sosreport-4.5.4ubuntu1/docs/conf.py 2023-05-26 22:32:49.000000000 +0530 @@ -59,9 +59,9 @@ # built documents. # # The short X.Y version. -version = '4.5.3' +version = '4.5.4' # The full version, including alpha/beta/rc tags. -release = '4.5.3' +release = '4.5.4' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff -Nru sosreport-4.5.3ubuntu2/sos/collector/clusters/juju.py sosreport-4.5.4ubuntu1/sos/collector/clusters/juju.py --- sosreport-4.5.3ubuntu2/sos/collector/clusters/juju.py 2023-04-28 22:46:21.000000000 +0530 +++ sosreport-4.5.4ubuntu1/sos/collector/clusters/juju.py 2023-05-26 22:32:49.000000000 +0530 @@ -8,6 +8,7 @@ # # See the LICENSE file in the source distribution for further information. +import logging import json import re @@ -45,6 +46,7 @@ self.apps = {} self.units = {} self.machines = {} + self.ui_log = logging.getLogger("sos") def add_principals(self, juju_status): """Adds principal units to index.""" @@ -69,7 +71,21 @@ for app, app_info in juju_status["applications"].items(): subordinate_to = app_info.get("subordinate-to", []) for parent in subordinate_to: + # If parent is missing + if not self.apps.get(parent): + self.ui_log.warning( + f"Principal charm {parent} is missing" + ) + continue self.apps[app].extend(self.apps[parent]) + + # If parent's units is missing + if "units" not in juju_status["applications"][parent]: + self.ui_log.warning( + f"Principal charm {parent} is missing units" + ) + continue + units = juju_status["applications"][parent]["units"] for unit, unit_info in units.items(): node = f"{self.model_name}:{unit_info['machine']}" diff -Nru sosreport-4.5.3ubuntu2/sos/collector/__init__.py sosreport-4.5.4ubuntu1/sos/collector/__init__.py --- sosreport-4.5.3ubuntu2/sos/collector/__init__.py 2023-04-28 22:46:21.000000000 +0530 +++ sosreport-4.5.4ubuntu1/sos/collector/__init__.py 2023-05-26 22:32:49.000000000 +0530 @@ -1186,11 +1186,18 @@ def collect(self): """ For each node, start a collection thread and then tar all collected sosreports """ - if self.primary.connected and not self.cluster.strict_node_list: + filters = set([self.primary.address, self.primary.hostname]) + # add primary if: + # - we are connected to it and + # - its hostname is in node_list, or + # - we dont forcibly remove local host from collection + # (i.e. strict_node_list=False) + if self.primary.connected and \ + (filters.intersection(set(self.node_list)) or + not self.cluster.strict_node_list): self.client_list.append(self.primary) self.ui_log.info("\nConnecting to nodes...") - filters = [self.primary.address, self.primary.hostname] nodes = [(n, None) for n in self.node_list if n not in filters] if self.opts.password_per_node: diff -Nru sosreport-4.5.3ubuntu2/sos/component.py sosreport-4.5.4ubuntu1/sos/component.py --- sosreport-4.5.3ubuntu2/sos/component.py 2023-04-28 22:46:21.000000000 +0530 +++ sosreport-4.5.4ubuntu1/sos/component.py 2023-05-26 22:32:49.000000000 +0530 @@ -346,7 +346,9 @@ def add_ui_log_to_stdout(self): ui_console = logging.StreamHandler(sys.stdout) ui_console.setFormatter(logging.Formatter('%(message)s')) - ui_console.setLevel(logging.INFO) + ui_console.setLevel( + logging.DEBUG if self.opts.verbosity > 1 else logging.INFO + ) self.ui_log.addHandler(ui_console) def set_loggers_verbosity(self, verbosity): @@ -392,7 +394,9 @@ # ui log self.ui_log = logging.getLogger('sos_ui') - self.ui_log.setLevel(logging.INFO) + self.ui_log.setLevel( + logging.DEBUG if self.opts.verbosity > 1 else logging.INFO + ) if not self.check_listing_options(): self.sos_ui_log_file = self.get_temp_file() ui_fhandler = logging.StreamHandler(self.sos_ui_log_file) diff -Nru sosreport-4.5.3ubuntu2/sos/__init__.py sosreport-4.5.4ubuntu1/sos/__init__.py --- sosreport-4.5.3ubuntu2/sos/__init__.py 2023-04-28 22:46:21.000000000 +0530 +++ sosreport-4.5.4ubuntu1/sos/__init__.py 2023-05-26 22:32:49.000000000 +0530 @@ -14,7 +14,7 @@ This module houses the i18n setup and message function. The default is to use gettext to internationalize messages. """ -__version__ = "4.5.3" +__version__ = "4.5.4" import os import sys diff -Nru sosreport-4.5.3ubuntu2/sos/policies/distros/azure.py sosreport-4.5.4ubuntu1/sos/policies/distros/azure.py --- sosreport-4.5.3ubuntu2/sos/policies/distros/azure.py 1970-01-01 05:30:00.000000000 +0530 +++ sosreport-4.5.4ubuntu1/sos/policies/distros/azure.py 2023-05-26 22:32:49.000000000 +0530 @@ -0,0 +1,45 @@ +# Copyright (C) Eric Desrochers + +# 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.policies.distros.redhat import RedHatPolicy, OS_RELEASE +import os + + +class AzurePolicy(RedHatPolicy): + + distro = "Azure Linux" + vendor = "Microsoft" + vendor_urls = [ + ('Distribution Website', 'https://github.com/microsoft/CBL-Mariner') + ] + + def __init__(self, sysroot=None, init=None, probe_runtime=True, + remote_exec=None): + super(AzurePolicy, self).__init__(sysroot=sysroot, init=init, + probe_runtime=probe_runtime, + remote_exec=remote_exec) + + @classmethod + def check(cls, remote=''): + + if remote: + return cls.distro in remote + + if not os.path.exists(OS_RELEASE): + return False + + with open(OS_RELEASE, 'r') as f: + for line in f: + if line.startswith('NAME'): + if 'Common Base Linux Mariner' in line: + return True + return False + +# vim: set et ts=4 sw=4 : diff -Nru sosreport-4.5.3ubuntu2/sos/policies/distros/mariner.py sosreport-4.5.4ubuntu1/sos/policies/distros/mariner.py --- sosreport-4.5.3ubuntu2/sos/policies/distros/mariner.py 2023-04-28 22:46:21.000000000 +0530 +++ sosreport-4.5.4ubuntu1/sos/policies/distros/mariner.py 1970-01-01 05:30:00.000000000 +0530 @@ -1,45 +0,0 @@ -# Copyright (C) Eric Desrochers - -# 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.policies.distros.redhat import RedHatPolicy, OS_RELEASE -import os - - -class MarinerPolicy(RedHatPolicy): - - distro = "CBL-Mariner" - vendor = "Microsoft" - vendor_urls = [ - ('Distribution Website', 'https://github.com/microsoft/CBL-Mariner') - ] - - def __init__(self, sysroot=None, init=None, probe_runtime=True, - remote_exec=None): - super(MarinerPolicy, self).__init__(sysroot=sysroot, init=init, - probe_runtime=probe_runtime, - remote_exec=remote_exec) - - @classmethod - def check(cls, remote=''): - - if remote: - return cls.distro in remote - - if not os.path.exists(OS_RELEASE): - return False - - with open(OS_RELEASE, 'r') as f: - for line in f: - if line.startswith('NAME'): - if 'Common Base Linux Mariner' in line: - return True - return False - -# vim: set et ts=4 sw=4 : diff -Nru sosreport-4.5.3ubuntu2/sos/policies/distros/redhat.py sosreport-4.5.4ubuntu1/sos/policies/distros/redhat.py --- sosreport-4.5.3ubuntu2/sos/policies/distros/redhat.py 2023-04-28 22:46:21.000000000 +0530 +++ sosreport-4.5.4ubuntu1/sos/policies/distros/redhat.py 2023-05-26 22:32:49.000000000 +0530 @@ -338,6 +338,10 @@ _user = self.get_upload_user() _token = json.loads(ret.text)['token'] else: + self.ui_log.debug( + f"DEBUG: auth attempt failed (status: {ret.status_code}): " + f"{ret.json()}" + ) self.ui_log.error( "Unable to retrieve Red Hat auth token using provided " "credentials. Will try anonymous." @@ -354,6 +358,12 @@ _(f"User {_user} used for anonymous upload. Please inform " f"your support engineer so they may retrieve the data.") ) + else: + self.ui_log.debug( + f"DEBUG: anonymous request failed (status: " + f"{anon.status_code}): {anon.json()}" + ) + if _user and _token: return super(RHELPolicy, self).upload_sftp(user=_user, password=_token) diff -Nru sosreport-4.5.3ubuntu2/sos/policies/distros/ubuntu.py sosreport-4.5.4ubuntu1/sos/policies/distros/ubuntu.py --- sosreport-4.5.3ubuntu2/sos/policies/distros/ubuntu.py 2023-04-28 22:46:21.000000000 +0530 +++ sosreport-4.5.4ubuntu1/sos/policies/distros/ubuntu.py 2023-05-26 22:32:49.000000000 +0530 @@ -9,6 +9,10 @@ from sos.report.plugins import UbuntuPlugin from sos.policies.distros.debian import DebianPolicy +from sos.policies.package_managers.snap import SnapPackageManager +from sos.policies.package_managers.dpkg import DpkgPackageManager +from sos.policies.package_managers import MultiPackageManager + import os @@ -31,6 +35,17 @@ super(UbuntuPolicy, self).__init__(sysroot=sysroot, init=init, probe_runtime=probe_runtime, remote_exec=remote_exec) + + self.package_manager = MultiPackageManager( + primary=DpkgPackageManager, + fallbacks=[SnapPackageManager], + chroot=self.sysroot, + remote_exec=remote_exec) + + if self.package_manager.pkg_by_name( + 'sosreport')['pkg_manager'] == 'snap': + self.sos_bin_path = '/snap/bin' + self.valid_subclasses += [UbuntuPlugin] @classmethod diff -Nru sosreport-4.5.3ubuntu2/sos/policies/package_managers/dpkg.py sosreport-4.5.4ubuntu1/sos/policies/package_managers/dpkg.py --- sosreport-4.5.3ubuntu2/sos/policies/package_managers/dpkg.py 2023-04-28 22:46:21.000000000 +0530 +++ sosreport-4.5.4ubuntu1/sos/policies/package_managers/dpkg.py 2023-05-26 22:32:49.000000000 +0530 @@ -15,10 +15,18 @@ """Subclass for dpkg-based distrubitons """ - query_command = "dpkg-query -W -f='${Package}|${Version}\\n'" + query_command = "dpkg-query -W -f='${Package}|${Version}|${Status}\\n'" query_path_command = "dpkg -S" verify_command = "dpkg --verify" verify_filter = "" + def _parse_pkg_list(self, pkg_list): + for pkg in pkg_list.splitlines(): + if '|' not in pkg: + continue + name, version, status = pkg.split('|') + if 'deinstall' in status: + continue + yield (name, version, None) # vim: set et ts=4 sw=4 : diff -Nru sosreport-4.5.3ubuntu2/sos/policies/package_managers/__init__.py sosreport-4.5.4ubuntu1/sos/policies/package_managers/__init__.py --- sosreport-4.5.3ubuntu2/sos/policies/package_managers/__init__.py 2023-04-28 22:46:21.000000000 +0530 +++ sosreport-4.5.4ubuntu1/sos/policies/package_managers/__init__.py 2023-05-26 22:32:49.000000000 +0530 @@ -53,19 +53,11 @@ chroot = None files = None - def __init__(self, chroot=None, query_command=None, verify_command=None, - verify_filter=None, files_command=None, - query_path_command=None, remote_exec=None): + def __init__(self, chroot=None, remote_exec=None): self._packages = {} self.files = [] self.remote_exec = remote_exec - self.query_command = query_command or self.query_command - self.verify_command = verify_command or self.verify_command - self.verify_filter = verify_filter or self.verify_filter - self.files_command = files_command or self.files_command - self.query_path_command = query_path_command or self.query_path_command - if chroot: self.chroot = chroot @@ -75,6 +67,10 @@ self._generate_pkg_list() return self._packages + @property + def manager_name(self): + return self.__class__.__name__.lower().split('package')[0] + def exec_cmd(self, command, timeout=30, need_root=False, env=None, get_pty=False, chroot=None): """ @@ -158,32 +154,44 @@ except Exception: return None + def _parse_pkg_list(self, pkg_list): + """ + Using the output of `query_command`, build the _packages dict. + + This should be overridden by distinct package managers and be a + generator for _generate_pkg_list which will insert the packages into + the _packages dict. + + This method should yield a tuple of name, version, release for each + package parsed. If the package manager or distribution does not use a + release field, set it to None. + + :param pkg_list: The output of the result of `query_command` + :type pkg_list: ``str`` + """ + raise NotImplementedError + def _generate_pkg_list(self): """Generates a dictionary of packages for internal use by the package manager in the format:: {'package_name': {'name': 'package_name', - 'version': 'major.minor.version'}} + 'version': 'major.minor.version', + 'release': 'package release' or None, + 'pkg_manager': 'package manager name'}} """ if self.query_command: cmd = self.query_command pkg_list = self.exec_cmd(cmd, timeout=30, chroot=self.chroot) - for pkg in pkg_list.splitlines(): - if '|' not in pkg: - continue - elif pkg.count("|") == 1: - name, version = pkg.split("|") - release = None - elif pkg.count("|") == 2: - name, version, release = pkg.split("|") - self._packages[name] = { - 'name': name, - 'version': version.split(".") + for pkg in self._parse_pkg_list(pkg_list): + self._packages[pkg[0]] = { + 'name': pkg[0], + 'version': pkg[1].split('.'), + 'release': pkg[2], + 'pkg_manager': self.manager_name } - release = release if release else None - self._packages[name]['release'] = release def pkg_version(self, pkg): """Returns the entry in self.packages for pkg if it exists @@ -285,4 +293,108 @@ return self.verify_command + " " + verify_packages +class MultiPackageManager(PackageManager): + """ + This class is used to leverage multiple individual package managers as a + single entity on systems that support multiple concurrent package managers. + + Policies that use this approach will need to specify a primary package + manager, and at least one fallback manager. When queries are sent to this + manager, the primary child manager is checked first. If there is a valid, + not None, response (e.g. a given package is installed) then that response + is used. However, if the response is empty or None, the fallback managers + are then queried in the order they were passed to MultiPackageManager + during initialization. + + :param primary: The primary package manager to rely on + :type primary: A subclass of `PackageManager` + + :param fallbacks: A list of package managers to use if the primary does not + provide a response + :type fallbacks: ``list`` of `PackageManager` subclasses + """ + + def __init__(self, primary, fallbacks, chroot=None, remote_exec=None): + super(MultiPackageManager, self).__init__(chroot=chroot, + remote_exec=remote_exec) + + if not issubclass(primary, PackageManager): + raise Exception( + f"Primary package manager must be PackageManager subclass, not" + f" {primary.__class__}" + ) + + if not isinstance(fallbacks, list): + raise Exception('Fallbacks must be specified in a list') + + for pm in fallbacks: + if not issubclass(pm, PackageManager): + raise Exception( + f"Fallback package managers must be PackageManager " + f"subclass, not {pm.__class__}" + ) + + self.primary = primary(chroot=chroot, remote_exec=remote_exec) + self.fallbacks = [ + pm(chroot=chroot, remote_exec=remote_exec) for pm in fallbacks + ] + + if not self.fallbacks: + raise Exception( + 'Must define at least one fallback package manager' + ) + + self._managers = [self.primary] + self._managers.extend(self.fallbacks) + + def all_files(self): + if not self.files: + for pm in self._managers: + self.files.extend(pm.all_files()) + return self.files + + def _generate_pkg_list(self): + self._packages.update(self.primary.packages) + for pm in self.fallbacks: + _pkgs = pm.packages + for pkg in _pkgs.keys(): + if pkg not in self._packages: + self._packages[pkg] = _pkgs[pkg] + + def _pm_wrapper(self, method): + """ + This wrapper method is used to provide implicit iteration through the + primary and any defined fallback managers that are set for a given + instance of MultiPackageManager. + + Important note: we pass the _name_ of the method to run here as a + string, and not any actual method as we rely on iteratively looking up + the actual method in each package manager. + + :param method: The name of the method we're wrapping for the purpose of + iterating through defined package managers + :type method: ``str`` + """ + def pkg_func(*args, **kwargs): + ret = None + for pm in self._managers: + if not ret or ret == 'unknown': + _wrapped_func = getattr(pm, method) + ret = _wrapped_func(*args, **kwargs) + return ret + return pkg_func + + def __getattribute__(self, item): + # if the attr is callable, then we need to iterate over our child + # managers until we get a response, unless it is _generate_pkg_list in + # which case we only want to use the one actually defined here, or + # _pm_wrapper, which we need to avoid this override for to not hit + # recursion hell. + if item in ['_generate_pkg_list', '_pm_wrapper', 'all_files']: + return super().__getattribute__(item) + attr = super().__getattribute__(item) + if hasattr(attr, '__call__'): + return self._pm_wrapper(item) + return attr + # vim: set et ts=4 sw=4 : diff -Nru sosreport-4.5.3ubuntu2/sos/policies/package_managers/rpm.py sosreport-4.5.4ubuntu1/sos/policies/package_managers/rpm.py --- sosreport-4.5.3ubuntu2/sos/policies/package_managers/rpm.py 2023-04-28 22:46:21.000000000 +0530 +++ sosreport-4.5.4ubuntu1/sos/policies/package_managers/rpm.py 2023-05-26 22:32:49.000000000 +0530 @@ -21,5 +21,11 @@ verify_command = 'rpm -V' verify_filter = ["debuginfo", "-devel"] + def _parse_pkg_list(self, pkg_list): + for pkg in pkg_list.splitlines(): + if '|' not in pkg: + continue + name, version, release = pkg.split('|') + yield (name, version, release) # vim: set et ts=4 sw=4 : diff -Nru sosreport-4.5.3ubuntu2/sos/policies/package_managers/snap.py sosreport-4.5.4ubuntu1/sos/policies/package_managers/snap.py --- sosreport-4.5.3ubuntu2/sos/policies/package_managers/snap.py 1970-01-01 05:30:00.000000000 +0530 +++ sosreport-4.5.4ubuntu1/sos/policies/package_managers/snap.py 2023-05-26 22:32:49.000000000 +0530 @@ -0,0 +1,33 @@ +# Copyright 2023 Canonical Ltd. Arif Ali + +# 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.policies.package_managers import PackageManager + + +class SnapPackageManager(PackageManager): + """Subclass for snap-based distributions + """ + + query_command = "snap list" + query_path_command = "" + verify_command = "" + verify_filter = "" + + def _parse_pkg_list(self, pkg_list): + for line in pkg_list.splitlines(): + if line == "": + continue + pkg = line.split() + if pkg[0] == "Name" or pkg[0] == "Connection": + continue + name, version = pkg[0], pkg[1] + yield (name, version, None) + +# vim: set et ts=4 sw=4 : diff -Nru sosreport-4.5.3ubuntu2/sos/report/plugins/alternatives.py sosreport-4.5.4ubuntu1/sos/report/plugins/alternatives.py --- sosreport-4.5.3ubuntu2/sos/report/plugins/alternatives.py 2023-04-28 22:46:21.000000000 +0530 +++ sosreport-4.5.4ubuntu1/sos/report/plugins/alternatives.py 2023-05-26 22:32:49.000000000 +0530 @@ -8,25 +8,17 @@ # # See the LICENSE file in the source distribution for further information. -from sos.report.plugins import Plugin, RedHatPlugin +from sos.report.plugins import Plugin, RedHatPlugin, UbuntuPlugin -class Alternatives(Plugin, RedHatPlugin): +class Alternatives(Plugin): short_desc = 'System alternatives' plugin_name = 'alternatives' - packages = ('chkconfig',) - commands = ('alternatives',) def setup(self): - self.add_cmd_tags({ - "alternatives --display java.*": 'display_java', - "alternatives --display python.*": - 'alternatives_display_python' - }) - - self.add_cmd_output('alternatives --version') + self.add_cmd_output('%s --version' % self.alternatives_cmd) alts = [] ignore = [ @@ -37,13 +29,55 @@ 'xinputrc' ] - res = self.collect_cmd_output('alternatives --list') + res = self.collect_cmd_output(self.alternatives_list) if res['status'] == 0: for line in res['output'].splitlines(): alt = line.split()[0] if alt not in ignore: alts.append(alt) - disp_cmd = "alternatives --display %s" + disp_cmd = "%s --display %s" % (self.alternatives_cmd, "%s") self.add_cmd_output([disp_cmd % alt for alt in alts]) + +class RedHatAlternatives(Alternatives, RedHatPlugin): + + packages = ('alternatives',) + commands = ('alternatives',) + + alternatives_cmd = 'alternatives' + alternatives_list = '%s --list' % alternatives_cmd + + def setup(self): + + super(RedHatAlternatives, self).setup() + + self.add_cmd_tags({ + "alternatives --display java.*": 'display_java', + "alternatives --display python.*": + 'alternatives_display_python' + }) + + +class UbuntuAlternatives(Alternatives, UbuntuPlugin): + + packages = ('dpkg',) + commands = ('update-alternatives',) + + alternatives_cmd = 'update-alternatives' + alternatives_list = '%s --get-selections' % alternatives_cmd + + def setup(self): + + super(UbuntuAlternatives, self).setup() + + if self.get_option("all_logs"): + self.add_copy_spec([ + "/var/log/alternatives.log*", + ]) + else: + self.add_copy_spec([ + "/var/log/alternatives.log", + "/var/log/alternatives.log.1", + ]) + # vim: set et ts=4 sw=4 : diff -Nru sosreport-4.5.3ubuntu2/sos/report/plugins/apache.py sosreport-4.5.4ubuntu1/sos/report/plugins/apache.py --- sosreport-4.5.3ubuntu2/sos/report/plugins/apache.py 2023-04-28 22:46:21.000000000 +0530 +++ sosreport-4.5.4ubuntu1/sos/report/plugins/apache.py 2023-05-26 22:32:49.000000000 +0530 @@ -50,9 +50,12 @@ 'ceilometer', 'cinder', 'foreman', + 'gnocchi', 'horizon', 'keystone', + 'manila', 'nova', + 'octavia', 'placement', 'pulp' ] @@ -131,7 +134,7 @@ class DebianApache(Apache, DebianPlugin, UbuntuPlugin): files = ('/etc/apache2/apache2.conf',) - apachepkg = 'apache' + apachepkg = 'apache2' def setup(self): super(DebianApache, self).setup() @@ -144,10 +147,15 @@ # collect only the current log set by default self.add_copy_spec([ - "/var/log/apache2/access_log", - "/var/log/apache2/error_log", + "/var/log/apache2/access.log", + "/var/log/apache2/error.log", + "/var/log/apache2/ssl_access.log", + "/var/log/apache2/ssl_error.log", + "/var/log/apache2/other_vhosts_access.log", ]) if self.get_option("log") or self.get_option("all_logs"): - self.add_copy_spec("/var/log/apache2/*") + self.add_copy_spec([ + "/var/log/apache2", + ]) # vim: set et ts=4 sw=4 : diff -Nru sosreport-4.5.3ubuntu2/sos/report/plugins/apport.py sosreport-4.5.4ubuntu1/sos/report/plugins/apport.py --- sosreport-4.5.3ubuntu2/sos/report/plugins/apport.py 2023-04-28 22:46:21.000000000 +0530 +++ sosreport-4.5.4ubuntu1/sos/report/plugins/apport.py 2023-05-26 22:32:49.000000000 +0530 @@ -26,6 +26,7 @@ ]) else: self.add_copy_spec("/var/log/apport*") + self.add_copy_spec("/var/crash/**") self.add_copy_spec("/etc/apport/*") self.add_copy_spec("/var/lib/whoopsie/whoopsie-id") self.add_cmd_output( diff -Nru sosreport-4.5.3ubuntu2/sos/report/plugins/apt.py sosreport-4.5.4ubuntu1/sos/report/plugins/apt.py --- sosreport-4.5.3ubuntu2/sos/report/plugins/apt.py 2023-04-28 22:46:21.000000000 +0530 +++ sosreport-4.5.4ubuntu1/sos/report/plugins/apt.py 2023-05-26 22:32:49.000000000 +0530 @@ -45,4 +45,18 @@ suggest_filename="apt-cache_policy_details" ) + def postproc(self): + super(Apt, self).postproc() + self.do_file_sub( + "/etc/apt/sources.list", + r"(deb\shttp(s)?://)\S+:\S+(@.*)", + r"\1******:******\3" + ) + self.do_path_regex_sub( + "/etc/apt/sources.list.d/", + r"(deb\shttp(s)?://)\S+:\S+(@.*)", + r"\1******:******\3" + ) + + # vim: set et ts=4 sw=4 : diff -Nru sosreport-4.5.3ubuntu2/sos/report/plugins/dnf.py sosreport-4.5.4ubuntu1/sos/report/plugins/dnf.py --- sosreport-4.5.3ubuntu2/sos/report/plugins/dnf.py 2023-04-28 22:46:21.000000000 +0530 +++ sosreport-4.5.4ubuntu1/sos/report/plugins/dnf.py 2023-05-26 22:32:49.000000000 +0530 @@ -46,7 +46,7 @@ if "[i]" in line: module = line.split()[0] if module != "Hint:": - self.add_cmd_output("dnf --assumeno module info " + module, + self.add_cmd_output("dnf module info " + module, tags='dnf_module_info') def setup(self): @@ -71,13 +71,12 @@ self.add_copy_spec("/var/log/dnf.librepo.log*") self.add_copy_spec("/var/log/dnf.rpm.log*") - self.add_cmd_output("dnf --assumeno module list", + self.add_cmd_output("dnf module list", tags='dnf_module_list') self.add_cmd_output([ "dnf --version", - "dnf --assumeno list installed *dnf*", - "dnf --assumeno list extras", + "dnf list extras", "package-cleanup --dupes", "package-cleanup --problems" ]) @@ -120,7 +119,7 @@ tags='dnf_history_info') # Get list of dnf installed modules and their details. - module_cmd = "dnf --assumeno module list --installed" + module_cmd = "dnf module list --installed" modules = self.collect_cmd_output(module_cmd) self.get_modules_info(modules['output']) diff -Nru sosreport-4.5.3ubuntu2/sos/report/plugins/elastic.py sosreport-4.5.4ubuntu1/sos/report/plugins/elastic.py --- sosreport-4.5.3ubuntu2/sos/report/plugins/elastic.py 2023-04-28 22:46:21.000000000 +0530 +++ sosreport-4.5.4ubuntu1/sos/report/plugins/elastic.py 2023-05-26 22:32:49.000000000 +0530 @@ -47,7 +47,7 @@ if self.get_option("all_logs"): self.add_copy_spec("/var/log/elasticsearch/*") else: - self.add_copy_spec("/var/log/elasticsearch/elasticsearch.log") + self.add_copy_spec("/var/log/elasticsearch/*.log") host, port = self.get_hostname_port(els_config_file) endpoint = host + ":" + port @@ -57,6 +57,8 @@ "curl -X GET '%s/_cluster/stats?pretty'" % endpoint, "curl -X GET '%s/_cat/nodes?v'" % endpoint, "curl -X GET '%s/_cat/indices'" % endpoint, + "curl -X GET '%s/_cat/shards'" % endpoint, + "curl -X GET '%s/_cat/aliases'" % endpoint, ]) # vim: set et ts=4 sw=4 : diff -Nru sosreport-4.5.3ubuntu2/sos/report/plugins/foreman.py sosreport-4.5.4ubuntu1/sos/report/plugins/foreman.py --- sosreport-4.5.3ubuntu2/sos/report/plugins/foreman.py 2023-04-28 22:46:21.000000000 +0530 +++ sosreport-4.5.4ubuntu1/sos/report/plugins/foreman.py 2023-05-26 22:32:49.000000000 +0530 @@ -131,6 +131,13 @@ 'ping -c1 -W1 %s' % _host_f, 'ping -c1 -W1 localhost' ]) + self.add_cmd_output( + 'qpid-stat -b amqps://localhost:5671 -q \ + --ssl-certificate=/etc/pki/katello/qpid_router_client.crt \ + --ssl-key=/etc/pki/katello/qpid_router_client.key \ + --sasl-mechanism=ANONYMOUS', + suggest_filename='qpid-stat_-q' + ) self.add_cmd_output("hammer ping", tags="hammer_ping") # Dynflow Sidekiq diff -Nru sosreport-4.5.3ubuntu2/sos/report/plugins/gnocchi.py sosreport-4.5.4ubuntu1/sos/report/plugins/gnocchi.py --- sosreport-4.5.3ubuntu2/sos/report/plugins/gnocchi.py 2023-04-28 22:46:21.000000000 +0530 +++ sosreport-4.5.4ubuntu1/sos/report/plugins/gnocchi.py 1970-01-01 05:30:00.000000000 +0530 @@ -1,107 +0,0 @@ -# Copyright (C) 2016 Red Hat, Inc., Sachin Patil -# Copyright (C) 2017 Red Hat, Inc., Martin Schuppert - -# 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. - -import os -from sos.report.plugins import Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin - - -class Gnocchi(Plugin): - - short_desc = 'Gnocchi - Metric as a service' - plugin_name = "gnocchi" - - profiles = ('openstack', 'openstack_controller') - - def setup(self): - self.add_copy_spec([ - "/etc/gnocchi/*", - ]) - - if self.get_option("all_logs"): - self.add_copy_spec([ - "/var/log/gnocchi/*", - "/var/log/{}*/gnocchi*".format(self.apachepkg) - ]) - else: - self.add_copy_spec([ - "/var/log/gnocchi/*.log", - "/var/log/{}*/gnocchi*.log".format(self.apachepkg) - ]) - - vars_all = [p in os.environ for p in [ - 'OS_USERNAME', 'OS_PASSWORD']] - - vars_any = [p in os.environ for p in [ - 'OS_TENANT_NAME', 'OS_PROJECT_NAME']] - - if not (all(vars_all) and any(vars_any)): - self.soslog.warning("Not all environment variables set. Source " - "the environment file for the user intended " - "to connect to the OpenStack environment.") - else: - self.add_cmd_output([ - "gnocchi --version", - "gnocchi status", - "gnocchi capabilities list", - "gnocchi archive-policy list", - "gnocchi resource list", - "gnocchi resource-type list" - ]) - - def postproc(self): - self.do_file_sub( - "/etc/gnocchi/gnocchi.conf", - r"(ceph_secret|password|memcache_secret_key)\s?=(.*)", - r"\1=*****", - ) - - -class RedHatGnocchi(Gnocchi, RedHatPlugin): - - apachepkg = 'httpd' - var_puppet_gen = "/var/lib/config-data/puppet-generated/gnocchi" - - packages = ( - 'openstack-gnocchi-metricd', 'openstack-gnocchi-common', - 'openstack-gnocchi-statsd', 'openstack-gnocchi-api', - 'openstack-gnocchi-carbonara' - ) - - def setup(self): - super(RedHatGnocchi, self).setup() - self.add_copy_spec([ - self.var_puppet_gen + "/etc/gnocchi/*", - self.var_puppet_gen + "/etc/httpd/conf/*", - self.var_puppet_gen + "/etc/httpd/conf.d/*", - self.var_puppet_gen + "/etc/httpd/conf.modules.d/wsgi.conf", - self.var_puppet_gen + "/etc/my.cnf.d/tripleo.cnf" - ]) - - def postproc(self): - super(RedHatGnocchi, self).postproc() - self.do_file_sub( - self.var_puppet_gen + "/etc/gnocchi/" - "gnocchi.conf", - r"(ceph_secret|password|memcache_secret_key)\s?=(.*)", - r"\1=*****", - ) - - -class DebianGnocchi(Gnocchi, DebianPlugin, UbuntuPlugin): - - apachepkg = 'apache' - - packages = ( - 'gnocchi-api', 'gnocchi-metricd', 'gnocchi-common' - 'gnocchi-statsd', 'python3-gnocchiclient' - ) - -# vim: set et ts=4 sw=4 : diff -Nru sosreport-4.5.3ubuntu2/sos/report/plugins/__init__.py sosreport-4.5.4ubuntu1/sos/report/plugins/__init__.py --- sosreport-4.5.3ubuntu2/sos/report/plugins/__init__.py 2023-04-28 22:46:21.000000000 +0530 +++ sosreport-4.5.4ubuntu1/sos/report/plugins/__init__.py 2023-05-26 22:32:49.000000000 +0530 @@ -3186,8 +3186,8 @@ self._collect_copy_specs() self._collect_container_copy_specs() self._collect_tailed_files() - self._collect_cmds() self._collect_strings() + self._collect_cmds() self._collect_manual() fields = (self.name(), time() - start) self._log_debug("collected plugin '%s' in %s" % fields) diff -Nru sosreport-4.5.3ubuntu2/sos/report/plugins/insights.py sosreport-4.5.4ubuntu1/sos/report/plugins/insights.py --- sosreport-4.5.3ubuntu2/sos/report/plugins/insights.py 2023-04-28 22:46:21.000000000 +0530 +++ sosreport-4.5.4ubuntu1/sos/report/plugins/insights.py 2023-05-26 22:32:49.000000000 +0530 @@ -28,6 +28,8 @@ config = ( '/etc/insights-client/insights-client.conf', '/etc/insights-client/.registered', + '/etc/insights-client/tags.yaml', + '/etc/insights-client/malware-detection-config.yml', '/etc/redhat-access-insights/redhat-access-insights.conf' ) diff -Nru sosreport-4.5.3ubuntu2/sos/report/plugins/juju.py sosreport-4.5.4ubuntu1/sos/report/plugins/juju.py --- sosreport-4.5.3ubuntu2/sos/report/plugins/juju.py 2023-04-28 22:46:21.000000000 +0530 +++ sosreport-4.5.4ubuntu1/sos/report/plugins/juju.py 2023-05-26 22:32:49.000000000 +0530 @@ -44,7 +44,8 @@ # want all logs you want this too. self.add_copy_spec([ "/var/log/juju", - "/var/lib/juju" + "/var/lib/juju", + "/var/lib/juju/**/.*", ]) self.add_forbidden_path("/var/lib/juju/kvm") else: diff -Nru sosreport-4.5.3ubuntu2/sos/report/plugins/kernel.py sosreport-4.5.4ubuntu1/sos/report/plugins/kernel.py --- sosreport-4.5.3ubuntu2/sos/report/plugins/kernel.py 2023-04-28 22:46:21.000000000 +0530 +++ sosreport-4.5.4ubuntu1/sos/report/plugins/kernel.py 2023-05-26 22:32:49.000000000 +0530 @@ -125,6 +125,7 @@ "/proc/misc", "/var/log/dmesg", "/sys/fs/pstore", + "/var/lib/systemd/pstore", "/sys/kernel/debug/dynamic_debug/control", "/sys/kernel/debug/extfrag/unusable_index", "/sys/kernel/debug/extfrag/extfrag_index", diff -Nru sosreport-4.5.3ubuntu2/sos/report/plugins/landscape.py sosreport-4.5.4ubuntu1/sos/report/plugins/landscape.py --- sosreport-4.5.3ubuntu2/sos/report/plugins/landscape.py 2023-04-28 22:46:21.000000000 +0530 +++ sosreport-4.5.4ubuntu1/sos/report/plugins/landscape.py 2023-05-26 22:32:49.000000000 +0530 @@ -29,9 +29,15 @@ ]) if not self.get_option("all_logs"): - self.add_copy_spec("/var/log/landscape/*.log") + self.add_copy_spec([ + "/var/log/landscape/*.log", + "/var/log/landscape-server/*.log", + ]) else: - self.add_copy_spec("/var/log/landscape") + self.add_copy_spec([ + "/var/log/landscape", + "/var/log/landscape-server" + ]) self.add_cmd_output([ "gpg --verify /etc/landscape/license.txt", diff -Nru sosreport-4.5.3ubuntu2/sos/report/plugins/lstopo.py sosreport-4.5.4ubuntu1/sos/report/plugins/lstopo.py --- sosreport-4.5.3ubuntu2/sos/report/plugins/lstopo.py 2023-04-28 22:46:21.000000000 +0530 +++ sosreport-4.5.4ubuntu1/sos/report/plugins/lstopo.py 2023-05-26 22:32:49.000000000 +0530 @@ -16,7 +16,11 @@ plugin_name = "lstopo" profiles = ("system", "hardware") - packages = ("hwloc-libs", "libhwloc5") + packages = ( + "hwloc-libs", + "libhwloc5", + "hwloc", + ) def setup(self): # binary depends on particular package, both require hwloc-libs one diff -Nru sosreport-4.5.3ubuntu2/sos/report/plugins/lxd.py sosreport-4.5.4ubuntu1/sos/report/plugins/lxd.py --- sosreport-4.5.3ubuntu2/sos/report/plugins/lxd.py 2023-04-28 22:46:21.000000000 +0530 +++ sosreport-4.5.4ubuntu1/sos/report/plugins/lxd.py 2023-05-26 22:32:49.000000000 +0530 @@ -44,6 +44,23 @@ snap_list = self.exec_cmd('snap list lxd') if snap_list["status"] == 0: self.add_cmd_output("lxd.buginfo", pred=lxd_pred) + + self.add_copy_spec([ + '/var/snap/lxd/common/config', + '/var/snap/lxd/common/global-conf', + '/var/snap/lxd/common/lxc/local.conf', + '/var/snap/lxd/common/lxd/logs/*/*.conf', + ]) + + if not self.get_option("all_logs"): + self.add_copy_spec([ + '/var/snap/lxd/common/lxd/logs/*.log', + '/var/snap/lxd/common/lxd/logs/*/*.log', + ]) + else: + self.add_copy_spec([ + '/var/snap/lxd/common/lxd/logs/**', + ]) else: self.add_copy_spec([ "/etc/default/lxd-bridge", diff -Nru sosreport-4.5.3ubuntu2/sos/report/plugins/microk8s.py sosreport-4.5.4ubuntu1/sos/report/plugins/microk8s.py --- sosreport-4.5.3ubuntu2/sos/report/plugins/microk8s.py 1970-01-01 05:30:00.000000000 +0530 +++ sosreport-4.5.4ubuntu1/sos/report/plugins/microk8s.py 2023-05-26 22:32:49.000000000 +0530 @@ -0,0 +1,52 @@ +# Copyright (C) 2023 Canonical Ltd., +# David Negreira + +# 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.report.plugins import Plugin, UbuntuPlugin + + +class Microk8s(Plugin, UbuntuPlugin): + """The Microk8s plugin collects the current status of the microk8s + snap on a Ubuntu machine. + + It will collect logs from journald related to the snap.microk8s + units as well as run microk8s commands to retrieve the configuration, + status, version and loaded plugins. + """ + + short_desc = 'The lightweight Kubernetes' + plugin_name = "microk8s" + profiles = ('container',) + + packages = ('microk8s',) + + microk8s_cmd = "microk8s" + + def setup(self): + self.add_journal(units="snap.microk8s.*") + + microk8s_subcmds = [ + 'addons repo list', + 'config', + 'ctr plugins ls', + 'ctr plugins ls -d', + 'status', + 'version' + ] + + self.add_cmd_output([ + f"microk8s {subcmd}" for subcmd in microk8s_subcmds + ]) + + def postproc(self): + rsub = r'(certificate-authority-data:|token:)\s.*' + self.do_cmd_output_sub("microk8s", rsub, r'\1 "**********"') + +# vim: set et ts=4 sw=4 diff -Nru sosreport-4.5.3ubuntu2/sos/report/plugins/networking.py sosreport-4.5.4ubuntu1/sos/report/plugins/networking.py --- sosreport-4.5.3ubuntu2/sos/report/plugins/networking.py 2023-04-28 22:46:21.000000000 +0530 +++ sosreport-4.5.4ubuntu1/sos/report/plugins/networking.py 2023-05-26 22:32:49.000000000 +0530 @@ -82,7 +82,8 @@ self.add_cmd_output("ip -o addr", root_symlink="ip_addr", tags='ip_addr') - self.add_cmd_output("route -n", root_symlink="route", tags='route') + self.add_cmd_output("ip route show table all", root_symlink="ip_route", + tags=['ip_route', 'iproute_show_table_all']) self.add_cmd_output("plotnetcfg") self.add_cmd_output("netstat %s -neopa" % self.ns_wide, @@ -93,7 +94,6 @@ "netstat -s", "netstat %s -agn" % self.ns_wide, "networkctl status -a", - "ip route show table all", "ip -6 route show table all", "ip -d route show cache", "ip -d -6 route show cache", @@ -210,6 +210,7 @@ ns_cmd_prefix + "ip -4 rule list", ns_cmd_prefix + "ip -6 rule list", ns_cmd_prefix + "ip vrf show", + ns_cmd_prefix + "sysctl -a", ns_cmd_prefix + "netstat %s -neopa" % self.ns_wide, ns_cmd_prefix + "netstat -s", ns_cmd_prefix + "netstat %s -agn" % self.ns_wide, @@ -253,7 +254,6 @@ "ethtool -k.*": "ethtool_k", "ip -d address": "ip_addr", "ip -s -s neigh show": "ip_neigh_show", - "ip route show table all": "iproute_show_table_all", "ip -s -d link": "ip_s_link", "netstat.*-neopa": "netstat", "netstat.*-agn": "netstat_agn", @@ -267,7 +267,7 @@ def setup(self): # Handle change from -T to -W in Red Hat netstat 2.0 and greater. try: - netstat_pkg = self.policy.package_manager.packages['net-tools'] + netstat_pkg = self.policy.package_manager.pkg_by_name('net-tools') # major version if int(netstat_pkg['version'][0]) < 2: self.ns_wide = "-T" diff -Nru sosreport-4.5.3ubuntu2/sos/report/plugins/networkmanager.py sosreport-4.5.4ubuntu1/sos/report/plugins/networkmanager.py --- sosreport-4.5.3ubuntu2/sos/report/plugins/networkmanager.py 2023-04-28 22:46:21.000000000 +0530 +++ sosreport-4.5.4ubuntu1/sos/report/plugins/networkmanager.py 2023-05-26 22:32:49.000000000 +0530 @@ -53,6 +53,7 @@ self.add_cmd_output([ "nmcli general status", "nmcli con", + "nmcli -f all con", "nmcli con show --active", "nmcli dev"]) nmcli_con_details_cmd = nmcli_con_details_template % "show" diff -Nru sosreport-4.5.3ubuntu2/sos/report/plugins/openstack_aodh.py sosreport-4.5.4ubuntu1/sos/report/plugins/openstack_aodh.py --- sosreport-4.5.3ubuntu2/sos/report/plugins/openstack_aodh.py 2023-04-28 22:46:21.000000000 +0530 +++ sosreport-4.5.4ubuntu1/sos/report/plugins/openstack_aodh.py 2023-05-26 22:32:49.000000000 +0530 @@ -34,12 +34,12 @@ if self.get_option("all_logs"): self.add_copy_spec([ "/var/log/aodh/*", - "/var/log/httpd/aodh*", + "/var/log/{}*/aodh*".format(self.apachepkg), ]) else: self.add_copy_spec([ "/var/log/aodh/*.log", - "/var/log/httpd/aodh*.log", + "/var/log/{}*/aodh*.log".format(self.apachepkg), ]) vars_all = [p in os.environ for p in [ @@ -92,17 +92,21 @@ class DebianOpenStackAodh(OpenStackAodh, DebianPlugin, UbuntuPlugin): + apachepkg = "apache2" packages = ( 'aodh-api', + 'aodh-common', 'aodh-evaluator', 'aodh-notifier', 'aodh-listener', - 'python-aodhclient' + 'python-aodh', + 'python3-aodh', ) class RedHatOpenStackAodh(OpenStackAodh, RedHatPlugin): + apachepkg = "httpd" packages = ('openstack-selinux',) def setup(self): diff -Nru sosreport-4.5.3ubuntu2/sos/report/plugins/openstack_ceilometer.py sosreport-4.5.4ubuntu1/sos/report/plugins/openstack_ceilometer.py --- sosreport-4.5.3ubuntu2/sos/report/plugins/openstack_ceilometer.py 2023-04-28 22:46:21.000000000 +0530 +++ sosreport-4.5.4ubuntu1/sos/report/plugins/openstack_ceilometer.py 2023-05-26 22:32:49.000000000 +0530 @@ -76,10 +76,11 @@ 'ceilometer-api', 'ceilometer-agent-central', 'ceilometer-agent-compute', + 'ceilometer-agent-notification', 'ceilometer-collector', 'ceilometer-common', 'python-ceilometer', - 'python-ceilometerclient' + 'python3-ceilometer', ) diff -Nru sosreport-4.5.3ubuntu2/sos/report/plugins/openstack_cinder.py sosreport-4.5.4ubuntu1/sos/report/plugins/openstack_cinder.py --- sosreport-4.5.3ubuntu2/sos/report/plugins/openstack_cinder.py 2023-04-28 22:46:21.000000000 +0530 +++ sosreport-4.5.4ubuntu1/sos/report/plugins/openstack_cinder.py 2023-05-26 22:32:49.000000000 +0530 @@ -63,12 +63,12 @@ if self.get_option("all_logs"): self.add_copy_spec([ "/var/log/cinder/", - "/var/log/httpd/cinder*", + "/var/log/{}*/cinder*".format(self.apachepkg), ]) else: self.add_copy_spec([ "/var/log/cinder/*.log", - "/var/log/httpd/cinder*.log", + "/var/log/{}*/cinder*.log".format(self.apachepkg), ]) def apply_regex_sub(self, regexp, subst): @@ -107,6 +107,7 @@ class DebianCinder(OpenStackCinder, DebianPlugin, UbuntuPlugin): cinder = False + apachepkg = 'apache2' packages = ( 'cinder-api', 'cinder-backup', @@ -114,24 +115,14 @@ 'cinder-scheduler', 'cinder-volume', 'python-cinder', - 'python-cinderclient' + 'python3-cinder', ) - def setup(self): - super(DebianCinder, self).setup() - if self.get_option("all_logs"): - self.add_copy_spec([ - "/var/log/apache/cinder*", - ]) - else: - self.add_copy_spec([ - "/var/log/apache/cinder*.log", - ]) - class RedHatCinder(OpenStackCinder, RedHatPlugin): cinder = False + apachepkg = 'httpd' packages = ('openstack-selinux',) def setup(self): diff -Nru sosreport-4.5.3ubuntu2/sos/report/plugins/openstack_glance.py sosreport-4.5.4ubuntu1/sos/report/plugins/openstack_glance.py --- sosreport-4.5.3ubuntu2/sos/report/plugins/openstack_glance.py 2023-04-28 22:46:21.000000000 +0530 +++ sosreport-4.5.4ubuntu1/sos/report/plugins/openstack_glance.py 2023-05-26 22:32:49.000000000 +0530 @@ -114,7 +114,8 @@ 'glance-client', 'glance-common', 'glance-registry', - 'python-glance' + 'python-glance', + 'python3-glance', ) service_name = 'glance-api.service' diff -Nru sosreport-4.5.3ubuntu2/sos/report/plugins/openstack_gnocchi.py sosreport-4.5.4ubuntu1/sos/report/plugins/openstack_gnocchi.py --- sosreport-4.5.3ubuntu2/sos/report/plugins/openstack_gnocchi.py 1970-01-01 05:30:00.000000000 +0530 +++ sosreport-4.5.4ubuntu1/sos/report/plugins/openstack_gnocchi.py 2023-05-26 22:32:49.000000000 +0530 @@ -0,0 +1,111 @@ +# Copyright (C) 2016 Red Hat, Inc., Sachin Patil +# Copyright (C) 2017 Red Hat, Inc., Martin Schuppert + +# 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. + +import os +from sos.report.plugins import Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin + + +class Gnocchi(Plugin): + + short_desc = 'Gnocchi - Metric as a service' + plugin_name = "openstack_gnocchi" + + profiles = ('openstack', 'openstack_controller') + + def setup(self): + self.add_copy_spec([ + "/etc/gnocchi/*", + ]) + + if self.get_option("all_logs"): + self.add_copy_spec([ + "/var/log/gnocchi/*", + "/var/log/{}*/gnocchi*".format(self.apachepkg) + ]) + else: + self.add_copy_spec([ + "/var/log/gnocchi/*.log", + "/var/log/{}*/gnocchi*.log".format(self.apachepkg) + ]) + + vars_all = [p in os.environ for p in [ + 'OS_USERNAME', 'OS_PASSWORD']] + + vars_any = [p in os.environ for p in [ + 'OS_TENANT_NAME', 'OS_PROJECT_NAME']] + + if not (all(vars_all) and any(vars_any)): + self.soslog.warning("Not all environment variables set. Source " + "the environment file for the user intended " + "to connect to the OpenStack environment.") + else: + self.add_cmd_output([ + "gnocchi --version", + "gnocchi status", + "gnocchi capabilities list", + "gnocchi archive-policy list", + "gnocchi resource list", + "gnocchi resource-type list" + ]) + + def postproc(self): + self.do_file_sub( + "/etc/gnocchi/gnocchi.conf", + r"(ceph_secret|password|memcache_secret_key)\s?=(.*)", + r"\1=*****", + ) + + +class RedHatGnocchi(Gnocchi, RedHatPlugin): + + apachepkg = 'httpd' + var_puppet_gen = "/var/lib/config-data/puppet-generated/gnocchi" + + packages = ( + 'openstack-gnocchi-metricd', 'openstack-gnocchi-common', + 'openstack-gnocchi-statsd', 'openstack-gnocchi-api', + 'openstack-gnocchi-carbonara' + ) + + def setup(self): + super(RedHatGnocchi, self).setup() + self.add_copy_spec([ + self.var_puppet_gen + "/etc/gnocchi/*", + self.var_puppet_gen + "/etc/httpd/conf/*", + self.var_puppet_gen + "/etc/httpd/conf.d/*", + self.var_puppet_gen + "/etc/httpd/conf.modules.d/wsgi.conf", + self.var_puppet_gen + "/etc/my.cnf.d/tripleo.cnf" + ]) + + def postproc(self): + super(RedHatGnocchi, self).postproc() + self.do_file_sub( + self.var_puppet_gen + "/etc/gnocchi/" + "gnocchi.conf", + r"(ceph_secret|password|memcache_secret_key)\s?=(.*)", + r"\1=*****", + ) + + +class DebianGnocchi(Gnocchi, DebianPlugin, UbuntuPlugin): + + apachepkg = 'apache2' + + packages = ( + 'gnocchi-api', + 'gnocchi-metricd', + 'gnocchi-common', + 'gnocchi-statsd', + 'python-gnocchi', + 'python3-gnocchi', + ) + +# vim: set et ts=4 sw=4 : diff -Nru sosreport-4.5.3ubuntu2/sos/report/plugins/openstack_heat.py sosreport-4.5.4ubuntu1/sos/report/plugins/openstack_heat.py --- sosreport-4.5.3ubuntu2/sos/report/plugins/openstack_heat.py 2023-04-28 22:46:21.000000000 +0530 +++ sosreport-4.5.4ubuntu1/sos/report/plugins/openstack_heat.py 2023-05-26 22:32:49.000000000 +0530 @@ -128,7 +128,7 @@ 'heat-common', 'heat-engine', 'python-heat', - 'python-heatclient' + 'python3-heat', ) service_name = 'heat-api.service' diff -Nru sosreport-4.5.3ubuntu2/sos/report/plugins/openstack_horizon.py sosreport-4.5.4ubuntu1/sos/report/plugins/openstack_horizon.py --- sosreport-4.5.3ubuntu2/sos/report/plugins/openstack_horizon.py 2023-04-28 22:46:21.000000000 +0530 +++ sosreport-4.5.4ubuntu1/sos/report/plugins/openstack_horizon.py 2023-05-26 22:32:49.000000000 +0530 @@ -75,8 +75,9 @@ packages = ( 'python-django-horizon', + 'python3-django-horizon', 'openstack-dashboard', - 'openstack-dashboard-ubuntu-theme' + 'openstack-dashboard-ubuntu-theme', ) def setup(self): diff -Nru sosreport-4.5.3ubuntu2/sos/report/plugins/openstack_keystone.py sosreport-4.5.4ubuntu1/sos/report/plugins/openstack_keystone.py --- sosreport-4.5.3ubuntu2/sos/report/plugins/openstack_keystone.py 2023-04-28 22:46:21.000000000 +0530 +++ sosreport-4.5.4ubuntu1/sos/report/plugins/openstack_keystone.py 2023-05-26 22:32:49.000000000 +0530 @@ -44,10 +44,12 @@ if self.get_option("all_logs"): self.add_copy_spec([ "/var/log/keystone/", + "/var/log/{}*/keystone*".format(self.apachepkg), ]) else: self.add_copy_spec([ "/var/log/keystone/*.log", + "/var/log/{}*/keystone*.log".format(self.apachepkg), ]) # collect domain config directory, if specified @@ -115,23 +117,18 @@ class DebianKeystone(OpenStackKeystone, DebianPlugin, UbuntuPlugin): + apachepkg = 'apache2' packages = ( 'keystone', 'python-keystone', - 'python-keystoneclient' + 'python3-keystone', ) class RedHatKeystone(OpenStackKeystone, RedHatPlugin): + apachepkg = 'httpd' packages = ('openstack-selinux',) - def setup(self): - super(RedHatKeystone, self).setup() - if self.get_option("all_logs"): - self.add_copy_spec("/var/log/httpd/keystone*") - else: - self.add_copy_spec("/var/log/httpd/keystone*.log") - # vim: set et ts=4 sw=4 : diff -Nru sosreport-4.5.3ubuntu2/sos/report/plugins/openstack_manila.py sosreport-4.5.4ubuntu1/sos/report/plugins/openstack_manila.py --- sosreport-4.5.3ubuntu2/sos/report/plugins/openstack_manila.py 2023-04-28 22:46:21.000000000 +0530 +++ sosreport-4.5.4ubuntu1/sos/report/plugins/openstack_manila.py 2023-05-26 22:32:49.000000000 +0530 @@ -82,9 +82,21 @@ 'manila-common', 'manila-api', 'manila-share', - 'manila-scheduler' + 'manila-scheduler', + 'python3-manila', ) + def setup(self): + super(DebianManila, self).setup() + if self.get_option("all_logs"): + self.add_copy_spec([ + "/var/log/apache2/manila*", + ]) + else: + self.add_copy_spec([ + "/var/log/apache2/manila*.log", + ]) + class RedHatManila(OpenStackManila, RedHatPlugin): @@ -95,5 +107,14 @@ super(RedHatManila, self).setup() self.add_copy_spec("/etc/sudoers.d/manila") + if self.get_option("all_logs"): + self.add_copy_spec([ + "/var/log/containers/manila/*" + ]) + else: + self.add_copy_spec([ + "/var/log/containers/manila/*.log" + ]) + # vim: et ts=4 sw=4 diff -Nru sosreport-4.5.3ubuntu2/sos/report/plugins/openstack_neutron.py sosreport-4.5.4ubuntu1/sos/report/plugins/openstack_neutron.py --- sosreport-4.5.3ubuntu2/sos/report/plugins/openstack_neutron.py 2023-04-28 22:46:21.000000000 +0530 +++ sosreport-4.5.4ubuntu1/sos/report/plugins/openstack_neutron.py 2023-05-26 22:32:49.000000000 +0530 @@ -111,7 +111,7 @@ 'neutron-plugin-ryu-agent', 'neutron-server', 'python-neutron', - 'python-neutronclient' + 'python3-neutron', ) def check_enabled(self): diff -Nru sosreport-4.5.3ubuntu2/sos/report/plugins/openstack_nova.py sosreport-4.5.4ubuntu1/sos/report/plugins/openstack_nova.py --- sosreport-4.5.3ubuntu2/sos/report/plugins/openstack_nova.py 2023-04-28 22:46:21.000000000 +0530 +++ sosreport-4.5.4ubuntu1/sos/report/plugins/openstack_nova.py 2023-05-26 22:32:49.000000000 +0530 @@ -92,6 +92,7 @@ if self.get_option("all_logs"): self.add_copy_spec([ "/var/log/nova/", + "/var/log/{}*/nova*".format(self.apachepkg), ]) else: novadir = '/var/log/nova/' @@ -106,6 +107,9 @@ ] for novalog in novalogs: self.add_copy_spec(self.path_join(novadir, novalog)) + self.add_copy_spec([ + "/var/log/{}*/nova*.log".format(self.apachepkg), + ]) pp = ['', '_libvirt', '_metadata', '_placement'] sp = [ @@ -162,6 +166,7 @@ class DebianNova(OpenStackNova, DebianPlugin, UbuntuPlugin): + apachepkg = "apache2" nova = False packages = ( 'nova-api-ec2', @@ -183,8 +188,8 @@ 'nova-volume', 'novnc', 'python-nova', - 'python-novaclient', - 'python-novnc' + 'python-novnc', + 'python3-nova', ) service_name = "nova-api.service" @@ -198,6 +203,7 @@ class RedHatNova(OpenStackNova, RedHatPlugin): + apachepkg = "httpd" nova = False packages = ('openstack-selinux',) @@ -212,12 +218,10 @@ ]) if self.get_option("all_logs"): self.add_copy_spec([ - "/var/log/httpd/nova*", "/var/log/httpd/placement*", ]) else: self.add_copy_spec([ - "/var/log/httpd/nova*.log", "/var/log/httpd/placement*.log", ]) diff -Nru sosreport-4.5.3ubuntu2/sos/report/plugins/openstack_octavia.py sosreport-4.5.4ubuntu1/sos/report/plugins/openstack_octavia.py --- sosreport-4.5.3ubuntu2/sos/report/plugins/openstack_octavia.py 2023-04-28 22:46:21.000000000 +0530 +++ sosreport-4.5.4ubuntu1/sos/report/plugins/openstack_octavia.py 2023-05-26 22:32:49.000000000 +0530 @@ -128,7 +128,11 @@ class DebianOctavia(OpenStackOctavia, DebianPlugin, UbuntuPlugin): - packages = ('octavia-common', 'octavia-api', ) + packages = ( + 'octavia-common', + 'octavia-api', + 'python3-octavia', + ) def setup(self): super(DebianOctavia, self).setup() diff -Nru sosreport-4.5.3ubuntu2/sos/report/plugins/openstack_placement.py sosreport-4.5.4ubuntu1/sos/report/plugins/openstack_placement.py --- sosreport-4.5.3ubuntu2/sos/report/plugins/openstack_placement.py 2023-04-28 22:46:21.000000000 +0530 +++ sosreport-4.5.4ubuntu1/sos/report/plugins/openstack_placement.py 2023-05-26 22:32:49.000000000 +0530 @@ -43,13 +43,15 @@ self.add_copy_spec([ "/var/log/placement/", "/var/log/containers/placement/", - "/var/log/containers/httpd/placement-api/" + "/var/log/containers/httpd/placement-api/", + "/var/log/{}*/placement*".format(self.apachepkg), ]) else: self.add_copy_spec([ "/var/log/placement/*.log", "/var/log/containers/placement/*.log", "/var/log/containers/httpd/placement-api/*log", + "/var/log/{}*/placement*.log".format(self.apachepkg), ]) self.add_copy_spec([ @@ -85,26 +87,17 @@ class DebianPlacement(OpenStackPlacement, DebianPlugin, UbuntuPlugin): - packages = ('placement',) - service_name = 'placement-api' - - def setup(self): - super(DebianPlacement, self).setup() - if self.get_option("all_logs"): - self.add_copy_spec("/var/log/apache2/placement*") - else: - self.add_copy_spec("/var/log/apache2/placement*.log") + apachepkg = "apache2" + packages = ( + 'placement-common', + 'placement-api', + 'python3-placement', + ) class RedHatPlacement(OpenStackPlacement, RedHatPlugin): + apachepkg = "httpd" packages = ('openstack-selinux',) - def setup(self): - super(RedHatPlacement, self).setup() - if self.get_option("all_logs"): - self.add_copy_spec("/var/log/httpd/placement*") - else: - self.add_copy_spec("/var/log/httpd/placement*.log") - # vim: set et ts=4 sw=4 : diff -Nru sosreport-4.5.3ubuntu2/sos/report/plugins/openstack_sahara.py sosreport-4.5.4ubuntu1/sos/report/plugins/openstack_sahara.py --- sosreport-4.5.3ubuntu2/sos/report/plugins/openstack_sahara.py 2023-04-28 22:46:21.000000000 +0530 +++ sosreport-4.5.4ubuntu1/sos/report/plugins/openstack_sahara.py 2023-05-26 22:32:49.000000000 +0530 @@ -70,7 +70,7 @@ 'sahara-common', 'sahara-engine', 'python-sahara', - 'python-saharaclient', + 'python3-sahara', ) def setup(self): diff -Nru sosreport-4.5.3ubuntu2/sos/report/plugins/openstack_swift.py sosreport-4.5.4ubuntu1/sos/report/plugins/openstack_swift.py --- sosreport-4.5.3ubuntu2/sos/report/plugins/openstack_swift.py 2023-04-28 22:46:21.000000000 +0530 +++ sosreport-4.5.4ubuntu1/sos/report/plugins/openstack_swift.py 2023-05-26 22:32:49.000000000 +0530 @@ -82,7 +82,8 @@ 'swift-proxy', 'swauth', 'python-swift', - 'python-swauth' + 'python-swauth', + 'python3-swift', ) diff -Nru sosreport-4.5.3ubuntu2/sos/report/plugins/openstack_trove.py sosreport-4.5.4ubuntu1/sos/report/plugins/openstack_trove.py --- sosreport-4.5.3ubuntu2/sos/report/plugins/openstack_trove.py 2023-04-28 22:46:21.000000000 +0530 +++ sosreport-4.5.4ubuntu1/sos/report/plugins/openstack_trove.py 2023-05-26 22:32:49.000000000 +0530 @@ -67,7 +67,8 @@ 'python-trove', 'trove-common', 'trove-api', - 'trove-taskmanager' + 'trove-taskmanager', + 'python3-trove', ) def setup(self): diff -Nru sosreport-4.5.3ubuntu2/sos/report/plugins/powerpc.py sosreport-4.5.4ubuntu1/sos/report/plugins/powerpc.py --- sosreport-4.5.3ubuntu2/sos/report/plugins/powerpc.py 2023-04-28 22:46:21.000000000 +0530 +++ sosreport-4.5.4ubuntu1/sos/report/plugins/powerpc.py 2023-05-26 22:32:49.000000000 +0530 @@ -39,7 +39,8 @@ "/proc/swaps", "/proc/version", "/dev/nvram", - "/var/lib/lsvpd/" + "/var/lib/lsvpd/", + "/etc/ct_node_id" ]) self.add_cmd_output([ "ppc64_cpu --info", @@ -55,7 +56,11 @@ "lscfg -v", "opal-elog-parse -s", "opal-elog-parse -a", - "opal-elog-parse -l" + "opal-elog-parse -l", + "lssrc -a", + "lsrsrc IBM.MCP", + "rmcdomainstatus -s ctrmc", + "rmcdomainstatus -s ctrmc -a ip" ]) if ispSeries: @@ -87,7 +92,18 @@ "lsslot", "amsstat" ]) - self.add_service_status("hcn-init") + + # Due to the lack of options in invscout for generating log files + # in locations other than /var/adm/invscout/, it is necessary to + # run invscout commands prior to collecting the log files. + self.collect_cmd_output("invscout") + self.collect_cmd_output("invscout -v") + self.add_copy_spec(["/var/adm/invscout/*"]) + + self.add_service_status([ + "hcn-init", + "ctrmc" + ]) if isPowerNV: self.add_copy_spec([ diff -Nru sosreport-4.5.3ubuntu2/sos/report/plugins/rhc.py sosreport-4.5.4ubuntu1/sos/report/plugins/rhc.py --- sosreport-4.5.3ubuntu2/sos/report/plugins/rhc.py 1970-01-01 05:30:00.000000000 +0530 +++ sosreport-4.5.4ubuntu1/sos/report/plugins/rhc.py 2023-05-26 22:32:49.000000000 +0530 @@ -0,0 +1,49 @@ +# Copyright (C) 2023 Red Hat, Inc., Jose Castillo + +# 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.report.plugins import Plugin, RedHatPlugin + + +class Rhc(Plugin, RedHatPlugin): + + """ + RHC is a client tool and daemon that connects the system + to Red Hat hosted services enabling system and + subscription management. This plugin captures + configuration files and the output of 'rhc status'. + """ + short_desc = 'Red Hat client for remote host configured services' + + plugin_name = "rhc" + packages = ("rhc", ) + + def setup(self): + self.add_copy_spec([ + "/etc/rhc/*", + ]) + + self.add_cmd_output([ + "rhc status", + ]) + + def postproc(self): + # hide workers/foreman_rh_cloud.toml FORWARDER_PASSWORD + # Example for scrubbing FORWARDER_PASSWORD + # + # "FORWARDER_PASSWORD=F0rW4rd3RPassW0rD" + # + # to + # + # "FORWARDER_PASSWORD= ******** + + self.do_path_regex_sub("/etc/rhc/workers/foreman_rh_cloud.toml", + r"(FORWARDER_PASSWORD\s*=\s*)(.+)(\"\,)", + r"\1********\3") +# vim: set et ts=4 sw=4 : diff -Nru sosreport-4.5.3ubuntu2/sos/report/plugins/rhui.py sosreport-4.5.4ubuntu1/sos/report/plugins/rhui.py --- sosreport-4.5.3ubuntu2/sos/report/plugins/rhui.py 2023-04-28 22:46:21.000000000 +0530 +++ sosreport-4.5.4ubuntu1/sos/report/plugins/rhui.py 2023-05-26 22:32:49.000000000 +0530 @@ -51,7 +51,7 @@ self.do_path_regex_sub("/etc/rhui/rhui-tools.conf", r"(registry_password:)\s*(.+)", r"\1 ********") - # obfuscate twoo cookies for login session + # obfuscate two cookies for login session for cookie in ["csrftoken", "sessionid"]: self.do_path_regex_sub( r"/root/\.rhui/.*/cookies.txt", diff -Nru sosreport-4.5.3ubuntu2/sos/report/plugins/ubuntu.py sosreport-4.5.4ubuntu1/sos/report/plugins/ubuntu.py --- sosreport-4.5.3ubuntu2/sos/report/plugins/ubuntu.py 2023-04-28 22:46:21.000000000 +0530 +++ sosreport-4.5.4ubuntu1/sos/report/plugins/ubuntu.py 2023-05-26 22:32:49.000000000 +0530 @@ -26,15 +26,22 @@ if self.is_installed('ubuntu-advantage-tools'): if is_executable('ua'): ua_tools_status = 'ua status' + elif is_executable('pro'): + ua_tools_status = 'pro status' else: ua_tools_status = 'ubuntu-advantage status' self.add_cmd_output(ua_tools_status) + self.add_cmd_output("%s --format json" % ua_tools_status) if not self.get_option("all_logs"): self.add_copy_spec([ "/var/log/ubuntu-advantage.log", "/var/log/ubuntu-advantage.log.1", "/var/log/ubuntu-advantage.log.2*", + "/var/log/ubuntu-advantage-timer.log", + "/var/log/ubuntu-advantage-timer.log.1", + "/var/log/ubuntu-advantage-timer.log.2*", ]) else: self.add_copy_spec("/var/log/ubuntu-advantage.log*") + self.add_copy_spec("/var/log/ubuntu-advantage-timer.log*") diff -Nru sosreport-4.5.3ubuntu2/sos.spec sosreport-4.5.4ubuntu1/sos.spec --- sosreport-4.5.3ubuntu2/sos.spec 2023-04-28 22:46:21.000000000 +0530 +++ sosreport-4.5.4ubuntu1/sos.spec 2023-05-26 22:32:49.000000000 +0530 @@ -1,6 +1,6 @@ Summary: A set of tools to gather troubleshooting information from a system Name: sos -Version: 4.5.3 +Version: 4.5.4 Release: 1%{?dist} Group: Applications/System Source0: https://github.com/sosreport/sos/archive/%{name}-%{version}.tar.gz @@ -13,6 +13,7 @@ BuildRequires: gettext Requires: python3-rpm Requires: python3-pexpect +Requires: python3-setuptools Recommends: python3-magic Recommends: python3-pyyaml Obsoletes: sos-collector <= 1.9 @@ -64,6 +65,9 @@ %config(noreplace) %{_sysconfdir}/sos/sos.conf %changelog +* Fri May 26 2023 Jake Hunsaker = 4.5.4 +- New upstream release + * Fri Apr 28 2023 Jake Hunsaker = 4.5.3 - New upstream release diff -Nru sosreport-4.5.3ubuntu2/tests/product_tests/foreman/foreman_tests.py sosreport-4.5.4ubuntu1/tests/product_tests/foreman/foreman_tests.py --- sosreport-4.5.3ubuntu2/tests/product_tests/foreman/foreman_tests.py 2023-04-28 22:46:21.000000000 +0530 +++ sosreport-4.5.4ubuntu1/tests/product_tests/foreman/foreman_tests.py 2023-05-26 22:32:49.000000000 +0530 @@ -26,6 +26,7 @@ """ sos_cmd = '-v' + arch = ['x86_64'] def test_tfm_plugins_ran(self): self.assertPluginIncluded([ @@ -102,6 +103,7 @@ """ sos_cmd = '-v -k foreman.proxyfeatures=on' + arch = ['x86_64'] @redhat_only def test_proxyfeatures_collected(self): @@ -115,6 +117,7 @@ """ sos_cmd = '-v -o foreman_installer' + arch = ['x86_64'] def test_foreman_installer_etc_collected(self): self.assertFileCollected("/etc/foreman-installer/scenarios.d") @@ -127,6 +130,7 @@ """ sos_cmd = '-v -o foreman_proxy' + arch = ['x86_64'] def test_foreman_proxy_settings_collected(self): self.assertFileCollected("/etc/foreman-proxy/settings.yml") diff -Nru sosreport-4.5.3ubuntu2/tests/sos_tests.py sosreport-4.5.4ubuntu1/tests/sos_tests.py --- sosreport-4.5.3ubuntu2/tests/sos_tests.py 2023-04-28 22:46:21.000000000 +0530 +++ sosreport-4.5.4ubuntu1/tests/sos_tests.py 2023-05-26 22:32:49.000000000 +0530 @@ -11,6 +11,7 @@ from avocado.core.output import LOG_UI from avocado import Test from avocado.utils import archive, process, distro, software_manager +from avocado.utils.cpu import get_arch from fnmatch import fnmatch import glob @@ -71,6 +72,7 @@ redhat_only = False ubuntu_only = False end_of_test_case = False + arch = [] @property def klass_name(self): @@ -227,6 +229,22 @@ if self.local_distro not in UBUNTU_DIST: raise TestSkipError("Not running on a Ubuntu or Debian distro") + def check_arch_for_enablement(self): + """ + Check if the test case is meant only for a specific architecture, and + if it is, that we're also currently running on (one of) those arches. + + This relies on the `arch` class attr, which should be a list. If the + list is empty, assume all arches are acceptable. Otherwise, raise a + TestSkipError. + """ + sys_arch = get_arch() + if not self.arch or sys_arch in self.arch: + return True + raise TestSkipError(f"Unsupported architecture {sys_arch} for test " + f"(supports: {self.arch})") + + def setUp(self): """Setup the tmpdir and any needed mocking for the test, then execute the defined sos command. Ensure that we only run the sos command once @@ -234,6 +252,7 @@ """ self.local_distro = distro.detect().name self.check_distro_for_enablement() + self.check_arch_for_enablement() # check to prevent multiple setUp() runs if not os.path.isdir(self.tmpdir): # setup our class-shared tmpdir diff -Nru sosreport-4.5.3ubuntu2/tests/unittests/juju/juju_cluster_tests.py sosreport-4.5.4ubuntu1/tests/unittests/juju/juju_cluster_tests.py --- sosreport-4.5.3ubuntu2/tests/unittests/juju/juju_cluster_tests.py 2023-04-28 22:46:21.000000000 +0530 +++ sosreport-4.5.4ubuntu1/tests/unittests/juju/juju_cluster_tests.py 2023-05-26 22:32:49.000000000 +0530 @@ -7,11 +7,12 @@ # version 2 of the GNU General Public License. # # See the LICENSE file in the source distribution for further information. +import json import pathlib import unittest from unittest.mock import call, patch -from sos.collector.clusters.juju import _parse_option_string, juju +from sos.collector.clusters.juju import _parse_option_string, juju, _get_index from sos.options import ClusterOption @@ -291,4 +292,33 @@ ) +class IndexTest(unittest.TestCase): + + def test_subordinate_parent_miss_units(self): + """Fix if subordinate's parent is missing units.""" + model = "sos" + index = _get_index(model_name=model) + + juju_status = json.loads(get_juju_output(model=model)) + juju_status["applications"]["ubuntu"].pop("units") + + # Ensure these commands won't fall even when + # subordinate's parent's units is missing. + index.add_principals(juju_status) + index.add_subordinates(juju_status) + + def test_subordinate_miss_parent(self): + """Fix if subordinate is missing parent.""" + model = "sos" + index = _get_index(model_name=model) + + juju_status = json.loads(get_juju_output(model=model)) + index.add_principals(juju_status) + + index.apps.pop("ubuntu") + # Ensure command won't fall even when + # subordinate's parent is missing + index.add_subordinates(juju_status) + + # vim: set et ts=4 sw=4 : diff -Nru sosreport-4.5.3ubuntu2/tests/unittests/policy_tests.py sosreport-4.5.4ubuntu1/tests/unittests/policy_tests.py --- sosreport-4.5.3ubuntu2/tests/unittests/policy_tests.py 2023-04-28 22:46:21.000000000 +0530 +++ sosreport-4.5.4ubuntu1/tests/unittests/policy_tests.py 2023-05-26 22:32:49.000000000 +0530 @@ -7,9 +7,13 @@ # See the LICENSE file in the source distribution for further information. import unittest +from avocado.utils import distro + from sos.policies import Policy, import_policy from sos.policies.distros import LinuxPolicy -from sos.policies.package_managers import PackageManager +from sos.policies.package_managers import PackageManager, MultiPackageManager +from sos.policies.package_managers.rpm import RpmPackageManager +from sos.policies.package_managers.dpkg import DpkgPackageManager from sos.report.plugins import (Plugin, IndependentPlugin, RedHatPlugin, DebianPlugin) @@ -97,6 +101,60 @@ self.assertEquals(self.pm.pkg_by_name('foo'), None) +class RpmPackageManagerTests(unittest.TestCase): + + def setUp(self): + if distro.detect().name not in ['fedora', 'centos', 'rhel']: + self.skipTest('Not running on an RPM distribution') + self.pm = RpmPackageManager() + + def test_load_all_packages(self): + self.assertNotEquals(self.pm.packages, {}) + + def test_pkg_is_formatted(self): + kpkg = self.pm.pkg_by_name('coreutils') + self.assertIsInstance(kpkg, dict) + self.assertIsInstance(kpkg['version'], list) + self.assertEquals(kpkg['pkg_manager'], 'rpm') + + +class DpkgPackageManagerTests(unittest.TestCase): + + def setUp(self): + if distro.detect().name not in ['Ubuntu', 'debian']: + self.skipTest('Not running on a dpkg distribution') + self.pm = DpkgPackageManager() + + def test_load_all_packages(self): + self.assertNotEquals(self.pm.packages, {}) + + def test_pkg_is_formatted(self): + kpkg = self.pm.pkg_by_name('coreutils') + self.assertIsInstance(kpkg, dict) + self.assertIsInstance(kpkg['version'], list) + self.assertEquals(kpkg['pkg_manager'], 'dpkg') + + +class MultiPackageManagerTests(unittest.TestCase): + + def setUp(self): + self.pm = MultiPackageManager(primary=RpmPackageManager, + fallbacks=[DpkgPackageManager]) + + def test_load_all_packages(self): + self.assertNotEquals(self.pm.packages, {}) + + def test_pkg_is_formatted(self): + kpkg = self.pm.pkg_by_name('coreutils') + self.assertIsInstance(kpkg, dict) + self.assertIsInstance(kpkg['version'], list) + _local = distro.detect().name + if _local in ['Ubuntu', 'debian']: + self.assertEquals(kpkg['pkg_manager'], 'dpkg') + else: + self.assertEquals(kpkg['pkg_manager'], 'rpm') + + if __name__ == "__main__": unittest.main()