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)[source]

Bases: object

Base 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, 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 renamed.

  • 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 ref is None.

  • ValueError – Raised in case the name of ref is empty.

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, newname)[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.

factory_produce(api, seed_data)[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=False, **kargs: dict) Optional[Union[List[cobbler.items.item.Item], cobbler.items.item.Item]][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.

from_list(_list: list)[source]

Create all collection object items from _list.

Parameters

_list – The list with all item dictionaries.

get(name: str)[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.

remove(name: str, with_delete: bool = True, with_sync: bool = True, with_triggers: bool = True, recursive: bool = False)[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

rename(ref: cobbler.items.item.Item, newname, 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.

to_list() list[source]

Serialize the collection

Returns

All elements of the collection as a list.

to_string() str[source]

Creates a printable representation of the collection suitable for reading by humans or parsing from scripts. Actually scripts would be better off reading the JSON in the cobbler_collections files directly.

Returns

The object as a string representation.

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)[source]

Bases: cobbler.cobbler_collections.collection.Collection

A 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)

factory_produce(api, item_dict)[source]

Return a Distro forged from item_dict

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 recursive is 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)[source]

Bases: cobbler.cobbler_collections.collection.Collection

Files 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)

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 File forged from item_dict

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 a non existent object should be deleted.

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)[source]

Bases: cobbler.cobbler_collections.collection.Collection

A 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)

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 Distro forged from item_dict

remove(name, with_delete: bool = True, with_sync: bool = True, with_triggers: bool = True, recursive: bool = True)[source]

Remove element named ‘name’ from the collection

Raises

CX – In case object does not exist or it would orhan a system.

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)[source]

Bases: object

Manages 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

distros()[source]

Return the definitive copy of the Distros collection

files() cobbler.cobbler_collections.files.Files[source]

Return the definitive copy of the Files collection

get_items(collection_type: str) Union[cobbler.cobbler_collections.distros.Distros, cobbler.cobbler_collections.profiles.Profiles, cobbler.cobbler_collections.systems.Systems, cobbler.cobbler_collections.repos.Repos, cobbler.cobbler_collections.images.Images, cobbler.cobbler_collections.mgmtclasses.Mgmtclasses, cobbler.cobbler_collections.packages.Packages, cobbler.cobbler_collections.files.Files, cobbler.cobbler_collections.menus.Menus][source]

Get a full collection of a single type.

Valid Values vor collection_type are: “distro”, “profile”, “repo”, “image”, “mgmtclass”, “package”, “file” and “settings”.

Parameters

collection_type – The type of collection to return.

Returns

The collection if collection_type is valid.

Raises

CX – If the collection_type is invalid.

has_loaded = False
images() cobbler.cobbler_collections.images.Images[source]

Return the definitive copy of the Images collection

menus()[source]

Return the definitive copy of the Menus collection

mgmtclasses() cobbler.cobbler_collections.mgmtclasses.Mgmtclasses[source]

Return the definitive copy of the Mgmtclasses collection

packages() cobbler.cobbler_collections.packages.Packages[source]

Return the definitive copy of the Packages collection

profiles() cobbler.cobbler_collections.profiles.Profiles[source]

Return the definitive copy of the Profiles collection

repos() cobbler.cobbler_collections.repos.Repos[source]

Return the definitive copy of the Repos collection

serialize()[source]

Save all cobbler_collections to disk

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

serialize_item(collection, item)[source]

Save a collection item to disk

Deprecated - Use above serialize_one_item function instead collection param can be retrieved

Parameters
  • collection – Collection

  • item – collection item

serialize_one_item(item)[source]

Save a collection item to disk

Parameters

item – collection item

settings()[source]

Return the definitive copy of the application settings

systems() cobbler.cobbler_collections.systems.Systems[source]

Return the definitive copy of the Systems collection

9.1.2.7. cobbler.cobbler_collections.menus module

Copyright 2021 Yuriy Chelpanov Yuriy Chelpanov <yuriy.chelpanov@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.menus.Menus(collection_mgr)[source]

Bases: cobbler.cobbler_collections.collection.Collection

A menu represents an element of the hierarchical boot menu.

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 Menu forged from item_dict

Parameters
  • api – The cobblerd API.

  • item_dict – The seed data.

Returns

A new menu instance.

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

Parameters
  • name – The name of the menu

  • with_delete – In case the deletion triggers are executed for this menu.

  • with_sync – In case a Cobbler Sync should be executed after the action.

  • with_triggers – In case the Cobbler Trigger mechanism should be executed.

  • recursive – In case you want to delete all objects this menu references.

Raises

CX – Raised in case you want to delete a none existing menu.

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)[source]

Bases: cobbler.cobbler_collections.collection.Collection

A 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)

factory_produce(api, item_dict)[source]

Return a mgmtclass forged from item_dict

Parameters
  • api – TODO

  • item_dict – TODO

Returns

TODO

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 the object does not exist.

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)[source]

Bases: cobbler.cobbler_collections.collection.Collection

A 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)

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 Package forged from item_dict

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 the object does not exist.

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)[source]

Bases: cobbler.cobbler_collections.collection.Collection

A 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)

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 Distro forged from item_dict

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 or any other descendant would be orphaned.

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)[source]

Bases: cobbler.cobbler_collections.collection.Collection

Repositories 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)

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 Distro forged from item_dict

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 the object does not exist.

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)[source]

Bases: cobbler.cobbler_collections.collection.Collection

Systems are hostnames/MACs/IP names and the associated profile they belong to.

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

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.