This commit is contained in:
+14
-2
@@ -39,7 +39,7 @@ type PveClusterStatus struct {
|
||||
|
||||
// PveResource represents a generic PVE resource object.
|
||||
type PveResource struct {
|
||||
Type string `mapstructure:"type"` // Type of resource (e.g., "lxc", "qemu", "node", "storage", "sdn").
|
||||
Type string `mapstructure:"type"` // Type of resource (e.g., "lxc", "qemu", "node", "storage", "sdn", "network").
|
||||
Node string `mapstructure:"node"` // Node where the resource is located.
|
||||
Status string `mapstructure:"status"` // Status of the resource (e.g., "running", "stopped", "online", "available").
|
||||
ID string `mapstructure:"id"` // Unique identifier for the resource.
|
||||
@@ -106,9 +106,12 @@ type PveStorageResource struct {
|
||||
}
|
||||
|
||||
// PveSdnResource represents a PVE software-defined network (SDN) resource.
|
||||
// PVE 8 reports these as "sdn" resources, PVE 9 as "network" resources.
|
||||
type PveSdnResource struct {
|
||||
PveResource
|
||||
SDN string `mapstructure:"sdn"` // Name of the SDN.
|
||||
SDN string `mapstructure:"sdn"` // Name of the SDN (only "sdn" resources).
|
||||
Network string `mapstructure:"network"` // Name of the network entity (only "network" resources).
|
||||
NetworkType string `mapstructure:"network-type"` // Type of the network entity, e.g. "zone" or "fabric" (only "network" resources).
|
||||
}
|
||||
|
||||
// PVE resources.
|
||||
@@ -455,6 +458,15 @@ func (r *PveResources) FindNodeSDN(nodeName string) *[]PveSdnResource {
|
||||
return &sdns
|
||||
}
|
||||
|
||||
// GetName returns the name of an SDN resource, regardless of whether it was
|
||||
// reported as an "sdn" (PVE 8) or a "network" (PVE 9) resource.
|
||||
func (r *PveSdnResource) GetName() string {
|
||||
if r.SDN != "" {
|
||||
return r.SDN
|
||||
}
|
||||
return r.Network
|
||||
}
|
||||
|
||||
// GetStatusNumeric returns the numeric status of an SDN resource.
|
||||
// Returns 1 if the status is "ok", otherwise returns 0.
|
||||
func (r *PveSdnResource) GetStatusNumeric() float64 {
|
||||
|
||||
Reference in New Issue
Block a user