Documentation
¶
Index ¶
- func FormatUptime(uptimeSec uint64) string
- type Client
- func (c *Client) AttachDiskToVM(uuidStr string, volumePath string, targetDev string) error
- func (c *Client) AttachNetworkInterfaceToVM(uuidStr string, networkName string, model string) error
- func (c *Client) CheckGuestAgentStatus(uuidStr string) (bool, error)
- func (c *Client) Close() error
- func (c *Client) CreateNWFilter(req core.CreateNWFilterRequest) error
- func (c *Client) CreateNetwork(name string, bridgeName string) error
- func (c *Client) CreateStoragePool(cfg core.PoolConfig) error
- func (c *Client) CreateVM(cfg core.VMCreationConfig) (core.VM_Detailed, error)
- func (c *Client) CreateVMSnapshot(uuidStr string, cfg core.CreateSnapshotRequest) (core.Snapshot, error)
- func (c *Client) CreateVolume(poolName string, volConfig core.VolumeConfig) error
- func (c *Client) DeleteImage(imageId string) error
- func (c *Client) DeleteNWFilter(name string) error
- func (c *Client) DeleteNetwork(name string) error
- func (c *Client) DeleteVM(uuidStr string, deleteDisks bool) error
- func (c *Client) DeleteVMSnapshot(uuidStr string, snapshotName string) error
- func (c *Client) DeleteVolume(poolName string, volumeName string) error
- func (c *Client) ForceStopVM(name string) error
- func (c *Client) GetActivity() []core.ActivityEvent
- func (c *Client) GetDomainByName(name string) (*libvirt.Domain, error)
- func (c *Client) GetGuestAgentStatus(vmName string) (string, error)
- func (c *Client) GetHostResources() (core.HostResources, error)
- func (c *Client) GetHostStatus() (core.HostStatus, error)
- func (c *Client) GetISOs() ([]core.Image, error)
- func (c *Client) GetImages() ([]core.Image, error)
- func (c *Client) GetNWFilter(name string) (core.NWFilter, error)
- func (c *Client) GetNetworks() ([]core.Network, error)
- func (c *Client) GetStoragePools() ([]core.StoragePool, error)
- func (c *Client) GetSystemInterfaces() ([]core.SystemInterface, error)
- func (c *Client) GetTemplates() ([]core.Image, error)
- func (c *Client) GetVMDetails(uuidStr string) (core.VM_Detailed, error)
- func (c *Client) GetVMPerformance(uuidStr string) (core.PerformanceSample, error)
- func (c *Client) GetVMSerialConsolePath(uuidStr string) (string, error)
- func (c *Client) GetVMSnapshots(uuidStr string) ([]core.Snapshot, error)
- func (c *Client) GetVMSummaries() ([]core.VM_Summary, error)
- func (c *Client) GetVMVNCInfo(uuidStr string) (core.VNCInfo, error)
- func (c *Client) GetVolumes(poolName string) ([]core.Volume, error)
- func (c *Client) ImportImageFromPath(sourcePath string) (core.Image, error)
- func (c *Client) InstallGuestAgent(uuidStr string) error
- func (c *Client) ListNWFilters() ([]core.NWFilter, error)
- func (c *Client) NewStream(flags libvirt.StreamFlags) (*libvirt.Stream, error)
- func (c *Client) PerformVMAction(uuidStr string, action string) error
- func (c *Client) RestartVM(name string, force bool) error
- func (c *Client) RevertToVMSnapshot(uuidStr string, snapshotName string) error
- func (c *Client) StartVM(name string) error
- func (c *Client) StopVM(name string) error
- func (c *Client) UpdateNWFilter(name string, req core.CreateNWFilterRequest) error
- func (c *Client) UpdateNetwork(name string, action string) error
- func (c *Client) UpdateVolume(poolName string, volumeName string, config core.VolumeConfig) error
- type ClientInterface
- type DomainXML
- type DomainXMLForPTY
- type DomainXMLForVNC
- type GuestAgentInfo
- type InterfaceStats
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatUptime ¶
FormatUptime converts seconds to a human-readable uptime string (e.g., "2h 30m 45s")
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client holds the libvirt connection.
func (*Client) AttachDiskToVM ¶
AttachDiskToVM attaches a disk volume to a running VM
func (*Client) AttachNetworkInterfaceToVM ¶
AttachNetworkInterfaceToVM attaches a network interface to a VM (supports hot-plug and cold-plug)
func (*Client) CheckGuestAgentStatus ¶
CheckGuestAgentStatus checks if guest agent is installed and running
func (*Client) CreateNWFilter ¶
func (c *Client) CreateNWFilter(req core.CreateNWFilterRequest) error
CreateNWFilter creates a new network filter
func (*Client) CreateNetwork ¶
CreateNetwork creates a new virtual network with the specified name and bridge name.
func (*Client) CreateStoragePool ¶
func (c *Client) CreateStoragePool(cfg core.PoolConfig) error
CreateStoragePool creates a new storage pool
func (*Client) CreateVM ¶
func (c *Client) CreateVM(cfg core.VMCreationConfig) (core.VM_Detailed, error)
CreateVM orchestrates creating a new volume and defining the VM.
func (*Client) CreateVMSnapshot ¶
func (c *Client) CreateVMSnapshot(uuidStr string, cfg core.CreateSnapshotRequest) (core.Snapshot, error)
CreateVMSnapshot creates a new snapshot from a name and description.
func (*Client) CreateVolume ¶
func (c *Client) CreateVolume(poolName string, volConfig core.VolumeConfig) error
func (*Client) DeleteImage ¶
DeleteImage deletes an image from the managed library
func (*Client) DeleteNWFilter ¶
DeleteNWFilter deletes a network filter by name
func (*Client) DeleteNetwork ¶
func (*Client) DeleteVMSnapshot ¶
DeleteVMSnapshot deletes a snapshot by its name.
func (*Client) DeleteVolume ¶
DeleteVolume deletes a storage volume
func (*Client) ForceStopVM ¶
ForceStopVM force stops a VM by name
func (*Client) GetActivity ¶
func (c *Client) GetActivity() []core.ActivityEvent
GetActivity returns the current activity events
func (*Client) GetDomainByName ¶
GetDomainByName returns a libvirt domain by name
func (*Client) GetGuestAgentStatus ¶
GetGuestAgentStatus gets guest agent status by VM name
func (*Client) GetHostResources ¶
func (c *Client) GetHostResources() (core.HostResources, error)
GetHostResources returns memory/cpu/storage aggregates.
func (*Client) GetHostStatus ¶
func (c *Client) GetHostStatus() (core.HostStatus, error)
GetHostStatus implements HostStatus gathering per your blueprint.
func (*Client) GetNWFilter ¶
GetNWFilter gets a specific network filter by name
func (*Client) GetNetworks ¶
GetNetworks fetches all virtual networks.
func (*Client) GetStoragePools ¶
func (c *Client) GetStoragePools() ([]core.StoragePool, error)
GetStoragePools lists pools and their status/capacities.
func (*Client) GetSystemInterfaces ¶
func (c *Client) GetSystemInterfaces() ([]core.SystemInterface, error)
GetSystemInterfaces returns all system network interfaces
func (*Client) GetTemplates ¶
GetTemplates returns available VM templates from the designated pool
func (*Client) GetVMDetails ¶
func (c *Client) GetVMDetails(uuidStr string) (core.VM_Detailed, error)
GetVMDetails(uuidStr)
func (*Client) GetVMPerformance ¶
func (c *Client) GetVMPerformance(uuidStr string) (core.PerformanceSample, error)
GetVMPerformance gets a single, real-time sample of performance counters for a VM.
func (*Client) GetVMSerialConsolePath ¶
GetVMSerialConsolePath extracts the PTY path for a VM's serial console
func (*Client) GetVMSnapshots ¶
GetVMSnapshots lists all snapshots for a given VM.
func (*Client) GetVMSummaries ¶
func (c *Client) GetVMSummaries() ([]core.VM_Summary, error)
GetVMSummaries returns a brief list, computing per-VM CPU percent via a short sample window. It samples all domains concurrently to avoid serial 1s sleeps per VM.
func (*Client) GetVMVNCInfo ¶
GetVMVNCInfo retrieves VNC connection information for a VM
func (*Client) GetVolumes ¶
GetVolumes lists volumes for a pool
func (*Client) ImportImageFromPath ¶
ImportImageFromPath imports an image from a host path
func (*Client) InstallGuestAgent ¶
InstallGuestAgent attempts to install guest agent via common package managers
func (*Client) ListNWFilters ¶
ListNWFilters fetches all network filters
func (*Client) PerformVMAction ¶
PerformVMAction(uuidStr, action)
func (*Client) RevertToVMSnapshot ¶
RevertToVMSnapshot reverts a VM's state.
func (*Client) UpdateNWFilter ¶
func (c *Client) UpdateNWFilter(name string, req core.CreateNWFilterRequest) error
UpdateNWFilter updates an existing network filter
func (*Client) UpdateNetwork ¶
DeleteNetwork deletes a virtual network by name
func (*Client) UpdateVolume ¶
UpdateVolume updates a storage volume (resize operation)
type ClientInterface ¶
type ClientInterface interface {
GetVMSummaries() ([]core.VM_Summary, error)
GetVMDetails(uuidStr string) (core.VM_Detailed, error)
GetVMSnapshots(uuidStr string) ([]core.Snapshot, error)
CreateVMSnapshot(uuidStr string, cfg core.CreateSnapshotRequest) (core.Snapshot, error)
DeleteVMSnapshot(uuidStr string, snapshotName string) error
RevertToVMSnapshot(uuidStr string, snapshotName string) error
GetVMPerformance(uuidStr string) (core.PerformanceSample, error)
PerformVMAction(uuidStr string, action string) error
DeleteVM(uuidStr string, deleteDisks bool) error
CreateVM(cfg core.VMCreationConfig) (core.VM_Detailed, error)
GetHostStatus() (core.HostStatus, error)
GetHostResources() (core.HostResources, error)
GetStoragePools() ([]core.StoragePool, error)
GetVolumes(poolName string) ([]core.Volume, error)
CreateVolume(poolName string, volConfig core.VolumeConfig) error
GetNetworks() ([]core.Network, error)
GetSystemInterfaces() ([]core.SystemInterface, error)
CreateNetwork(name string, bridgeName string) error
DeleteNetwork(name string) error
GetISOs() ([]core.Image, error)
GetTemplates() ([]core.Image, error)
GetImages() ([]core.Image, error)
ImportImageFromPath(path string) (core.Image, error)
DeleteImage(imageId string) error
GetVMSerialConsolePath(uuidStr string) (string, error)
GetDomainByName(name string) (*libvirt.Domain, error)
NewStream(flags libvirt.StreamFlags) (*libvirt.Stream, error)
AttachDiskToVM(uuidStr string, volumePath string, targetDev string) error
AttachNetworkInterfaceToVM(uuidStr string, networkName string, model string) error
GetActivity() []core.ActivityEvent
Close() error
// Guest agent operations
GetGuestAgentStatus(vmName string) (string, error)
CheckGuestAgentStatus(uuidStr string) (bool, error)
InstallGuestAgent(uuidStr string) error
// Storage operations
CreateStoragePool(cfg core.PoolConfig) error
UpdateVolume(poolName string, volumeName string, config core.VolumeConfig) error
DeleteVolume(poolName string, volumeName string) error
// Network operations
UpdateNetwork(name string, bridgeName string) error
// VNC operations
GetVMVNCInfo(uuidStr string) (core.VNCInfo, error)
// Firewall/NWFilter operations
ListNWFilters() ([]core.NWFilter, error)
GetNWFilter(name string) (core.NWFilter, error)
CreateNWFilter(req core.CreateNWFilterRequest) error
UpdateNWFilter(name string, req core.CreateNWFilterRequest) error
DeleteNWFilter(name string) error
}
ClientInterface defines the interface for all libvirt operations.
type DomainXML ¶
type DomainXML struct {
XMLName xml.Name `xml:"domain"`
Type string `xml:"type,attr"`
Name string `xml:"name"`
Memory struct {
Unit string `xml:"unit,attr"`
Value uint64 `xml:",chardata"`
} `xml:"memory"`
VCPU struct {
Placement string `xml:"placement,attr"`
Value int `xml:",chardata"`
} `xml:"vcpu"`
OS struct {
Type struct {
Arch string `xml:"arch,attr"`
Machine string `xml:"machine,attr"`
Value string `xml:",chardata"`
} `xml:"type"`
Boot struct {
Dev string `xml:"dev,attr"`
} `xml:"boot"`
Kernel string `xml:"kernel,omitempty"` // For PXE: kernel URL
Initrd string `xml:"initrd,omitempty"` // For PXE: initrd URL
Cmdline string `xml:"cmdline,omitempty"` // For PXE: kernel arguments
} `xml:"os"`
Devices struct {
Emulator string `xml:"emulator"`
Disks []struct {
Type string `xml:"type,attr"`
Device string `xml:"device,attr"`
Driver struct {
Name string `xml:"name,attr"`
Type string `xml:"type,attr"`
} `xml:"driver"`
Source struct {
Pool string `xml:"pool,attr,omitempty"`
Volume string `xml:"volume,attr,omitempty"`
File string `xml:"file,attr,omitempty"`
} `xml:"source"`
Target struct {
Dev string `xml:"dev,attr"`
Bus string `xml:"bus,attr"`
} `xml:"target"`
} `xml:"disk"`
Interfaces []struct {
Type string `xml:"type,attr"`
Source struct {
Network string `xml:"network,attr,omitempty"`
Bridge string `xml:"bridge,attr,omitempty"`
Dev string `xml:"dev,attr,omitempty"`
Mode string `xml:"mode,attr,omitempty"`
} `xml:"source"`
Model struct {
Type string `xml:"type,attr"`
} `xml:"model"`
} `xml:"interface"`
Graphics struct {
Type string `xml:"type,attr"`
Port int `xml:"port,attr"`
Autoport string `xml:"autoport,attr"`
Listen struct {
Type string `xml:"type,attr"`
} `xml:"listen"`
} `xml:"graphics"`
Serial struct {
Type string `xml:"type,attr"`
Target struct {
Type string `xml:"type,attr"`
Port int `xml:"port,attr"`
Model struct {
Name string `xml:"name,attr"`
} `xml:"model"`
} `xml:"target"`
} `xml:"serial"`
Console struct {
Type string `xml:"type,attr"`
Target struct {
Type string `xml:"type,attr"`
Port int `xml:"port,attr"`
} `xml:"target"`
} `xml:"console"`
} `xml:"devices"`
}
DomainXML defines the structure for marshalling a libvirt domain XML. This is a simplified version for v0.
type DomainXMLForPTY ¶
type DomainXMLForPTY struct {
Devices struct {
Consoles []struct {
Type string `xml:"type,attr"`
Source struct {
Path string `xml:"path,attr"`
} `xml:"source"`
} `xml:"console"`
Serials []struct {
Type string `xml:"type,attr"`
Source struct {
Path string `xml:"path,attr"`
} `xml:"source"`
} `xml:"serial"`
} `xml:"devices"`
}
DomainXMLForPTY represents the structure for parsing libvirt domain XML to extract PTY paths
type DomainXMLForVNC ¶
type DomainXMLForVNC struct {
Devices struct {
Graphics struct {
Type string `xml:"type,attr"`
Port string `xml:"port,attr"`
Listen string `xml:"listen,attr"`
} `xml:"graphics"`
} `xml:"devices"`
}
DomainXMLForVNC represents the structure for parsing libvirt domain XML to extract VNC details
type GuestAgentInfo ¶
type GuestAgentInfo struct {
OSName string `json:"os_name"`
OSVersion string `json:"os_version"`
IPAddresses []string `json:"ip_addresses"`
Hostname string `json:"hostname"`
Available bool `json:"available"`
LastSeen time.Time `json:"last_seen"`
}
GuestAgentInfo holds information retrieved from qemu guest agent