Documentation
¶
Overview ¶
Package libnetwork provides the basic functionality and extension points to create network namespaces and allocate interfaces for containers to use.
// Create a new controller instance
controller := libnetwork.New()
// This option is only needed for in-tree drivers. Plugins(in future) will get
// their options through plugin infrastructure.
option := options.Generic{}
driver, err := controller.NewNetworkDriver("simplebridge", option)
if err != nil {
return
}
netOptions := options.Generic{}
// Create a network for containers to join.
network, err := controller.NewNetwork(driver, "network1", netOptions)
if err != nil {
return
}
// For a new container: create a sandbox instance (providing a unique key).
// For linux it is a filesystem path
networkPath := "/var/lib/docker/.../4d23e"
networkNamespace, err := sandbox.NewSandbox(networkPath)
if err != nil {
return
}
// For each new container: allocate IP and interfaces. The returned network
// settings will be used for container infos (inspect and such), as well as
// iptables rules for port publishing.
ep, err := network.CreateEndpoint("Endpoint1", networkNamespace.Key(), "")
if err != nil {
return
}
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNilNetworkDriver is returned if a nil network driver // is passed to NewNetwork api. ErrNilNetworkDriver = errors.New("nil NetworkDriver instance") // ErrInvalidNetworkDriver is returned if an invalid driver // instance is passed. ErrInvalidNetworkDriver = errors.New("invalid driver bound to network") )
Functions ¶
This section is empty.
Types ¶
type ActiveEndpointsError ¶
type ActiveEndpointsError struct {
// contains filtered or unexported fields
}
ActiveEndpointsError is returned when a network is deleted which has active endpoints in it.
func (*ActiveEndpointsError) Error ¶
func (aee *ActiveEndpointsError) Error() string
type Endpoint ¶
type Endpoint interface {
// A system generated id for this endpoint.
ID() string
// Name returns the name of this endpoint.
Name() string
// Network returns the name of the network to which this endpoint is attached.
Network() string
// SandboxInfo returns the sandbox information for this endpoint.
SandboxInfo() *driverapi.SandboxInfo
// Delete and detaches this endpoint from the network.
Delete() error
}
Endpoint represents a logical connection between a network and a sandbox.
type Network ¶
type Network interface {
// A user chosen name for this network.
Name() string
// A system generated id for this network.
ID() string
// The type of network, which corresponds to its managing driver.
Type() string
// Create a new endpoint to this network symbolically identified by the
// specified unique name. The options parameter carry driver specific options.
// Labels support will be added in the near future.
CreateEndpoint(name string, sboxKey string, options interface{}) (Endpoint, error)
// Endpoints returns the list of Endpoint in this network.
Endpoints() []Endpoint
// Delete the network.
Delete() error
}
A Network represents a logical connectivity zone that containers may join using the Link method. A Network is managed by a specific driver.
type NetworkController ¶
type NetworkController interface {
// NOTE: This method will go away when moving to plugin infrastructure
NewNetworkDriver(networkType string, options interface{}) (*NetworkDriver, error)
// Create a new network. The options parameter carries network specific options.
// Labels support will be added in the near future.
NewNetwork(d *NetworkDriver, name string, options interface{}) (Network, error)
}
NetworkController provides the interface for controller instance which manages networks.
type NetworkDriver ¶
type NetworkDriver struct {
// contains filtered or unexported fields
}
NetworkDriver provides a reference to driver and way to push driver specific config
type NetworkNameError ¶
type NetworkNameError string
NetworkNameError is returned when a network with the same name already exists.
func (NetworkNameError) Error ¶
func (name NetworkNameError) Error() string
type NetworkTypeError ¶
type NetworkTypeError string
NetworkTypeError type is returned when the network type string is not known to libnetwork.
func (NetworkTypeError) Error ¶
func (nt NetworkTypeError) Error() string
type UnknownEndpointError ¶
type UnknownEndpointError struct {
// contains filtered or unexported fields
}
UnknownEndpointError is returned when libnetwork could not find in it's database an endpoint with the same name and id.
func (*UnknownEndpointError) Error ¶
func (uee *UnknownEndpointError) Error() string
type UnknownNetworkError ¶
type UnknownNetworkError struct {
// contains filtered or unexported fields
}
UnknownNetworkError is returned when libnetwork could not find in it's database a network with the same name and id.
func (*UnknownNetworkError) Error ¶
func (une *UnknownNetworkError) Error() string
Directories
¶
| Path | Synopsis |
|---|---|
|
Godeps
|
|
|
_workspace/src/github.com/vishvananda/netlink
Package netlink provides a simple library for netlink.
|
Package netlink provides a simple library for netlink. |
|
_workspace/src/github.com/vishvananda/netlink/nl
Package nl has low level primitives for making Netlink calls.
|
Package nl has low level primitives for making Netlink calls. |
|
_workspace/src/github.com/vishvananda/netns
Package netns allows ultra-simple network namespace handling.
|
Package netns allows ultra-simple network namespace handling. |
|
cmd
|
|
|
readme_test
command
|
|
|
test
command
|
|
|
drivers
|
|
|
Package ipallocator defines the default IP allocator.
|
Package ipallocator defines the default IP allocator. |
|
pkg
|
|
|
options
Package options provides a way to pass unstructured sets of options to a component expecting a strongly-typed configuration structure.
|
Package options provides a way to pass unstructured sets of options to a component expecting a strongly-typed configuration structure. |