Skip to main content

CLI tool for importing cloud images to Proxmox server

Project description

Proxmox Cloud Image Importer

A CLI tool for importing cloud images to Proxmox server with support for multiple distributions and automatic VM template creation.

Features

  • Rich CLI Interface: Beautiful command-line interface with progress bars, tables, and colored output using Rich library
  • Multiple OS Support: Pre-configured support for Ubuntu, Debian, CentOS Stream, and Rocky Linux cloud images
  • Checksum Verification: Automatic verification of downloaded images using published checksums
  • Automatic VM Template Creation: Creates ready-to-use VM templates with proper cloud-init configuration
  • Process Management: Uses Plumbum library for robust process execution instead of subprocess
  • YAML Configuration: Flexible configuration system for managing image metadata
  • Download Management: Intelligent download caching and cleanup options

Requirements

  • Python 3.8+
  • Proxmox VE server with CLI access (qm, qemu-img commands)
  • Internet access for downloading cloud images

Installation

This project uses uv for dependency management. Install it first:

curl -LsSf https://astral.sh/uv/install.sh | sh

Then clone and install the project:

git clone <repository-url>
cd proxmox-cloud-image-importer
uv sync

Quick Start with uvx

If you want to try the tool without installing it, you can use uvx (part of the uv toolchain) to run it directly:

# Install uv first if you haven't already
curl -LsSf https://astral.sh/uv/install.sh | sh

# Run the tool directly from PyPI (once published)
uvx proxmox-cloud-importer list

# Or run from a local directory
uvx --from . proxmox-cloud-importer list

# Or from a git repository
uvx --from git+https://github.com/yurzs/proxmox-cloud-image-importer proxmox-cloud-importer list

This approach creates a temporary isolated environment and runs the tool without permanently installing it on your system.

Configuration

The tool uses a YAML configuration file (images.yaml) to define available cloud images and settings. The default configuration includes:

  • Ubuntu 22.04 LTS and 20.04 LTS
  • Debian 12 (Bookworm) and 11 (Bullseye)
  • CentOS Stream 9
  • Rocky Linux 9

Configuration Structure

images:
  ubuntu_22_04:
    name: "Ubuntu 22.04 LTS"
    description: "Ubuntu 22.04 LTS (Jammy Jellyfish) Cloud Image"
    url: "https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img"
    format: "qcow2"
    os_type: "ubuntu"
    version: "22.04"
    architecture: "amd64"
    checksum_url: "https://cloud-images.ubuntu.com/jammy/current/SHA256SUMS"
    cloud_init: true

proxmox:
  default_storage: "local-lvm"
  default_vm_id_start: 9000
  temp_download_path: "/tmp/cloud-images"

settings:
  verify_checksums: true
  cleanup_downloads: true
  default_disk_size: "20G"
  qemu_guest_agent: true

Usage

You can run the tool in two ways:

  1. Traditional installation (after running uv sync):

    proxmox-cloud-importer <command>
    
  2. Using uvx (no installation required):

    uvx --from . proxmox-cloud-importer <command>
    # Or from git repository:
    uvx --from git+https://github.com/example/proxmox-cloud-image-importer proxmox-cloud-importer <command>
    

List Available Images

# Traditional approach
proxmox-cloud-importer list

# Using uvx
uvx --from . proxmox-cloud-importer list

Show Image Information

# Traditional approach
proxmox-cloud-importer info ubuntu_22_04

# Using uvx
uvx --from . proxmox-cloud-importer info ubuntu_22_04

Download an Image Only

# Traditional approach
proxmox-cloud-importer download ubuntu_22_04 --output-dir ./downloads

# Using uvx
uvx --from . proxmox-cloud-importer download ubuntu_22_04 --output-dir ./downloads

Import Image to Proxmox

# Traditional approach - Import with auto-generated VM ID
proxmox-cloud-importer import-image ubuntu_22_04

# Using uvx - Import with auto-generated VM ID
uvx --from . proxmox-cloud-importer import-image ubuntu_22_04

# Traditional approach - Import with specific VM ID and storage
proxmox-cloud-importer import-image ubuntu_22_04 --vm-id 100 --storage local-lvm --template-name "Ubuntu-22.04-Template"

# Using uvx - Import with specific VM ID and storage
uvx --from . proxmox-cloud-importer import-image ubuntu_22_04 --vm-id 100 --storage local-lvm --template-name "Ubuntu-22.04-Template"

# Traditional approach - Download only without importing
proxmox-cloud-importer import-image ubuntu_22_04 --download-only

# Using uvx - Download only without importing
uvx --from . proxmox-cloud-importer import-image ubuntu_22_04 --download-only

Custom Configuration File

# Traditional approach
proxmox-cloud-importer --config /path/to/custom-images.yaml list

# Using uvx
uvx --from . proxmox-cloud-importer --config /path/to/custom-images.yaml list

Commands

  • list - List all available cloud images
  • info <image_id> - Show detailed information about a specific image
  • download <image_id> - Download a cloud image
  • import-image <image_id> - Download and import image to Proxmox

How It Works

  1. Download: Downloads cloud images from official sources with progress tracking
  2. Verify: Validates downloaded images against published checksums
  3. Convert: Converts images to qcow2 format if necessary using qemu-img
  4. Import: Uses qm importdisk to import the disk image to Proxmox storage
  5. Configure: Creates VM with appropriate settings (memory, CPU, network)
  6. Template: Converts the VM to a template for easy deployment

VM Template Configuration

The imported templates are configured with:

  • 2 GB RAM (configurable)
  • 2 CPU cores (configurable)
  • VirtIO network adapter on vmbr0
  • VirtIO SCSI controller
  • Cloud-init support (IDE2 drive)
  • Serial console access
  • QEMU guest agent (if enabled)

Error Handling

The tool includes comprehensive error handling:

  • Network connectivity issues
  • Checksum verification failures
  • Proxmox command execution errors
  • Automatic cleanup of failed imports

Development

Project Structure

proxmox-cloud-image-importer/
├── proxmox_cloud_importer/
│   ├── __init__.py
│   ├── cli.py          # CLI interface with Rich
│   ├── config.py       # Configuration handling
│   └── importer.py     # Core import functionality
├── tests/
├── images.yaml         # Default image configuration
├── pyproject.toml      # Project configuration
└── README.md

Running Tests

# With traditional installation
uv run pytest

# With uvx (from local directory)
uvx --from . --with pytest pytest

# With uvx (from git repository)
uvx --from git+https://github.com/example/proxmox-cloud-image-importer --with pytest pytest

Code Formatting

# With traditional installation
uv run black .

# With uvx
uvx --from . --with black black .

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Run the test suite
  6. Submit a pull request

License

MIT License - see LICENSE file for details

Troubleshooting

Common Issues

  1. Permission Denied: Ensure you have sudo access on the Proxmox server
  2. Storage Not Found: Verify the storage name in your configuration exists in Proxmox
  3. Network Issues: Check internet connectivity for image downloads
  4. Checksum Failures: May indicate network issues or corrupted downloads

Logging

Enable debug logging:

# With traditional installation
proxmox-cloud-importer --log-level DEBUG <command>

# With uvx
uvx --from . proxmox-cloud-importer --log-level DEBUG <command>

# Alternative approach using Python module
export PYTHONPATH=.
python -m proxmox_cloud_importer.cli --help

For verbose output, check the system logs on the Proxmox server after import failures.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

proxmox_cloud_importer-0.1.1.tar.gz (70.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

proxmox_cloud_importer-0.1.1-py3-none-any.whl (15.2 kB view details)

Uploaded Python 3

File details

Details for the file proxmox_cloud_importer-0.1.1.tar.gz.

File metadata

File hashes

Hashes for proxmox_cloud_importer-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a61086ae8d7904b00cfeb771ee75256963538be065f234dd58f1ef04654c56da
MD5 6220370996a812b9441c9d2a0b004870
BLAKE2b-256 e4ee5ae2b517eddcf59dde97b2f8405af8ca27c5678ea5e031e21688e0c40e79

See more details on using hashes here.

File details

Details for the file proxmox_cloud_importer-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for proxmox_cloud_importer-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b8263713e21199f30b0c02be222919587c5c2d62a87bef97f71abec8006af7be
MD5 506d65a699e0d83bccf6b1c7a0912117
BLAKE2b-256 83b3621dad924e14a7a6c6f69fc2e995be2793c4bff7cb5e6c4c490f0dd4900b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page