Arthur Lu
30037f2e06
refactor hosts to nodes, change json return values to lowercase for instances and nodes, combine rebuildVM and rebuildCT to rebuildInstance
70 lines
1.7 KiB
Go
70 lines
1.7 KiB
Go
package app
|
|
|
|
import (
|
|
"sync"
|
|
|
|
"github.com/luthermonson/go-proxmox"
|
|
)
|
|
|
|
type Cluster struct {
|
|
lock sync.Mutex
|
|
pve ProxmoxClient
|
|
Nodes map[string]*Node
|
|
}
|
|
|
|
type Node struct {
|
|
lock sync.Mutex
|
|
Name string `json:"name"`
|
|
Cores uint64 `json:"cores"`
|
|
Memory uint64 `json:"memory"`
|
|
Swap uint64 `json:"swap"`
|
|
Devices map[string]*Device `json:"devices"`
|
|
Instances map[uint]*Instance `json:"instances"`
|
|
pvenode *proxmox.Node
|
|
}
|
|
|
|
type InstanceType string
|
|
|
|
const (
|
|
VM InstanceType = "VM"
|
|
CT InstanceType = "CT"
|
|
)
|
|
|
|
type Instance struct {
|
|
lock sync.Mutex
|
|
Type InstanceType `json:"type"`
|
|
Name string `json:"name"`
|
|
Proctype string `json:"cpu"`
|
|
Cores uint64 `json:"cores"`
|
|
Memory uint64 `json:"memory"`
|
|
Swap uint64 `json:"swap"`
|
|
Volumes map[string]*Volume `json:"volumes"`
|
|
Nets map[uint]*Net `json:"nets"`
|
|
Devices map[uint][]*Device `json:"devices"`
|
|
pveconfig interface{}
|
|
configDisks map[string]string
|
|
configNets map[string]string
|
|
configHostPCIs map[string]string
|
|
}
|
|
|
|
type Volume struct {
|
|
Storage string `json:"storage"`
|
|
Format string `json:"format"`
|
|
Size uint64 `json:"size"`
|
|
Volid string `json:"volid"`
|
|
}
|
|
|
|
type Net struct {
|
|
Rate uint64 `json:"rate"`
|
|
VLAN uint64 `json:"vlan"`
|
|
}
|
|
|
|
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 `json:"reserved"`
|
|
}
|