# denisfoulon/xcpng-snapshot-manager architecture

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

- Interactive diagram: https://gitdiagram.com/denisfoulon/xcpng-snapshot-manager
- Repository: https://github.com/denisfoulon/xcpng-snapshot-manager

## Overview

XCP-ng Snapshot Manager is a one-shot snapshot lifecycle and compliance tool for XCP-ng environments accessed through Xen Orchestra. The main run collects infrastructure inventory, evaluates snapshot and Storage Repository policies, emits administrator-facing reports, optionally remediates expired snapshots, and verifies changes. Separate invocations can process scheduled snapshot requests or perform optional SR maintenance. The graph reflects the documented capabilities; unsampled implementation details are represented only where README or sampled call sites support them.

Main entry points: [`src/core/engine.py`](https://github.com/denisfoulon/xcpng-snapshot-manager/blob/master/src/core/engine.py) (Execution engine), [`src/providers/xo_provider.py`](https://github.com/denisfoulon/xcpng-snapshot-manager/blob/master/src/providers/xo_provider.py) (XO provider), [`src/core/snapshot_scheduler.py`](https://github.com/denisfoulon/xcpng-snapshot-manager/blob/master/src/core/snapshot_scheduler.py) (Scheduled snapshots), [`src/snapshot_manager.py`](https://github.com/denisfoulon/xcpng-snapshot-manager/blob/master/src/snapshot_manager.py) (Command entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Execution"]
  node_cli["Command entry"]
  node_config["Configuration loader<br/>[config.py]"]
  node_engine["Execution engine<br/>[engine.py]"]
end

subgraph group_inventory["XO Inventory"]
  node_xo_provider["XO provider<br/>[xo_provider.py]"]
  node_xo_client["XO REST client<br/>[xo_client.py]"]
  node_rest["HTTP transport<br/>[rest_client.py]"]
  node_inventory_model["Infrastructure inventory<br/>[models.py]"]
end

subgraph group_compliance["Compliance"]
  node_discovery["Check discovery<br/>[discovery.py]"]
  node_checks["Policy checks"]
end

subgraph group_operations["Lifecycle Operations"]
  node_remediation["Snapshot remediation<br/>[remediation.py]"]
  node_verification["Post-change verification<br/>[engine.py]"]
  node_scheduler["Scheduled snapshots"]
  node_requests["Snapshot request files"]
  node_archives["Request archives"]
  node_maintenance["SR maintenance<br/>[engine.py]"]
  node_maintenance_state["Maintenance state"]
end

subgraph group_outputs["Reports"]
  node_serialization["Report serialization<br/>[serialization.py]"]
  node_console["Console reports<br/>[console.py]"]
  node_json_report["JSON report<br/>[json_report.py]"]
  node_html_report["HTML report<br/>[html_report.py]"]
  node_report_files["Report files"]
end

node_operator(("Administrator"))
node_xo_service{{"Xen Orchestra"}}

node_operator -->|"runs command"| node_cli
node_cli -->|"loads settings"| node_config
node_cli -->|"starts run"| node_engine
node_engine -->|"collects inventory"| node_xo_provider
node_xo_provider -->|"requests data"| node_xo_client
node_xo_client -->|"sends requests"| node_rest
node_rest -->|"calls API"| node_xo_service
node_xo_provider -->|"builds inventory"| node_inventory_model
node_engine -->|"discovers checks"| node_discovery
node_discovery -->|"selects checks"| node_checks
node_engine -->|"evaluates inventory"| node_checks
node_engine -->|"builds payload"| node_serialization
node_engine -->|"displays results"| node_console
node_engine -->|"writes JSON"| node_json_report
node_engine -->|"writes HTML"| node_html_report
node_json_report -->|"writes report"| node_report_files
node_html_report -->|"writes report"| node_report_files
node_engine -->|"selects candidates"| node_remediation
node_engine -->|"deletes snapshots"| node_xo_provider
node_engine -->|"checks changes"| node_verification
node_verification -->|"refreshes inventory"| node_xo_provider
node_engine -->|"processes requests"| node_scheduler
node_scheduler -->|"reads requests"| node_requests
node_scheduler -->|"creates snapshots"| node_xo_provider
node_scheduler -->|"archives outcomes"| node_archives
node_engine -->|"runs when enabled"| node_maintenance
node_maintenance -->|"scans repositories"| node_xo_provider
node_maintenance -->|"loads and saves state"| node_maintenance_state

click node_cli "https://github.com/denisfoulon/xcpng-snapshot-manager/blob/master/src/snapshot_manager.py"
click node_config "https://github.com/denisfoulon/xcpng-snapshot-manager/blob/master/src/core/config.py"
click node_engine "https://github.com/denisfoulon/xcpng-snapshot-manager/blob/master/src/core/engine.py"
click node_xo_provider "https://github.com/denisfoulon/xcpng-snapshot-manager/blob/master/src/providers/xo_provider.py"
click node_xo_client "https://github.com/denisfoulon/xcpng-snapshot-manager/blob/master/src/clients/xo_client.py"
click node_rest "https://github.com/denisfoulon/xcpng-snapshot-manager/blob/master/src/clients/rest_client.py"
click node_inventory_model "https://github.com/denisfoulon/xcpng-snapshot-manager/blob/master/src/core/models.py"
click node_discovery "https://github.com/denisfoulon/xcpng-snapshot-manager/blob/master/src/core/discovery.py"
click node_checks "https://github.com/denisfoulon/xcpng-snapshot-manager/tree/master/src/checks"
click node_remediation "https://github.com/denisfoulon/xcpng-snapshot-manager/blob/master/src/core/remediation.py"
click node_verification "https://github.com/denisfoulon/xcpng-snapshot-manager/blob/master/src/core/engine.py"
click node_scheduler "https://github.com/denisfoulon/xcpng-snapshot-manager/blob/master/src/core/snapshot_scheduler.py"
click node_requests "https://github.com/denisfoulon/xcpng-snapshot-manager/tree/master/config/snapshot_requests"
click node_archives "https://github.com/denisfoulon/xcpng-snapshot-manager/tree/master/config/snapshot_archives"
click node_maintenance "https://github.com/denisfoulon/xcpng-snapshot-manager/blob/master/src/core/engine.py"
click node_maintenance_state "https://github.com/denisfoulon/xcpng-snapshot-manager/blob/master/src/core/storage_maintenance.py"
click node_serialization "https://github.com/denisfoulon/xcpng-snapshot-manager/blob/master/src/reports/serialization.py"
click node_console "https://github.com/denisfoulon/xcpng-snapshot-manager/blob/master/src/reports/console.py"
click node_json_report "https://github.com/denisfoulon/xcpng-snapshot-manager/blob/master/src/reports/json_report.py"
click node_html_report "https://github.com/denisfoulon/xcpng-snapshot-manager/blob/master/src/reports/html_report.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_config,node_engine toneBlue
class node_xo_provider,node_xo_client,node_rest,node_inventory_model toneAmber
class node_discovery,node_checks toneMint
class node_remediation,node_verification,node_scheduler,node_requests,node_archives,node_maintenance,node_maintenance_state toneRose
class node_serialization,node_console,node_json_report,node_html_report,node_report_files,node_operator,node_xo_service toneIndigo
```

## Components

### Execution

- [Command entry](https://github.com/denisfoulon/xcpng-snapshot-manager/blob/master/src/snapshot_manager.py): `src/snapshot_manager.py`
- [Configuration loader](https://github.com/denisfoulon/xcpng-snapshot-manager/blob/master/src/core/config.py): `src/core/config.py`
- [Execution engine](https://github.com/denisfoulon/xcpng-snapshot-manager/blob/master/src/core/engine.py): `src/core/engine.py`

### XO Inventory

- [XO provider](https://github.com/denisfoulon/xcpng-snapshot-manager/blob/master/src/providers/xo_provider.py): `src/providers/xo_provider.py`
- [XO REST client](https://github.com/denisfoulon/xcpng-snapshot-manager/blob/master/src/clients/xo_client.py): `src/clients/xo_client.py`
- [HTTP transport](https://github.com/denisfoulon/xcpng-snapshot-manager/blob/master/src/clients/rest_client.py): `src/clients/rest_client.py`
- [Infrastructure inventory](https://github.com/denisfoulon/xcpng-snapshot-manager/blob/master/src/core/models.py): `src/core/models.py`

### Compliance

- [Check discovery](https://github.com/denisfoulon/xcpng-snapshot-manager/blob/master/src/core/discovery.py): `src/core/discovery.py`
- [Policy checks](https://github.com/denisfoulon/xcpng-snapshot-manager/tree/master/src/checks): `src/checks`

### Lifecycle Operations

- [Snapshot remediation](https://github.com/denisfoulon/xcpng-snapshot-manager/blob/master/src/core/remediation.py): `src/core/remediation.py`
- [Post-change verification](https://github.com/denisfoulon/xcpng-snapshot-manager/blob/master/src/core/engine.py): `src/core/engine.py`
- [Scheduled snapshots](https://github.com/denisfoulon/xcpng-snapshot-manager/blob/master/src/core/snapshot_scheduler.py): `src/core/snapshot_scheduler.py`
- [Snapshot request files](https://github.com/denisfoulon/xcpng-snapshot-manager/tree/master/config/snapshot_requests): `config/snapshot_requests`
- [Request archives](https://github.com/denisfoulon/xcpng-snapshot-manager/tree/master/config/snapshot_archives): `config/snapshot_archives`
- [SR maintenance](https://github.com/denisfoulon/xcpng-snapshot-manager/blob/master/src/core/engine.py): `src/core/engine.py`
- [Maintenance state](https://github.com/denisfoulon/xcpng-snapshot-manager/blob/master/src/core/storage_maintenance.py): `src/core/storage_maintenance.py`

### Reports

- [Report serialization](https://github.com/denisfoulon/xcpng-snapshot-manager/blob/master/src/reports/serialization.py): `src/reports/serialization.py`
- [Console reports](https://github.com/denisfoulon/xcpng-snapshot-manager/blob/master/src/reports/console.py): `src/reports/console.py`
- [JSON report](https://github.com/denisfoulon/xcpng-snapshot-manager/blob/master/src/reports/json_report.py): `src/reports/json_report.py`
- [HTML report](https://github.com/denisfoulon/xcpng-snapshot-manager/blob/master/src/reports/html_report.py): `src/reports/html_report.py`
- **Report files**

### Other components

- **Administrator**
- **Xen Orchestra**

## Connections

- Administrator → Command entry: runs command
- Command entry → Configuration loader: loads settings
- Command entry → Execution engine: starts run
- Execution engine → XO provider: collects inventory
- XO provider → XO REST client: requests data
- XO REST client → HTTP transport: sends requests
- HTTP transport → Xen Orchestra: calls API
- XO provider → Infrastructure inventory: builds inventory
- Execution engine → Check discovery: discovers checks
- Check discovery → Policy checks: selects checks
- Execution engine → Policy checks: evaluates inventory
- Execution engine → Report serialization: builds payload
- Execution engine → Console reports: displays results
- Execution engine → JSON report: writes JSON
- Execution engine → HTML report: writes HTML
- JSON report → Report files: writes report
- HTML report → Report files: writes report
- Execution engine → Snapshot remediation: selects candidates
- Execution engine → XO provider: deletes snapshots
- Execution engine → Post-change verification: checks changes
- Post-change verification → XO provider: refreshes inventory
- Execution engine → Scheduled snapshots: processes requests
- Scheduled snapshots → Snapshot request files: reads requests
- Scheduled snapshots → XO provider: creates snapshots
- Scheduled snapshots → Request archives: archives outcomes
- Execution engine → SR maintenance: runs when enabled
- SR maintenance → XO provider: scans repositories
- SR maintenance → Maintenance state: loads and saves state
