mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-05-04 23:35:11 -04:00
qemu-metadata-api: allow building without cgo dependencies for linting
This commit is contained in:
parent
15d51c3a3f
commit
78085cba68
8 changed files with 119 additions and 36 deletions
|
@ -6,38 +6,8 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
|
||||
package virtwrapper
|
||||
|
||||
import "libvirt.org/go/libvirt"
|
||||
|
||||
// Connect wraps a libvirt connection.
|
||||
type Connect struct {
|
||||
Conn *libvirt.Connect
|
||||
}
|
||||
|
||||
// LookupNetworkByName looks up a network by name.
|
||||
func (c *Connect) LookupNetworkByName(name string) (*Network, error) {
|
||||
net, err := c.Conn.LookupNetworkByName(name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &Network{Net: net}, nil
|
||||
}
|
||||
|
||||
// Network wraps a libvirt network.
|
||||
type Network struct {
|
||||
Net virNetwork
|
||||
}
|
||||
|
||||
// GetDHCPLeases returns the underlying DHCP leases.
|
||||
func (n *Network) GetDHCPLeases() ([]libvirt.NetworkDHCPLease, error) {
|
||||
return n.Net.GetDHCPLeases()
|
||||
}
|
||||
|
||||
// Free the network resource.
|
||||
func (n *Network) Free() {
|
||||
_ = n.Net.Free()
|
||||
}
|
||||
|
||||
type virNetwork interface {
|
||||
GetDHCPLeases() ([]libvirt.NetworkDHCPLease, error)
|
||||
Free() error
|
||||
// NetworkDHCPLease abstracts a libvirt DHCP lease.
|
||||
type NetworkDHCPLease struct {
|
||||
IPaddr string
|
||||
Hostname string
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue