9.1.2. cobbler.cobbler_collections package
9.1.2.1. Submodules
9.1.2.2. cobbler.cobbler_collections.collection module
Copyright 2006-2009, Red Hat, Inc and Others Michael DeHaan <michael.dehaan AT gmail>
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- class cobbler.cobbler_collections.collection.Collection(collection_mgr: CollectionManager)[source]
Bases:
objectBase class for any serializable list of things.
- SEARCH_REKEY = {'boot_loader': 'boot_loaders', 'dhcp-tag': 'dhcp_tag', 'enable_gpxe': 'enable_ipxe', 'inherit': 'parent', 'ip': 'ip_address', 'kopts': 'kernel_options', 'kopts_post': 'kernel_options_post', 'mac': 'mac_address', 'netboot-enabled': 'netboot_enabled', 'virt-auto-boot': 'virt_auto_boot', 'virt-bridge': 'virt_bridge', 'virt-cpus': 'virt_cpus', 'virt-disk-driver': 'virt_disk_driver', 'virt-file-size': 'virt_file_size', 'virt-group': 'virt_group', 'virt-host': 'virt_host', 'virt-path': 'virt_path', 'virt-ram': 'virt_ram', 'virt-type': 'virt_type'}
- add(ref: Item, save: bool = False, with_copy: bool = False, with_triggers: bool = True, with_sync: bool = True, quick_pxe_update: bool = False, check_for_duplicate_names: bool = False)[source]
Add an object to the collection
- Parameters:
ref – The reference to the object.
save – If this is true then the objet is persisted on the disk.
with_copy – Is a bit of a misnomer, but lots of internal add operations can run with “with_copy” as False. True means a real final commit, as if entered from the command line (or basically, by a user). With with_copy as False, the particular add call might just be being run during deserialization, in which case extra semantics around the add don’t really apply. So, in that case, don’t run any triggers and don’t deal with any actual files.
with_sync – If a sync should be triggered when the object is renamed.
with_triggers – If triggers should be run when the object is added.
quick_pxe_update – This decides if there should be run a quick or full update after the add was done.
check_for_duplicate_names – If the name of an object should be unique or not.
- Raises:
TypError – Raised in case
refis None.ValueError – Raised in case the name of
refis empty.
- add_to_indexes(ref: ITEM) None[source]
Add indexes for the object. :param ref: The reference to the object whose indexes are updated.
- static collection_type() str[source]
Returns the string key for the name of the collection (used by serializer etc)
- static collection_types() str[source]
Returns the string key for the plural name of the collection (used by serializer)
- copy(ref: Item, newname: str, with_sync: bool = True, with_triggers: bool = True)[source]
Copy an object with a new name into the same collection.
- Parameters:
ref – The reference to the object which should be copied.
newname – The new name for the copied object.
with_sync – If a sync should be triggered when the object is copying.
with_triggers – If triggers should be run when the object is copying.
- property deserialize_running: bool
If set to
true, then the collection items are currently being loaded from disk. :getter: The deserialize_running for the collection. :setter: The new deserialize_running value for the collection.
- factory_produce(api: CobblerAPI, seed_data: Dict[str, Any]) Item[source]
Must override in subclass. Factory_produce returns an Item object from dict.
- Parameters:
api – The API to resolve all information with.
seed_data – Unused Parameter in the base collection.
- find(name: str = '', return_list: bool = False, no_errors: bool = False, **kargs: Any) List[Item] | Item | None[source]
Return first object in the collection that matches all item=’value’ pairs passed, else return None if no objects can be found. When return_list is set, can also return a list. Empty list would be returned instead of None in that case.
- Parameters:
name – The object name which should be found.
return_list – If a list should be returned or the first match.
no_errors – If errors which are possibly thrown while searching should be ignored or not.
kargs – If name is present, this is optional, otherwise this dict needs to have at least a key with
name. You may specify more keys to finetune the search.
- Returns:
The first item or a list with all matches.
- Raises:
ValueError – In case no arguments for searching were specified.
- find_by_indexes(kargs: Dict[str, Any]) List[ITEM] | None[source]
Searching for items in the collection by indexes. :param kwargs: The dict to match for the items.
- from_list(_list: List[Dict[str, Any]])[source]
Create all collection object items from
_list.- Parameters:
_list – The list with all item dictionaries.
- get(name: str) Item | None[source]
Return object with name in the collection
- Parameters:
name – The name of the object to retrieve from the collection.
- Returns:
The object if it exists. Otherwise None.
- get_names() List[str][source]
Return list of names in the collection. :return: list of names in the collection.
- property inmemory: bool
If set to
true, then all items of the collection are loaded into memory. :getter: The inmemory for the collection. :setter: The new inmemory value for the collection.
- remove(name: str, with_delete: bool = True, with_sync: bool = True, with_triggers: bool = True, recursive: bool = False) None[source]
Remove an item from collection. This method must be overridden in any subclass.
- Parameters:
name – Item Name
with_delete – sync and run triggers
with_sync – sync to server file system
with_triggers – run “on delete” triggers
recursive – recursively delete children
- Returns:
NotImplementedError
- remove_from_indexes(ref: ITEM) None[source]
Remove index keys for the object. :param ref: The reference to the object whose index keys are removed.
- rename(ref: Item, newname: str, with_sync: bool = True, with_triggers: bool = True)[source]
Allows an object “ref” to be given a new name without affecting the rest of the object tree.
- Parameters:
ref – The reference to the object which should be renamed.
newname – The new name for the object.
with_sync – If a sync should be triggered when the object is renamed.
with_triggers – If triggers should be run when the object is renamed.
9.1.2.3. cobbler.cobbler_collections.distros module
Copyright 2006-2009, Red Hat, Inc and Others Michael DeHaan <michael.dehaan AT gmail>
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- class cobbler.cobbler_collections.distros.Distros(collection_mgr: CollectionManager)[source]
Bases:
CollectionA distro represents a network bootable matched set of kernels and initrd files.
- static collection_type() str[source]
Returns the string key for the name of the collection (used by serializer etc)
- static collection_types() str[source]
Returns the string key for the plural name of the collection (used by serializer)
- remove(name, with_delete: bool = True, with_sync: bool = True, with_triggers: bool = True, recursive: bool = False)[source]
Remove element named ‘name’ from the collection
- Raises:
CX – In case any subitem (profiles or systems) would be orphaned. If the option
recursiveis set then the orphaned items would be removed automatically.
9.1.2.4. cobbler.cobbler_collections.files module
Copyright 2010, Kelsey Hightower Kelsey Hightower <kelsey.hightower@gmail.com>
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- class cobbler.cobbler_collections.files.Files(collection_mgr: CollectionManager)[source]
Bases:
CollectionFiles provide a container for file resources.
- static collection_type() str[source]
Returns the string key for the name of the collection (used by serializer etc)
9.1.2.5. cobbler.cobbler_collections.images module
Copyright 2006-2009, Red Hat, Inc and Others Michael DeHaan <michael.dehaan AT gmail>
This software may be freely redistributed under the terms of the GNU general public license.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- class cobbler.cobbler_collections.images.Images(collection_mgr: CollectionManager)[source]
Bases:
CollectionA image instance represents a ISO or virt image we want to track and repeatedly install. It differs from a answer-file based installation.
- static collection_type() str[source]
Returns the string key for the name of the collection (used by serializer etc)
9.1.2.6. cobbler.cobbler_collections.manager module
Repository of the Cobbler object model
Copyright 2006-2009, Red Hat, Inc and Others Michael DeHaan <michael.dehaan AT gmail>
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- class cobbler.cobbler_collections.manager.CollectionManager(api: CobblerAPI)[source]
Bases:
objectManages a definitive copy of all data cobbler_collections with weakrefs pointing back into the class so they can understand each other’s contents.
- deserialize()[source]
Load all cobbler_collections from disk
- Raises:
CX – if there is an error in deserialization
- deserialize_one_item(obj) dict[source]
Load a collection item from disk :param obj: collection item
- get_items(collection_type: str) Distros | Profiles | Systems | Repos | Images | Mgmtclasses | Packages | Files | Menus | Settings[source]
Get a full collection of a single type.
Valid Values vor
collection_typeare: “distro”, “profile”, “repo”, “image”, “mgmtclass”, “package”, “file” and “settings”.- Parameters:
collection_type – The type of collection to return.
- Returns:
The collection if
collection_typeis valid.- Raises:
CX – If the
collection_typeis invalid.
- has_loaded = False
Return the definitive copy of the Menus collection
- mgmtclasses() Mgmtclasses[source]
Return the definitive copy of the Mgmtclasses collection
- serialize_delete(collection, item)[source]
Delete a collection item from disk
- Parameters:
collection – collection
item – collection item
- serialize_delete_one_item(item)[source]
Save a collection item to disk
- Parameters:
item – collection item
9.1.2.8. cobbler.cobbler_collections.mgmtclasses module
Copyright 2010, Kelsey Hightower Kelsey Hightower <kelsey.hightower@gmail.com>
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- class cobbler.cobbler_collections.mgmtclasses.Mgmtclasses(collection_mgr: CollectionManager)[source]
Bases:
CollectionA mgmtclass provides a container for management resources.
- static collection_type() str[source]
Returns the string key for the name of the collection (used by serializer etc)
- static collection_types() str[source]
Returns the string key for the plural name of the collection (used by serializer)
9.1.2.9. cobbler.cobbler_collections.packages module
Copyright 2010, Kelsey Hightower Kelsey Hightower <kelsey.hightower@gmail.com>
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- class cobbler.cobbler_collections.packages.Packages(collection_mgr: CollectionManager)[source]
Bases:
CollectionA package provides a container for package resources.
- static collection_type() str[source]
Returns the string key for the name of the collection (used by serializer etc)
9.1.2.10. cobbler.cobbler_collections.profiles module
Copyright 2006-2009, Red Hat, Inc and Others Michael DeHaan <michael.dehaan AT gmail>
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- class cobbler.cobbler_collections.profiles.Profiles(collection_mgr: CollectionManager)[source]
Bases:
CollectionA profile represents a distro paired with an automatic OS installation template file.
- static collection_type() str[source]
Returns the string key for the name of the collection (used by serializer etc)
9.1.2.11. cobbler.cobbler_collections.repos module
Copyright 2006-2009, Red Hat, Inc and Others Michael DeHaan <michael.dehaan AT gmail>
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- class cobbler.cobbler_collections.repos.Repos(collection_mgr: CollectionManager)[source]
Bases:
CollectionRepositories in Cobbler are way to create a local mirror of a yum repository. When used in conjunction with a mirrored distro tree (see “cobbler import”), outside bandwidth needs can be reduced and/or eliminated.
- static collection_type() str[source]
Returns the string key for the name of the collection (used by serializer etc)
9.1.2.12. cobbler.cobbler_collections.systems module
Copyright 2008-2009, Red Hat, Inc and Others Michael DeHaan <michael.dehaan AT gmail>
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- class cobbler.cobbler_collections.systems.Systems(collection_mgr: CollectionManager)[source]
Bases:
CollectionSystems are hostnames/MACs/IP names and the associated profile they belong to.
- add_to_indexes(ref: System) None[source]
Add indexes for the system. :param ref: The reference to the system whose indexes are updated.
- static collection_type() str[source]
Returns the string key for the name of the collection (used by serializer etc)
- static collection_types() str[source]
Returns the string key for the plural name of the collection (used by serializer)
- factory_produce(api, item_dict)[source]
Return a System forged from item_dict
- Parameters:
api – TODO
item_dict – TODO
- Returns:
TODO
- remove(name: str, with_delete: bool = True, with_sync: bool = True, with_triggers: bool = True, recursive: bool = False)[source]
Remove element named ‘name’ from the collection
- Raises:
CX – In case the name of the object was not given.
- remove_from_indexes(ref: System) None[source]
Remove index keys for the system. :param ref: The reference to the system whose index keys are removed.
- remove_interface_from_indexes(ref: System, name: str) None[source]
Remove index keys for the system interface. :param ref: The reference to the system whose index keys are removed. :param name: The reference to the system whose index keys are removed.
- update_interface_index_value(interface: NetworkInterface, attribute_name: str, old_value: str, new_value: str) None[source]
TODO
- Parameters:
interface – TODO
attribute_name – TODO
old_value – TODO
new_value – TODO
9.1.2.13. Module contents
The collections have the responsibility of ensuring the relational validity of the data present in Cobbler. Further they hold the data at runtime.