Proxmox Virtual Environment Management Substrate
ObjProxmox is a concrete implementation of the ObjSubstrate base class that provides an interface for managing resources in a Proxmox Virtual Environment (PVE). It uses the proxmoxer library to communicate with the Proxmox API.
This class allows you to list, start, and stop both QEMU virtual machines and LXC containers running on a Proxmox cluster, all through the unified ObjSubstrate interface.
ObjProxmox requires connection details for your Proxmox server to be configured in the config.yaml file under the proxmox section.
config.yaml Example:
proxmox:
url: "https://your-proxmox-host:8006"
user: "your-api-user@pve"
pass: "your-password"
mastertoken: "your-api-token-secret"
ObjProxmox provides concrete implementations for the core methods in ObjSubstrate.
| Method | Proxmox Implementation Details |
|---|---|
connect() |
Initializes the ProxmoxAPI client using the credentials from config.yaml and verifies the connection. |
list_instances() |
Scans all nodes in the cluster and returns a combined list of all QEMU VMs and LXC containers, including their name, ID, node, type, and status. |
get_instance(name) |
Retrieves detailed configuration and status information for a specific VM or container by its name. |
start_instance(name) |
Starts a stopped VM or container. |
stop_instance(name, force) |
Stops a running VM or container. The force parameter is not directly used; Proxmox's standard stop command is issued. |
create_instance(config) |
Not Implemented. This method will return an error, as instance creation is complex and not yet supported. |
delete_instance(name, force) |
Not Implemented. This method will return an error. |
execute_command(name, command) |
Not Implemented. This method will return an error, as direct command execution is not supported via the Proxmox API in this implementation. |
ObjProxmox also retains some of its original methods for managing VM tags:
| Method | Description |
|---|---|
get_vm_tags(node, vm_id) |
Retrieves the tags for a specific VM. |
set_vm_tags(node, vm_id, tags) |
Sets the tags for a specific VM. |
ObjProxmox.py provides a CLI for basic instance management.
listLists all VMs and containers across all nodes in the cluster.
python3 factory.deploy/ObjProxmox.py list
statusGets detailed status and configuration for a specific VM or container.
python3 factory.deploy/ObjProxmox.py status <instance-name>
startStarts a specified VM or container.
python3 factory.deploy/ObjProxmox.py start <instance-name>
stopStops a specified VM or container.
python3 factory.deploy/ObjProxmox.py stop <instance-name>
get-tagsGets the tags for a specific VM.
python3 factory.deploy/ObjProxmox.py get-tags --node <node-name> --vm-id <vm-id>
set-tagsSets the tags for a specific VM.
python3 factory.deploy/ObjProxmox.py set-tags --node <node-name> --vm-id <vm-id> --tags <tags-string>