# ganeti/ganeti architecture

> Architecture diagram of the GitHub repository ganeti/ganeti, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ganeti/ganeti
- Repository: https://github.com/ganeti/ganeti

## Overview

Ganeti is a virtual-machine cluster manager. The principal workflow is an operator requesting a cluster or instance operation through the command-line or REST interface, followed by cluster-side job processing and node-level execution through virtualization and storage backends. The graph also preserves query, networking, allocation, watcher, and configuration capabilities visible in the repository tree. Most internal connections are dashed: the supplied excerpts and reference index do not establish their exact call paths, so they are presented as unverified rather than asserted.

Main entry points: [`lib/cmdlib`](https://github.com/ganeti/ganeti/tree/master/lib/cmdlib) (Operation handlers), [`lib/backend.py`](https://github.com/ganeti/ganeti/blob/master/lib/backend.py) (Node backend), [`lib/cli.py`](https://github.com/ganeti/ganeti/blob/master/lib/cli.py) (CLI framework), [`lib/client/gnt_cluster.py`](https://github.com/ganeti/ganeti/blob/master/lib/client/gnt_cluster.py) (Cluster commands)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User interfaces"]
  node_cli["CLI framework<br/>[cli.py]"]
  node_cluster_cli["Cluster commands<br/>[gnt_cluster.py]"]
  node_instance_cli["Instance commands<br/>[gnt_instance.py]"]
  node_rapi_client["REST client<br/>[client.py]"]
  node_rapi_server["REST service<br/>[rapi.py]"]
  node_rapi_routes["REST routes<br/>[rlib2.py]"]
end

subgraph group_control["Cluster control"]
  node_cmdlib["Operation handlers"]
  node_instance_ops["Instance operations"]
  node_instance_storage["Instance storage operations"]
  node_query["Query engine<br/>[query.py]"]
  node_allocator["Instance allocator<br/>[iallocator.py]"]
  node_jobs["Job queue<br/>[__init__.py]"]
end

subgraph group_nodeops["Node operations"]
  node_noded["Node daemon<br/>[noded.py]"]
  node_backend["Node backend<br/>[backend.py]"]
  node_rpc["Node RPC<br/>[client.py]"]
end

subgraph group_platform["Virtualization and storage"]
  node_hypervisor["Hypervisor drivers<br/>[hv_xen.py]"]
  node_storage["Storage drivers"]
  node_network["Network management<br/>[network.py]"]
end

subgraph group_support["Cluster services"]
  node_config[("Cluster configuration<br/>[__init__.py]")]
  node_locking["Resource locking<br/>[locking.py]"]
  node_watcher["Cluster watcher<br/>[__init__.py]"]
  node_confd["Configuration daemon<br/>[__init__.py]"]
  node_io["File I/O utilities<br/>[io.py]"]
end

node_operator(("Operator"))

node_operator -.->|"invokes"| node_cli
node_operator -.->|"invokes"| node_rapi_client
node_cli -.->|"dispatches"| node_cluster_cli
node_cli -.->|"dispatches"| node_instance_cli
node_cluster_cli -.->|"requests operations"| node_cmdlib
node_instance_cli -.->|"requests operations"| node_cmdlib
node_rapi_client -.->|"sends requests"| node_rapi_server
node_rapi_server -.->|"routes requests"| node_rapi_routes
node_rapi_routes -.->|"requests operations"| node_cmdlib
node_cmdlib -.->|"submits jobs"| node_jobs
node_cmdlib -.->|"reads and updates"| node_config
node_cmdlib -.->|"acquires locks"| node_locking
node_cmdlib -.->|"queries resources"| node_query
node_cmdlib -.->|"requests placement"| node_allocator
node_cmdlib -.->|"delegates instance work"| node_instance_ops
node_instance_ops -.->|"uses storage operations"| node_instance_storage
node_jobs -.->|"dispatches node work"| node_rpc
node_rpc -.->|"sends node requests"| node_noded
node_noded -.->|"invokes backend"| node_backend
node_backend -.->|"controls guests"| node_hypervisor
node_backend -.->|"manages storage"| node_storage
node_backend -.->|"configures networking"| node_network
node_watcher -.->|"requests recovery work"| node_jobs
node_confd -.->|"serves cluster configuration"| node_config
node_cluster_cli -.->|"uses file utilities"| node_io
node_rapi_client -.->|"uses file utilities"| node_io
node_hypervisor -.->|"uses file utilities"| node_io

click node_cli "https://github.com/ganeti/ganeti/blob/master/lib/cli.py"
click node_cluster_cli "https://github.com/ganeti/ganeti/blob/master/lib/client/gnt_cluster.py"
click node_instance_cli "https://github.com/ganeti/ganeti/blob/master/lib/client/gnt_instance.py"
click node_rapi_client "https://github.com/ganeti/ganeti/blob/master/lib/rapi/client.py"
click node_rapi_server "https://github.com/ganeti/ganeti/blob/master/lib/server/rapi.py"
click node_rapi_routes "https://github.com/ganeti/ganeti/blob/master/lib/rapi/rlib2.py"
click node_cmdlib "https://github.com/ganeti/ganeti/tree/master/lib/cmdlib"
click node_instance_ops "https://github.com/ganeti/ganeti/blob/master/lib/cmdlib/instance_operation.py"
click node_instance_storage "https://github.com/ganeti/ganeti/blob/master/lib/cmdlib/instance_storage.py"
click node_query "https://github.com/ganeti/ganeti/blob/master/lib/query.py"
click node_allocator "https://github.com/ganeti/ganeti/blob/master/lib/masterd/iallocator.py"
click node_jobs "https://github.com/ganeti/ganeti/blob/master/lib/jqueue/__init__.py"
click node_config "https://github.com/ganeti/ganeti/blob/master/lib/config/__init__.py"
click node_locking "https://github.com/ganeti/ganeti/blob/master/lib/locking.py"
click node_watcher "https://github.com/ganeti/ganeti/blob/master/lib/watcher/__init__.py"
click node_confd "https://github.com/ganeti/ganeti/blob/master/lib/confd/__init__.py"
click node_noded "https://github.com/ganeti/ganeti/blob/master/lib/server/noded.py"
click node_backend "https://github.com/ganeti/ganeti/blob/master/lib/backend.py"
click node_rpc "https://github.com/ganeti/ganeti/blob/master/lib/rpc/client.py"
click node_hypervisor "https://github.com/ganeti/ganeti/blob/master/lib/hypervisor/hv_xen.py"
click node_storage "https://github.com/ganeti/ganeti/tree/master/lib/storage"
click node_network "https://github.com/ganeti/ganeti/blob/master/lib/network.py"
click node_io "https://github.com/ganeti/ganeti/blob/master/lib/utils/io.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_cluster_cli,node_instance_cli,node_rapi_client,node_rapi_server,node_rapi_routes toneBlue
class node_cmdlib,node_instance_ops,node_instance_storage,node_query,node_allocator,node_jobs toneAmber
class node_noded,node_backend,node_rpc toneMint
class node_hypervisor,node_storage,node_network toneRose
class node_config,node_locking,node_watcher,node_confd,node_io,node_operator toneIndigo
```

## Components

### User interfaces

- [CLI framework](https://github.com/ganeti/ganeti/blob/master/lib/cli.py): `lib/cli.py`
- [Cluster commands](https://github.com/ganeti/ganeti/blob/master/lib/client/gnt_cluster.py): `lib/client/gnt_cluster.py`
- [Instance commands](https://github.com/ganeti/ganeti/blob/master/lib/client/gnt_instance.py): `lib/client/gnt_instance.py`
- [REST client](https://github.com/ganeti/ganeti/blob/master/lib/rapi/client.py): `lib/rapi/client.py`
- [REST service](https://github.com/ganeti/ganeti/blob/master/lib/server/rapi.py): `lib/server/rapi.py`
- [REST routes](https://github.com/ganeti/ganeti/blob/master/lib/rapi/rlib2.py): `lib/rapi/rlib2.py`

### Cluster control

- [Operation handlers](https://github.com/ganeti/ganeti/tree/master/lib/cmdlib): `lib/cmdlib`
- [Instance operations](https://github.com/ganeti/ganeti/blob/master/lib/cmdlib/instance_operation.py): `lib/cmdlib/instance_operation.py`
- [Instance storage operations](https://github.com/ganeti/ganeti/blob/master/lib/cmdlib/instance_storage.py): `lib/cmdlib/instance_storage.py`
- [Query engine](https://github.com/ganeti/ganeti/blob/master/lib/query.py): `lib/query.py`
- [Instance allocator](https://github.com/ganeti/ganeti/blob/master/lib/masterd/iallocator.py): `lib/masterd/iallocator.py`
- [Job queue](https://github.com/ganeti/ganeti/blob/master/lib/jqueue/__init__.py): `lib/jqueue/__init__.py`

### Node operations

- [Node daemon](https://github.com/ganeti/ganeti/blob/master/lib/server/noded.py): `lib/server/noded.py`
- [Node backend](https://github.com/ganeti/ganeti/blob/master/lib/backend.py): `lib/backend.py`
- [Node RPC](https://github.com/ganeti/ganeti/blob/master/lib/rpc/client.py): `lib/rpc/client.py`

### Virtualization and storage

- [Hypervisor drivers](https://github.com/ganeti/ganeti/blob/master/lib/hypervisor/hv_xen.py): `lib/hypervisor/hv_xen.py`
- [Storage drivers](https://github.com/ganeti/ganeti/tree/master/lib/storage): `lib/storage`
- [Network management](https://github.com/ganeti/ganeti/blob/master/lib/network.py): `lib/network.py`

### Cluster services

- [Cluster configuration](https://github.com/ganeti/ganeti/blob/master/lib/config/__init__.py): `lib/config/__init__.py`
- [Resource locking](https://github.com/ganeti/ganeti/blob/master/lib/locking.py): `lib/locking.py`
- [Cluster watcher](https://github.com/ganeti/ganeti/blob/master/lib/watcher/__init__.py): `lib/watcher/__init__.py`
- [Configuration daemon](https://github.com/ganeti/ganeti/blob/master/lib/confd/__init__.py): `lib/confd/__init__.py`
- [File I/O utilities](https://github.com/ganeti/ganeti/blob/master/lib/utils/io.py): `lib/utils/io.py`

### Other components

- **Operator**

## Connections

- Operator → CLI framework: invokes
- Operator → REST client: invokes
- CLI framework → Cluster commands: dispatches
- CLI framework → Instance commands: dispatches
- Cluster commands → Operation handlers: requests operations
- Instance commands → Operation handlers: requests operations
- REST client → REST service: sends requests
- REST service → REST routes: routes requests
- REST routes → Operation handlers: requests operations
- Operation handlers → Job queue: submits jobs
- Operation handlers → Cluster configuration: reads and updates
- Operation handlers → Resource locking: acquires locks
- Operation handlers → Query engine: queries resources
- Operation handlers → Instance allocator: requests placement
- Operation handlers → Instance operations: delegates instance work
- Instance operations → Instance storage operations: uses storage operations
- Job queue → Node RPC: dispatches node work
- Node RPC → Node daemon: sends node requests
- Node daemon → Node backend: invokes backend
- Node backend → Hypervisor drivers: controls guests
- Node backend → Storage drivers: manages storage
- Node backend → Network management: configures networking
- Cluster watcher → Job queue: requests recovery work
- Configuration daemon → Cluster configuration: serves cluster configuration
- Cluster commands → File I/O utilities: uses file utilities (evidence: `lib/client/gnt_cluster.py`)
- REST client → File I/O utilities: uses file utilities (evidence: `lib/rapi/client.py`)
- Hypervisor drivers → File I/O utilities: uses file utilities (evidence: `lib/hypervisor/hv_xen.py`)
