Constants for on-disk preset fields
Bases: sos.policies.Policy
This Policy will be returned if no other policy can be loaded. This should allow for IndependentPlugins to be executed on any system
Bases: object
Encapsulates an init system to provide service-oriented functions to sos.
This should be used to query the status of services, such as if they are enabled or disabled on boot, or if the service is currently running.
Get a list of all services discovered on the system that match the given regex.
Returns the status for the given service name along with the output of the query command
Check if a given service name is disabled
Check if given service name is enabled
Checks if the given service name is in a running state.
This should be overridden by initsystems that subclass InitSystem
Checks if the given service name exists on the system at all, this does not check for the service status
This loads all services known to the init system into a dict. The dict should be keyed by the service name, and contain a dict of the name and service status
Parses the output returned by the query command to make a determination of what the state of the service is
This should be overriden by anything that subclasses InitSystem
Bases: sos.policies.Policy
This policy is meant to be an abc class that provides common implementations used in Linux distros
Returns the name usd in the pre_work step
Formats the user/password credentials using basic auth
Helper function to determine if we should use the policy default upload password or one provided by the user
Helper function to determine if we should use the policy default upload url or one provided by the user
Used by distro policies to potentially change the string used to report upload location from the URL to a more human-friendly string
Helper function to determine if we should use the policy default upload user or one provided by the user
Obtain a list of loaded kernel modules to reference later for plugin enablement and SoSPredicate checks
Should be overridden by policies to determine if a password needs to be provided for upload or not
Should be overridden by policies to determine if a user needs to be provided or not
Entry point for sos attempts to upload the generated archive to a policy or user specified location.
Curerntly there is support for HTTPS, SFTP, and FTP. HTTPS uploads are preferred for policy-defined defaults.
Policies that need to override uploading methods should override the respective upload_https(), upload_sftp(), and/or upload_ftp() methods and should NOT override this method.
In order to enable this for a policy, that policy needs to implement the following:
_upload_user Default username, if any else None _upload_password Default password, if any else None _use_https_streaming Set to True if the HTTPS endpoint
supports streaming data
Attempts to upload the archive to either the policy defined or user provided FTP location.
Attempts to upload the archive to an HTTPS location.
Policies may define whether this upload attempt should use streaming or non-streaming data by setting the use_https_streaming class attr to True
Attempts to upload the archive to an SFTP location.
Due to the lack of well maintained, secure, and generally widespread python libraries for SFTP, sos will shell-out to the system’s local ssh installation in order to handle these uploads.
Do not override this method with one that uses python-paramiko, as the upstream sos team will reject any PR that includes that dependency.
Bases: object
Encapsulates a package manager. If you provide a query_command to the constructor it should print each package on the system in the following format:
package name|package.version
You may also subclass this class and provide a get_pkg_list method to build the list of packages and versions.
Returns a list of files known by the package manager
Return a list of all packages.
Return a list of packages that match name.
Return a list of packages that match regex_name.
Generate a command to verify the list of packages given in packages using the native package manager’s verification tool.
The command to be executed is returned as a string that may be passed to a command execution routine (for e.g. sos_get_command_output().
Parameters: | packages – a string, or a list of strings giving package names to be verified. |
---|---|
Returns: | a string containing an executable command that will perform verification of the given packages. |
Returntype : | str or NoneType |
Returns a dictionary of packages in the following format:
{'package_name': {'name': 'package_name',
‘version’: ‘major.minor.version’}}
Return a single package that matches name.
Bases: object
Add a new on-disk preset and write it to the configured presets path.
Parameters: | preset – the new PresetDefaults to add |
---|
This function is responsible for determining if the underlying system is supported by this policy.
Return the OS version
Find a preset profile matching the specified preset string.
Parameters: | preset – a string containing a preset profile name. |
---|---|
Returns: | a matching PresetProfile. |
This function should return the filename of the archive without the extension.
This uses the policy’s name_pattern attribute to determine the name. There are two pre-defined naming patterns - ‘legacy’ and ‘friendly’ that give names like the following:
legacy - ‘sosreport-tux.123456-20171224185433’ friendly - ‘sosreport-tux-mylabel-123456-2017-12-24-ezcfcop.tar.xz’
A custom name_pattern can be used by a policy provided that it defines name_pattern using a format() style string substitution.
Usable substitutions are:
name - the short hostname of the system label - the label given by –label case - the case id given by –case-id or –ticker-number rand - a random string of 7 alpha characters
Note that if a datestamp is needed, the substring should be set in the name_pattern in the format accepted by strftime().
This method is used to prepare the preamble text to display to the user in non-batch mode. If your policy sets self.distro that text will be substituted accordingly. You can also override this method to do something more complicated.
Return the class object of the prefered archive format for this platform
Returns the string name of the hashlib-supported checksum algorithm to use
Returns True if sos is running inside a container environment.
This method should return true if the user calling the script is considered to be a superuser
Load presets from disk.
Read JSON formatted preset data from the specified path, or the default location at /var/lib/sos/presets.
Parameters: | presets_path – a directory containing JSON presets. |
---|
This function is called after the sosreport has been generated.
This function is called prior to collection.
Return a PresetDefaults object matching the runing host.
Stub method to be implemented by derived policy classes.
Returns: | a PresetDefaults object. |
---|
Add new presets to this policy object.
Merges the presets dictionary presets into this Policy object, or replaces the current presets if replace is True.
presets should be a dictionary mapping str preset names to <class PresetDefaults> objects specifying the command line defaults.
Parameters: |
|
---|
list of subclasses that this policy can process
Verifies that the plugin_class should execute under this policy
Bases: object
Preset command line defaults.
True if this preset if built-in or False otherwise.
Human readable preset description
Preset name, used for selection
Notes on preset behaviour
Options set for this preset
Write this preset to disk in JSON notation.
Parameters: | presets_path – the directory where the preset will be written. |
---|
Bases: sos.policies.InitSystem