instances

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2023 License: AGPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BootstrapNetworkName is the name of the ephemeral libvirt network used for bootstrapping the cluster
	BootstrapNetworkName = "rhyzome-bootstrap-network"
)

Variables

This section is empty.

Functions

func AttachInterface

func AttachInterface(id string, nic NetworkInterface) error

AttachInterface to an existing instance if nic.Tagged and the MAC matches an existing interface, the tagged vlan will be added to the existing port

func DomainNameToID

func DomainNameToID(domainname string) string

func Ensure

func Ensure(instance *protos.Instance) error

func IDToDomainName

func IDToDomainName(resourceID string) string

func Start

func Start(ctx context.Context, id string) error

func Stop

func Stop(ctx context.Context, id string, graceful bool) error

Types

type AllNICs

type AllNICs map[string]NICFilters

type LegacyInstance

type LegacyInstance struct {
	ID                string             // The instance ID
	Image             string             // Image is the URL of the image to write to the root disk
	DiskSizeGB        int                // DiskSizeGB is the size (in gigabytes) to allocate for the root disk
	MemoryMB          int                // MemoryMB is the amount of memory (RAM) to allocate to the instance
	Cores             int                // Cores is the number of CPU cores to allocate to the instance
	Volumes           []string           // Volumes is a list of volume IDs to attach to this instance
	NetworkInterfaces []NetworkInterface // a list of NICs for this instance
	SpecialCases      []SpecialCase      // SpecialCase is a list of special cases to apply. See SpecialCase type for options and details. Do not allow to be written by the API.

	Smbios map[int]map[string]string // Smbios is the smbios data to pass to qemu. int key is type, string key is smbios field, value is value. See https://gist.github.com/smoser/290f74c256c89cb3f3bd434a27b9f64c for mappings
}

LegacyInstance represents an virtual machine. But it's 2023 so we call them "instances"

func (LegacyInstance) Create

func (i LegacyInstance) Create(conn *libvirt.Connect) error

Create the instance in libvirt

func (LegacyInstance) DomainName

func (i LegacyInstance) DomainName() string

func (LegacyInstance) GetDomain

func (i LegacyInstance) GetDomain(conn *libvirt.Connect) (*libvirt.Domain, error)

func (LegacyInstance) GetDomainXML

func (i LegacyInstance) GetDomainXML(conn *libvirt.Connect) (libvirtxml.Domain, error)

func (LegacyInstance) RootVolumeName

func (i LegacyInstance) RootVolumeName() string

RootVolumeName returns the name of the instance's root volume

type NICFilters

type NICFilters struct {
	Unfiltered bool     `json:",omitempty"`
	RouterPort string   `json:",omitempty"`
	IPs        []string `json:",omitempty"`
}

type NetworkInterface

type NetworkInterface struct {
	MAC    string
	VLAN   uint
	Tagged bool
	IPs    []string
}

NetworkInterface is a NIC to attach to an instance

type SpecialCase

type SpecialCase string

SpecialCase are different instance configurations that can be requested

var (
	// SpecialCaseRouter means the instance gets a WAN port, maybe some other stuff
	SpecialCaseRouter SpecialCase = "router"

	// SpecialCaseCloudInitNoCloud passes the configured metadata server to the instance via qemu's -smbios flag
	SpecialCaseCloudInitNoCloud SpecialCase = "cloud-init-nocloud"

	// SpecialCaseControlNetwork causes an instance to be added to the control network
	SpecialCaseControlNetwork SpecialCase = "control-network"
)

Jump to

Keyboard shortcuts

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