add supported cpu types to node model

This commit is contained in:
2025-04-30 21:20:29 +00:00
parent cd12365336
commit b2360500f2
2 changed files with 16 additions and 0 deletions

View File

@@ -23,6 +23,12 @@ type PVEDevice struct { // used only for requests to PVE
Subsystem_Vendor_Name string `json:"subsystem_vendor_name"`
}
type PVEProctype struct {
Custom int
Name string
Vendor string
}
func NewClient(url string, token string, secret string) ProxmoxClient {
HTTPClient := http.Client{
Transport: &http.Transport{
@@ -104,6 +110,15 @@ func (pve ProxmoxClient) Node(nodeName string) (*Node, error) {
}
}
proctypes := []PVEProctype{}
err = pve.client.Get(context.Background(), fmt.Sprintf("/nodes/%s/capabilities/qemu/cpu", nodeName), &proctypes)
if err != nil {
return &host, err
}
for _, proctype := range proctypes {
host.Proctypes = append(host.Proctypes, proctype.Name)
}
host.Name = node.Name
host.Cores = uint64(node.CPUInfo.CPUs)
host.Memory = uint64(node.Memory.Total)

View File

@@ -20,6 +20,7 @@ type Node struct {
Swap uint64 `json:"swap"`
Devices map[DeviceBus]*Device `json:"devices"`
Instances map[InstanceID]*Instance `json:"instances"`
Proctypes []string `json:"cpus"`
pvenode *proxmox.Node
}