This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Cobbler is a Linux installation server that automates network installation environments. It manages PXE booting, autoinstallation (kickstart/preseed/autoyast), DHCP, DNS, TFTP, and configuration management orchestration for rapid deployment of Linux systems.
All development has to be done inside the Docker Compose Stack due to the dependency on the managed daemons that aren't available locally.
# Build the package
make build
# Build RPMs
make rpms
# Build DEBs
make debs
# Clean build artifacts
make clean# Run unit tests (default - excludes integration tests)
pytest
# Run unit tests with coverage
pytest --cov=./cobbler
# Run integration tests (marked with @pytest.mark.integration)
pytest -m integration
# Run system tests
make system-test
# Run specific distribution tests in Docker
make test-rocky9
make test-fedora41
make test-debian12# Format code with black
make qa
# Run pre-commit hooks
pre-commit run --all-files# Install locally for development
make install DESTDIR=/path/to/installCobbler uses an object-oriented design with inheritance:
BaseItem (cobbler/items/abstract/base_item.py)
├── InheritableItem (cobbler/items/abstract/inheritable_item.py)
│ ├── BootableItem (cobbler/items/abstract/bootable_item.py)
│ │ ├── Distro (cobbler/items/distro.py)
│ │ ├── Profile (cobbler/items/profile.py)
│ │ ├── System (cobbler/items/system.py)
│ │ └── Image (cobbler/items/image.py)
│ ├── Repo (cobbler/items/repo.py)
│ └── Menu (cobbler/items/menu.py)
├── NetworkInterface (cobbler/items/network_interface.py)
└── Template (cobbler/items/template.py)
Key inheritance pattern: Profiles inherit from Distros, Systems inherit from Profiles. This creates a hierarchy: Distro → Profile → System, where lower-level objects inherit properties from their parents unless explicitly overridden.
Each item type has a corresponding collection class in cobbler/cobbler_collections/:
collection.py: Abstract base collection with CRUD operationsdistros.py,profiles.py,systems.py, etc.: Concrete collections
Collections are managed by CollectionManager (manager.py) which coordinates all collections.
-
Python API (
cobbler/api.py): Main API for internal use and external Python clients- Provides methods like
new_distro(),add_distro(),find_distro(), etc. - Used by CLI tools and the XML-RPC API
- Provides methods like
-
XML-RPC API (
cobbler/remote.py): Remote API for network clients- Wraps the Python API for remote access
- Used by web UI and remote management tools
Cobbler uses a plugin system in cobbler/modules/:
- authentication/: Authentication backends (configfile, ldap, pam, etc.)
- authorization/: Authorization backends (allowall, ownership)
- installation/: Pre/post installation hooks (pre_log, post_power, post_puppet, etc.)
- managers/: Service managers for DHCP/DNS/TFTP
bind.py: BIND DNS managerdnsmasq.py: dnsmasq DHCP/DNS managerisc.py: ISC DHCP managerin_tftpd.py: in.tftpd managerimport_signatures.py: OS detection signatures
- serializers/: Storage backends (file, mongodb)
Modules are dynamically loaded by module_loader.py.
cobbler/settings/: Settings management with schema validationcobbler/settings/migrations/: Automatic settings migrations between versions- Settings are validated using the
schemalibrary (cobbler/validate.py)
cobbler/tftpgen.py: Generates TFTP configuration and PXE menuscobbler/services.py: Manages DHCP/DNS service configurationcobbler/yumgen.py: Generates YUM repository configurationscobbler/configgen.py: Template-based configuration generation
tests/: Unit tests mirroring thecobbler/structure- Mark integration tests with
@pytest.mark.integration - Use fixtures from
conftest.py
- Mark integration tests with
system-tests/: System-level integration teststests/test_data/: Test fixtures and sample data
When modifying items (Distro, Profile, System, etc.):
- Item definitions: Start in
cobbler/items/(e.g.,distro.py) - Collection management: Update corresponding collection in
cobbler/cobbler_collections/ - API exposure: Ensure CRUD methods exist in
cobbler/api.py - XML-RPC exposure: Add remote methods in
cobbler/remote.pyif needed - Validation: Add property validation in the item's setter methods
- Tests: Add tests in
tests/items/ortests/cobbler_collections/
Modern Cobbler uses properties (getters/setters) instead of direct attributes:
- Inherited properties use the
@InheritablePropertydecorator - Lazy-loaded properties use the
@LazyPropertydecorator - Properties should validate input and handle type conversion
- Use
enums.pyfor enumerated values
Items support inheritance via the parent relationship:
- Profiles inherit from Distros
- Systems inherit from Profiles
- Use
VALUE_INHERITED(fromenums.py) to explicitly inherit a value - Resolution methods walk the inheritance chain to find actual values
When Cobbler is installed, key directories:
/var/lib/cobbler/: Data storage (when using file serializer)/etc/cobbler/: Configuration files/var/www/cobbler/: Web-accessible files/srv/tftp/: TFTP boot files
Use Docker Compose for development:
docker compose -f docker/tests/compose.yml up -dIndividual distribution test containers are defined in docker/rpms/ and docker/debs/.