libcobblersignatures package

Submodules

libcobblersignatures.cli module

libcobblersignatures.enums module

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

class libcobblersignatures.enums.ExportTypes

Bases: enum.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

Bases: enum.Enum

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

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

Bases: enum.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

Bases: enum.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: libcobblersignatures.enums.ExportTypes, target: str = '', sort_keys: bool = False, indent: Union[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: libcobblersignatures.enums.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.

osbreeds

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.
signaturesjson

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.