network

package
v0.0.0-...-04e5504 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2021 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const ForkdnsServersListFile = "servers.conf"

ForkdnsServersListFile file that contains the server candidates list.

View Source
const ForkdnsServersListPath = "forkdns.servers"

ForkdnsServersListPath defines the path that contains the forkdns server candidate file.

Variables

This section is empty.

Functions

func AttachInterface

func AttachInterface(netName string, devName string) error

AttachInterface attaches an interface to a bridge.

func DefaultGatewaySubnetV4

func DefaultGatewaySubnetV4() (*net.IPNet, string, error)

DefaultGatewaySubnetV4 returns subnet of default gateway interface.

func DetachInterface

func DetachInterface(netName string, devName string) error

DetachInterface detaches an interface from a bridge.

func FillConfig

func FillConfig(req *api.NetworksPost) error

FillConfig populates the supplied api.NetworkPost with automatically populated values.

func ForkdnsServersList

func ForkdnsServersList(networkName string) ([]string, error)

ForkdnsServersList reads the server list file and returns the list as a slice.

func GetDevMTU

func GetDevMTU(devName string) (uint64, error)

GetDevMTU retrieves the current MTU setting for a named network device.

func GetHostDevice

func GetHostDevice(parent string, vlan string) string

GetHostDevice returns the interface name to use for a combination of parent device name and VLAN ID. If no vlan ID supplied, parent name is returned unmodified. If non-empty VLAN ID is supplied then it will look for an existing VLAN device and return that, otherwise it will return the default "parent.vlan" format as name.

func GetIP

func GetIP(subnet *net.IPNet, host int64) net.IP

GetIP returns a net.IP representing the IP belonging to the subnet for the host number supplied.

func GetLeaseAddresses

func GetLeaseAddresses(s *state.State, networkName string, hwaddr string) ([]api.InstanceStateNetworkAddress, error)

GetLeaseAddresses returns the lease addresses for a network and hwaddr.

func GetMACSlice

func GetMACSlice(hwaddr string) []string

GetMACSlice parses MAC address.

func IsInUse

func IsInUse(c instance.Instance, networkName string) bool

IsInUse indicates if network is reference by any instance's NIC devices. Checks if the device's parent or network properties match the network name.

func UpdateDNSMasqStatic

func UpdateDNSMasqStatic(s *state.State, networkName string) error

UpdateDNSMasqStatic rebuilds the DNSMasq static allocations.

func UsesIPv4Firewall

func UsesIPv4Firewall(netConfig map[string]string) bool

UsesIPv4Firewall returns whether network config will need to use the IPv4 firewall.

func UsesIPv6Firewall

func UsesIPv6Firewall(netConfig map[string]string) bool

UsesIPv6Firewall returns whether network config will need to use the IPv6 firewall.

Types

type DHCPRange

type DHCPRange struct {
	Start net.IP
	End   net.IP
}

DHCPRange represents a range of IPs from start to end.

type Network

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

Network represents a LXD network.

func LoadByName

func LoadByName(s *state.State, name string) (*Network, error)

LoadByName loads the network info from the database by name.

func (*Network) Config

func (n *Network) Config() map[string]string

Config returns the network config.

func (*Network) DHCPv4Ranges

func (n *Network) DHCPv4Ranges() []DHCPRange

DHCPv4Ranges returns a parsed set of DHCPv4 ranges for this network.

func (*Network) DHCPv6Ranges

func (n *Network) DHCPv6Ranges() []DHCPRange

DHCPv6Ranges returns a parsed set of DHCPv6 ranges for this network.

func (*Network) Delete

func (n *Network) Delete(withDatabase bool) error

Delete deletes a network.

func (*Network) HasDHCPv4

func (n *Network) HasDHCPv4() bool

HasDHCPv4 indicates whether the network has DHCPv4 enabled.

func (*Network) HasDHCPv6

func (n *Network) HasDHCPv6() bool

HasDHCPv6 indicates whether the network has DHCPv6 enabled (includes stateless SLAAC router advertisement mode). Technically speaking stateless SLAAC RA mode isn't DHCPv6, but for consistency with LXD's config paradigm, DHCP here means "an ability to automatically allocate IPs and routes", rather than stateful DHCP with leases. To check if true stateful DHCPv6 is enabled check the "ipv6.dhcp.stateful" config key.

func (*Network) HasIPv4Firewall

func (n *Network) HasIPv4Firewall() bool

HasIPv4Firewall indicates whether the network has IPv4 firewall enabled.

func (*Network) HasIPv6Firewall

func (n *Network) HasIPv6Firewall() bool

HasIPv6Firewall indicates whether the network has IPv6 firewall enabled.

func (*Network) IsRunning

func (n *Network) IsRunning() bool

IsRunning returns whether the network is up.

func (*Network) IsUsed

func (n *Network) IsUsed() bool

IsUsed returns whether the network is used by any instances.

func (*Network) Name

func (n *Network) Name() string

Name returns the network name.

func (*Network) RefreshForkdnsServerAddresses

func (n *Network) RefreshForkdnsServerAddresses(heartbeatData *cluster.APIHeartbeat) error

RefreshForkdnsServerAddresses retrieves the IPv4 address of each cluster node (excluding ourselves) for this network. It then updates the forkdns server list file if there are changes.

func (*Network) Rename

func (n *Network) Rename(name string) error

Rename renames a network.

func (*Network) Start

func (n *Network) Start() error

Start starts the network.

func (*Network) Stop

func (n *Network) Stop() error

Stop stops the network.

func (*Network) Update

func (n *Network) Update(newNetwork api.NetworkPut, notify bool) error

Update updates the network.

Jump to

Keyboard shortcuts

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