libvirt

package
v0.0.1-alpha.0 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2017 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LifeCycleTranslationMap = map[int]LifeCycle{
	libvirt.VIR_DOMAIN_NOSTATE:     NoState,
	libvirt.VIR_DOMAIN_RUNNING:     Running,
	libvirt.VIR_DOMAIN_BLOCKED:     Blocked,
	libvirt.VIR_DOMAIN_PAUSED:      Paused,
	libvirt.VIR_DOMAIN_SHUTDOWN:    Shutdown,
	libvirt.VIR_DOMAIN_SHUTOFF:     Shutoff,
	libvirt.VIR_DOMAIN_CRASHED:     Crashed,
	libvirt.VIR_DOMAIN_PMSUSPENDED: PMSuspended,
}

Functions

This section is empty.

Types

type Address

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

type Alias

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

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" json:"model"`
}

type BandWidth

type BandWidth struct {
}

type Boot

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

type BootMenu

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

type BootOrder

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

type Channel

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

type ChannelSource

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

type ChannelTarget

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

type Clock

type Clock struct {
}

type Connection

type Connection interface {
	LookupDomainByName(name string) (VirDomain, error)
	DomainDefineXML(xml string) (VirDomain, error)
	CloseConnection() (int, error)
	DomainEventRegister(dom libvirt.VirDomain, eventId int, callback *libvirt.DomainEventCallback, opaque func()) int
	ListAllDomains(flags uint32) ([]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 Devices

type Devices struct {
	Emulator   string      `xml:"emulator" json:"emulator"`
	Interfaces []Interface `xml:"interface" json:"interfaces,omitempty"`
	Channels   []Channel   `xml:"channel" json:"channels,omitempty"`
	Video      []Video     `xml:"video" json:"video,omitempty"`
	Graphics   []Graphics  `xml:"graphics" json:"graphics,omitempty"`
	Ballooning *Ballooning `xml:"memballoon,omitempty" json:"memballoon,omitempty"`
	Disks      []Disk      `xml:"disk" json:"disks,omitempty"`
}

type Disk

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

type DiskDriver

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

type DiskSource

type DiskSource struct {
	File          string `xml:"file,attr" json:"file"`
	StartupPolicy string `xml:"startupPolicy,attr,omitempty" json:"startupPolicy,omitempty"`
}

type DiskTarget

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

type Domain

type Domain struct {
	unversioned.TypeMeta
	ObjectMeta api.ObjectMeta
	Spec       DomainSpec
	Status     DomainStatus
}

func (*Domain) GetObjectKind

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

Required to satisfy Object interface

func (*Domain) GetObjectMeta

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

Required to satisfy ObjectMetaAccessor interface

type DomainList

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

func (*DomainList) GetListMeta

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

Required to satisfy ListMetaAccessor interface

func (*DomainList) GetObjectKind

func (dl *DomainList) GetObjectKind() unversioned.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" json:"-"`
	Name    string   `xml:"name" json:"name"`
	UUID    string   `xml:"uuid,omitempty" json:"uuid,omitempty"`
	Memory  Memory   `xml:"memory" json:"memory"`
	Type    string   `xml:"type,attr" json:"type"`
	OS      OS       `xml:"os" json:"os"`
	SysInfo *SysInfo `xml:"sysinfo,omitempty" json:"sysInfo,omitempty"`
	Devices Devices  `xml:"devices" json:"devices"`
	Clock   *Clock   `xml:"clock,omitempty" json:"clock,omitempty"`
}

func NewMinimalVM

func NewMinimalVM(vmName string) *DomainSpec

type DomainStatus

type DomainStatus struct {
	Status LifeCycle
}

type Entry

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

type FilterRef

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

type Graphics

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

type Interface

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

type InterfaceSource

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

type InterfaceTarget

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

type LibvirtConnection

type LibvirtConnection struct {
	libvirt.VirConnection
}

func (*LibvirtConnection) DomainDefineXML

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

func (*LibvirtConnection) ListAllDomains

func (l *LibvirtConnection) ListAllDomains(flags uint32) ([]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
const (
	NoState     LifeCycle = "NoState"
	Running     LifeCycle = "Running"
	Blocked     LifeCycle = "Blocked"
	Paused      LifeCycle = "Paused"
	Shutdown    LifeCycle = "Shutdown"
	Shutoff     LifeCycle = "Shutoff"
	Crashed     LifeCycle = "Crashed"
	PMSuspended LifeCycle = "PMSuspended"
)

type LinkState

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

type Listen

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

type Loader

type Loader struct {
}

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

type MAC

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

type Memory

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

type MockConnection

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

Mock of Connection interface

func NewMockConnection

func NewMockConnection(ctrl *gomock.Controller) *MockConnection

func (*MockConnection) CloseConnection

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

func (*MockConnection) DomainDefineXML

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

func (*MockConnection) DomainEventRegister

func (_m *MockConnection) DomainEventRegister(dom libvirt_go.VirDomain, eventId int, callback *libvirt_go.DomainEventCallback, opaque func()) int

func (*MockConnection) EXPECT

func (_m *MockConnection) EXPECT() *_MockConnectionRecorder

func (*MockConnection) ListAllDomains

func (_m *MockConnection) ListAllDomains(flags uint32) ([]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() ([]int, error)

func (*MockVirDomain) GetUUIDString

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

func (*MockVirDomain) GetXMLDesc

func (_m *MockVirDomain) GetXMLDesc(flags uint32) (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" json:"type"`
}

type NVRam

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

type OS

type OS struct {
	Type      OSType    `xml:"type" json:"type"`
	SMBios    *SMBios   `xml:"smbios,omitempty" json:"smBIOS,omitempty"`
	BootOrder []Boot    `xml:"boot" json:"bootOrder"`
	BootMenu  *BootMenu `xml:"bootmenu,omitempty" json:"bootMenu,omitempty"`
	BIOS      *BIOS     `xml:"bios,omitempty" json:"bios,omitempty"`
}

type OSType

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

type RandomGenerator

type RandomGenerator struct {
}

type ReadOnly

type ReadOnly struct{}

type SMBios

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

type SysInfo

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

type Timer

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

type Video

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

type VideoModel

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

type VirDomain

type VirDomain interface {
	GetState() ([]int, error)
	Create() error
	Resume() error
	Destroy() error
	GetName() (string, error)
	GetUUIDString() (string, error)
	GetXMLDesc(flags uint32) (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
JackTT - Gopher 🇻🇳