闲社服务运行正常AI智能体自动化平台
p

PVE自动化

技能标识:pve-automation

Automate Proxmox VE (PVE) virtual machine and container management tasks including VM lifecycle operations (create, start, stop, delete), template management, cloud-init configuration, plugin installation, and cluster operations. Use this skill whenever the user mentions Proxmox, PVE, VM management, container (LXC) operations, qemu, or virtualization automation.

作者:admin | 来源记录:ClawHub
登记来源
ClawHub
版本
V 0.1.0
检测标记
后台标记通过
免费
免费获取
0
收藏
来源与检测标记为平台登记信息,并不代表已展示可复核的检测报告。使用前请核对版本、依赖和所需权限,建议先在隔离环境中运行。
概述
安装方式
版本历史

PVE自动化

Proxmox VE 自动化技能

本技能通过Proxmox VE的REST API提供全面的自动化管理功能。

概述

Proxmox VE是一个开源服务器虚拟化管理平台,支持:

  • - QEMU/KVM虚拟机(VM)
  • LXC容器(Linux容器)
  • 存储管理
  • 集群管理
  • 备份与快照

API基础

  • - 基础URL:https://:/api2/json/
- 默认端口:8006 - 可在PVE设置中配置自定义端口
  • - 认证方式:基于票据(Cookie)或API令牌
  • 数据格式:JSON
  • API浏览器:https://:/pve-docs/api-viewer/

自定义API端口

PVE API端口可从默认的8006进行自定义:

bash

检查当前API端口配置


grep port /etc/default/pveproxy

或通过API:GET /nodes/{node}/services

在代码中使用自定义端口:
python

选项1:在主机中包含端口


client = PVEClient(host=pve.example.com:8443, ...)

选项2:显式端口参数

class PVEClient: def init(self, host, port=8006, ...): self.base_url = fhttps://{host}:{port}/api2/json

选项3:环境变量

port = os.environ.get(PVE_PORT, 8006)

认证方法

方法1:API令牌(推荐用于自动化)

API令牌提供无状态访问,无需CSRF令牌:

bash

请求头格式


Authorization: PVEAPIToken=USER@REALM!TOKENID=UUID

示例

curl -H Authorization: PVEAPIToken=root@pam!automation=aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee \ https://pve.example.com:8006/api2/json/nodes

创建API令牌:

  1. 1. Web界面:数据中心 → 权限 → API令牌 → 添加
  2. 或通过API:POST /access/users/{userid}/token/{tokenid}

方法2:基于票据的认证

适用于交互式会话或无法使用API令牌时:

bash

1. 获取票据和CSRF令牌


curl -k -d username=root@pam --data-urlencode password=secret \
https://pve.example.com:8006/api2/json/access/ticket

响应:{ data: { ticket: ..., CSRFPreventionToken: ... } }

2. 在后续请求中使用票据

curl -k -b PVEAuthCookie= \ -H CSRFPreventionToken: \ https://pve.example.com:8006/api2/json/nodes

票据有效期2小时。通过将旧票据作为密码传递来续期。

常见操作

节点操作

bash

列出所有节点


GET /nodes

获取节点状态

GET /nodes/{node}/status

获取节点资源(CPU、内存、磁盘使用情况)

GET /nodes/{node}/resources

虚拟机(QEMU)操作

bash

列出节点上的虚拟机


GET /nodes/{node}/qemu

获取虚拟机状态

GET /nodes/{node}/qemu/{vmid}/status/current

启动虚拟机

POST /nodes/{node}/qemu/{vmid}/status/start

停止虚拟机(优雅关机)

POST /nodes/{node}/qemu/{vmid}/status/shutdown

停止虚拟机(强制/断电)

POST /nodes/{node}/qemu/{vmid}/status/stop

重置虚拟机

POST /nodes/{node}/qemu/{vmid}/status/reset

删除虚拟机

DELETE /nodes/{node}/qemu/{vmid}

LXC容器操作

bash

列出容器


GET /nodes/{node}/lxc

获取容器状态

GET /nodes/{node}/lxc/{vmid}/status/current

启动容器

POST /nodes/{node}/lxc/{vmid}/status/start

停止容器

POST /nodes/{node}/lxc/{vmid}/status/stop

删除容器

DELETE /nodes/{node}/lxc/{vmid}

虚拟机/容器创建

从模板创建虚拟机:
bash
POST /nodes/{node}/qemu

参数:

  • - vmid:唯一虚拟机ID(100-999999999)
  • name:虚拟机名称
  • memory:内存(MB)
  • cores:CPU核心数
  • sockets:CPU插槽数
  • cpu:CPU类型(host、kvm64等)
  • net0:网络配置(例如virtio,bridge=vmbr0)
  • ide2:CD/DVD驱动器或cloud-init(例如local:iso/ubuntu-22.04.iso,media=cdrom)
  • scsi0:磁盘(例如local-lvm:32,format=raw)
  • ostype:操作系统类型(l26适用于Linux 2.6+,win11适用于Windows 11)

创建LXC容器:
bash
POST /nodes/{node}/lxc

参数:

  • - vmid:唯一容器ID
  • hostname:容器主机名
  • memory:内存(MB)
  • swap:交换空间(MB)
  • cores:CPU核心数
  • ostemplate:模板路径(例如local:vztmpl/debian-12-standard12.0-1amd64.tar.zst)
  • storage:rootfs的存储
  • rootfs:根文件系统大小(例如local-lvm:8)
  • net0:网络配置(例如name=eth0,bridge=vmbr0,ip=dhcp)
  • password:root密码(或使用ssh-public-keys)

模板管理

bash

列出存储上的可用模板


GET /nodes/{node}/storage/{storage}/content?content=vztmpl

从Proxmox VE仓库下载模板

POST /nodes/{node}/storage/{storage}/download-url

参数:

  • - url:模板URL
  • filename:目标文件名
  • content:容器模板为vztmpl,ISO镜像为iso

列出可供下载的容器模板

GET /nodes/{node}/aplinfo

从aplinfo下载(官方模板)

POST /nodes/{node}/storage/{storage}/aplinfo

Cloud-Init配置

Cloud-init允许虚拟机在首次启动时自动初始化:

bash

设置cloud-init参数


POST /nodes/{node}/qemu/{vmid}/config

参数:

  • - cicustom:自定义cloud-init配置(可选)
  • ciuser:默认用户名
  • cipassword:默认用户密码
  • citype:配置驱动器类型(configdrive2、nocloud)
  • ciupgrade:启动时运行软件包升级(0/1)
  • sshkeys:公共SSH密钥(URL编码)
  • ipconfig0:IP配置(例如ip=192.168.1.100/24,gw=192.168.1.1)
  • ipconfig1:额外网络配置
  • nameserver:DNS服务器
  • searchdomain:DNS搜索域

重要提示:Cloud-init需要支持cloud-init的镜像(Ubuntu Cloud Images、Debian Cloud等)以及已配置的CD/DVD驱动器(通常为ide2)用于配置驱动器。

快照与备份

bash

列出快照


GET /nodes/{node}/qemu/{vmid}/snapshot

创建快照

POST /nodes/{node}/qemu/{vmid}/snapshot 参数:
  • - snapname:快照名称
  • description:可选描述
  • vmstate:包含RAM状态(1/0)

回滚到快照

POST /nodes/{node}/qemu/{vmid}/snapshot/{snapname}/rollback

删除快照

DELETE /nodes/{node}/qemu/{vmid}/snapshot/{snapname}

创建备份

POST /nodes/{node}/vzdump 参数:
  • - vmid:要备份的虚拟机ID
  • storage:目标存储
  • mode:快照/挂起/停止
  • compress:压缩级别(0-9)

存储操作

bash

列出存储


GET /storage

获取存储状态

GET /nodes/{node}/storage/{storage}/status

列出存储内容

GET /nodes/{node}/storage/{storage}/content

上传文件到存储(ISO、模板)

POST /nodes/{node}/storage/{storage}/upload Content-Type: multipart/form-data

网络配置

bash

列出节点上的网络接口


GET /nodes/{node}/network

创建网络桥接

POST /nodes/{

标签

skill ai

通过对话安装

以下为平台配置的接入选项,并非逐项实测通过。能否安装取决于客户端支持、技能来源和运行环境:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 pve-automation-1776276920 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 pve-automation-1776276920 技能

通过命令行安装

skillhub install pve-automation-1776276920

下载

⬇ 下载 pve-automation v0.1.0(免费)

文件大小: 17.66 KB | 发布时间: 2026-4-16 17:28

v0.1.0 最新 2026-4-16 17:28
Initial release of pve-automation skill for Proxmox VE management.

- Automates VM and LXC container lifecycle tasks: create, start, stop, delete.
- Supports template management, cloud-init configuration, and storage operations.
- Handles plugin installation and Proxmox cluster operations (status, tasks, resources).
- Offers guidance on Proxmox API usage, authentication (token and ticket), and best practices.
- Responds to user prompts related to Proxmox, PVE, virtualization, or LXC automation.
返回顶部