7.1.7.1.5. cobbler.modules.serializers package

7.1.7.1.5.1. Submodules

7.1.7.1.5.2. cobbler.modules.serializers.file module

Cobbler’s file-based object serializer. As of 9/2014, this is Cobbler’s default serializer and the most stable one. It uses multiple JSON files in /var/lib/cobbler/collections/distros, profiles, etc

class cobbler.modules.serializers.file.FileSerializer(api: CobblerAPI)[source]

Bases: StorageBase

JSON-file based serializer for Cobbler items.

deserialize(collection: Collection[ITEM], topological: bool = True) None[source]

Load a collection from disk.

Parameters:
  • collection – The Cobbler collection to know the type of the item.

  • topological – Sort collection based on each items’ depth attribute in the list of collection items. This ensures properly ordered object loading from disk with objects having parent/child relationships, i.e. profiles/subprofiles. See cobbler/items/abstract/inheritable_item.py

deserialize_item(collection_type: str, uid: str) Dict[str, Any][source]

Get a collection item from disk and parse it into an object.

Parameters:
  • collection_type – The collection type to fetch.

  • uid – collection Item uid

Returns:

Dictionary of the collection item.

deserialize_raw(collection_type: str) List[Dict[str, Any]][source]

Read the collection from the disk.

Parameters:

collection_type – The collection type to read.

Returns:

The list of collection dicts.

serialize(collection: Collection[ITEM]) None[source]

Save a collection to disk

Parameters:

collection – The collection to serialize.

serialize_delete(collection: Collection[ITEM], item: ITEM) None[source]

Delete a collection item from disk.

Parameters:
  • collection – collection

  • item – collection item

serialize_item(collection: Collection[ITEM], item: ITEM) None[source]

Save a collection item to disk

Parameters:
  • collection – The Cobbler collection to know the type of the item.

  • item – The collection item to serialize.

cobbler.modules.serializers.file.register() str[source]

The mandatory Cobbler module registration hook.

cobbler.modules.serializers.file.storage_factory(api: CobblerAPI) FileSerializer[source]

Factory method to allow the serializer interface to instaniate the concrete serializer without knowing which serializer is initalized.

cobbler.modules.serializers.file.what() str[source]

Module identification function

7.1.7.1.5.3. cobbler.modules.serializers.mongodb module

Cobbler’s Mongo database based object serializer.

class cobbler.modules.serializers.mongodb.MongoDBSerializer(api: CobblerAPI)[source]

Bases: StorageBase

MongoDB based serializer for Cobbler items.

deserialize(collection: Collection[ITEM], topological: bool = True) None[source]

Load a collection from disk.

Parameters:
  • collection – The Cobbler collection to know the type of the item.

  • topological – Sort collection based on each items’ depth attribute in the list of collection items. This ensures properly ordered object loading from disk with objects having parent/child relationships, i.e. profiles/subprofiles. See cobbler/items/abstract/inheritable_item.py

deserialize_item(collection_type: str, uid: str) Dict[str, Any][source]

Get a collection item from database.

Parameters:
  • collection_type – The collection type to fetch.

  • uid – collection Item uid

Returns:

Dictionary of the collection item.

deserialize_raw(collection_type: str) List[Dict[str, Any]][source]

Read the collection from the disk.

Parameters:

collection_type – The collection type to read.

Returns:

The list of collection dicts.

serialize(collection: Collection[ITEM]) None[source]

Save a collection to disk

Parameters:

collection – The collection to serialize.

serialize_delete(collection: Collection[ITEM], item: ITEM) None[source]

Delete a collection item from disk.

Parameters:
  • collection – collection

  • item – collection item

serialize_item(collection: Collection[ITEM], item: ITEM) None[source]

Save a collection item to disk

Parameters:
  • collection – The Cobbler collection to know the type of the item.

  • item – The collection item to serialize.

cobbler.modules.serializers.mongodb.register() str[source]

The mandatory Cobbler module registration hook.

cobbler.modules.serializers.mongodb.storage_factory(api: CobblerAPI) MongoDBSerializer[source]

Factory method to allow the serializer interface to instaniate the concrete serializer without knowing which serializer is initalized.

cobbler.modules.serializers.mongodb.what() str[source]

Module identification function

7.1.7.1.5.4. cobbler.modules.serializers.sqlite module

Cobbler’s SQLite database based object serializer.

class cobbler.modules.serializers.sqlite.SQLiteSerializer(api: CobblerAPI)[source]

Bases: StorageBase

SQLite based serializer for Cobbler items.

Each collection is stored in a separate table named distros, profiles, etc. Tables are created on demand, when the first object of this type is written.

TABLE name // name from collection.collection_types()
(
    uid  TEXT PRIMARY KEY,    // uid from item.uid
    item TEXT                 // JSON representation of an object
)
deserialize(collection: Collection[ITEM], topological: bool = True) None[source]

Load a collection from disk.

Parameters:
  • collection – The Cobbler collection to know the type of the item.

  • topological – Sort collection based on each items’ depth attribute in the list of collection items. This ensures properly ordered object loading from disk with objects having parent/child relationships, i.e. profiles/subprofiles. See cobbler/items/abstract/inheritable_item.py

deserialize_item(collection_type: str, uid: str) Dict[str, Any][source]

Get a collection item from disk and parse it into an object.

Parameters:
  • collection_type – The collection type to deserialize.

  • uid – The collection item uid to deserialize.

Returns:

Dictionary of the collection item.

deserialize_raw(collection_type: str) List[Dict[str, Any]][source]

Read the collection from the table.

Parameters:

collection_type – The collection type to read.

Returns:

The list of collection dicts.

serialize(collection: Collection[ITEM]) None[source]

Save a collection to disk

Parameters:

collection – The collection to serialize.

serialize_delete(collection: Collection[ITEM], item: ITEM) None[source]

Delete a collection item from table

Parameters:
  • collection – The Cobbler collection to know the type of the item.

  • item – The collection item to delete.

serialize_item(collection: Collection[ITEM], item: ITEM) None[source]

Save a collection item to table

Parameters:
  • collection – The Cobbler collection to know the type of the item.

  • item – The collection item to serialize.

cobbler.modules.serializers.sqlite.register() str[source]

The mandatory Cobbler module registration hook.

cobbler.modules.serializers.sqlite.storage_factory(api: CobblerAPI) SQLiteSerializer[source]

Factory method to allow the serializer interface to instaniate the concrete serializer without knowing which serializer is initalized.

cobbler.modules.serializers.sqlite.what() str[source]

Module identification function

7.1.7.1.5.5. Module contents

This module contains code to persist the in memory state of Cobbler on a target. The name of the target should be the name of the Python file. Cobbler is currently only tested against the file serializer.

class cobbler.modules.serializers.StorageBase(api: CobblerAPI)[source]

Bases: object

Base class for all storage modules. The serializers are responsible for transforming the items from and to the serializer representation.

deserialize(collection: Collection[ITEM], topological: bool = True) None[source]

Load a collection from disk.

Parameters:
  • collection – The Cobbler collection to know the type of the item.

  • topological – Sort collection based on each items’ depth attribute in the list of collection items. This ensures properly ordered object loading from disk with objects having parent/child relationships, i.e. profiles/subprofiles. See cobbler/items/abstract/inheritable_item.py

deserialize_item(collection_type: str, uid: str) Dict[str, Any][source]

Get a collection item from disk and parse it into an object.

Parameters:
  • collection_type – The collection type to deserialize.

  • uid – The collection item uid to deserialize.

Returns:

Dictionary of the collection item.

deserialize_raw(collection_type: str) List[Dict[str, Any]][source]

Read the collection from the disk.

Parameters:

collection_type – The collection type to read.

Returns:

The list of collection dicts.

serialize(collection: Collection[ITEM]) None[source]

Save a collection to disk

Parameters:

collection – The collection to serialize.

serialize_delete(collection: Collection[ITEM], item: ITEM) None[source]

Delete a collection item from disk.

Parameters:
  • collection – collection

  • item – collection item

serialize_item(collection: Collection[ITEM], item: ITEM) None[source]

Save a collection item to disk

Parameters:
  • collection – The Cobbler collection to know the type of the item.

  • item – The collection item to serialize.

cobbler.modules.serializers.register() str[source]

The mandatory Cobbler module registration hook.

cobbler.modules.serializers.storage_factory(api: CobblerAPI) StorageBase[source]

Factory method to allow the serializer interface to instaniate the concrete serializer without knowing which serializer is initalized.

cobbler.modules.serializers.what() str[source]

Module identification function