Documentation ¶
Index ¶
- Constants
- Variables
- func RenderMainConfig(configSubDir string) []byte
- type ConfigFile
- type Networker
- func (nw *Networker) ConfigBaseDir() string
- func (nw *Networker) ConfigFile(interfaceName string) string
- func (nw *Networker) ConfigSubDir() string
- func (nw *Networker) IntrusiveMode() bool
- func (nw *Networker) IsPrimaryInterfaceOrLoopback(interfaceName string) bool
- func (nw *Networker) Kill()
- func (nw *Networker) Wait() error
Constants ¶
const DefaultConfigBaseDir = "/etc/network"
DefaultConfigBaseDir is the usual root directory where the network configuration is kept.
const ManagedHeader = "# Managed by Juju, please don't change.\n\n"
ManagedHeader is the header of a network config file managed by Juju.
Variables ¶
var ( ExecuteCommands = executeCommands Interfaces = interfaces InterfaceIsUp = interfaceIsUp InterfaceHasAddress = interfaceHasAddress )
Functions defined here for easier patching when testing.
Functions ¶
func RenderMainConfig ¶
RenderMainConfig generates a managed main config file, which includes *.cfg individual config files inside configSubDir (i.e. /etc/network/interfaces).
Types ¶
type ConfigFile ¶
type ConfigFile interface { // InterfaceName returns the inteface name for this config file. InterfaceName() string // FileName returns the full path for storing this config file on // disk. FileName() string // InterfaceInfo returns the network.InterfaceInfo associated with // this config file. InterfaceInfo() network.InterfaceInfo // ReadData opens the underlying config file and populates the // data. ReadData() error // Data returns the original raw contents of this config file. Data() []byte // RenderManaged generates network config based on the known // network.InterfaceInfo and returns it. RenderManaged() []byte // NeedsUpdating returns true if this config file needs to be // written to disk. NeedsUpdating() bool // IsPendingRemoval returns true if this config file needs to be // removed. IsPendingRemoval() bool // IsManaged returns true if this config file is managed by Juju. IsManaged() bool // UpdateData updates the internally stored raw contents of this // config file, and sets the "needs updating" internal flag, // returning true, if newData is different. If newData is the same // as the old or the interface is not managed, returns false and // does not change anything. UpdateData(newData []byte) bool // MarkForRemoval marks this config file as pending for removal, // if the interface is managed. MarkForRemoval() // Apply updates the config file data (if it needs updating), // removes the file (if it's marked removal), or does nothing. Apply() error }
ConfigFile defines operations on a network config file for a single network interface.
type Networker ¶
type Networker struct {
// contains filtered or unexported fields
}
Networker configures network interfaces on the machine, as needed.
func NewNetworker ¶
func NewNetworker( st apinetworker.State, agentConfig agent.Config, intrusiveMode bool, configBaseDir string, ) (*Networker, error)
NewNetworker returns a Worker that handles machine networking configuration. If there is no <configBasePath>/interfaces file, an error is returned.
func (*Networker) ConfigBaseDir ¶
ConfigBaseDir returns the root directory where the networking config is kept. Usually, this is /etc/network.
func (*Networker) ConfigFile ¶
ConfigFile returns the full path to the network config file for the given interface. If interfaceName is "", the path to the main network config file is returned (usually, this is /etc/network/interfaces).
func (*Networker) ConfigSubDir ¶
ConfigSubDir returns the directory where individual config files for each network interface are kept. Usually, this is /etc/network/interfaces.d.
func (*Networker) IntrusiveMode ¶
IntrusiveMode returns whether the networker is changing networking configuration files (intrusive mode) or won't modify them on the machine (non-intrusive mode).
func (*Networker) IsPrimaryInterfaceOrLoopback ¶
IsPrimaryInterfaceOrLoopback returns whether the given interfaceName matches the primary or loopback network interface.