7.1.6.1.1. cobbler.items.abstract package
7.1.6.1.1.1. Submodules
7.1.6.1.1.2. cobbler.items.abstract.base_item module
“BaseItem” is the highest point in the object hierarchy of Cobbler. All concrete objects that can be generated should inherit from it or one of its derived classes.
- class cobbler.items.abstract.base_item.BaseItem(api: CobblerAPI, *args: Any, **kwargs: Any)[source]
Bases:
ABCAbstract base class to represent the common attributes that a concrete item needs to have at minimum.
- COLLECTION_TYPE = 'base'
- TYPE_NAME = 'base'
- property cache: ItemCache
Getting the ItemCache object.
Note
This is a read only property.
- Getter:
This is the ItemCache object.
- check_if_valid() None[source]
Raise exceptions if the object state is inconsistent.
- Raises:
CX – In case the name of the item is not set.
- clean_cache(name: str | None = None)[source]
Clearing the Item cache.
- Parameters:
name – The name of Item attribute or None.
- property comment: str
For every object you are able to set a unique comment which will be persisted on the object.
- Getter:
The comment or an emtpy string.
- Setter:
The new comment for the item.
- property ctime: float
Property which represents the creation time of the object.
- Getter:
The float which can be passed to Python time stdlib.
- Setter:
Should only be used by the Cobbler Item Factory.
- deserialize() None[source]
Deserializes the object itself and, if necessary, recursively all the objects it depends on.
- find_match(kwargs: Dict[str, Any], no_errors: bool = False) bool[source]
Find from a given dict if the item matches the kv-pairs.
- Parameters:
kwargs – The dict to match for in this item.
no_errors – How strict this matching is.
- Returns:
True if matches or False if the item does not match.
- find_match_single_key(data: Dict[str, Any], key: str, value: Any, no_errors: bool = False) bool[source]
Look if the data matches or not. This is an alternative for
find_match().- Parameters:
data – The data to search through.
key – The key to look for int the item.
value – The value for the key.
no_errors – How strict this matching is.
- Returns:
Whether the data matches or not.
- from_dict(dictionary: Dict[Any, Any]) None[source]
Modify this object to take on values in
dictionary.- Parameters:
dictionary – This should contain all values which should be updated.
- Raises:
AttributeError – In case during the process of setting a value for an attribute an error occurred.
KeyError – In case there were keys which could not be set in the item dictionary.
- property in_transaction: bool
Property to reflect if the given item is currently part of a transaction.
- Getter:
Returns True if the item is part of at least one transaction.
- Setter:
Set the new boolean if the value is part of a transaction or not.
- property inmemory: bool
If set to
false, only the Item name is in memory. The rest of the Item’s properties can be retrieved either on demand or as a result of theload_itemsbackground task.- Getter:
The inmemory for the item.
- Setter:
The new inmemory value for the object. Should only be used by the Cobbler serializers.
- property mtime: float
Represents the last modification time of the object via the API. This is not updated automagically.
- Getter:
The float which can be fed into a Python time object.
- Setter:
The new time something was edited via the API.
- property name: str
Property which represents the objects name.
- Getter:
The name of the object.
- Setter:
Updating this has broad implications. Please try to use the
rename()functionality from the corresponding collection.
- property owners: List[str]
This is a feature which is related to the ownership module of Cobbler which gives only specific people access to specific records. Otherwise this is just a cosmetic feature to allow assigning records to specific users.
Warning
This is never validated against a list of existing users. Thus you can lock yourself out of a record.
Note
This property can be set to
<<inherit>>.- Getter:
Return the list of users which are currently assigned to the record.
- Setter:
The list of people which should be new owners. May lock you out if you are using the ownership authorization module.
- serialize() Dict[str, Any][source]
This method is a proxy for
to_dict()and contains additional logic for serialization to a persistent location.- Returns:
The dictionary with the information for serialization.
- sort_key(sort_fields: List[Any])[source]
Convert the item to a dict and sort the data after specific given fields.
- Parameters:
sort_fields – The fields to sort the data after.
- Returns:
The sorted data.
- to_dict(resolved: bool = False) Dict[str, Any][source]
This converts everything in this object to a dictionary.
- Parameters:
resolved – If this is True, Cobbler will resolve the values to its final form, rather than give you the objects raw value.
- Returns:
A dictionary with all values present in this object.
- property uid: str
The uid is the internal unique representation of a Cobbler object. It should never be used twice, even after an object was deleted.
- Getter:
The uid for the item. Should be unique across a running Cobbler instance.
- Setter:
The new uid for the object. Should only be used by the Cobbler Item Factory.
7.1.6.1.1.3. cobbler.items.abstract.bootable_item module
Cobbler module that contains the code for a generic Cobbler item.
Changelog:
- V3.4.0 (unreleased):
Renamed to BootableItem
- (Re-)Added Cache implementation with the following new methods and properties:
cacheinmemoryclean_cache()
- Overhauled the parent/child system:
childrenis now insideitem.py.tree_walk()was added.logical_parentwas added.get_parent()was added which returns the internal reference that is used to return the object of theparentproperty.
- Removed:
mgmt_classes
mgmt_parameters
last_cached_mtime
fetchable_files
boot_files
- V3.3.4 (unreleased):
No changes
- V3.3.3:
- Added:
grab_tree
- V3.3.2:
No changes
- V3.3.1:
No changes
- V3.3.0:
This release switched from pure attributes to properties (getters/setters).
- Added:
depth: intcomment: strowners: Union[list, str]mgmt_classes: Union[list, str]mgmt_classes: Union[dict, str]conceptual_parent: Union[distro, profile]
- Removed:
collection_mgr: collection_mgr
- Remove unreliable caching:
get_from_cache()set_cache()remove_from_cache()
- Changed:
Constructor: Takes an instance of
CobblerAPIinstead ofCollectionManager.children: dict -> listctime: int -> floatmtime: int -> floatuid: strkernel_options: dict -> Union[dict, str]kernel_options_post: dict -> Union[dict, str]autoinstall_meta: dict -> Union[dict, str]fetchable_files: dict -> Union[dict, str]boot_files: dict -> Union[dict, str]
- V3.2.2:
No changes
- V3.2.1:
No changes
- V3.2.0:
No changes
- V3.1.2:
No changes
- V3.1.1:
No changes
- V3.1.0:
No changes
- V3.0.1:
No changes
- V3.0.0:
- Added:
collection_mgr: collection_mgrkernel_options: dictkernel_options_post: dictautoinstall_meta: dictfetchable_files: dictboot_files: dicttemplate_files: dictname: strlast_cached_mtime: int
- Changed:
Rename:
cached_datastruct->cached_dict
- Removed:
config
- V2.8.5:
- Added:
config: ?settings: settingsis_subobject: boolparent: Union[distro, profile]children: dictlog_func: collection_mgr.api.logctime: intmtime: intuid: strlast_cached_mtime: intcached_datastruct: str
- class cobbler.items.abstract.bootable_item.BootableItem(api: CobblerAPI, *args: Any, is_subobject: bool = False, **kwargs: Any)[source]
Bases:
InheritableItem,ABCA BootableItem is a serializable thing that can appear in a Collection
- COLLECTION_TYPE = 'bootable_abstract'
- TYPE_NAME = 'bootable_abstract'
- property autoinstall_meta: Dict[Any, Any]
A comma delimited list of key value pairs, like ‘a=b,c=d,e=f’ or a dict. The meta tags are used as input to the templating system to preprocess automatic installation template files.
Note
This property can be set to
<<inherit>>.- Getter:
The metadata or an empty dict.
- Setter:
Accepts anything which can be split by
input_string_or_dict().
- deserialize() None[source]
Deserializes the object itself and, if necessary, recursively all the objects it depends on.
- dump_vars(formatted_output: bool = True, remove_dicts: bool = False) Dict[str, Any] | str[source]
Dump all variables.
- Parameters:
formatted_output – Whether to format the output or not.
remove_dicts – If True the dictionaries will be put into str form.
- Returns:
The raw or formatted data.
- property kernel_options: Dict[str, str | int | float | bool | None | List[str | int | float | bool | None]]
Kernel options are a space delimited list, like ‘a=b c=d e=f g h i=j’ or a dict.
Note
This property can be set to
<<inherit>>.- Getter:
The parsed kernel options represented as a flat dict mapping option names to scalar values (str/bool/int/float/None). Duplicate options result in a list of those scalar values. Nested dictionaries are not supported.
- Setter:
The new kernel options as a space delimited list. May raise
ValueErrorin case of parsing problems.
- property kernel_options_post: Dict[str, str | int | float | bool | None | List[str | int | float | bool | None]]
Post kernel options are a space delimited list, like ‘a=b c=d e=f g h i=j’ or a dict.
Note
This property can be set to
<<inherit>>.- Getter:
The parsed post-install kernel options represented as a flat dict mapping option names to scalar values (str/bool/int/float/None). Duplicate options result in a list of those scalar values. Nested dictionaries are not supported.
- Setter:
Accepts str in above mentioned format or directly a dict.
- property template_files: Dict[str, str]
File mappings for built-in configuration management. The keys are the template source files and the value is the destination. The destination must be inside the bootloc (most of the time TFTP server directory).
This property took over the duties of boot_files additionaly. During signature import the values of “boot_files” will be added to “template_files”.
- Getter:
The dictionary with name-path key-value pairs.
- Setter:
A dict. If not a dict must be a str which is split by
input_string_or_dict(). RaisesTypeErrorotherwise.
7.1.6.1.1.4. cobbler.items.abstract.inheritable_item module
“InheritableItem” the entry point for items that have logical parents and children.
- Changelog:
- V3.4.0 (unreleased):
Initial creation of the class
- class cobbler.items.abstract.inheritable_item.HierarchyItem(dependant_item_type: str, dependant_type_attribute: str)[source]
Bases:
NamedTupleNamedTuple to display the dependency that a single item has. The dependant_item_type object is stored in the dependant_type_attribute attribute of the Item.
For example, an item with HierarchyItem(“profile”, “repos”) contains Profile objects in the repos attribute.
- class cobbler.items.abstract.inheritable_item.InheritableItem(api: CobblerAPI, *args: Any, is_subobject: bool = False, **kwargs: Any)[source]
-
Abstract class that acts as a starting point in the inheritance for items that have a parent and children.
- COLLECTION_TYPE = 'inheritable_abstract'
- LOGICAL_INHERITANCE: Dict[str, LogicalHierarchy] = {'distro': ([], [('profile', 'distro')]), 'distro_group': ([('distro_group', 'parent')], [('distro_group', 'parent')]), 'image': ([], [('system', 'image')]), 'profile': ([('distro', 'distro')], [('system', 'profile')]), 'profile_group': ([('profile_group', 'parent')], [('profile_group', 'parent')]), 'system': ([('image', 'image'), ('profile', 'profile')], []), 'system_group': ([('system_group', 'parent')], [('system_group', 'parent')])}
- TYPE_DEPENDENCIES: Dict[str, List[HierarchyItem]] = {'distro': [('profile', 'distro'), ('distro_group', 'members')], 'distro_group': [('distro_group', 'parent')], 'image': [('system', 'image')], 'menu': [('menu', 'parent'), ('image', 'menu'), ('profile', 'menu')], 'network_interface': [], 'profile': [('profile', 'parent'), ('system', 'profile'), ('profile_group', 'members')], 'profile_group': [('profile_group', 'parent')], 'repo': [('profile', 'repos')], 'system': [('network_interface', 'system_uid'), ('system_group', 'members')], 'system_group': [('system_group', 'parent')]}
- TYPE_NAME = 'inheritable_abstract'
- property children: List[InheritableItem]
The list of logical children of any depth.
Note
This is a read only property.
- Getter:
An empty list in case of items which don’t have logical children.
- property depth: int
This represents the logical depth of an object in the category of the same items. Important for the order of loading items from the disk and other related features where the alphabetical order is incorrect for sorting.
- Getter:
The logical depth of the object.
- Setter:
The new int for the logical object-depth.
- property descendants: List[InheritableItem]
Get objects that depend on this object, i.e. those that would be affected by a cascading delete, etc.
Note
This is a read only property.
- Getter:
This is a list of all descendants. May be empty if none exist.
- get_conceptual_parent() InheritableItem | None[source]
The parent may just be a superclass for something like a sub-profile. Get the first parent of a different type.
- Returns:
The first item which is conceptually not from the same type.
- property get_parent: str
This method returns the name of the parent for the object. In case there is not parent this return empty string.
- grab_tree() List[InheritableItem | Settings][source]
Climb the tree and get every node.
- Returns:
The list of items with all parents from that object upwards the tree. Contains at least the item itself and the settings of Cobbler.
- property is_subobject: bool
Weather the object is a subobject of another object or not.
- Getter:
True in case the object is a subobject, False otherwise.
- Setter:
Sets the value. If this is not a bool, this will raise a
TypeError.
- property logical_parent: Any
This property contains the name of the logical parent of an object. In case there is not parent this return None.
Note
This is a read only property.
- Getter:
Returns the parent object or None if it can’t be resolved via the Cobbler API.
- class cobbler.items.abstract.inheritable_item.LogicalHierarchy(up: List[HierarchyItem], down: List[HierarchyItem])[source]
Bases:
NamedTupleNamedTuple to display the order of hierarchy in the dependency tree.
- down: List[HierarchyItem]
Alias for field number 1
- up: List[HierarchyItem]
Alias for field number 0
7.1.6.1.1.5. cobbler.items.abstract.item_cache module
Module that contains the logic for Cobbler to cache an item.
The cache significantly speeds up Cobbler. This effect is achieved thanks to the reduced amount of lookups that are required to be done.
- class cobbler.items.abstract.item_cache.ItemCache(api: CobblerAPI)[source]
Bases:
objectA Cobbler ItemCache object.
7.1.6.1.1.6. cobbler.items.abstract.item_group module
“ItemGroup” is the abstract base class for groups of items.
- Changelog:
- V3.4.0 (unreleased):
Initial creation of the class
- class cobbler.items.abstract.item_group.ItemGroup(api: CobblerAPI, *args: Any, **kwargs: Any)[source]
Bases:
InheritableItem,ABCAbstract class for item groups in Cobbler.
- COLLECTION_TYPE = 'item_groups'
- TYPE_NAME = 'item_group_abstract'
7.1.6.1.1.7. Module contents
Package to describe the abstract items that we define.