hypervisors

package
v0.32.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCopyImageNotImplemented error = errors.New("CopyImage not implemented for this hypervisor")

Functions

func HasAvailableImage added in v0.30.0

func HasAvailableImage(hv Hypervisor, vms hope.VMs, imageName string) (bool, error)

func HasBuiltImage added in v0.30.0

func HasBuiltImage(hv Hypervisor, vms hope.VMs, imageName string) (bool, error)

func HasNode added in v0.30.0

func HasNode(hv Hypervisor, node string) (bool, error)

func ParameterMap added in v0.31.0

func ParameterMap(params []string) map[string]string

Types

type CopyImageMode added in v0.29.0

type CopyImageMode int
const (
	// The hypervisor does not support copying images between instances.
	// Invocations to `CopyImage` should result in a
	// `ErrCopyImageNotImplemented`
	CopyImageModeNone CopyImageMode = iota

	// After calling `CreateImage`, the user can reliably invoke `CopyImage`
	// for each hypervisor in the hypervisor list.
	CopyImageModeToAll

	// After calling `CreateImage`, the user can reliably invoke `CopyImage`
	// for each hypervisor _except_ the one with which `CreateImage“ was
	// invoked.
	CopyImageModeFromFirst
)

type EngineBuildPlan added in v0.29.0

type EngineBuildPlan struct {
	Engine           string
	NumHypervisors   int
	BuildHypervisors []Hypervisor
	CopyHypervisors  []Hypervisor
}

func GetEnginePlans added in v0.29.0

func GetEnginePlans(hypervisors []Hypervisor) ([]EngineBuildPlan, error)

type EsxiHypervisor

type EsxiHypervisor struct {
	// contains filtered or unexported fields
}

func (*EsxiHypervisor) CopyImage added in v0.21.0

func (hyp *EsxiHypervisor) CopyImage(vms hope.VMs, vmImageSpec hope.VMImageSpec, srcHypervisor Hypervisor) error

func (*EsxiHypervisor) CopyImageMode added in v0.29.0

func (hyp *EsxiHypervisor) CopyImageMode() CopyImageMode

func (*EsxiHypervisor) CreateImage added in v0.21.0

func (hyp *EsxiHypervisor) CreateImage(vms hope.VMs, vmImageSpec hope.VMImageSpec, args []string, force bool) error

func (*EsxiHypervisor) CreateNode added in v0.21.0

func (hyp *EsxiHypervisor) CreateNode(node hope.Node, vms hope.VMs, vmImageSpec hope.VMImageSpec) error

func (*EsxiHypervisor) DeleteVM added in v0.21.0

func (hyp *EsxiHypervisor) DeleteVM(name string) error

func (*EsxiHypervisor) Initialize added in v0.28.4

func (hyp *EsxiHypervisor) Initialize(node hope.Node) error

func (*EsxiHypervisor) ListAvailableImages added in v0.30.0

func (hyp *EsxiHypervisor) ListAvailableImages(vms hope.VMs) ([]string, error)

func (*EsxiHypervisor) ListBuiltImages added in v0.30.0

func (hyp *EsxiHypervisor) ListBuiltImages(vms hope.VMs) ([]string, error)

func (*EsxiHypervisor) ListNodes

func (hyp *EsxiHypervisor) ListNodes() ([]string, error)

func (*EsxiHypervisor) ResolveNode

func (hyp *EsxiHypervisor) ResolveNode(node hope.Node) (hope.Node, error)

func (*EsxiHypervisor) StartVM added in v0.21.0

func (hyp *EsxiHypervisor) StartVM(name string) error

func (*EsxiHypervisor) StopVM added in v0.21.0

func (hyp *EsxiHypervisor) StopVM(name string) error

func (*EsxiHypervisor) UnderlyingNode

func (hyp *EsxiHypervisor) UnderlyingNode() (hope.Node, error)

func (*EsxiHypervisor) VMIPAddress added in v0.21.0

func (hyp *EsxiHypervisor) VMIPAddress(name string) (string, error)

type Hypervisor

type Hypervisor interface {
	// Initialize using the provided Node.
	Initialize(hope.Node) error

	// Return a list of identifiers for the nodes present on the hypervisor.
	ListNodes() ([]string, error)

	// Return a list of identifiers for the images available to be copied to
	// the hypervisor.
	// Images in this list may not be in a state where they can be created
	// using `CreateNode` yet, and may still need to be copied to the
	// hypervisor
	ListBuiltImages(hope.VMs) ([]string, error)

	// Return a list of identifiers for image on the hypervisor that could be
	// cloned/created right now.
	ListAvailableImages(hope.VMs) ([]string, error)

	// Ask the hypervisor for the host of the node, and return a new node with
	// reachable IP in its host field.
	ResolveNode(node hope.Node) (hope.Node, error)

	// Returns the base object used to create the hypervisor.
	UnderlyingNode() (hope.Node, error)

	// How instances this hypervisor expect images to be copied
	CopyImageMode() CopyImageMode

	// Copy an image from the packer cache to all hypervisors it should exist
	// on.
	CopyImage(hope.VMs, hope.VMImageSpec, Hypervisor) error

	// Create an image using the given image spec.
	CreateImage(hope.VMs, hope.VMImageSpec, []string, bool) error

	// Create a node from the given image spec.
	CreateNode(hope.Node, hope.VMs, hope.VMImageSpec) error

	// Start the VM identified by the given value.
	StartVM(string) error

	// Start the VM identified by the given value.
	StopVM(string) error

	// Delete the VM identified by the given value.
	DeleteVM(string) error

	// Get the IP address of the VM identified by the given value.
	VMIPAddress(string) (string, error)
}

Hypervisor acts as a catch-all for "an entity that exposes access to manage a virtual machine".

type ToHypervisorFactoryFunc added in v0.30.0

type ToHypervisorFactoryFunc func(hope.Node) (Hypervisor, error)
var ToHypervisor ToHypervisorFactoryFunc = func(node hope.Node) (Hypervisor, error) {
	if !node.IsHypervisor() {
		return nil, fmt.Errorf("node named %s is not a hypervisor", node.Name)
	}

	var rv Hypervisor = nil
	switch node.Engine {
	case "esxi":
		rv = &EsxiHypervisor{}
	default:
		return nil, fmt.Errorf("failed to resolve hypervisor engine: %s", node.Engine)
	}

	if err := rv.Initialize(node); err != nil {
		return nil, err
	}
	return rv, nil
}

Jump to

Keyboard shortcuts

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