sos.policies — Policy Interface

class sos.policies.GenericPolicy(sysroot=None)[source]

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

get_msg()[source]
class sos.policies.LinuxPolicy(sysroot=None)[source]

Bases: sos.policies.Policy

This policy is meant to be an abc class that provides common implementations used in Linux distros

PATH = '/bin:/sbin:/usr/bin:/usr/sbin'
default_runlevel()[source]
distro = 'Linux'
get_arch()[source]
get_local_name()[source]

Returns the name usd in the pre_work step

get_preferred_hash_name()[source]
host_name()[source]
is_kernel_smp()[source]
kernel_version()[source]
pre_work()[source]
sanitize_case_id(case_id)[source]
sanitize_report_name(report_name)[source]
vendor = 'None'
class sos.policies.PackageManager(chroot=None, query_command=None, verify_command=None, verify_filter=None)[source]

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.

all_pkgs()[source]

Return a list of all packages.

all_pkgs_by_name(name)[source]

Return a list of packages that match name.

all_pkgs_by_name_regex(regex_name, flags=0)[source]

Return a list of packages that match regex_name.

build_verify_command(self, packages) → str[source]

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
chroot = None
get_pkg_list()[source]

Returns a dictionary of packages in the following format:

{'package_name': {'name': 'package_name',
                  'version': 'major.minor.version'}}
pkg_by_name(name)[source]

Return a single package that matches name.

pkg_nvra(pkg)[source]
query_command = None
verify_command = None
verify_filter = None
class sos.policies.Policy(sysroot=None)[source]

Bases: object

PATH = ''
check()[source]

This function is responsible for determining if the underlying system is supported by this policy.

del_valid_subclasses()[source]
display_results(archive, directory, checksum)[source]
dist_version()[source]

Return the OS version

distro = 'Unknown'
get_archive_name()[source]

This function should return the filename of the archive without the extension.

get_msg()[source]

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.

get_preferred_archive()[source]

Return the class object of the prefered archive format for this platform

get_preferred_hash_name()[source]

Returns the string name of the hashlib-supported checksum algorithm to use

get_tmp_dir(opt_tmp_dir)[source]
get_valid_subclasses()[source]
host_sysroot()[source]
in_container()[source]

Returns True if sos is running inside a container environment.

is_root()[source]

This method should return true if the user calling the script is considered to be a superuser

match_plugin(plugin_classes)[source]
msg = 'This command will collect system configuration and diagnostic information from this %(distro)s system. An archive containing the collected information will be generated in %(tmpdir)s.\n\nFor more information on %(vendor)s visit:\n\n %(vendor_url)s\n\nThe generated archive may contain data considered sensitive and its content should be reviewed by the originating organization before being passed to any third party.\n\nNo changes will be made to system configuration.\n%(vendor_text)s\n'
pkg_by_name(pkg)[source]
post_work()[source]

This function is called after the sosreport has been generated.

pre_work()[source]

This function is called prior to collection.

set_commons(commons)[source]
set_exec_path()[source]
set_valid_subclasses(subclasses)[source]
valid_subclasses

list of subclasses that this policy can process

validate_plugin(plugin_class, experimental=False)[source]

Verifies that the plugin_class should execute under this policy

vendor = 'Unknown'
vendor_text = ''
vendor_url = 'http://www.example.com/'
sos.policies.import_policy(name)[source]
sos.policies.load(cache={}, sysroot=None)[source]