Views:
The Proxmox VE API allows for automated VM deployments, which is useful for scripting, CI/CD pipelines, or bulk VM provisioning. For more information, see Proxmox REST API v2 .
TrendAI™ recommends the following VM configuration:
  • vCPUs: 4 (1 socket × 4 vCPUs - minimum recommended configuration
  • Memory: 8 GB (8192 MB - minimum recommended configuration)
For more information on the system requirements. see Private Access Connector system requirements and sizing guide.
Before starting, ensure that the required qcow2 image has already been uploaded to your storage area in the proxmox environment. If your storage area is local, ensure the file is present in the folder corresponding to your local:import” directory, which typically is /var/lib/vz/import. Your local:import folder location can be verified from the Proxmox UI by going to Datacenter → Storage → local.

Generate the Proxmox API Token

  1. Log into your Proxmox VE Web UI using an administrative account.
  2. In the left-hand hierarchical resource tree, click on Datacenter.
  3. In the center operational menu, select Permissions, and then click on API Tokens from the sub-menu.
  4. Click the Add button at the top of the pane to open the creation dialog.
  5. Configure the following parameters in the form field boxes:
    • User: Select `root@pam` (or your dedicated automation daemon system account).
    • Token ID: Enter a short descriptive name (For example, `automation` or `scripting`).
    • Privilege Separation: Keep this box checked. This creates a security boundary ensuring the token only inherits explicit access paths granted to it.
    • Expire: Set to Never (unless compliance policies require rotational expiration boundaries).
  6. Click Add in the bottom-right corner.
Important
Important
A secondary window will display a Token ID (For example, `root@pam!automation`) and a Secret Key. Copy and save this Secret Key immediately. Proxmox will never display this value again after the window is closed.
Assigning Token Permissions
By default, new tokens possess zero privileges. To authorize the token to build and modify hardware profiles, apply these steps:
  1. Navigate back to Datacenter -> Permissions.
  2. Click the Add dropdown button and select API Token Permission.
  3. Fill out the permission layout with these exact parameters:
    • Path: `/` *(Applies permissions cluster-wide to all nodes, pools, and storage objects)*
    • Token: Select your newly generated token string from the dropdown.
    • Role: Select Administrator.
      Note
      Note
      This role is explicitly required because the script must simultaneously perform compute changes, allocate disk space via the storage controller, and register new hardware maps).*
    • Propagate: Ensure this box is checked so permissions cascade down to child items.
  4. Click Add.
More information about Proxmox API tokens is here: https://pve.proxmox.com/pve-docs/pveum-plain.html

Update script variables for your Proxmax environment

The provisioning scripts accept key-value pairs that translate directly to virtualized physical allocations on the host hypervisor. Adjust the variables within the script payloads using the technical boundary guide below:

Definition of key fields

Field
Description
PVE_HOST
Your Proxmox IP or hostname
PVE_PORT
8006 is the Default Proxmox API port
NODE_NAME
The Proxmox target node name
TOKEN_ID,
TOKEN_SECRET
Your API Token ID and secret
VM_ID
Unique Proxmox VM ID
VM_NAME
Defaults to “TM-PrivateAccess-Connector”.
FILE_NAME
Defaults to “TrendMicroVisionOne-PrivateAccessConnector.qcow2”
VM_MEMORY_MB
Total RAM in Megabytes. 8 GB or more recommended
VM_CORES
CPU Cores per Socket. 4 cores recommended
VM_SOCKETS
Number of CPU Sockets
NET_BRIDGE
Proxmox Linux Bridge network adapter
TARGET_STORAGE
Storage target where the running VM disk will live. For local disk, defaults to “local”.
IMPORT_STORAGE
Storage source where your imported .qcow2 file sits. For local disk, defaults to “local”.

Deployment automation scripts

Once files are placed and the token is configured, choose one of the two unified, simplified operational deployment scripts below. All versions follow the same process: create the VM shell, link the `.qcow2` storage allocation, wait 5 seconds for backend synchronization, and boot the machine.
Python Script
import time
import uuid
import requests
import urllib3

# Suppress insecure connection warnings if using self-signed certs
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

# --- CONFIGURATION ---
PVE_HOST = "hostname"                               # Your Proxmox IP or hostname
PVE_PORT = "8006"                                   # Default Proxmox API port
NODE_NAME = "proxmoxpve-node-01"                    # The target node name
TOKEN_ID = "root@pam!automation"                     # Your API Token ID
TOKEN_SECRET = "XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX" # Your API Token Secret

# --- VM IDENTITY CONFIGURATION ---
VM_ID = "XXX"                              # Unique Proxmox VM ID
VM_NAME = "TM-PrivateAccess-Connector"     # The displayed Name of the VM
FILE_NAME = "TrendMicroVisionOne-PrivateAccessConnector.qcow2"

# --- HARDWARE CONFIGURATION ---
VM_MEMORY_MB = "8192"                      # Total RAM in Megabytes
VM_CORES     = "4"                         # CPU Cores per Socket
VM_SOCKETS   = "1"                         # Number of CPU Sockets
NET_BRIDGE   = "vmbr1"                     # Proxmox Linux Bridge network adapter

# --- STORAGE CONFIGURATION ---
TARGET_STORAGE = "local"                   # Storage target where the running VM disk will live
IMPORT_STORAGE = "local"                   # Storage source where your imported .qcow2 file sits

# --- GLOBAL SETTINGS ---
BASE_URL = f"https://{PVE_HOST}:{PVE_PORT}/api2/json"
HEADERS = {
    "Authorization": f"PVEAPIToken={TOKEN_ID}={TOKEN_SECRET}"
}

def main():
    # -------------------------------------------------------------
    # STEP 1: CREATE THE VM SHELL
    # -------------------------------------------------------------
    print("Creating Virtual Machine shell...")
    random_uuid = str(uuid.uuid4())
    smbios_string = f"serial=TMV1PrivateAccessConnectorProxmox,uuid={random_uuid}"
    
    vm_payload = {
        "vmid": VM_ID,
        "name": VM_NAME,
        "memory": VM_MEMORY_MB,
        "cores": VM_CORES,
        "sockets": VM_SOCKETS,
        "cpu": "host",
        "bios": "ovmf",
        "boot": "order=scsi0",
        "efidisk0": f"{TARGET_STORAGE}:0,pre-enrolled-keys=0",
        "net0": f"virtio,bridge={NET_BRIDGE}",
        "ostype": "l26",
        "scsihw": "virtio-scsi-pci",
        "tablet": "1",
        "vga": "qxl",
        "smbios1": smbios_string
    }
    
    create_url = f"{BASE_URL}/nodes/{NODE_NAME}/qemu"
    response = requests.post(create_url, headers=HEADERS, data=vm_payload, verify=False)
    response.raise_for_status()
    print("VM shell successfully built.")

    # -------------------------------------------------------------
    # STEP 2: ATTACH AND IMPORT THE DISK IMAGE
    # -------------------------------------------------------------
    print("Attaching virtual disk image...")
    import_payload = {
        "scsi0": f"{TARGET_STORAGE}:0,discard=on,import-from={IMPORT_STORAGE}:import/{FILE_NAME}"
    }
    
    config_url = f"{BASE_URL}/nodes/{NODE_NAME}/qemu/{VM_ID}/config"
    response = requests.put(config_url, headers=HEADERS, data=import_payload, verify=False)
    response.raise_for_status()
    print("Disk linked successfully.")

    # Give Proxmox a brief moment to commit the hardware configuration changes
    print("Waiting 5 seconds for backend configuration synchronization...")
    time.sleep(5)

    # -------------------------------------------------------------
    # STEP 3: START THE VM
    # -------------------------------------------------------------
    print(f"Booting up Virtual Machine {VM_ID}...")
    start_url = f"{BASE_URL}/nodes/{NODE_NAME}/qemu/{VM_ID}/status/start"
    response = requests.post(start_url, headers=HEADERS, verify=False)
    response.raise_for_status()
    print("Pipeline finished successfully! The VM is starting.")

if __name__ == "__main__":
    main()
Bash shell script
#!/bin/bash

# Exit immediately if any command fails
set -e

# --- CONFIGURATION ---
PVE_HOST="hostname"                          # Your Proxmox IP or hostname
PVE_PORT="8006"                              # Default Proxmox API port
NODE_NAME="proxmoxpve-node-01"        # The target node name
TOKEN_ID="root@pam!automation"               # Your API Token ID
TOKEN_SECRET="XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX" # Your API Token Secret

# --- VM IDENTITY CONFIGURATION ---
VM_ID="XXX"                              # Unique Proxmox VM ID
VM_NAME="TM-PrivateAccess-Connector"     # The displayed Name of the VM
FILE_NAME="TrendMicroVisionOne-PrivateAccessConnector.qcow2"

# --- HARDWARE CONFIGURATION ---
VM_MEMORY_MB="8192"                      # Total RAM in Megabytes
VM_CORES="4"                             # CPU Cores per Socket
VM_SOCKETS="1"                           # Number of CPU Sockets
NET_BRIDGE="vmbr1"                       # Proxmox Linux Bridge network adapter

# --- STORAGE CONFIGURATION ---
TARGET_STORAGE="local"                   # Storage target where the running VM disk will live
IMPORT_STORAGE="local"                   # Storage source where the imported .qcow2 file sits

# --- GLOBAL SETTINGS ---
BASE_URL="https://${PVE_HOST}:${PVE_PORT}/api2/json"
AUTH_HEADER="Authorization: PVEAPIToken=${TOKEN_ID}=${TOKEN_SECRET}"

# -------------------------------------------------------------
# STEP 1: CREATE THE VM SHELL
# -------------------------------------------------------------
echo "Creating Virtual Machine shell..."

# Natively handles UUID generation on both macOS and Linux
if command -v uuidgen &> /dev/null; then
    RANDOM_UUID=$(uuidgen | tr '[:upper:]' '[:lower:]')
else
    RANDOM_UUID=$(cat /proc/sys/kernel/random/uuid)
fi
SMBIOS_STRING="serial=TMV1PrivateAccessConnectorProxmox,uuid=${RANDOM_UUID}"

curl -k -s -X POST "${BASE_URL}/nodes/${NODE_NAME}/qemu" \
  -H "${AUTH_HEADER}" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  --data-urlencode "vmid=${VM_ID}" \
  --data-urlencode "name=${VM_NAME}" \
  --data-urlencode "memory=${VM_MEMORY_MB}" \
  --data-urlencode "cores=${VM_CORES}" \
  --data-urlencode "sockets=${VM_SOCKETS}" \
  --data-urlencode "cpu=host" \
  --data-urlencode "bios=ovmf" \
  --data-urlencode "boot=order=scsi0" \
  --data-urlencode "efidisk0=${TARGET_STORAGE}:0,pre-enrolled-keys=0" \
  --data-urlencode "net0=virtio,bridge=${NET_BRIDGE}" \
  --data-urlencode "ostype=l26" \
  --data-urlencode "scsihw=virtio-scsi-pci" \
  --data-urlencode "tablet=1" \
  --data-urlencode "vga=qxl" \
  --data-urlencode "smbios1=${SMBIOS_STRING}" > /dev/null

echo "VM shell successfully built."

# -------------------------------------------------------------
# STEP 2: ATTACH AND IMPORT THE DISK IMAGE
# -------------------------------------------------------------
echo "Attaching virtual disk image..."

curl -k -s -X PUT "${BASE_URL}/nodes/${NODE_NAME}/qemu/${VM_ID}/config" \
  -H "${AUTH_HEADER}" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  --data-urlencode "scsi0=${TARGET_STORAGE}:0,discard=on,import-from=${IMPORT_STORAGE}:import/${FILE_NAME}" > /dev/null

echo "Disk linked successfully."

echo "Waiting 5 seconds for backend configuration synchronization..."
sleep 5

# -------------------------------------------------------------
# STEP 3: START THE VM
# -------------------------------------------------------------
echo "Booting up Virtual Machine ${VM_ID}..."

curl -k -s -X POST "${BASE_URL}/nodes/${NODE_NAME}/qemu/${VM_ID}/status/start" \
  -H "${AUTH_HEADER}" > /dev/null

echo "Pipeline finished successfully! The VM is starting."