aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* [plugins] Convert docstrings to class attrsJake Hunsaker2020-04-30298-578/+590
| | | | | | | | | | Converts all current plugin docstrings into a `short_desc` attribute, that is now referenced by `Plugin.get_description()`. Closes: #1960 Resolves: #2036 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [redhat] fix RH containers without sysrootRobert Thomas Manes2020-04-301-1/+1
| | | | | | | | | | | | Attempting to run sosreport in a container currently will always traceback unless ENV_HOST_SYSROOT is set to '/'. Allow default NoneType sysroot to function as well. Resolves: #2028 Signed off by: Robb Manes <rmanes@redhat.com> Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [sos] Don't double log error level messagesJake Hunsaker2020-04-281-1/+3
| | | | | | | | | | | Only set the logging handler that prints ERROR level messages to console if we're running in quiet mode, as otherwise we'll double log from the normal console handler. Closes: #1999 Resolves: #2033 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [maas] Add snap support to maas pluginAdam Collard2020-04-281-14/+51
| | | | | | | | | | From 2.7.0 onwards, MAAS is using snaps for it's releases, and this changes the location of files and logs. Resolves: #1964 Signed-off-by: Adam Collard <adam.collard@canonical.com> Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [collect] When collect is unavailable, don't fail on unknown optionsJake Hunsaker2020-04-232-1/+9
| | | | | | | | | | | | | | | | | | | | When `collect` is unavailable locally, we should always print the unavailable message in all cases. However, due to the way the parser was configured, any options passed to `sos collect` would trigger argparse's "Unknown argument" error output instead. Now, capture the unknown args when we perform the first parsing to capture the component, then for cases where `collect` is unavailable, simply ignore the parser to always force our own error message to be printed. This commit marks the end of the patchset for collect integration into sos. Closes: #1988 Resolves: #2017 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [collect] Catch keyboard interrupt in disclaimer promptJake Hunsaker2020-04-221-2/+5
| | | | | | | Properly catch a keyboard interrupt during the prompt used in the disclaimer text when --batch is not used. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [cluster] Improve logging formating for errorsJake Hunsaker2020-04-221-4/+3
| | | | | | | | | Removes the header formatted for error level messages, as these are printed to console directly. Additionally improves the formatting of the error message used when we could not get a list of nodes from the cluster. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [sosnode] Fix checking sos version from container imageJake Hunsaker2020-04-223-9/+23
| | | | | | | | | | | Since hooking into Policy(), checking the version of sos installed in a container on a containerized host was failing. Add an explicit override check for this to the policies that need it, rather than bending PackageManager to also allow container based checks since all other package checks will still need to be done against the host and not the container. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [satellite] Simplify node enumerationJake Hunsaker2020-04-221-5/+6
| | | | | | | | Simplifies the node enumeration from the db query using the `copy` function of psql to dump the results to stdout without the DB header/footer. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [sosnode] Do not load local sos information when using --no-localJake Hunsaker2020-04-221-2/+10
| | | | | | | Skip the sos info checks for local execution for --no-local is used. Still load the local policy for package checks however. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [collect] Do not display local host if --no-local is usedJake Hunsaker2020-04-221-2/+3
| | | | | | | | Fixes an issue where even though we weren't collecting from local host if --no-local was specified, we would still display it in the list of nodes to collect from. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [collector] Passthru --threads, replace with --jobs for collectJake Hunsaker2020-04-223-9/+27
| | | | | | | | | | Replaces the previous `--threads` option in collect with a `--jobs` option to determine the number of concurrent collections to run. Uses `--threads` as a passthru option now if the node supports it (sos-3.6+), in an effort to unify option meanings between components. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [collector] Ensure parsed plugin options are always a listJake Hunsaker2020-04-222-4/+7
| | | | | | | | Ensures that the parsed values for any of the plugin enablement or plugin option options are parsed as a list, by changing their parser action to 'extend', like we do with report. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [collector] Always cleanup on graceful exitJake Hunsaker2020-04-221-0/+1
| | | | | | | Rather than leave spurious temp directories on the filesystem from gracefully failed runs, always run cleanup(). Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [collector] Add options to parser in groupsJake Hunsaker2020-04-222-119/+129
| | | | | | | | | | | | Changes the way collector adds options to the parser, such that they are now logically grouped together. Options that modify how report is run on nodes are now under a 'Report Passthru' group, while collector-specific options are listed under a 'Collector' group. This should make --help easier to consume by users. Additionally adds the default global options to a 'Global' group. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [sosnode] Explicitly import all exceptionsJake Hunsaker2020-04-221-1/+9
| | | | | | | Following flake8 review, replace the * import of exceptions, and instead explicitly import each exception used in sosnode. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [PEP257] Fix docstrings in exceptions.pyJake Hunsaker2020-04-221-12/+12
| | | | Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [sosnode] Fix conflicts between password-per-node and sudo optionsJake Hunsaker2020-04-222-3/+6
| | | | | | | | | | | | | | Under specific circumstances, we previously could end up prompting for SSH passwords for nodes that would then be overridden by --password-per-node, which in turn could potentially cause issues for use cases where sudo was used both locally and remotely where the sudo passwords differed (as indicated by password-per-node). Adjust prompting and setting of the sudo passwords so that we prompt the user the correct (minimal) amount of times, and the correct passwords are used for sudo usage (when needed). Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [options] Rename insecure-sudo to nopasswd-sudoJake Hunsaker2020-04-222-8/+8
| | | | Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [sosnode|collector] Add support for newer report optionsJake Hunsaker2020-04-222-20/+63
| | | | | | | | | Adds support for newer sos report options like `allow_system_changes` and `plugin_timeout` to collector. These options are version dependent, so they are evaluated on a per-node basis during final sos command construction. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [collector] Properly remove localhost if local sudo is needed but missingJake Hunsaker2020-04-221-2/+4
| | | | | | | | | | Fixes an issue where we would still attempt to run through local sos report setup if we need sudo but the password was not given. This final catch is done right before sosreport is called on connected nodes, so it will catch any future conditions where no_local gets set after the initial configuration check. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [collector] Don't collect only from localhostJake Hunsaker2020-04-221-0/+12
| | | | | | | | If we detect that we only have localhost 'connected', exit as it is unlikely to be desired to use sos collect to capture an sosreport just from localhost. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [collector] Use jbon cluster is none is determined but we have nodesJake Hunsaker2020-04-221-0/+6
| | | | | | | | | | | If we end up with no cluster determination, but have a manual list of nodes provided, then attempt to continue by setting the cluster type to JBON (just a bunch of nodes - our 'none' cluster). This will not address situations where a cluster type cannot be determined, and the node strings are all regexes. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [collector] Fix local collections requiring sudoJake Hunsaker2020-04-222-9/+49
| | | | | | | | | | Local report generation when running as a non-root user were broken following the transition away from the Configuration() approach. Now, adjust to the new way we execute so that we properly detect non-root runs, prompt for a sudo password if needed, and/or fail appropriately if we cannot use sudo locally for generating the report. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [sos] Do not require collect to be available for base sos runsJake Hunsaker2020-04-222-3/+61
| | | | | | | | | | | | | | | | | | | | | Not all distributions want to add a dependency on pexpect as a default for the installation of sos, as report does not require it. As such, if we fail to import the collector module, add placeholder psuedo-components so that --help output (and attempts to run the command outright) still indicate that the functionality is available in some manner, just with an additional step from the user. This covers two distinct failures during the collector import: 1. The collector module is not present. This implies that the module has been split into sub-packages. The user will need to install the appropriate sub-package for their distro. 2. The pexpect package is not present. The user will just need to install the python3 pexpect package. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [travis] Update 18.04 native run to install pexpectJake Hunsaker2020-04-221-1/+1
| | | | | | | Adds pexpect to the 18.04 native run installation step. For now, leaving it out of the 16.04 run. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [collector] Actually validate cluster option valuesJake Hunsaker2020-04-221-8/+9
| | | | | | | | | At some point in the transition process, it seems we stopped calling `_validate_option()` on provided cluster options via the CLI. Fix that, so that we can be sure that clusters are getting the data types they expect for options they support. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [options] Move ClusterOption into sos.optionsJake Hunsaker2020-04-223-12/+14
| | | | | | | Moves `ClusterOption` into sos.options, instead of living in sos.collector.clusters. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [collector] Don't override _exit from SoSComponentJake Hunsaker2020-04-221-13/+13
| | | | | | | Avoids overriding `_exit()` from `SoSComponent` by renaming the method to simply `exit()`. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [collect] Add sos-collector redirection commandJake Hunsaker2020-04-221-0/+35
| | | | | | | Adds a sos-collector executable under bin/ to serve as a redirection point for legacy sos-collector commands Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [build] Add pexpect dep and update setuptoolsJake Hunsaker2020-04-223-2/+8
| | | | Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [sosnode] Adjust logging mechanism and levelsJake Hunsaker2020-04-221-21/+22
| | | | | | | | | | Changes the logging approach in `SoSNode` so that we more closely align to the approach taken by report. That is, don't print info level messages to console unless they are explicitly set to print to the console - thus allowing us to get sufficient data from a run without needing to always set verbosity higher. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [docs] Add general sos manpage, rename sosreport.1, add symlinksJake Hunsaker2020-04-224-334/+418
| | | | | | | | | | | | Adds a general manpage for the sos command that then points to the available components. Renames sosreport.1 to sos-report.1 to match the component style, and then symlinks sosreport.1 to it. Adds a symlink from sos-collector.1 to sos-collect.1. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [docs] Add manpage for sos collectJake Hunsaker2020-04-221-0/+312
| | | | | | | | | | Adds the manpage from sos-collector to the tree as 'sos-collect', and updates the instances of 'sos-collector' to 'sos collect' within the manpage. Additionally updates the man page to include newly available options. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [collector] Properly set desc attribute for parserJake Hunsaker2020-04-221-1/+8
| | | | Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [linters] PEP8, PEP257, flake8 fixesJake Hunsaker2020-04-225-140/+136
| | | | | | | Various fixups for PEP8, PEP257, and unused imports as highlighted by flake8. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [Hosts|Policies|Collect] Merge SoSHost into Policy, drop SoSHostJake Hunsaker2020-04-228-264/+108
| | | | | | | | | | | | | | | | | | Moves the functions from `SoSHost` into `Policy`, and adjusts the calls in `SoSNode` appropriately. Adds a `pkg_version` method to `PackageManager` to satisfy the version checking requirements that had previously been using `SoSHost`. Finally drops the sos/collector/hosts directory from the tree as it is no longer used. At this point, `sos collect` should be able to be run on any distribution that has a defined `Policy`. Note that new policies will need to specify 2 new class attrs, `sos_pkg_name` and `sos_bin_path` in order for them to be supported as well. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [collector|Policies] Load a Policy rather than SoSHost within SoSNodeJake Hunsaker2020-04-222-14/+15
| | | | | | | | | | | | | | | Rather than load a `SoSHost` instance, `SoSNode` will now load a `Policy` that is determined by the content of `/etc/os-release` on the remote node, as this is a standardized file for Linux-based systems and allows for reliable identification of the host. Each per-node policy will load the host-side package information for use by collector in determining cluster profile and sos capabilities. This per-node policy will not however load an `InitSystem()` or a `ContainerRuntime()`. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [PackageManager] Allow for remote execution of package commandsJake Hunsaker2020-04-227-21/+50
| | | | | | | | | | When loading a policy, there is now support for a `remote_exec` parameter, which should be an ssh command, to which will be appended `PackageManager` related commands so that collector can get package data off of the remote nodes, without having to reimplement a subset of `PackageManager` itself. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [policies] Expose init and probe_runtime to all policiesJake Hunsaker2020-04-226-22/+33
| | | | | | | | | Exposes the `init` and `probe_runtime` parameters of `Policy` to all existing vendor-defined policies. This will allow collector to replace `SoSHost` with `Policy` while not loading the local system's init system and container runtime information. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [Policy] Allow check() to inspect remote contentJake Hunsaker2020-04-228-15/+68
| | | | | | | | | | | Updates the `check()` method within `Policy` to allow consumers to specify a `remote` parameter that can be used in place of the locally available files. This is the first step in merging `SoSHost` from collector with the standard `Policy` which is far better defined. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [collect] Make batch actually completely non-interactiveJake Hunsaker2020-04-221-3/+10
| | | | | | | | | We should not have any exceptions to --batch being non-interactive, so in the event that a user would need a password but fails to provide one alongside the --batch option, it should be expected that the run will fail, rather than stop to collect the password. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [collect] PEP8 fixupsJake Hunsaker2020-04-221-21/+19
| | | | Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [component|collector] Fix collector --list-optionsJake Hunsaker2020-04-222-13/+27
| | | | | | | | | | | Fixes `sos collect --list-options` to actually display known cluster options, as this was initially lost/overlooked in the move from a standalone utility to sos-4.0 integration. Additionally, only setup a log file if none of the known `list*` options are set for any component. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [clusters|node] Fix setting node SSH key based on clusterJake Hunsaker2020-04-223-2/+18
| | | | | | | | | | | | | | Previously, the ovirt (and family) cluster profile would attempt to set a global SSH key if the ovirt-generated key was locally available by changing the options entry for ssh_key. This no longer worked since decoupling the shared dict, so instead create a new mechanism by which clusters may set this. It may prove necessary in the future to extend this functionality to arbitrary settings, however for now I do not see that being common place. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [sosnode] Move modification of sos command into SoSNode()Jake Hunsaker2020-04-223-27/+35
| | | | | | | | Moves the update of options for a node based on a cluster profile out of `Cluster()` and into `SoSNode()`, since the commons dict is not a shared instance. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [collector] Adjust order of prompts and setupJake Hunsaker2020-04-222-34/+41
| | | | | | | | | Since moving away from a shared dict configuration, we need to do the initial steps of displaying the disclaimer, prompting for input, and connecting to the master to determine a cluster type in a slightly different order. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [archive|component] Move archive setup and cleanup into SoSComponentJake Hunsaker2020-04-224-93/+86
| | | | | | | | | | | | | | | | | | | | Moves archive setup and cleanup directly into `SoSComponent()`, then has `SoSCollector` utilize the class rather than manually creating the archive at the end of a run. `SoSReport()` has been updated where needed to leverage the new location of `cleanup()`. This also adds encryption options to `SoSCollector()` to encrypt the final archive. It may prove later than this option should also (or instead) pass the encryption option to the sosreport runs that occur on the hosts. Note that this commit marks the point from which functional, complete, runs of `sos collect` are expected to run without error and result in a tarball of one or more collected sosreports. Resolves: #1988 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [collector] Align with SoSComponent.execute() callsJake Hunsaker2020-04-222-6/+12
| | | | | | | | | Moves the actual workings of SoSCollector() into an execute() method to be called by the sos binary. The initialization of SoSCollector now just handles policy and logging setup, and option validation. All connections to nodes and further command execution is now gated behind execute() Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [collector] Drop Configuration class and use SoSOptionsJake Hunsaker2020-04-225-447/+267
| | | | | | | | | | | | | | | Moves the `collect` component away from using the Configuration class and merges relevant options into the SoSOptions framework, whereas other options are made into either class attrs or part of a 'commons' dict similar to what we do in `report`. At this point, `sos collect` has basic discovery functionality, meaning that a user can run it locally or point it to a master node via `--master` and get a returned list of nodes that would be collected from. However, collection is likely to fail even if the remote command execution works. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>