add and switch type usage to common library types
This commit is contained in:
@@ -0,0 +1,3 @@
|
|||||||
|
[submodule "proxmoxaas-common-lib"]
|
||||||
|
path = proxmoxaas-common-lib
|
||||||
|
url = https://git.tronnet.net/tronnet/proxmoxaas-common-lib
|
||||||
+3
-1
@@ -4,6 +4,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
paas "proxmoxaas-fabric/paas-common-lib"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (cluster *Cluster) Init(pve ProxmoxClient) {
|
func (cluster *Cluster) Init(pve ProxmoxClient) {
|
||||||
@@ -241,7 +243,7 @@ func (instance *Instance) RebuildVolume(host *Node, volid string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
voltype := AnyPrefixes(volid, VolumeTypes)
|
voltype := AnyPrefixes(volid, paas.VolumeTypes)
|
||||||
volume.Type = voltype
|
volume.Type = voltype
|
||||||
volume.Volume_ID = VolumeID(volid)
|
volume.Volume_ID = VolumeID(volid)
|
||||||
instance.Volumes[VolumeID(volid)] = volume
|
instance.Volumes[VolumeID(volid)] = volume
|
||||||
|
|||||||
+18
-73
@@ -1,12 +1,14 @@
|
|||||||
package app
|
package app
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
paas "proxmoxaas-fabric/paas-common-lib"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/luthermonson/go-proxmox"
|
"github.com/luthermonson/go-proxmox"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Cluster struct {
|
type Cluster struct {
|
||||||
|
paas.Cluster
|
||||||
lock sync.Mutex
|
lock sync.Mutex
|
||||||
pve ProxmoxClient
|
pve ProxmoxClient
|
||||||
Nodes map[string]*Node `json:"nodes"`
|
Nodes map[string]*Node `json:"nodes"`
|
||||||
@@ -14,36 +16,20 @@ type Cluster struct {
|
|||||||
|
|
||||||
type Node struct {
|
type Node struct {
|
||||||
lock sync.Mutex
|
lock sync.Mutex
|
||||||
Name string `json:"name"`
|
paas.Node
|
||||||
Cores uint64 `json:"cores"`
|
|
||||||
Memory uint64 `json:"memory"`
|
|
||||||
Swap uint64 `json:"swap"`
|
|
||||||
Devices map[DeviceBus]*Device `json:"devices"`
|
|
||||||
Instances map[InstanceID]*Instance `json:"instances"`
|
Instances map[InstanceID]*Instance `json:"instances"`
|
||||||
Proctypes []string `json:"cpus"`
|
|
||||||
pvenode *proxmox.Node
|
pvenode *proxmox.Node
|
||||||
}
|
}
|
||||||
|
|
||||||
type InstanceID uint64
|
type InstanceID = paas.InstanceID
|
||||||
type InstanceType string
|
type InstanceType = paas.InstanceType
|
||||||
|
|
||||||
const (
|
const VM InstanceType = paas.VM
|
||||||
VM InstanceType = "VM"
|
const CT InstanceType = paas.CT
|
||||||
CT InstanceType = "CT"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Instance struct {
|
type Instance struct {
|
||||||
lock sync.Mutex
|
lock sync.Mutex
|
||||||
Type InstanceType `json:"type"`
|
paas.Instance
|
||||||
Name string `json:"name"`
|
|
||||||
Proctype string `json:"cpu"`
|
|
||||||
Cores uint64 `json:"cores"`
|
|
||||||
Memory uint64 `json:"memory"`
|
|
||||||
Swap uint64 `json:"swap"`
|
|
||||||
Volumes map[VolumeID]*Volume `json:"volumes"`
|
|
||||||
Nets map[NetID]*Net `json:"nets"`
|
|
||||||
Devices map[DeviceID]*Device `json:"devices"`
|
|
||||||
Boot BootOrder `json:"boot"`
|
|
||||||
pveconfig any
|
pveconfig any
|
||||||
configDisks map[string]string
|
configDisks map[string]string
|
||||||
configNets map[string]string
|
configNets map[string]string
|
||||||
@@ -51,54 +37,13 @@ type Instance struct {
|
|||||||
configBoot string
|
configBoot string
|
||||||
}
|
}
|
||||||
|
|
||||||
var VolumeTypes = []string{
|
type VolumeID = paas.VolumeID
|
||||||
"sata",
|
type Volume = paas.Volume
|
||||||
"scsi",
|
type NetID = paas.NetID
|
||||||
"ide",
|
type Net = paas.Net
|
||||||
"rootfs",
|
type DeviceID = paas.DeviceID
|
||||||
"mp",
|
type DeviceBus = paas.DeviceBus
|
||||||
"unused",
|
type Device = paas.Device
|
||||||
}
|
type FunctionID = paas.FunctionID
|
||||||
|
type Function = paas.Function
|
||||||
type VolumeID string
|
type BootOrder = paas.BootOrder
|
||||||
type Volume struct {
|
|
||||||
Volume_ID VolumeID `json:"volume_id"`
|
|
||||||
Type string `json:"type"`
|
|
||||||
Storage string `json:"storage"`
|
|
||||||
Format string `json:"format"`
|
|
||||||
Size uint64 `json:"size"`
|
|
||||||
File string `json:"file"`
|
|
||||||
MP string `json:"mp"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type NetID string
|
|
||||||
type Net struct {
|
|
||||||
Net_ID NetID `json:"net_id"`
|
|
||||||
Value string `json:"value"`
|
|
||||||
Rate uint64 `json:"rate"`
|
|
||||||
VLAN uint64 `json:"vlan"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type DeviceID string
|
|
||||||
type DeviceBus string
|
|
||||||
type Device struct {
|
|
||||||
Device_ID DeviceID `json:"device_id"`
|
|
||||||
Device_Bus DeviceBus `json:"device_bus"`
|
|
||||||
Device_Name string `json:"device_name"`
|
|
||||||
Vendor_Name string `json:"vendor_name"`
|
|
||||||
Functions map[FunctionID]*Function `json:"functions"`
|
|
||||||
Reserved bool `json:"reserved"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type FunctionID string
|
|
||||||
type Function struct {
|
|
||||||
Function_ID FunctionID `json:"function_id"`
|
|
||||||
Function_Name string `json:"subsystem_device_name"`
|
|
||||||
Vendor_Name string `json:"subsystem_vendor_name"`
|
|
||||||
Reserved bool `json:"reserved"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type BootOrder struct {
|
|
||||||
Enabled []any `json:"enabled"`
|
|
||||||
Disabled []any `json:"disabled"`
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -5,8 +5,11 @@ go 1.26.0
|
|||||||
require (
|
require (
|
||||||
github.com/gin-gonic/gin v1.12.0
|
github.com/gin-gonic/gin v1.12.0
|
||||||
github.com/luthermonson/go-proxmox v0.4.1
|
github.com/luthermonson/go-proxmox v0.4.1
|
||||||
|
paas-common-lib v0.0.0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
replace paas-common-lib => ./paas-common-lib
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/buger/goterm v1.0.4 // indirect
|
github.com/buger/goterm v1.0.4 // indirect
|
||||||
github.com/bytedance/gopkg v0.1.4 // indirect
|
github.com/bytedance/gopkg v0.1.4 // indirect
|
||||||
|
|||||||
Submodule
+1
Submodule proxmoxaas-common-lib added at a2bf608a54
Reference in New Issue
Block a user