models

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 4, 2026 License: Apache-2.0 Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cluster

type Cluster struct {
	Name       string      `json:"name"`
	Datastores []Datastore `json:"datastores"`
	Hosts      []Host      `json:"hosts"`
	Networks   []Network   `json:"networks"`
}

Cluster represents a VMware cluster with its resources.

type Concern

type Concern struct {
	Id         string `json:"id" db:"Concern_ID"`
	Label      string `json:"label" db:"Label"`
	Category   string `json:"category" db:"Category"`
	Assessment string `json:"assessment" db:"Assessment"`
}

Concern represents a validation concern for a VM.

type Concerns

type Concerns []Concern

Concerns is a slice of Concern that implements sql.Scanner for DuckDB LIST type.

func (*Concerns) Scan

func (c *Concerns) Scan(value interface{}) error

func (Concerns) Value

func (c Concerns) Value() (driver.Value, error)

type ControllerTracker added in v0.5.0

type ControllerTracker struct {
	// contains filtered or unexported fields
}

ControllerTracker generates unique controller keys per bus type.

func NewControllerTracker added in v0.5.0

func NewControllerTracker() *ControllerTracker

NewControllerTracker creates a new ControllerTracker.

func (*ControllerTracker) GetKeyAndBus added in v0.5.0

func (ct *ControllerTracker) GetKeyAndBus(controllerName string) (key int32, bus string)

GetKeyAndBus returns the controller key and bus type for a controller name. It caches results so the same controller name always returns the same key/bus.

type Datastore

type Datastore struct {
	Cluster                 string  `db:"cluster" json:"-"`
	DiskId                  string  `db:"diskId" json:"diskId"`
	FreeCapacityGB          float64 `db:"freeCapacityGB" json:"freeCapacityGB"`
	HardwareAcceleratedMove bool    `db:"hardwareAcceleratedMove" json:"hardwareAcceleratedMove"`
	HostId                  string  `db:"hostId" json:"hostId"`
	Model                   string  `db:"model" json:"model"`
	ProtocolType            string  `db:"protocolType" json:"protocolType"`
	TotalCapacityGB         float64 `db:"totalCapacityGB" json:"totalCapacityGB"`
	Type                    string  `db:"type" json:"type"`
	Vendor                  string  `db:"vendor" json:"vendor"`
}

Datastore represents a VMware datastore.

type Disk

type Disk struct {
	Key                   string `json:"key" db:"Disk Key"`
	UnitNumber            int32  `json:"unitNumber" db:"Unit #"` // Changed to int32 for OPA
	ControllerKey         int32  `json:"controllerKey"`          // Populated by scanner using ControllerTracker
	File                  string `json:"file" db:"Path"`
	Capacity              int64  `json:"capacity" db:"Capacity MiB"` // SQL returns bytes
	Shared                bool   `json:"shared" db:"Sharing mode"`
	RDM                   bool   `json:"rdm" db:"Raw"`
	Bus                   string `json:"bus" db:"Shared Bus"` // Populated by scanner using ControllerTracker
	Mode                  string `json:"mode,omitempty" db:"Disk Mode"`
	Serial                string `json:"serial" db:"Disk UUID"`
	Thin                  string `json:"thin" db:"Thin"`
	Controller            string `json:"controller" db:"Controller"`
	Label                 string `json:"label" db:"Label"`
	SCSIUnit              string `json:"scsiUnit" db:"SCSI Unit #"`
	Datastore             Ref    `json:"datastore"`             // Changed from string to Ref
	ChangeTrackingEnabled bool   `json:"changeTrackingEnabled"` // Inherited from VM for OPA per-disk CBT check
}

Disk represents a virtual disk from the vdisk table.

type Disks

type Disks []Disk

Disks is a slice of Disk that implements sql.Scanner for DuckDB LIST type.

func (*Disks) Scan

func (d *Disks) Scan(value interface{}) error

func (Disks) Value

func (d Disks) Value() (driver.Value, error)

type Host

type Host struct {
	Cluster    string `db:"cluster" json:"-"`
	CpuCores   int    `db:"cpuCores" json:"cpuCores"`
	CpuSockets int    `db:"cpuSockets" json:"cpuSockets"`
	Id         string `db:"id" json:"id"`
	MemoryMB   int    `db:"memoryMB" json:"memoryMB"`
	Model      string `db:"model" json:"model"`
	Vendor     string `db:"vendor" json:"vendor"`
}

Host represents a VMware ESXi host.

type NIC

type NIC struct {
	Network         Ref    `json:"network"` // Changed from string to Ref
	MAC             string `json:"mac" db:"Mac Address"`
	Label           string `json:"label" db:"NIC label"`
	Adapter         string `json:"adapter" db:"Adapter"`
	Switch          string `json:"switch" db:"Switch"`
	Connected       bool   `json:"connected" db:"Connected"`
	StartsConnected bool   `json:"startsConnected" db:"Starts Connected"`
	Type            string `json:"type" db:"Type"`
	IPv4Address     string `json:"ipv4Address" db:"IPv4 Address"`
	IPv6Address     string `json:"ipv6Address" db:"IPv6 Address"`
}

NIC represents a network interface from the vnetwork table.

type NICs

type NICs []NIC

NICs is a slice of NIC that implements sql.Scanner for DuckDB LIST type.

func (*NICs) Scan

func (n *NICs) Scan(value interface{}) error

func (NICs) Value

func (n NICs) Value() (driver.Value, error)

type Network

type Network struct {
	Cluster  string `db:"cluster" json:"-"`
	Dvswitch string `db:"dvswitch" json:"dvswitch"`
	Name     string `db:"name" json:"name"`
	Type     string `db:"type" json:"type"`
	VlanId   string `db:"vlanId" json:"vlanId"`
	VmsCount int    `db:"vmsCount" json:"vmsCount"`
}

Network represents a VMware network.

type Networks

type Networks []string

Networks is a slice of strings that implements sql.Scanner for DuckDB LIST type.

func (*Networks) Scan

func (n *Networks) Scan(value interface{}) error

func (Networks) Value

func (n Networks) Value() (driver.Value, error)

type Os

type Os struct {
	Name                  string  `db:"name" json:"name"`
	Count                 int     `db:"count" json:"count"`
	Supported             bool    `db:"supported" json:"supported"`
	UpgradeRecommendation *string `db:"upgrade_recommendation" json:"upgradeRecommendation,omitempty"`
}

Os represents an operating system summary.

type Ref added in v0.5.0

type Ref struct {
	ID string `json:"id"`
}

Ref represents an object reference with ID.

type VM

type VM struct {
	ID                       string   `json:"id" db:"VM ID"`
	Name                     string   `json:"name" db:"VM"`
	Folder                   string   `json:"folder" db:"Folder ID"`
	Host                     string   `json:"host" db:"Host"`
	UUID                     string   `json:"uuid" db:"SMBIOS UUID"`
	Firmware                 string   `json:"firmware" db:"Firmware"`
	PowerState               string   `json:"powerState" db:"Powerstate"`
	ConnectionState          string   `json:"connectionState" db:"Connection state"`
	CpuHotAddEnabled         bool     `json:"cpuHotAddEnabled" db:"Hot Add"`       // vcpu
	CpuHotRemoveEnabled      bool     `json:"cpuHotRemoveEnabled" db:"Hot Remove"` // vcpu
	MemoryHotAddEnabled      bool     `json:"memoryHotAddEnabled" db:"Hot Add"`    // vmemory
	FaultToleranceEnabled    bool     `json:"faultToleranceEnabled" db:"FT State"` // vinfo
	CpuCount                 int32    `json:"cpuCount" db:"CPUs"`                  // vinfo
	CpuSockets               int32    `json:"cpuSockets" db:"Sockets"`             // vcpu
	CoresPerSocket           int32    `json:"coresPerSocket" db:"Cores p/s"`       // vcpu
	MemoryMB                 int32    `json:"memoryMB" db:"Memory"`                // vinfo
	GuestName                string   `json:"guestName" db:"OS according to the configuration file"`
	GuestNameFromVmwareTools string   `json:"guestNameFromVmwareTools" db:"OS according to the VMware Tools"`
	HostName                 string   `json:"hostName" db:"DNS Name"`
	BalloonedMemory          int32    `json:"balloonedMemory" db:"Ballooned"` // vmemory
	IpAddress                string   `json:"ipAddress" db:"Primary IP Address"`
	StorageUsed              int64    `json:"storageUsed" db:"In Use MiB"` // SQL returns bytes
	IsTemplate               bool     `json:"isTemplate" db:"Template"`
	ChangeTrackingEnabled    bool     `json:"changeTrackingEnabled" db:"CBT"`
	NICs                     NICs     `json:"nics"`
	Disks                    Disks    `json:"disks"`
	Networks                 Networks `json:"networks" db:"network_object_id"`
	DiskEnableUuid           bool     `json:"diskEnableUuid" db:"EnableUUID"`
	Datacenter               string   `json:"datacenter" db:"Datacenter"`
	Cluster                  string   `json:"cluster" db:"Cluster"`
	HWVersion                string   `json:"hwVersion" db:"HW version"`
	TotalDiskCapacityMiB     int32    `json:"totalDiskCapacityMiB" db:"Total disk capacity MiB"`
	ProvisionedMiB           int32    `json:"provisionedMiB" db:"Provisioned MiB"`
	ResourcePool             string   `json:"resourcePool" db:"Resource pool"`
	Concerns                 Concerns `json:"concerns"`
	NumaNodeAffinity         []string `json:"numaNodeAffinity"` // Always empty for RVTools, included for OPA compatibility
}

VM represents a virtual machine from VMware inventory.

func (VM) EffectiveGuestName added in v0.5.0

func (vm VM) EffectiveGuestName() string

EffectiveGuestName returns the best available guest OS name. Prefers VMware Tools detection over configuration file.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL