HyperV-agent/README.md
2025-04-14 10:19:00 +08:00

87 lines
1.3 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# PXVDI Hyper-V Agent
这是一个用Rust编写的Hyper-V管理代理提供REST API接口来管理Hyper-V虚拟机。
## 功能特性
- 列出所有虚拟机
- 获取虚拟机详细信息
- 启动/停止虚拟机
- 获取虚拟机网络信息
- 获取虚拟机快照信息
## 系统要求
- Windows操作系统
- 已安装Hyper-V
- Rust开发环境
## 安装
1. 确保已安装Rust开发环境
2. 克隆此仓库
3. 在项目目录中运行:
```bash
cargo build --release
```
## 运行
```bash
cargo run --release
```
服务器将在 http://localhost:3000 启动
## API接口
所有API请求都需要在header中包含 `Key: hyperv`
### 获取虚拟机列表
```
GET /api2/ListVM
```
### 获取虚拟机详细信息
```
GET /api2/ListVMDetils?VMID=<虚拟机ID>
```
### 获取所有虚拟机信息
```
GET /api2/GetALL
```
### 获取网络信息
```
GET /api2/GetNetWork
GET /api2/GetNetWork?VMID=<虚拟机ID>
```
### 获取快照信息
```
GET /api2/GetSnapShot
GET /api2/GetSnapShot?VMID=<虚拟机ID>
```
### 停止虚拟机
```
POST /api2/StopVM?VMID=<虚拟机ID>
```
### 启动虚拟机
```
POST /api2/StartVM?VMID=<虚拟机ID>
```
## 错误处理
所有API都会返回适当的HTTP状态码和JSON格式的错误信息
- 400: 请求参数错误
- 401: 认证错误
- 500: 服务器内部错误
## 许可证
MIT