2024-10-18 04:28:31 +00:00
|
|
|
package app
|
|
|
|
|
2025-01-20 21:42:13 +00:00
|
|
|
import (
|
|
|
|
"sync"
|
2025-01-08 22:42:17 +00:00
|
|
|
|
2025-01-20 21:42:13 +00:00
|
|
|
"github.com/luthermonson/go-proxmox"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Cluster struct {
|
|
|
|
lock sync.Mutex
|
|
|
|
pve ProxmoxClient
|
|
|
|
Hosts map[string]*Host
|
2024-12-27 19:59:44 +00:00
|
|
|
}
|
2024-10-18 04:28:31 +00:00
|
|
|
|
2024-12-27 19:59:44 +00:00
|
|
|
type Host struct {
|
2025-01-20 21:42:13 +00:00
|
|
|
lock sync.Mutex
|
2025-01-14 04:44:18 +00:00
|
|
|
Name string
|
2025-01-28 00:48:53 +00:00
|
|
|
Cores uint64
|
|
|
|
Memory uint64
|
|
|
|
Swap uint64
|
2025-01-14 04:44:18 +00:00
|
|
|
Devices map[string]*Device
|
|
|
|
Instances map[uint]*Instance
|
2025-01-20 21:42:13 +00:00
|
|
|
pvenode *proxmox.Node
|
2024-12-27 19:59:44 +00:00
|
|
|
}
|
2024-10-18 04:28:31 +00:00
|
|
|
|
2025-01-14 04:44:18 +00:00
|
|
|
type InstanceType string
|
2025-01-08 22:42:17 +00:00
|
|
|
|
|
|
|
const (
|
2025-01-14 04:44:18 +00:00
|
|
|
VM InstanceType = "VM"
|
|
|
|
CT InstanceType = "CT"
|
2025-01-08 22:42:17 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type Instance struct {
|
2025-01-20 21:42:13 +00:00
|
|
|
lock sync.Mutex
|
2025-01-10 01:08:44 +00:00
|
|
|
Type InstanceType
|
|
|
|
Name string
|
|
|
|
Proctype string
|
|
|
|
Cores uint64
|
|
|
|
Memory uint64
|
|
|
|
Swap uint64
|
2025-01-14 04:44:18 +00:00
|
|
|
Volumes map[string]*Volume
|
|
|
|
Nets map[uint]*Net
|
|
|
|
Devices map[uint][]*Device
|
2025-01-20 21:42:13 +00:00
|
|
|
pveconfig interface{}
|
2025-01-10 01:08:44 +00:00
|
|
|
configDisks map[string]string
|
|
|
|
configNets map[string]string
|
|
|
|
configHostPCIs map[string]string
|
2025-01-20 21:42:13 +00:00
|
|
|
}
|
|
|
|
|
2024-12-27 19:59:44 +00:00
|
|
|
type Volume struct {
|
|
|
|
Path string
|
2025-01-08 22:42:17 +00:00
|
|
|
Format string
|
|
|
|
Size uint64
|
|
|
|
Volid string
|
2024-12-27 19:59:44 +00:00
|
|
|
}
|
|
|
|
|
2025-01-08 22:42:17 +00:00
|
|
|
type Net struct {
|
|
|
|
Rate uint64
|
|
|
|
VLAN uint64
|
|
|
|
}
|
|
|
|
|
2025-01-14 04:44:18 +00:00
|
|
|
type Device struct {
|
|
|
|
BusID string `json:"id"`
|
|
|
|
DeviceName string `json:"device_name"`
|
|
|
|
VendorName string `json:"vendor_name"`
|
|
|
|
SubsystemDeviceName string `json:"subsystem_device_name"`
|
|
|
|
SubsystemVendorName string `json:"subsystem_vendor_name"`
|
|
|
|
Reserved bool
|
2024-10-18 04:28:31 +00:00
|
|
|
}
|