libcobblersignatures package

Subpackages

Submodules

libcobblersignatures.cli module

The CLI. This CLI is interactive and may not be used in scripts. Please use the library for this purpose. This module contains no logic related to the library, it just contains logic for making it possible to edit the data managed by it.

class libcobblersignatures.cli.IntegerValidator

Bases: Validator

Validator class which checks if the input is an integer.

validate(document)

Validation function which does raise a ValidationError or does not return a value.

Parameters:

document – The user input. Handed over by questionary.

Raises:

ValidationError – In case the text could not be parsed to an integer.

libcobblersignatures.cli.edit_menu()

Second level menu with the purpose to catch all functionality related to editing the current loaded information.

libcobblersignatures.cli.edit_menu_breed_version_info()

Third level menu to edit the information of an Osversion.

libcobblersignatures.cli.edit_menu_breed_version_info_boot_files(my_osversion)
libcobblersignatures.cli.edit_menu_breed_version_info_signatures(my_osversion)

Fourth level menu to edit the signatures of an Osversion.

Parameters:

my_osversion – The Osversion to edit.

libcobblersignatures.cli.edit_menu_breed_version_info_supported_arches(my_osversion)
libcobblersignatures.cli.edit_menu_breed_version_info_supported_repo_breeds(my_osversion)
libcobblersignatures.cli.export_menu()

Second level menu with the purpose to catch all functionality related to exporting the data to a target.

libcobblersignatures.cli.get_os_breed_names() list

This searches for all names of the operation system breeds in the current instance of the library.

Returns:

An empty list if no names are found. Otherwise all names of the operating system breeds.

libcobblersignatures.cli.get_os_version_names(breed) list

This searches for all names of the given breed in the current instance of the library.

Parameters:

breed – This is the breed object.

Returns:

The list of all names if the breed has them. Otherwise an empty list.

libcobblersignatures.cli.import_menu()

Second level menu with the purpose to catch all functionality related to importing the data from a source.

libcobblersignatures.cli.main()

The main entrypoint for the CLI. This is called when you execute the CLI. The exitcode of the application is zero. This is a first level menu.

libcobblersignatures.cli.prepare_version_edit_information_os_version(version)

Add the information of an Osversion to the CLI prompt in the edit menu.

Parameters:

version – The Osversion to fetch information of.

libcobblersignatures.cli.reset_edit_information_os_version()

Reset the CLI edit prompt of the Osversion.

libcobblersignatures.cli.update_choices(question: list, values: list)

Update the choices of the first question to the attached list and add a “Go Back” option.

Parameters:
  • question – The list with the dictionaries with the questions.

  • values – The values which will replace the old choices.

libcobblersignatures.enums module

This module contains all enums which are used in the library.

class libcobblersignatures.enums.ExportTypes(value)

Bases: Enum

An enumeration which defines the possible export targets for the JSON file.

FILE = 0

This value shall be given when the content of the manipulated content shall be exported to a file.

STRING = 1

This value shall be given when the content of the manipulated content shall be exported to a String which is outputted to the shell.

class libcobblersignatures.enums.ImportTypes(value)

Bases: Enum

An enumeration which defines the possible sources for importing the JSON file.

BUILT_IN = 3

This value shall be given when the content shall be imported from the built in file in data/v3/distro_signatures.json

FILE = 0

This value shall be given when the content shall be imported from a file on a file system which is locally accessible.

STRING = 2

This value shall be given when the content shall be imported from a string. This string shall not contain any linebreaks.

URL = 1

This value shall be given when the content shall be imported from a URL.

class libcobblersignatures.enums.OsArchitectures(value)

Bases: Enum

An enumeration which defines the in Cobbler available architectures.

amd64 = 5

Synonym for x86_64.

i386 = 1

32-bit architecture which is also called IA-32 or 80x86 by some people.

ppc = 3

32-bit big-endian PowerPC architecture.

ppc64 = 4

64-bit big-endian PowerPC architecture.

x86_64 = 2

64-bit architecture which is also called x64, x86-64, AMD64 or amd64.

class libcobblersignatures.enums.RepositoryBreeds(value)

Bases: Enum

An enumeration which defines the in Cobbler available repository breeds.

apt = 4

A repository which is managed by apt.

rhn = 2

A repository type from Red Hat which can be used by yum.

rsync = 1

A repository which is synced by rsync.

yum = 3

A repository which is manged by yum.

Module contents

This library contains additionally a CLI which enables you to have a feature equal way to manipulate the objects, as well as to im- and export them.

class libcobblersignatures.Signatures

Bases: object

This is the entry point of the library. You may create one or more objects of this class. Each instance of it is independent of the other. I recommend only to have on object at a time of this class. This library doesn’t persist anything except you explicitly use the export method of the instance.

addosbreed(name: str)

Add a new OsBreed.

Parameters:

name – The name of the new breed. Must not exist in the currently loaded models.

addosversion(breedindex: int, versionname: str, versiondata)

Add a new Osversion.

Parameters:
  • breedindex – The index of the operating system breed. This can be found by using get_breed_index_by_name().

  • versionname – The name of the new version.

  • versiondata – The object with the data of the version to add. If this is None then an empty version will be created.

exportsignatures(export_type: ExportTypes, target: str = '', sort_keys: bool = False, indent: None | int = None)

This is the main export function.

Parameters:
  • export_type – One of the values from the ExportTypes.

  • target – This is only required when using this for a file based export. Otherwise this can be skipped.

  • sort_keys – If the keys of the dictionary should be sorted to be more human readable.

  • indent – If this is something other then None then the JSON will be pretty printed.

Raises:
  • ValueError – When the ExportTypes is not implemented or not known.

  • TypeError – When one of the arguments has the wrong type.

get_breed_index_by_name(name: str) int

Searches with the name of the OsBreed for the index.

Parameters:

name – The name of the OsBreed to look for.

Returns:

The number of the index or -1.

importsignatures(import_type: ImportTypes, source: str)

This is the main import function.

Parameters:
  • import_type – This is one of the four options from the ImportTypes Enum

  • source – A string containing the data to be parsed into a json in the end

jsontomodels()

Convert the loaded JSON to the internal modules. Without calling this the loaded data will not be available for manipulation.

property osbreeds: List[OsBreed]

This property represents the currently manipulated data structures.

Returns:

The list with the content which is currently manipulated.

removeosbreed(index: int)

Remove an operating system breed via its index. All nested content will be removed.

Parameters:

index – The index which will be removed.

removeosversion(breedindex: int, versionname: str)

Remove a single operating system version.

Parameters:
  • breedindex – The index of the operating system breed index.

  • versionname – The name of the version to remove.

property signaturesjson: dict

This property represents the json which was im- or exported.

Raises:

JSONDecodeError – If invalid json is given

Returns:

The last valid content of the json which the library knows about.