sos.archive — Archive Interface

class sos.archive.Archive[source]

Bases: object

Abstract base class for archives.

add_binary(content, dest)[source]
add_dir(path)[source]
add_file(src, dest=None)[source]
add_link(source, link_name)[source]
add_node(path, mode, device)[source]
add_string(content, dest, mode='w')[source]
classmethod archive_type()[source]

Returns the archive class’s name as a string.

cleanup()[source]

Clean up any temporary resources used by an Archive class.

finalize(method)[source]

Finalize an archive object via method. This may involve creating An archive that is subsequently compressed or simply closing an archive that supports in-line handling. If method is automatic then the following methods are tried in order: xz, gzip

get_archive_path()[source]

Return a string representing the path to the temporary archive. For archive classes that implement in-line handling this will be the archive file itself. Archives that use a directory based cache prior to packaging should return the path to the temporary directory where the report content is located

get_tmp_dir()[source]

Return a temporary directory that clients of the archive may use to write content to. The content of the path is guaranteed to be included in the generated archive.

log = <Logger sos (WARNING)>
log_debug(msg)[source]
log_error(msg)[source]
log_info(msg)[source]
log_warn(msg)[source]
name_max()[source]

Return the maximum file name length this archive can support. This is the lesser of the name length limit of the archive format and any temporary file system based cache.

set_debug(debug)[source]
class sos.archive.FileCacheArchive(name, tmpdir, policy, threads, enc_opts, sysroot, manifest=None)[source]

Bases: sos.archive.Archive

Abstract superclass for archive types that use a temporary cache directory in the file system.

add_binary(content, dest)[source]
add_dir(path)[source]

Create a directory in the archive.

Parameters:path – the path in the host file system to add
add_file(src, dest=None)[source]
add_final_manifest_data(method)[source]

Adds component-agnostic data to the manifest so that individual SoSComponents do not need to redundantly add these manually

add_link(source, link_name)[source]
add_node(path, mode, device)[source]
add_string(content, dest, mode='w')[source]
cleanup()[source]

Clean up any temporary resources used by an Archive class.

dest_path(name)[source]
finalize(method)[source]

Finalize an archive object via method. This may involve creating An archive that is subsequently compressed or simply closing an archive that supports in-line handling. If method is automatic then the following methods are tried in order: xz, gzip

get_archive_path()[source]

Return a string representing the path to the temporary archive. For archive classes that implement in-line handling this will be the archive file itself. Archives that use a directory based cache prior to packaging should return the path to the temporary directory where the report content is located

get_tmp_dir()[source]

Return a temporary directory that clients of the archive may use to write content to. The content of the path is guaranteed to be included in the generated archive.

join_sysroot(path)[source]
makedirs(path, mode=448)[source]

Create path, including leading components.

Used by sos.sosreport to set up sos_* directories.

name_max()[source]

Return the maximum file name length this archive can support. This is the lesser of the name length limit of the archive format and any temporary file system based cache.

open_file(path)[source]
rename_archive_root(cleaner)[source]

Rename the archive to an obfuscated version using an initialized SoSCleaner instance

class sos.archive.TarFileArchive(name, tmpdir, policy, threads, enc_opts, sysroot, manifest=None)[source]

Bases: sos.archive.FileCacheArchive

archive class using python TarFile to create tar archives

copy_permissions_filter(tarinfo)[source]
get_selinux_context(path)[source]
method = None
name()[source]
name_max()[source]

Return the maximum file name length this archive can support. This is the lesser of the name length limit of the archive format and any temporary file system based cache.

set_tarinfo_from_stat(tar_info, fstat, mode=None)[source]