networker

package
v0.0.0-...-a002913 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2015 License: AGPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultConfigBaseDir = "/etc/network"

DefaultConfigBaseDir is the usual root directory where the network configuration is kept.

View Source
const ManagedHeader = "# Managed by Juju, please don't change.\n\n"

ManagedHeader is the header of a network config file managed by Juju.

Variables

View Source
var (
	ExecuteCommands     = executeCommands
	Interfaces          = interfaces
	InterfaceIsUp       = interfaceIsUp
	InterfaceHasAddress = interfaceHasAddress
)

Functions defined here for easier patching when testing.

Functions

func RenderMainConfig

func RenderMainConfig(configSubDir string) []byte

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

func (nw *Networker) ConfigBaseDir() string

ConfigBaseDir returns the root directory where the networking config is kept. Usually, this is /etc/network.

func (*Networker) ConfigFile

func (nw *Networker) ConfigFile(interfaceName string) string

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

func (nw *Networker) ConfigSubDir() string

ConfigSubDir returns the directory where individual config files for each network interface are kept. Usually, this is /etc/network/interfaces.d.

func (*Networker) IntrusiveMode

func (nw *Networker) IntrusiveMode() bool

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

func (nw *Networker) IsPrimaryInterfaceOrLoopback(interfaceName string) bool

IsPrimaryInterfaceOrLoopback returns whether the given interfaceName matches the primary or loopback network interface.

func (*Networker) Kill

func (nw *Networker) Kill()

Kill implements Worker.Kill().

func (*Networker) Wait

func (nw *Networker) Wait() error

Wait implements Worker.Wait().

Jump to

Keyboard shortcuts

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