VM on Golem Requestor CLI - Create and manage virtual machines on the Golem Network
Project description
VM on Golem Requestor
A sophisticated command-line interface for managing virtual machines on the Golem Network. The requestor works in tandem with provider nodes to create and manage VMs with secure SSH access.
Architecture Overview
graph TB
subgraph Requestor
CLI[CLI Interface]
DB[Local Database]
SSH[SSH Manager]
PC[Provider Client]
end
subgraph Provider
API[Provider API]
VM[VM Manager]
Proxy[SSH Proxy]
RT[Resource Tracker]
end
CLI --> PC
PC --> API
SSH --> Proxy
VM --> RT
How It Works
1. VM Creation Flow
sequenceDiagram
participant User
participant CLI
participant SSH
participant Provider
participant VM
User->>CLI: Create VM Command
CLI->>SSH: Generate SSH Key
SSH-->>CLI: Key Pair
CLI->>Provider: Create VM Request + Public Key
Provider->>VM: Launch with Cloud-Init
Provider->>Proxy: Configure SSH Port
Provider-->>CLI: VM Details + Port
CLI->>DB: Save VM State
CLI-->>User: Connection Info
When you create a VM:
- The requestor generates an SSH key pair or uses your system's existing keys
- The provider receives the public key and injects it during VM creation via cloud-init
- The provider allocates a dedicated port and configures SSH forwarding
- Connection details are stored locally for future access
2. SSH Connection Flow
sequenceDiagram
participant User
participant CLI
participant DB
participant Proxy
participant VM
User->>CLI: SSH Command
CLI->>DB: Get VM Details
DB-->>CLI: Connection Info
CLI->>Proxy: SSH Connection
Proxy->>VM: Forward Connection
VM-->>User: Interactive Shell
The SSH connection process:
- The CLI retrieves stored VM details from the local database
- The provider's proxy system forwards your SSH connection to the VM
- All traffic is securely routed through the allocated port
Installation
# Install using pip
pip install golem-vm-requestor
# Or install from source
git clone https://github.com/golem/vm-on-golem.git
cd vm-on-golem/requestor-server
pip install -e .
Usage
Provider Discovery
List available providers with their resources:
golem vm providers
Example output:
────────────────────────────────────────────────
🌍 Available Providers (3 total)
────────────────────────────────────────────────
Provider ID Country CPU Memory Storage
provider-1 🌍 SE 💻 4 🧠 8GB 💾 40GB
provider-2 🌍 US 💻 8 🧠 16GB 💾 80GB
provider-3 🌍 DE 💻 2 🧠 4GB 💾 20GB
────────────────────────────────────────────────
Creating a VM
golem vm create my-webserver --provider-id provider-1 --cpu 2 --memory 4 --storage 20
The system will:
- Verify provider availability
- Check resource requirements
- Set up SSH access
- Deploy and configure the VM
- Save connection details locally
Example output:
────────────────────────────────────────────────
🎉 VM Deployed Successfully!
────────────────────────────────────────────────
VM Details
┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈
🏷️ Name : my-webserver
💻 Resources : 2 CPU, 4GB RAM, 20GB Storage
🟢 Status : running
Connection Details
┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈
🌐 IP Address : 192.168.1.100
🔌 Port : 50800
Quick Connect
┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈
🔑 SSH Command : ssh -i ~/.golem/ssh/id_rsa -p 50800 ubuntu@192.168.1.100
────────────────────────────────────────────────
Managing VMs
List your VMs:
golem vm list
Example output:
────────────────────────────────────────────────
📋 Your VMs (2 total)
────────────────────────────────────────────────
Name Status IP Address Resources
my-webserver ● running 192.168.1.100 2 CPU, 4GB RAM
my-database ● stopped 192.168.1.101 4 CPU, 8GB RAM
────────────────────────────────────────────────
Other commands:
# SSH into a VM
golem vm ssh my-webserver
# Stop a VM
golem vm stop my-webserver
# Start a VM
golem vm start my-webserver
# Destroy a VM
golem vm destroy my-webserver
Configuration
The requestor uses a hierarchical configuration system:
- Environment Variables:
# Discovery Service
export GOLEM_REQUESTOR_DISCOVERY_URL="http://discovery.golem.network:9001"
# Base Directory (default: ~/.golem)
export GOLEM_REQUESTOR_BASE_DIR="/path/to/golem/dir"
# Individual Paths (override base dir)
export GOLEM_REQUESTOR_SSH_KEY_DIR="/path/to/keys"
export GOLEM_REQUESTOR_DB_PATH="/path/to/database.db"
# Environment Mode (defaults to "production")
export GOLEM_REQUESTOR_ENVIRONMENT="development" # Optional: Switch to development mode
export GOLEM_REQUESTOR_FORCE_LOCALHOST="true" # Optional: Force localhost in development mode
- Directory Structure:
~/.golem/
├── ssh/ # SSH keys
│ ├── id_rsa # Private key
│ └── id_rsa.pub # Public key
└── vms.db # SQLite database
Technical Details
SSH Key Management
The system intelligently handles SSH keys:
- Uses existing system SSH keys if available
- Generates and manages Golem-specific keys if needed
- Ensures proper key permissions (0600 for private, 0644 for public)
- Supports key reuse across VMs
State Management
Local state is maintained in SQLite:
- VM details and configuration
- Provider information
- Connection parameters
- VM status tracking
Provider Integration
The requestor communicates with providers through:
- Discovery service for provider location
- Direct API calls for VM management
- SSH proxy system for secure access
- Resource tracking for capacity management
Error Handling
The system provides clear error messages and recovery steps:
Error: Unable to establish SSH connection (VM may be starting up)
Solution: Wait a few moments and try again. The VM is likely still initializing.
Error: Provider is no longer available (they may have gone offline)
Solution: Choose a different provider or wait for the original to come back online.
Error: VM not found in local database
Solution: The VM may have been manually removed. Use 'golem vm list' to see available VMs.
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Run the tests
- Submit a pull request
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file request_vm_on_golem-0.1.22.tar.gz.
File metadata
- Download URL: request_vm_on_golem-0.1.22.tar.gz
- Upload date:
- Size: 17.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.1 CPython/3.9.21 Linux/6.8.0-1021-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d1252b0914e0356d52778dc1194660f85acb6a264aa1becd2e9e6a19838b94af
|
|
| MD5 |
382e86dd7f6a60f37b8e7c466c887eb4
|
|
| BLAKE2b-256 |
6156051b213e02cd7db9ab915bf71200352ea2cec9e1b40555b4323c92a2653a
|
File details
Details for the file request_vm_on_golem-0.1.22-py3-none-any.whl.
File metadata
- Download URL: request_vm_on_golem-0.1.22-py3-none-any.whl
- Upload date:
- Size: 19.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.1 CPython/3.9.21 Linux/6.8.0-1021-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dff80ea97ce498b7f075a5ec5e121976af82ded8b6678295d11f55b3370ee34f
|
|
| MD5 |
425e16dc715a579f5a51331da457c8c7
|
|
| BLAKE2b-256 |
529130ba653a3b373e4b46da7fe3e9632380a1593d960dc64295208b9530dde2
|