rename volume volid to file to better represent the meaning,

add raw value string to devices,
fix JSON to go naming for device_name vendor_name ... in devices,
bump API version to 0.03
This commit is contained in:
2025-04-16 20:07:56 +00:00
parent a07a0a5e98
commit a1b4353b06
4 changed files with 32 additions and 29 deletions

View File

@@ -13,7 +13,7 @@ import (
"github.com/luthermonson/go-proxmox" "github.com/luthermonson/go-proxmox"
) )
const APIVersion string = "0.0.2" const APIVersion string = "0.0.3"
var client ProxmoxClient var client ProxmoxClient

View File

@@ -238,5 +238,7 @@ func (instance *Instance) RebuildDevice(host *Node, deviceid string) error {
// sub function assignment not supported yet // sub function assignment not supported yet
} }
instance.Devices[InstanceDeviceID(instanceDeviceBusID)].Value = instanceDevice
return nil return nil
} }

View File

@@ -82,17 +82,17 @@ func (pve ProxmoxClient) Node(nodeName string) (*Node, error) {
functionid := FunctionID(x[1]) functionid := FunctionID(x[1])
if _, ok := host.Devices[deviceid]; !ok { if _, ok := host.Devices[deviceid]; !ok {
host.Devices[deviceid] = &Device{ host.Devices[deviceid] = &Device{
DeviceID: deviceid, Device_ID: deviceid,
DeviceName: device.DeviceName, Device_Name: device.Device_Name,
VendorName: device.VendorName, Vendor_Name: device.Vendor_Name,
Functions: make(map[FunctionID]*Function), Functions: make(map[FunctionID]*Function),
} }
} }
host.Devices[deviceid].Functions[functionid] = &Function{ host.Devices[deviceid].Functions[functionid] = &Function{
FunctionID: functionid, Function_ID: functionid,
FunctionName: device.SubsystemDeviceName, Function_Name: device.Subsystem_Device_Name,
VendorName: device.SubsystemVendorName, Vendor_Name: device.Subsystem_Vendor_Name,
Reserved: false, Reserved: false,
} }
} }
@@ -225,7 +225,7 @@ func GetVolumeInfo(host *Node, volume string) (*Volume, error) {
volumeData.Storage = storageID volumeData.Storage = storageID
volumeData.Format = c.Format volumeData.Format = c.Format
volumeData.Size = uint64(c.Size) volumeData.Size = uint64(c.Size)
volumeData.Volid = VolumeID(volumeID) volumeData.File = volumeID
} }
} }

View File

@@ -59,11 +59,11 @@ var VolumeTypes = []string{
type VolumeID string type VolumeID string
type Volume struct { type Volume struct {
Type string `json:"type"` Type string `json:"type"`
Storage string `json:"storage"` Storage string `json:"storage"`
Format string `json:"format"` Format string `json:"format"`
Size uint64 `json:"size"` Size uint64 `json:"size"`
Volid VolumeID `json:"volid"` File string `json:"file"`
} }
type NetID uint64 type NetID uint64
@@ -74,27 +74,28 @@ type Net struct {
} }
type PVEDevice struct { type PVEDevice struct {
ID string `json:"id"` ID string `json:"id"`
DeviceName string `json:"device_name"` Device_Name string `json:"device_name"`
VendorName string `json:"vendor_name"` Vendor_Name string `json:"vendor_name"`
SubsystemDeviceName string `json:"subsystem_device_name"` Subsystem_Device_Name string `json:"subsystem_device_name"`
SubsystemVendorName string `json:"subsystem_vendor_name"` Subsystem_Vendor_Name string `json:"subsystem_vendor_name"`
} }
type DeviceID string type DeviceID string
type InstanceDeviceID uint64 type InstanceDeviceID uint64
type Device struct { type Device struct {
DeviceID DeviceID `json:"device_id"` Device_ID DeviceID `json:"device_id"`
DeviceName string `json:"device_name"` Device_Name string `json:"device_name"`
VendorName string `json:"vendor_name"` Vendor_Name string `json:"vendor_name"`
Functions map[FunctionID]*Function `json:"functions"` Functions map[FunctionID]*Function `json:"functions"`
Reserved bool `json:"reserved"` Reserved bool `json:"reserved"`
Value string
} }
type FunctionID string type FunctionID string
type Function struct { type Function struct {
FunctionID FunctionID `json:"function_id"` Function_ID FunctionID `json:"function_id"`
FunctionName string `json:"subsystem_device_name"` Function_Name string `json:"subsystem_device_name"`
VendorName string `json:"subsystem_vendor_name"` Vendor_Name string `json:"subsystem_vendor_name"`
Reserved bool `json:"reserved"` Reserved bool `json:"reserved"`
} }