network

package
v0.0.0-...-28e6f37 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2019 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IPAMPersistentMode = iota
	IPAMMemoryMode
)
View Source
const (
	DefaultSubnet     = "192.168.1.0/24"
	DefaultBridgeName = "capsule_bridge0"
)

Variables

This section is empty.

Functions

func DeleteNetwork

func DeleteNetwork(driver string, name string) error

func Disconnect

func Disconnect(endpoint *Endpoint) error

func InitNetworkDrivers

func InitNetworkDrivers(runtimeRoot string) error

Types

type BridgeNetworkDriver

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

func (*BridgeNetworkDriver) Connect

func (driver *BridgeNetworkDriver) Connect(endpointId string, network *Network, portMappings []string, containerInitPid int) (*Endpoint, error)

func (*BridgeNetworkDriver) Create

func (driver *BridgeNetworkDriver) Create(subnet string, bridgeName string) (*Network, error)

func (*BridgeNetworkDriver) Delete

func (driver *BridgeNetworkDriver) Delete(name string) error

func (*BridgeNetworkDriver) Disconnect

func (driver *BridgeNetworkDriver) Disconnect(endpoint *Endpoint) error

func (*BridgeNetworkDriver) List

func (driver *BridgeNetworkDriver) List() ([]*Network, error)

func (*BridgeNetworkDriver) Load

func (driver *BridgeNetworkDriver) Load(name string) (*Network, error)

func (*BridgeNetworkDriver) Name

func (driver *BridgeNetworkDriver) Name() string

func (*BridgeNetworkDriver) NetworkLabel

func (driver *BridgeNetworkDriver) NetworkLabel() string

type Endpoint

type Endpoint struct {
	Name         string        `json:"name"`
	IpAddress    net.IP        `json:"ip_address"`
	Device       *netlink.Veth `json:"device"`
	Network      *Network      `json:"network"`
	PortMappings []string      `json:"port_mappings"`
}

对应一个网络端点,比如容器中会有一个veth和一个loopback

func Connect

func Connect(endpointId string, networkName string, portMappings []string, containerInitPid int) (*Endpoint, error)

func (*Endpoint) GetContainerVethName

func (endpoint *Endpoint) GetContainerVethName() string

func (*Endpoint) GetHostVethName

func (endpoint *Endpoint) GetHostVethName() string

func (*Endpoint) String

func (endpoint *Endpoint) String() string

type IPAM

type IPAM interface {
	Allocate(subnet *net.IPNet) (net.IP, error)
	Release(subnet *net.IPNet, ip net.IP) error
	Allocatable(subnet *net.IPNet) uint
}

ipam is short for ip address management

func NewMemoryIPAllocator

func NewMemoryIPAllocator() (IPAM, error)

func NewPersistentIPAllocator

func NewPersistentIPAllocator(runtimeRoot string) (IPAM, error)

type IPAMMode

type IPAMMode int

func (IPAMMode) String

func (m IPAMMode) String() string

type LocalIPAM

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

BitSet的文档: https://godoc.org/github.com/willf/bitset#BitSet

func (*LocalIPAM) Allocatable

func (ipam *LocalIPAM) Allocatable(subnet *net.IPNet) uint

func (*LocalIPAM) Allocate

func (ipam *LocalIPAM) Allocate(subnet *net.IPNet) (net.IP, error)

func (*LocalIPAM) Release

func (ipam *LocalIPAM) Release(subnet *net.IPNet, ip net.IP) error

type Network

type Network struct {
	// 网络名称
	Name string `json:"name"`

	// 网络驱动名(网络类型)
	Driver string `json:"driver"`
	// contains filtered or unexported fields
}

对应一个网段,Driver取值有Bridge

func CreateNetwork

func CreateNetwork(driver string, subnet string, name string) (*Network, error)

func ListAllNetwork

func ListAllNetwork() ([]*Network, error)

func ListNetwork

func ListNetwork(driver string) ([]*Network, error)

func LoadNetwork

func LoadNetwork(driver string, name string) (*Network, error)

func LoadNetworkByName

func LoadNetworkByName(name string) (*Network, error)

func (*Network) GatewayIP

func (network *Network) GatewayIP() net.IP

func (*Network) String

func (network *Network) String() string

func (*Network) Subnet

func (network *Network) Subnet() *net.IPNet

type NetworkDriver

type NetworkDriver interface {
	Name() string
	NetworkLabel() string
	Create(subnet string, name string) (*Network, error)
	Load(name string) (*Network, error)
	Delete(name string) error
	Connect(endpointId string, network *Network, portMappings []string, containerInitPid int) (*Endpoint, error)
	Disconnect(endpoint *Endpoint) error
	List() ([]*Network, error)
}

Jump to

Keyboard shortcuts

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