libvirtn

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2021 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BRIDGE = BridgeMgr{
	Bridges: make([]Bridge, 0, 32),
}
View Source
var (
	NetworkAll = libvirt.CONNECT_LIST_NETWORKS_ACTIVE | libvirt.CONNECT_LIST_NETWORKS_INACTIVE
)

Functions

func AddHyperListener

func AddHyperListener(listen HyperListener)

func ListLeases

func ListLeases() (map[string]DHCPLease, error)

Types

type Bridge

type Bridge struct {
	Network string `json:"network"`
	Name    string `json:"name"`
	Type    string `json:"type"` // bridge, ovs etc.
}

type BridgeMgr

type BridgeMgr struct {
	Bridges []Bridge `json:"bridge"`
}

func (*BridgeMgr) Get

func (br *BridgeMgr) Get(name string) (Bridge, error)

func (*BridgeMgr) List

func (br *BridgeMgr) List() []Bridge

type BridgeXML

type BridgeXML struct {
	XMLName xml.Name `xml:"bridge" json:"-"`
	Name    string   `xml:"name,attr" json:"name"`
	Stp     string   `xml:"stp,attr,omitempty" json:"stp,omitempty"`     // on,off
	Delay   string   `xml:"delay,attr,omitempty" json:"delay,omitempty"` // 0-32
}

type DHCPLease

type DHCPLease struct {
	Type     int    `json:"type"`
	Mac      string `json:"mac"`
	IPAddr   string `json:"ipAddr"`
	Prefix   uint   `json:"prefix"`
	Hostname string `json:"hostname"`
}

func LookupLeases

func LookupLeases(uuid string) ([]DHCPLease, error)

type DHCPRangeXML

type DHCPRangeXML struct {
	XMLName xml.Name `xml:"range" json:"-"`
	Start   string   `xml:"start,attr,omitempty" json:"start,omitempty"`
	End     string   `xml:"end,attr,omitempty" json:"end,omitempty"`
}

type DHCPXML

type DHCPXML struct {
	XMLName xml.Name       `xml:"dhcp" json:"-"`
	Range   []DHCPRangeXML `xml:"range" json:"range"`
}

type ForwardXML

type ForwardXML struct {
	XMLName xml.Name `xml:"forward" json:"-"`
	Mode    string   `xml:"mode,attr" json:"mode"`
}

type HyperListener

type HyperListener struct {
	Opened func(Conn *libvirt.Connect) error
	Closed func(Conn *libvirt.Connect) error
}

type HyperVisor

type HyperVisor struct {
	Name     string
	Conn     *libvirt.Connect
	Listener []HyperListener
	Lock     sync.RWMutex
	Ticker   *time.Ticker
	Done     chan bool
	Leases   map[string]DHCPLease
}

func GetHyper

func GetHyper() (*HyperVisor, error)

func SetHyper

func SetHyper(name string) (*HyperVisor, error)

func (*HyperVisor) AddListener

func (h *HyperVisor) AddListener(listen HyperListener)

func (*HyperVisor) Close

func (h *HyperVisor) Close()

func (*HyperVisor) GetLeases

func (h *HyperVisor) GetLeases() map[string]DHCPLease

func (*HyperVisor) ListAllNetworks

func (h *HyperVisor) ListAllNetworks() ([]Network, error)

func (*HyperVisor) LookupLeases

func (h *HyperVisor) LookupLeases(uuid string) ([]DHCPLease, error)

func (*HyperVisor) LookupNetwork

func (h *HyperVisor) LookupNetwork(name string) (*Network, error)

name: uuid, name

func (*HyperVisor) LoopForever

func (h *HyperVisor) LoopForever()

func (*HyperVisor) NetworkDefineXML

func (h *HyperVisor) NetworkDefineXML(xml string) (*Network, error)

func (*HyperVisor) Open

func (h *HyperVisor) Open() error

func (*HyperVisor) OpenNotSafe

func (h *HyperVisor) OpenNotSafe() error

func (*HyperVisor) SyncLeases

func (h *HyperVisor) SyncLeases() error

type IPv4XML

type IPv4XML struct {
	XMLName xml.Name `xml:"ip" json:"-"`
	Address string   `xml:"address,attr" json:"address"`
	Prefix  string   `xml:"prefix,attr" json:"prefix"`
	Netmask string   `xml:"netmask,attr" json:"netmask"`
	DHCP    *DHCPXML `xml:"dhcp,omitempty" json:"dhcp,omitempty"`
}

type Network

type Network struct {
	libvirt.Network
}

func ListNetworks

func ListNetworks() ([]Network, error)

func LookupNetwork

func LookupNetwork(uuid string) (*Network, error)

func NewNetworkFromVir

func NewNetworkFromVir(net *libvirt.Network) *Network

type NetworkXML

type NetworkXML struct {
	XMLName     xml.Name        `xml:"network" json:"-"`
	Name        string          `xml:"name" json:"name"`
	UUID        string          `xml:"uuid" json:"uuid"`
	Forward     *ForwardXML     `xml:"forward,omitempty" json:"forward"`
	IPv4        *IPv4XML        `xml:"ip,omitempty" json:"ipv4"`
	Bridge      BridgeXML       `xml:"bridge" json:"bridge"`
	VirtualPort *VirtualPortXML `xml:"virtualport" json:"virtualport"`
}

func NewNetworkXMLFromNet

func NewNetworkXMLFromNet(net *Network) *NetworkXML

type VirtualPortXML

type VirtualPortXML struct {
	XMLName xml.Name `xml:"virtualport" json:"-"`
	Type    string   `xml:"type,attr,omitempty" json:"type,omitempty"` //openvswitch
}

Jump to

Keyboard shortcuts

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