vm

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2023 License: MPL-2.0 Imports: 43 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 interface{}) 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.

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) CrashDump

func (p *Provisioner) CrashDump(ctx context.Context, cluster provision.Cluster, out io.Writer)

CrashDump produces debug information to help with debugging failures.

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) 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) DestroyDHCPd

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

DestroyDHCPd destoys load balancer.

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) 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.

Jump to

Keyboard shortcuts

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