aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* [component] Add Policy loading and move to new component.pyJake Hunsaker2020-04-082-144/+172
| | | | | | | | | | | | | Adds Policy loading into `SoSComponent()` so that any subcommand can, if it needs it, have policies loaded consistenly. This is controlled via the `load_policy` class attr, which defaults to True. Future subcommands that do not need to have a policy loaded (E.G. the planned `info` command), can simply set this to False in order to skip this step. Moves `SoSComponent()` out of sos/__init__.py and into sos/component.py to ease import conflicts arising from policy loading. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [soscomponent] Add exit handling to SoSComponentJake Hunsaker2020-04-081-0/+17
| | | | | | Adds the exit handling from SoSReport() directly into SoSComponent() Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [options] Update option loading from config fileJake Hunsaker2020-04-082-38/+92
| | | | | | | | | | | | | | | | | | | | As we are moving to decouple SoSOptions() from report, we need to adjust how some of the option loading is handled, such as loading values from a conf file. The previous approach was to instantiate a new SoSOptions() object, read into it from the config file, and then merge that with the "main" SoSOptions() object. This worked well when we only had report to worry about since the arguments were more or less static. However, in allowing new subcommands to define their own options this presented a problem due to the behavior of merging. This was compounded by the fact that merging still functioned how we expected/needed for actions like merging commandline options against the defaults. As such, the new approach is to use the "main" SoSOptions() instance to read the config file specifications and then directly modify the needed values rather than relying on the merging behavior. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [sos] Extract logging setup from reportJake Hunsaker2020-04-082-0/+89
| | | | | | | | | | | Moves logging setup into `SoSComponent`, and logging is setup by default at component initialization, unless the `configure_logging` class attr is set to `False`. Moves the TempFileUtil() class out of report and into utilities for easier usage by all sos components. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [options] Decouple SoSOptions from reportJake Hunsaker2020-04-083-91/+39
| | | | | | | | This is the first of probably a number of commits aimed at making SoSOptions() a generic option handling class for all components in sos, rather than being tightly bound to `report`. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [sos] Dynamically build argparser usage stringsJake Hunsaker2020-04-081-2/+23
| | | | | | | | | | Now dynamically build the usage string reported by --help for the top-level parser (I.E. `sos --help`) to print available components. Additionally, rework the subparser usage strings to accurately report the syntax for subcommands. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [policies] Fix imports after moving SoSOptionsJake Hunsaker2020-04-081-2/+2
| | | | Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [sos] Fix bad imports/typosJake Hunsaker2020-04-081-5/+5
| | | | Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [options] Split SoSOptions into a new moduleJake Hunsaker2020-04-082-321/+342
| | | | | | | | | Moves `SoSOptions()` and the related bits to a new sos/options.py location. This should allow for easier maintenance and ongoing development as our option handling approach will be shared across components. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [4.0] Create new binary and define new entrypoints for subcommandsJake Hunsaker2020-04-082-14/+116
| | | | | | | | | | | | | | | This is the first patch to add a new `sos` binary to act as the new commandline interface for users. It adds the basic `SoS()` and `SoSComponent()` classes that will be built out and used going forward for new subcommand development. Actual functionality will be added in coming patches, as this is mainly serving as a checkpoint to avoid over-large commits affecting wide swathes of changes at once. Resolves: #1986 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [utilities] Move gettext into utilitiesJake Hunsaker2020-04-071-0/+12
| | | | Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [4.0] Remove __run__.pyJake Hunsaker2020-04-071-14/+0
| | | | | | | | Removes the redundant __run__.py from the project root, as it has not been used for quite some time and the legacy `sosreport` binary was its replacement. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [report] Move sosreport.py into report/__init__.pyJake Hunsaker2020-04-073-1469/+1469
| | | | | | | Moves the legacy sosreport.py into sos/report/__init__.py as part of the reorganization for 4.0 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [global] Fix report import pathsJake Hunsaker2020-04-07308-319/+323
| | | | | | | | | | | Updates the uses of 'from sos.plugins' to 'from sos.report.plugins' in order to fix imports across the project with the new tree organization. Additionally, the legacy `sosreport` binary now injects the user's current working directory into the path the python interpreter uses in order to allow local execution from a git checkout. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [4.0] Re-organize tree for sos-4.0Jake Hunsaker2020-04-07298-0/+0
| | | | | | | | | | | | | | | This is the beginning of the sos-4.0 design rework. First, move the existing `sosreport` binary into a new top-level `bin` dir. The future `sos` binary will also live here. Second, create a `report` subdir within the `sos` module, and move the relevant `sosreport` bits to that subdir. A following commit will update all references like `from sos.plugins` to `from sos.report.plugins`. Related: #1986 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [Plugin] Remove add_udev_info methodJake Hunsaker2020-04-071-19/+0
| | | | | | | | | | Removes the add_udev_info method as its original purpose was to easily iterate over a list of devices which is now handled (better) by add_blockdev_cmd. Resolves: #1508 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [scsi] Use new add_blockdev_cmd methodJake Hunsaker2020-04-071-1/+2
| | | | | | | Updates the scsi plugin to use the new add_blockdev_cmd() method instead of add_udev_info(). Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [fibrechannel] Use new add_blockdev_cmd methodJake Hunsaker2020-04-071-14/+1
| | | | | | | Updates the fibrechannel plugin to replace the ad-hoc device enumeration with the new add_blockdev_cmd method. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [nvme] Use new add_blockdev_cmd methodJake Hunsaker2020-04-071-19/+13
| | | | | | | Updates the nvme plugin to replace the ad-hoc device enumeration and command building with the new add_blockdev_cmd method. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [block] Use new add_blockdev_cmd methodJake Hunsaker2020-04-071-15/+10
| | | | | | | Updates the block plugin to replace the ad-hoc device enumeration and command building with using the new add_blockdev_cmd method. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [Plugin] Add new method for iterating over storage devicesJake Hunsaker2020-04-074-20/+147
| | | | | | | | | | | | | | | | | | | | | | | Adds a new mechanism for iterating over a list of devices with a given command or list of commands. This is to allow us to stop doing ad-hoc device enumeration in multiple plugins and instead provide a consistent behavior for iterating over devices such as disks. Before setting up plugins, sos will now enumerate a list of block devices and fibre devices that is made available to the plugins. From there the new 'add_blockdev_cmd()' method may be passed a command or list of commands that will be iterated over for every device. Commands passed need to include '%(dev)s' in the appropriate place for device name substitution. By default this will iterate over all discovered block devices. The 'devices' parameter may be used to change this, either by passing 'fibre' to instead iterate over fibre devices, or by passing a list of devices to use directly. To filter out or restrict commands to running on specific types of devices, the blacklist and whitelist parameters can be used respectively and can accept either a single regex string or a list of regexes. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [podman] Update plugin to utilize policy container runtimeJake Hunsaker2020-04-071-20/+7
| | | | | | | | | | Updates the plugin to use the new `ContainerRuntime` abstraction provided by the loaded `Policy` rather than shelling out again to get the same data loaded during `Policy` initialization. Resolves: #1873 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [docker] Update plugin to utilize policy container runtimeJake Hunsaker2020-04-071-20/+7
| | | | | | | | Updates the plugin to use the new `ContainerRuntime` abstraction provided by the loaded `Policy` rather than shelling out again to get the same data loaded during `Policy` initialization. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [rabbitmq] Update to use ContainerRuntimeJake Hunsaker2020-04-071-12/+7
| | | | | | | Updates the `rabbitmq` plugin to use the new ContainerRuntime abstraction. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [ovn_central] Use new ContainerRuntime methodsJake Hunsaker2020-04-071-22/+8
| | | | | | | | | | | | Updates `ovn_central` to use the new ContainerRuntime methods exposed to the `Plugin` class. Rather than manually checking for runtimes, and then manually building the exec commands, the plugin now relies on the `Plugin` methods for discovering containers and formatting commands to be run in a container, if applicable. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [Openstack] Update plugins to use ContainerRuntime methodsJake Hunsaker2020-04-076-60/+7
| | | | | | | | Removes the duplicated container runtime checks from individual plugins, and updates them to use the new methods exposed in `Plugin`, thus reducing the number of times sos calls out to the runtime. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [Plugin] Integrate ContainerRuntime in Plugin APIJake Hunsaker2020-04-071-5/+97
| | | | | | | | | | | | | | | | | | Integrates the ContainerRuntime checks to the Plugin API - `Plugin.exec_cmd()` now accepts a `container` argument that, if set, will first check to see if the container exists and if it does, format the requested command to be executed by the runtime in the selected container. If the runtime is not available, or the container does not exist, the command is not run. Additionally adds a `container_exists()` call to check to see if a container is present/running, and a `fmt_container_cmd()` call that wraps the `ContainerRuntime` method to allow for easy formatting of commands for `add_cmd_output()` calls. Closes: #1866 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [Policy] Add Container Runtime abstraction classJake Hunsaker2020-04-073-35/+218
| | | | | | | | | | | | | | | | | Adds a `ContainerRuntime()` class to allow policies to specify a container runtime to allow plugins to utilize. The `ContainerRuntime` is intended to allow for the discovery of containers, including specific ones by name, and for the execution of commands inside those containers. This is meant to remove the overhead of manually defining ways to determine an active runtime and if a component is containerized within plugins. Related: #1866 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [ovirt] add additional log files to collect.Ehud Yonasi2020-04-071-0/+6
| | | | | | | | | Adds collection of log files for metrics, setup, and vmconsole Resolves: #2002 Signed-off-by: Ehud Yonasi <eyonasi@redhat.com> Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [hardware] Add output of lshwJose Castillo2020-04-071-0/+1
| | | | | | | | | This plugin adds the output of the command lshw, and its output complements what we already collect with dmidecode. Signed-off-by: Jose Castillo <jcastillo@redhat.com> Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [ovirt_engine_backup] Add a new "ovirt_engine_backup" plugin3.9.1Miguel Martin2020-03-241-0/+52
| | | | | | | | | Add a new plugin to retrieve an oVirt engine database backup. Resolves: #1977 Signed-off-by: Miguel Martin <mmartinv@redhat.com> Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [Plugin] Collect plugin service status by defaultJake Hunsaker2020-03-244-3/+12
| | | | | | | | | | | | | | By default, plugins will now capture service status information from the init system for any services defined in the plugin's `services` member, provided that that service actually exists on the system. This is done by calling a new method, `add_default_collections()` before we call `Plugin.setup()` for each plugin. This will allow us to more easily extend default collection behaviors going forward. Resolves: #1965 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [sos_extras] A new plugin to collect user defined dataPavel Moravec2020-03-181-0/+92
| | | | | | | | | | | | | | | | | | | | | | | | | | | Enabled by presence of /etc/sos.extras.d/ directory, the plugin will execute all commands from all files in the directory, in order to collect extra user-defined data e.g. specific for a given system or product (or not yet being collected by sosreport otherwise). Empty lines or lines starting by '#' are ignored. Files or file patterns to be collected must be preceded by ':' , optionally followed by sizelimit. Examples: :/path/to/file :/path/to/files* sizelimit Other lines are treated as commands to execute, with output stored under sos_commands/sos_extras/<filename>/<command> directory. Resolves: #1663 Resolves: #1788 Signed-off-by: Pavel Moravec <pmoravec@redhat.com> Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [Plugin] New Validation Framework pluginCédric Jeanneret2020-03-181-0/+40
| | | | | | | | | | | | | The Validation Framework provides an overview of deployed services. For now, this Framework is linked to OpenStack and TripleO[1], but since it might be used by other products, it's probably better to get a generic name. Resolves: #1970 Signed-off-by: Cédric Jeanneret <cjeanner@redhat.com> Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [foreman] collect smart proxies detailsJan Jansky2020-03-181-1/+5
| | | | | | | | | | Adding commands which collects smart proxies details. Closes: #1972 Signed-off-by: Jan Jansky <jjansky@redhat.com> Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [tests] Make simple.sh consistentBryan Quigley2020-03-181-9/+1
| | | | | | | | | | | We no longer have to workaround an odd LXD/Travis interaction so make simple.sh not treat Travis special. Closes: #1921 Resolves: #1983 Signed-off-by: Bryan Quigley <bryan.quigley@canonical.com> Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [console] Add new pluginKazuhito Hagio2020-03-181-0/+29
| | | | | | | | | | Add a new plugin for collecting information about console and keyboard including the status of console and Scroll Lock flag. Resolves: #1981 Signed-off-by: Kazuhito Hagio <k-hagio-ab@nec.com> Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [sar] Fix "sar: could not list /var/log/sa/*" warningKazuhito Hagio2020-03-181-4/+4
| | | | | | | | | | | | | | Commit d334c5dedbcf ("[sar] Fix the parameter specified in add_copy_spec() to wildcard") appended the wildcard to the sa_path. But since it is passed to os.listdir() as is, the following warning is printed and later commands are not collected. [plugin:sar] sar: could not list /var/log/sa/* Resolves: #1978 Signed-off-by: Kazuhito Hagio <k-hagio-ab@nec.com> Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [selinux] collect /var/lib/selinuxRenaud Métrich2020-03-181-1/+2
| | | | | | | | | | On RHEL 8, modules and contexts are not in /etc/selinux/<policy> directory anymore, but in /var/lib/selinux/<policy> directory. Resolves: #1976 Signed-off-by: Renaud Métrich <rmetrich@redhat.com> Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [powerpc] Remove check_enablement() overrideJake Hunsaker2020-03-181-3/+1
| | | | | | | | | Removes the check_enablement() override for this plugin and replaces it with the new architecture enablement check. Closes: #1975 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [iprconfig] Remove check_enablement() overrideJake Hunsaker2020-03-181-5/+3
| | | | | | | | | Replaces the check_enablement() override with the standard package check, and the new arch check functionality. Related: #1975 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [pci] Do not run lspci commands when buses are not enumeratedJake Hunsaker2020-03-181-2/+4
| | | | | | | | | | From support team feedback, power systems may not have useful pci information. Now, gate `lspci` command collection behind the presence of bus directories under /proc/bus/pci. Related: #1975 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [Plugin] Add enablement check based on architectureJake Hunsaker2020-03-181-4/+15
| | | | | | | | | | | | Plugins may now set an 'architectures' tuple when instantiating a Plugin to restrict that plugin from enabling only on those architectures provided any other enablement checks pass as well. By default, a plugin is considered to be runnable on any architecture. Related: #1975 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [Plugin] Allow negative matching for SoSPredicateJake Hunsaker2020-03-181-27/+70
| | | | | | | | | | | | | | | | | | | | Extends SoSPredicate to allow for 'negative' presence checks, e.g. a package is _not_ installed or a system is _not_ of a specified list of architectures. This is done by setting the relevant test in the 'required' dict handed to SoSPredicate instances to be set to 'none' (the string, not the NoneType). For example, in order to run a command provided that a particular service is not running, the following predicate would be used: SoSPredicate(self, services='foobar', required={'services': 'none'}) Related: #1975 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [Plugin] Extend SoSPredicate to gate on system architectureJake Hunsaker2020-03-181-6/+28
| | | | | | | | | | | | | Extends `SoSPredicate()` so that plugins may test for being run on specific architectures. This predicate test only really supports the 'any' test as a system can only have one architecture, so the use of an 'all' predicate test does not make sense. Related: #1975 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [Plugin] Do not write empty files to archive on command failureJake Hunsaker2020-03-181-0/+4
| | | | | | | | | | | | | | | | If a command is not found on the system, sos traditionally will handle that failed call by simply not writing any output to the archive. However, if the command was given a suggested_filename or a root_symlink parameter in the `add_cmd_output()` call, we would end up writing an empty file to the archive. Now, we will re-check the status of the command attempt after the chroot check (and possible re-run) is done, and if the command "still" is not found, exit immediately to avoid the empty writes. Related: #1975 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [lxd] Drop db collection and introduce lxd.buginfoEric Desrochers2020-03-161-26/+18
| | | | | | | | | | | | | | | | | | | | | The content of lxd database is rarely useful unless DB corruption and can get very large. This can be run manually if needed (outside sosreport) lxd.buginfo command only available via SNAP installation, would have the advantage of not needing updates whenever lxd upstream add a new feature or find something new that’s worth capturing. LXD upstream reference: https://discuss.linuxcontainers.org/t/what-lxd-information-should-be-collected-by-sosreport https://github.com/lxc/lxd-pkg-snap/issues/14 Resolves: #1982 Signed-off-by: Eric Desrochers <eric.desrochers@canonical.com> Signed-off-by: Bryan Quigley <bryan.quigley@canonical.com>
* [Foreman] collect /etc/sysconfig/dynflowdWilliam Bradford Clark2020-02-261-0/+1
| | | | | | | Resolves: #1966 Signed-off-by: William Bradford Clark <wclark@redhat.com> Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [tests] add license header to source filesBryn M. Reeves2020-02-269-0/+63
| | | | | | | Resolves: #1958 Signed-off-by: Bryn M. Reeves <bmr@redhat.com> Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [tests] delete random shebangsBryn M. Reeves2020-02-264-8/+0
| | | | | | | | | | | | | Various unit test source files in tests/ have unnecessary shell "shebang" notation specifying a particular Python interpereter. Since these files are executed under the test suite runner there is no need for them to include these lines. Related: #1949 Signed-off-by: Bryn M. Reeves <bmr@redhat.com> Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>