2023-05-17 11:34:29 -04:00
|
|
|
//go:build !cgo
|
|
|
|
|
|
|
|
/*
|
|
|
|
Copyright (c) Edgeless Systems GmbH
|
|
|
|
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
|
|
|
package virtwrapper
|
|
|
|
|
|
|
|
import "errors"
|
|
|
|
|
|
|
|
// Connect wraps a libvirt connection.
|
|
|
|
type Connect struct{}
|
|
|
|
|
|
|
|
// LookupNetworkByName looks up a network by name.
|
|
|
|
// This function errors if CGO is disabled.
|
|
|
|
func (c *Connect) LookupNetworkByName(_ string) (*Network, error) {
|
|
|
|
return nil, errors.New("using virtwrapper requires building with CGO")
|
|
|
|
}
|
|
|
|
|
|
|
|
// Network wraps a libvirt network.
|
2023-08-18 08:25:14 -04:00
|
|
|
type Network struct {
|
|
|
|
Net Net
|
|
|
|
}
|
2023-05-17 11:34:29 -04:00
|
|
|
|
|
|
|
// GetDHCPLeases returns the underlying DHCP leases.
|
|
|
|
// This function errors if CGO is disabled.
|
|
|
|
func (n *Network) GetDHCPLeases() ([]NetworkDHCPLease, error) {
|
2023-08-18 08:25:14 -04:00
|
|
|
return n.Net.GetDHCPLeases()
|
2023-05-17 11:34:29 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Free the network resource.
|
|
|
|
// This function does nothing if CGO is disabled.
|
|
|
|
func (n *Network) Free() {}
|
2023-08-18 08:25:14 -04:00
|
|
|
|
|
|
|
// Net is a libvirt Network.
|
|
|
|
type Net interface {
|
|
|
|
GetDHCPLeases() ([]NetworkDHCPLease, error)
|
|
|
|
}
|