diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..69f71d5 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "proxmoxaas-common-lib"] + path = proxmoxaas-common-lib + url = https://git.tronnet.net/tronnet/proxmoxaas-common-lib diff --git a/app/model.go b/app/model.go index 4c14d80..5ce6d34 100644 --- a/app/model.go +++ b/app/model.go @@ -4,6 +4,8 @@ import ( "fmt" "log" "strings" + + paas "proxmoxaas-fabric/paas-common-lib" ) func (cluster *Cluster) Init(pve ProxmoxClient) { @@ -241,7 +243,7 @@ func (instance *Instance) RebuildVolume(host *Node, volid string) error { return err } - voltype := AnyPrefixes(volid, VolumeTypes) + voltype := AnyPrefixes(volid, paas.VolumeTypes) volume.Type = voltype volume.Volume_ID = VolumeID(volid) instance.Volumes[VolumeID(volid)] = volume diff --git a/app/types.go b/app/types.go index 5526155..ccd0648 100644 --- a/app/types.go +++ b/app/types.go @@ -1,49 +1,35 @@ package app import ( + paas "proxmoxaas-fabric/paas-common-lib" "sync" "github.com/luthermonson/go-proxmox" ) type Cluster struct { + paas.Cluster lock sync.Mutex pve ProxmoxClient Nodes map[string]*Node `json:"nodes"` } type Node struct { - lock sync.Mutex - Name string `json:"name"` - Cores uint64 `json:"cores"` - Memory uint64 `json:"memory"` - Swap uint64 `json:"swap"` - Devices map[DeviceBus]*Device `json:"devices"` + lock sync.Mutex + paas.Node Instances map[InstanceID]*Instance `json:"instances"` - Proctypes []string `json:"cpus"` pvenode *proxmox.Node } -type InstanceID uint64 -type InstanceType string +type InstanceID = paas.InstanceID +type InstanceType = paas.InstanceType -const ( - VM InstanceType = "VM" - CT InstanceType = "CT" -) +const VM InstanceType = paas.VM +const CT InstanceType = paas.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[VolumeID]*Volume `json:"volumes"` - Nets map[NetID]*Net `json:"nets"` - Devices map[DeviceID]*Device `json:"devices"` - Boot BootOrder `json:"boot"` + lock sync.Mutex + paas.Instance pveconfig any configDisks map[string]string configNets map[string]string @@ -51,54 +37,13 @@ type Instance struct { configBoot string } -var VolumeTypes = []string{ - "sata", - "scsi", - "ide", - "rootfs", - "mp", - "unused", -} - -type VolumeID string -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"` -} +type VolumeID = paas.VolumeID +type Volume = paas.Volume +type NetID = paas.NetID +type Net = paas.Net +type DeviceID = paas.DeviceID +type DeviceBus = paas.DeviceBus +type Device = paas.Device +type FunctionID = paas.FunctionID +type Function = paas.Function +type BootOrder = paas.BootOrder diff --git a/go.mod b/go.mod index 719ded1..414e0d4 100644 --- a/go.mod +++ b/go.mod @@ -5,8 +5,11 @@ go 1.26.0 require ( github.com/gin-gonic/gin v1.12.0 github.com/luthermonson/go-proxmox v0.4.1 + paas-common-lib v0.0.0 ) +replace paas-common-lib => ./paas-common-lib + require ( github.com/buger/goterm v1.0.4 // indirect github.com/bytedance/gopkg v0.1.4 // indirect diff --git a/proxmoxaas-common-lib b/proxmoxaas-common-lib new file mode 160000 index 0000000..a2bf608 --- /dev/null +++ b/proxmoxaas-common-lib @@ -0,0 +1 @@ +Subproject commit a2bf608a54b1098dbe9225375cf3280dda237000