vm

package
v1.10.0-alpha.0 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: MPL-2.0 Imports: 51 Imported by: 0

Documentation

Overview

Package vm implements common methods for VM provisioners.

Index

Constants

This section is empty.

Variables

This section is empty.

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 DumpIPAMRecord

func DumpIPAMRecord(statePath string, record IPAMRecord) error

DumpIPAMRecord appends IPAM record to the database.

func NewHTTPServer

func NewHTTPServer(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 added in v1.5.0

func StopProcessByPidfile(pidPath string) error

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

func TFTPd added in v1.6.2

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

TFTPd starts a TFTP server on the given IPs.

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(state *State, clusterReq provision.ClusterRequest) error

CreateDHCPd creates DHCPd.

func (*Provisioner) CreateDisks

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

CreateDisks creates empty disk files for each disk.

func (*Provisioner) CreateJSONLogs added in v1.9.0

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

CreateJSONLogs creates JSON logs server.

func (*Provisioner) CreateKMS added in v1.5.0

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

CreateKMS creates KMS server.

func (*Provisioner) CreateLoadBalancer

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

CreateLoadBalancer creates load balancer.

func (*Provisioner) CreateNetwork

func (p *Provisioner) CreateNetwork(ctx context.Context, state *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 added in v1.7.0

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

CreateSiderolinkAgent creates siderlink agent.

func (*Provisioner) DestroyDHCPd

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

DestroyDHCPd destoys load balancer.

func (*Provisioner) DestroyJSONLogs added in v1.9.0

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

DestroyJSONLogs destroys JSON logs server.

func (*Provisioner) DestroyKMS added in v1.5.0

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

DestroyKMS destroys KMS server.

func (*Provisioner) DestroyLoadBalancer

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

DestroyLoadBalancer destroys load balancer.

func (*Provisioner) DestroyNetwork

func (p *Provisioner) DestroyNetwork(state *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 added in v1.7.0

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

DestroySiderolinkAgent destroys siderolink agent.

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

type State struct {
	ProvisionerName string
	BridgeName      string

	ClusterInfo provision.ClusterInfo

	VMCNIConfig *libcni.NetworkConfigList
	// contains filtered or unexported fields
}

State common state representation for vm provisioners.

func NewState

func NewState(statePath, provisionerName, clusterName string) (*State, error)

NewState create new vm provisioner state.

func (*State) GetRelativePath

func (s *State) GetRelativePath(path string) string

GetRelativePath get file path relative to config folder.

func (*State) Info

func (s *State) Info() provision.ClusterInfo

Info get cluster info.

func (*State) Provisioner

func (s *State) Provisioner() string

Provisioner get provisioner name.

func (*State) Save

func (s *State) Save() error

Save save state to config file.

func (*State) StatePath

func (s *State) StatePath() (string, error)

StatePath get state config file path.

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