virtwrap

package
v0.0.1-alpha.4 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2017 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NoState     LifeCycle = "NoState"
	Running     LifeCycle = "Running"
	Blocked     LifeCycle = "Blocked"
	Paused      LifeCycle = "Paused"
	Shutdown    LifeCycle = "ShuttingDown"
	Shutoff     LifeCycle = "Shutoff"
	Crashed     LifeCycle = "Crashed"
	PMSuspended LifeCycle = "PMSuspended"

	// Common reasons
	ReasonUnknown StateChangeReason = "Unknown"

	// ShuttingDown reasons
	ReasonUser StateChangeReason = "User"

	// Shutoff reasons
	ReasonShutdown     StateChangeReason = "Shutdown"
	ReasonDestroyed    StateChangeReason = "Destroyed"
	ReasonMigrated     StateChangeReason = "Migrated"
	ReasonCrashed      StateChangeReason = "Crashed"
	ReasonSaved        StateChangeReason = "Saved"
	ReasonFailed       StateChangeReason = "Failed"
	ReasonFromSnapshot StateChangeReason = "FromSnapshot"
)

Variables

View Source
var LifeCycleTranslationMap = map[libvirt.DomainState]LifeCycle{
	libvirt.DOMAIN_NOSTATE:     NoState,
	libvirt.DOMAIN_RUNNING:     Running,
	libvirt.DOMAIN_BLOCKED:     Blocked,
	libvirt.DOMAIN_PAUSED:      Paused,
	libvirt.DOMAIN_SHUTDOWN:    Shutdown,
	libvirt.DOMAIN_SHUTOFF:     Shutoff,
	libvirt.DOMAIN_CRASHED:     Crashed,
	libvirt.DOMAIN_PMSUSPENDED: PMSuspended,
}
View Source
var ShutdownReasonTranslationMap = map[libvirt.DomainShutdownReason]StateChangeReason{
	libvirt.DOMAIN_SHUTDOWN_UNKNOWN: ReasonUnknown,
	libvirt.DOMAIN_SHUTDOWN_USER:    ReasonUser,
}
View Source
var ShutoffReasonTranslationMap = map[libvirt.DomainShutoffReason]StateChangeReason{
	libvirt.DOMAIN_SHUTOFF_UNKNOWN:       ReasonUnknown,
	libvirt.DOMAIN_SHUTOFF_SHUTDOWN:      ReasonShutdown,
	libvirt.DOMAIN_SHUTOFF_DESTROYED:     ReasonDestroyed,
	libvirt.DOMAIN_SHUTOFF_CRASHED:       ReasonCrashed,
	libvirt.DOMAIN_SHUTOFF_MIGRATED:      ReasonMigrated,
	libvirt.DOMAIN_SHUTOFF_SAVED:         ReasonSaved,
	libvirt.DOMAIN_SHUTOFF_FAILED:        ReasonFailed,
	libvirt.DOMAIN_SHUTOFF_FROM_SNAPSHOT: ReasonFromSnapshot,
}

Functions

This section is empty.

Types

type Address

type Address struct {
	Type     string `xml:"type,attr"`
	Domain   string `xml:"domain,attr"`
	Bus      string `xml:"bus,attr"`
	Slot     string `xml:"slot,attr"`
	Function string `xml:"function,attr"`
}

type Alias

type Alias struct {
	Name string `xml:"name,attr"`
}

type BIOS

type BIOS struct {
}

TODO <loader readonly='yes' secure='no' type='rom'>/usr/lib/xen/boot/hvmloader</loader>

type Ballooning

type Ballooning struct {
	Model string `xml:"model,attr"`
}

type BandWidth

type BandWidth struct {
}

type Boot

type Boot struct {
	Dev string `xml:"dev,attr"`
}

type BootMenu

type BootMenu struct {
	Enabled bool  `xml:"enabled,attr"`
	Timeout *uint `xml:"timeout,attr,omitempty"`
}

type BootOrder

type BootOrder struct {
	Order uint `xml:"order,attr"`
}

type Channel

type Channel struct {
	Type   string         `xml:"type,attr"`
	Source ChannelSource  `xml:"source,omitempty"`
	Target *ChannelTarget `xml:"target,omitempty"`
}

type ChannelSource

type ChannelSource struct {
	Mode string `xml:"mode,attr"`
	Path string `xml:"path,attr"`
}

type ChannelTarget

type ChannelTarget struct {
	Name    string `xml:"name,attr,omitempty"`
	Type    string `xml:"type,attr"`
	Address string `xml:"address,attr,omitempty"`
	Port    uint   `xml:"port,attr,omitempty"`
}

type Clock

type Clock struct {
}

type Connection

type Connection interface {
	LookupDomainByName(name string) (VirDomain, error)
	DomainDefineXML(xml string) (VirDomain, error)
	Close() (int, error)
	DomainEventLifecycleRegister(dom *libvirt.Domain, callback libvirt.DomainEventLifecycleCallback) (int, error)
	ListAllDomains(flags libvirt.ConnectListAllDomainsFlags) ([]VirDomain, error)
}

TODO: Should we handle libvirt connection errors transparent or panic?

func NewConnection

func NewConnection(uri string, user string, pass string) (Connection, error)

type Console

type Console struct {
	Type   string        `xml:"type,attr"`
	Target ConsoleTarget `xml:"target"`
}

type ConsoleTarget

type ConsoleTarget struct {
	Type string `xml:"type,attr"`
	Port *uint  `xml:"port,attr,omitempty"`
}

type Devices

type Devices struct {
	Emulator   string      `xml:"emulator"`
	Interfaces []Interface `xml:"interface"`
	Channels   []Channel   `xml:"channel"`
	Video      []Video     `xml:"video"`
	Graphics   []Graphics  `xml:"graphics"`
	Ballooning *Ballooning `xml:"memballoon,omitempty"`
	Disks      []Disk      `xml:"disk"`
	Serials    []Serial    `xml:"serial"`
	Consoles   []Console   `xml:"console"`
}

type Disk

type Disk struct {
	Device   string      `xml:"device,attr"`
	Snapshot string      `xml:"snapshot,attr,omitempty"`
	Type     string      `xml:"type,attr"`
	Source   DiskSource  `xml:"source"`
	Target   DiskTarget  `xml:"target"`
	Serial   string      `xml:"serial,omitempty"`
	Driver   *DiskDriver `xml:"driver,omitempty"`
	ReadOnly *ReadOnly   `xml:"readonly,omitempty"`
}

type DiskDriver

type DiskDriver struct {
	Cache       string `xml:"cache,attr,omitempty"`
	ErrorPolicy string `xml:"error_policy,attr,omitempty"`
	IO          string `xml:"io,attr,omitempty"`
	Name        string `xml:"name,attr"`
	Type        string `xml:"type,attr"`
}

type DiskSource

type DiskSource struct {
	File          string          `xml:"file,attr,omitempty"`
	StartupPolicy string          `xml:"startupPolicy,attr,omitempty"`
	Protocol      string          `xml:"protocol,attr,omitempty"`
	Name          string          `xml:"name,attr,omitempty"`
	Host          *DiskSourceHost `xml:"host,omitempty"`
}

type DiskSourceHost

type DiskSourceHost struct {
	Name string `xml:"name,attr"`
	Port string `xml:"port,attr,omitempty"`
}

type DiskTarget

type DiskTarget struct {
	Bus    string `xml:"bus,attr,omitempty"`
	Device string `xml:"dev,attr"`
}

type Domain

type Domain struct {
	metav1.TypeMeta
	ObjectMeta kubev1.ObjectMeta
	Spec       DomainSpec
	Status     DomainStatus
}

func NewDomainReferenceFromName

func NewDomainReferenceFromName(name string) *Domain

func NewMinimalDomain

func NewMinimalDomain(name string) *Domain

func (*Domain) GetObjectKind

func (d *Domain) GetObjectKind() schema.ObjectKind

Required to satisfy Object interface

func (*Domain) GetObjectMeta

func (d *Domain) GetObjectMeta() meta.Object

Required to satisfy ObjectMetaAccessor interface

func (*Domain) SetState

func (d *Domain) SetState(status libvirt.DomainState, reason int)

type DomainList

type DomainList struct {
	metav1.TypeMeta
	ListMeta metav1.ListMeta
	Items    []Domain
}

func (*DomainList) GetListMeta

func (dl *DomainList) GetListMeta() metav1.List

Required to satisfy ListMetaAccessor interface

func (*DomainList) GetObjectKind

func (dl *DomainList) GetObjectKind() schema.ObjectKind

Required to satisfy Object interface

type DomainManager

type DomainManager interface {
	SyncVM(*v1.VM) error
	KillVM(*v1.VM) error
}

func NewLibvirtDomainManager

func NewLibvirtDomainManager(connection Connection, recorder record.EventRecorder) (DomainManager, error)

type DomainSpec

type DomainSpec struct {
	XMLName xml.Name `xml:"domain"`
	Name    string   `xml:"name"`
	UUID    string   `xml:"uuid,omitempty"`
	Memory  Memory   `xml:"memory"`
	Type    string   `xml:"type,attr"`
	OS      OS       `xml:"os"`
	SysInfo *SysInfo `xml:"sysinfo,omitempty"`
	Devices Devices  `xml:"devices"`
	Clock   *Clock   `xml:"clock,omitempty"`
}

func NewMinimalDomainSpec

func NewMinimalDomainSpec(vmName string) *DomainSpec

type DomainStatus

type DomainStatus struct {
	Status LifeCycle
	Reason StateChangeReason
}

type Entry

type Entry struct {
	Name  string `xml:"name"`
	Value string `xml:",chardata"`
}

type FilterRef

type FilterRef struct {
	Filter string `xml:"filter,attr"`
}

type Graphics

type Graphics struct {
	AutoPort      string `xml:"autoPort,attr,omitempty"`
	DefaultMode   string `xml:"defaultMode,attr,omitempty"`
	Listen        Listen `xml:"listen,omitempty"`
	PasswdValidTo string `xml:"passwdValidTo,attr,omitempty"`
	Port          int32  `xml:"port,attr,omitempty"`
	TLSPort       int    `xml:"tlsPort,attr,omitempty"`
	Type          string `xml:"type,attr"`
}

type Interface

type Interface struct {
	Address   *Address         `xml:"address,omitempty"`
	Type      string           `xml:"type,attr"`
	Source    InterfaceSource  `xml:"source"`
	Target    *InterfaceTarget `xml:"target,omitempty"`
	Model     *Model           `xml:"model,omitempty"`
	MAC       *MAC             `xml:"mac,omitempty"`
	BandWidth *BandWidth       `xml:"bandwidth,omitempty"`
	BootOrder *BootOrder       `xml:"boot,omitempty"`
	LinkState *LinkState       `xml:"link,omitempty"`
	FilterRef *FilterRef       `xml:"filterref,omitempty"`
	Alias     *Alias           `xml:"alias,omitempty"`
}

type InterfaceSource

type InterfaceSource struct {
	Network string `xml:"network,attr,omitempty"`
	Device  string `xml:"dev,attr,omitempty"`
	Bridge  string `xml:"bridge,attr,omitempty"`
}

type InterfaceTarget

type InterfaceTarget struct {
	Device string `xml:"dev,attr"`
}

type LibvirtConnection

type LibvirtConnection struct {
	libvirt.Connect
	// contains filtered or unexported fields
}

func (*LibvirtConnection) DomainDefineXML

func (l *LibvirtConnection) DomainDefineXML(xml string) (VirDomain, error)

func (*LibvirtConnection) ListAllDomains

func (l *LibvirtConnection) ListAllDomains(flags libvirt.ConnectListAllDomainsFlags) ([]VirDomain, error)

func (*LibvirtConnection) LookupDomainByName

func (l *LibvirtConnection) LookupDomainByName(name string) (VirDomain, error)

type LibvirtDomainManager

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

func (*LibvirtDomainManager) KillVM

func (l *LibvirtDomainManager) KillVM(vm *v1.VM) error

func (*LibvirtDomainManager) SyncVM

func (l *LibvirtDomainManager) SyncVM(vm *v1.VM) error

type LifeCycle

type LifeCycle string

type LinkState

type LinkState struct {
	State string `xml:"state,attr"`
}

type Listen

type Listen struct {
	Type    string `xml:"type,attr"`
	Address string `xml:"address,attr,omitempty"`
	Network string `xml:"newtork,attr,omitempty"`
}

type Loader

type Loader struct {
}

TODO <bios useserial='yes' rebootTimeout='0'/>

type MAC

type MAC struct {
	MAC string `xml:"address,attr"`
}

type Memory

type Memory struct {
	Value uint   `xml:",chardata"`
	Unit  string `xml:"unit,attr"`
}

type MockConnection

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

Mock of Connection interface

func NewMockConnection

func NewMockConnection(ctrl *gomock.Controller) *MockConnection

func (*MockConnection) Close

func (_m *MockConnection) Close() (int, error)

func (*MockConnection) DomainDefineXML

func (_m *MockConnection) DomainDefineXML(xml string) (VirDomain, error)

func (*MockConnection) DomainEventLifecycleRegister

func (_m *MockConnection) DomainEventLifecycleRegister(dom *libvirt_go.Domain, callback libvirt_go.DomainEventLifecycleCallback) (int, error)

func (*MockConnection) EXPECT

func (_m *MockConnection) EXPECT() *_MockConnectionRecorder

func (*MockConnection) ListAllDomains

func (_m *MockConnection) ListAllDomains(flags libvirt_go.ConnectListAllDomainsFlags) ([]VirDomain, error)

func (*MockConnection) LookupDomainByName

func (_m *MockConnection) LookupDomainByName(name string) (VirDomain, error)

type MockDomainManager

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

Mock of DomainManager interface

func NewMockDomainManager

func NewMockDomainManager(ctrl *gomock.Controller) *MockDomainManager

func (*MockDomainManager) EXPECT

func (_m *MockDomainManager) EXPECT() *_MockDomainManagerRecorder

func (*MockDomainManager) KillVM

func (_m *MockDomainManager) KillVM(_param0 *v1.VM) error

func (*MockDomainManager) SyncVM

func (_m *MockDomainManager) SyncVM(_param0 *v1.VM) error

type MockVirDomain

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

Mock of VirDomain interface

func NewMockVirDomain

func NewMockVirDomain(ctrl *gomock.Controller) *MockVirDomain

func (*MockVirDomain) Create

func (_m *MockVirDomain) Create() error

func (*MockVirDomain) Destroy

func (_m *MockVirDomain) Destroy() error

func (*MockVirDomain) EXPECT

func (_m *MockVirDomain) EXPECT() *_MockVirDomainRecorder

func (*MockVirDomain) GetName

func (_m *MockVirDomain) GetName() (string, error)

func (*MockVirDomain) GetState

func (_m *MockVirDomain) GetState() (libvirt_go.DomainState, int, error)

func (*MockVirDomain) GetUUIDString

func (_m *MockVirDomain) GetUUIDString() (string, error)

func (*MockVirDomain) GetXMLDesc

func (_m *MockVirDomain) GetXMLDesc(flags libvirt_go.DomainXMLFlags) (string, error)

func (*MockVirDomain) Resume

func (_m *MockVirDomain) Resume() error

func (*MockVirDomain) Undefine

func (_m *MockVirDomain) Undefine() error

type Model

type Model struct {
	Type string `xml:"type,attr"`
}

type NVRam

type NVRam struct {
	NVRam    string `xml:",chardata,omitempty"`
	Template string `xml:"template,attr,omitempty"`
}

type OS

type OS struct {
	Type       OSType    `xml:"type"`
	SMBios     *SMBios   `xml:"smbios,omitempty"`
	BootOrder  []Boot    `xml:"boot"`
	BootMenu   *BootMenu `xml:"bootmenu,omitempty"`
	BIOS       *BIOS     `xml:"bios,omitempty"`
	Kernel     string    `xml:"kernel,omitempty"`
	Initrd     string    `xml:"initrd,omitempty"`
	KernelArgs string    `xml:"cmdline,omitempty"`
}

type OSType

type OSType struct {
	OS      string `xml:",chardata"`
	Arch    string `xml:"arch,attr,omitempty"`
	Machine string `xml:"machine,attr,omitempty"`
}

type RandomGenerator

type RandomGenerator struct {
}

type ReadOnly

type ReadOnly struct{}

type SMBios

type SMBios struct {
	Mode string `xml:"mode,attr"`
}

type Serial

type Serial struct {
	Type   string       `xml:"type,attr"`
	Target SerialTarget `xml:"target"`
}

type SerialTarget

type SerialTarget struct {
	Port uint `xml:"port,attr"`
}

type StateChangeReason

type StateChangeReason string

type SysInfo

type SysInfo struct {
	Type      string  `xml:"type,attr"`
	System    []Entry `xml:"system>entry"`
	BIOS      []Entry `xml:"bios>entry"`
	BaseBoard []Entry `xml:"baseBoard>entry"`
}

type Timer

type Timer struct {
	Name       string `xml:"name,attr"`
	TickPolicy string `xml:"tickpolicy,attr,omitempty"`
	Present    string `xml:"present,attr,omitempty"`
}

type Video

type Video struct {
	Model VideoModel `xml:"model"`
}

type VideoModel

type VideoModel struct {
	Type   string `xml:"type,attr"`
	Heads  uint   `xml:"heads,attr,omitempty"`
	Ram    uint   `xml:"ram,attr,omitempty"`
	VRam   uint   `xml:"vram,attr,omitempty"`
	VGAMem uint   `xml:"vgamem,attr,omitempty" vgamem:"vram,omitempty"`
}

type VirDomain

type VirDomain interface {
	GetState() (libvirt.DomainState, int, error)
	Create() error
	Resume() error
	Destroy() error
	GetName() (string, error)
	GetUUIDString() (string, error)
	GetXMLDesc(flags libvirt.DomainXMLFlags) (string, error)
	Undefine() error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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