8.1.4.1.5. cobbler.modules.serializers package
8.1.4.1.5.1. Submodules
8.1.4.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
TODO
- 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, name: 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.
name – collection Item name
- 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]
TODO
8.1.4.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
TODO
- 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, name: str) Dict[str, Any] [source]
Get a collection item from database.
- Parameters
collection_type – The collection type to fetch.
name – collection Item name
- 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]
TODO
8.1.4.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
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() (
name TEXT PRIMARY KEY, // name from item.name 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, name: 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.
item_name – The collection item name 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]
TODO
8.1.4.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
TODO
- 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, name: 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.
item_name – The collection item name 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.storage_factory(api: CobblerAPI) StorageBase [source]
TODO