vm

package
v0.1.28 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2026 License: MPL-2.0 Imports: 55 Imported by: 0

Documentation

Overview

Package vm implements common methods for VM provisioners.

Index

Constants

This section is empty.

Variables

View Source
var NewState = provision.NewState

Deprecated: Use provision.NewState instead.

Functions

func ConfigureSignals

func ConfigureSignals() chan os.Signal

ConfigureSignals configures signal handling for the process.

func DHCPd

func DHCPd(ifName string, ips []net.IP, statePath string) error

DHCPd entrypoint.

func DNSd

func DNSd(ips []net.IP, resolvConfPath string) error

DNSd entrypoint.

func DumpIPAMRecord

func DumpIPAMRecord(statePath string, record IPAMRecord) error

DumpIPAMRecord appends IPAM record to the database.

func GetVmnetInterfaceName

func GetVmnetInterfaceName(allCurrentInterfaces []string) (string, error)

GetVmnetInterfaceName returns the name of the interface that will be assigned to the next vmnet interface. The name is assigned incrementing by one, starting from "bridge100".

func NewHTTPServer

func NewHTTPServer(ctx context.Context, gatewayAddr netip.Addr, port int, config []byte, controller Controller) (inmemhttp.Server, error)

NewHTTPServer creates new inmemhttp.Server and mounts config file into it.

func ReadConfig

func ReadConfig(config any) error

ReadConfig loads configuration from stdin.

func StopProcessByPidfile

func StopProcessByPidfile(pidPath string) error

StopProcessByPidfile stops a process by reading its PID from a file.

func TFTPd

func TFTPd(ips []net.IP, nextHandler string) error

TFTPd starts a TFTP server on the given IPs.

func Virtiofsd

func Virtiofsd(ctx context.Context, virtiofsdBin, share, socket string) error

Virtiofsd starts virtiofsd and restarts it if it exits. The restart is needed, because the virtiofsd exits when client disconnects.

Types

type Controller

type Controller interface {
	PowerOn() error
	PowerOff() error
	Reboot() error
	PXEBootOnce() error
	Status() Status
}

Controller interface should be implemented by the VM to be controlled via the API.

type IPAMDatabase

type IPAMDatabase map[string]map[int]IPAMRecord

IPAMDatabase is a mapping from MAC address to records with IPv4/IPv6 flag.

func LoadIPAMRecords

func LoadIPAMRecords(statePath string) (IPAMDatabase, error)

LoadIPAMRecords loads all the IPAM records indexed by the MAC address.

type IPAMRecord

type IPAMRecord struct {
	IP          netip.Addr
	Netmask     byte
	MAC         string
	Hostname    string
	Gateway     netip.Addr
	MTU         int
	Nameservers []netip.Addr

	TFTPServer       string
	IPXEBootFilename string
}

IPAMRecord describes a single record about a node.

type Provisioner

type Provisioner struct {
	// Name actual provisioner type.
	Name string
}

Provisioner base for VM provisioners.

func (*Provisioner) CreateDHCPd

func (p *Provisioner) CreateDHCPd(ctx context.Context, state *provision.State, clusterReq provision.ClusterRequest) error

CreateDHCPd creates a DHCP server.

func (*Provisioner) CreateDNSd

func (p *Provisioner) CreateDNSd(state *State, clusterReq provision.ClusterRequest) error

CreateDNSd creates the DNSd server.

func (*Provisioner) CreateDisks

func (p *Provisioner) CreateDisks(state *provision.State, nodeReq provision.NodeRequest) (diskPaths []string, err error)

CreateDisks creates empty disk files for each disk.

func (*Provisioner) CreateImageCache

func (p *Provisioner) CreateImageCache(state *State, clusterReq provision.ClusterRequest) error

CreateImageCache creates the Image Cache server.

func (*Provisioner) CreateJSONLogs

func (p *Provisioner) CreateJSONLogs(state *provision.State, clusterReq provision.ClusterRequest, options provision.Options) error

CreateJSONLogs creates JSON logs server.

func (*Provisioner) CreateKMS

func (p *Provisioner) CreateKMS(state *provision.State, clusterReq provision.ClusterRequest, options provision.Options) error

CreateKMS creates KMS server.

func (*Provisioner) CreateLoadBalancer

func (p *Provisioner) CreateLoadBalancer(state *provision.State, clusterReq provision.ClusterRequest) error

CreateLoadBalancer creates load balancer.

func (*Provisioner) CreateNetwork

func (p *Provisioner) CreateNetwork(ctx context.Context, state *provision.State, network provision.NetworkRequest, options provision.Options) error

CreateNetwork builds bridge interface name by taking part of checksum of the network name so that interface name is defined by network name, and different networks have different bridge interfaces.

func (*Provisioner) CreateSiderolinkAgent

func (p *Provisioner) CreateSiderolinkAgent(state *provision.State, clusterReq provision.ClusterRequest) error

CreateSiderolinkAgent creates siderlink agent.

func (*Provisioner) CreateVirtiofsd

func (p *Provisioner) CreateVirtiofsd(state *State, clusterReq provision.ClusterRequest, virtiofdPath string) error

CreateVirtiofsd creates the Virtiofsd server.

func (*Provisioner) DestroyDHCPd

func (p *Provisioner) DestroyDHCPd(state *provision.State) error

DestroyDHCPd destoys load balancer.

func (*Provisioner) DestroyDNSd

func (p *Provisioner) DestroyDNSd(state *State) error

DestroyDNSd destoys DNSd server.

func (*Provisioner) DestroyImageCache

func (p *Provisioner) DestroyImageCache(state *State) error

DestroyImageCache destoys Image Cache server.

func (*Provisioner) DestroyJSONLogs

func (p *Provisioner) DestroyJSONLogs(state *provision.State) error

DestroyJSONLogs destroys JSON logs server.

func (*Provisioner) DestroyKMS

func (p *Provisioner) DestroyKMS(state *provision.State) error

DestroyKMS destroys KMS server.

func (*Provisioner) DestroyLoadBalancer

func (p *Provisioner) DestroyLoadBalancer(state *provision.State) error

DestroyLoadBalancer destroys load balancer.

func (*Provisioner) DestroyNetwork

func (p *Provisioner) DestroyNetwork(state *provision.State) error

DestroyNetwork destroy bridge interface by name to clean up.

func (*Provisioner) DestroyNode

func (p *Provisioner) DestroyNode(node provision.NodeInfo) error

DestroyNode destroys VM.

func (*Provisioner) DestroyNodes

func (p *Provisioner) DestroyNodes(cluster provision.ClusterInfo, options *provision.Options) error

DestroyNodes destroys all VMs.

func (*Provisioner) DestroySiderolinkAgent

func (p *Provisioner) DestroySiderolinkAgent(state *provision.State) error

DestroySiderolinkAgent destroys siderolink agent.

func (*Provisioner) DestroyVirtiofsd

func (p *Provisioner) DestroyVirtiofsd(state *State) error

DestroyVirtiofsd destoys Virtiofsd server.

func (*Provisioner) FindVirtiofsd

func (p *Provisioner) FindVirtiofsd() (string, error)

FindVirtiofsd tries to find the virtiofsd binary in common locations.

func (*Provisioner) Reflect

func (p *Provisioner) Reflect(ctx context.Context, clusterName, stateDirectory string) (provision.Cluster, error)

Reflect decode state file.

func (*Provisioner) UserDiskName

func (p *Provisioner) UserDiskName(index int) string

UserDiskName returns disk device path.

type State deprecated

type State = provision.State

Deprecated: Use provision.State instead.

type Status

type Status struct {
	PoweredOn bool
}

Status describes current VM status.

Directories

Path Synopsis
internal
ipxe
Package ipxe provides utility to deliver iPXE images and build iPXE scripts.
Package ipxe provides utility to deliver iPXE images and build iPXE scripts.

Jump to

Keyboard shortcuts

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