network

package
v0.0.0-...-10ea56a Latest Latest
Warning

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

Go to latest
Published: May 29, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_IP_ADDR_MANAGER_ALLOCATOR_PATH = "/var/run/dicker/network/ipam/subnet.json"
)
View Source
const (
	DEFAULT_NETWORK_PATH = "/var/run/dicker/network/network"
)

Variables

This section is empty.

Functions

func ConnectToNetwork

func ConnectToNetwork(nwName string, containerInfo *container.ContainerInfo) error

func CreateNetwork

func CreateNetwork(driver, subnet, nwName string) error

Create a new network in the subnet with the driver.

func DeleteNetwork

func DeleteNetwork(nwName string) error

func DisconnectFromNetwork

func DisconnectFromNetwork(nwName string, containerInfo *container.ContainerInfo) error

func Init

func Init() error

func ListNetwork

func ListNetwork() error

Types

type BridgeNetworkDriver

type BridgeNetworkDriver struct {
}

func (*BridgeNetworkDriver) ConnectToNetwork

func (b *BridgeNetworkDriver) ConnectToNetwork(nw *Network, endpoint *Endpoint) error

Connect the endpoint to the network.

func (*BridgeNetworkDriver) CreateNetwork

func (b *BridgeNetworkDriver) CreateNetwork(nwName, subnet string, gatewayIp net.IP) (*Network, error)

func (*BridgeNetworkDriver) DeleteNetwork

func (b *BridgeNetworkDriver) DeleteNetwork(nw *Network) error

func (*BridgeNetworkDriver) DisconnectFromNetwork

func (b *BridgeNetworkDriver) DisconnectFromNetwork(nw *Network, endpoint *Endpoint) error

Disconnect the endpoint from the network.

func (*BridgeNetworkDriver) Name

func (b *BridgeNetworkDriver) Name() string

type Endpoint

type Endpoint struct {
	Id           string           `json:"id"`
	Device       *netlink.Veth    `json:"device"`
	Ip           net.IP           `json:"ip"`
	Mac          net.HardwareAddr `json:"mac"`
	Network      *Network         `json:"network"`
	PortMappings []string         `json:"port_mappings"`
}

type IpAddrManager

type IpAddrManager struct {
	// The path of the JSON format storage file of the allocation status of the subnets.
	SubnetAllocatorPath string
	// Subnet table, each value is bool slice whose elements are indicators of
	// the validity of each IP address in the subnet.
	Subnets map[string][]bool
}

func (*IpAddrManager) Alloc

func (ipam *IpAddrManager) Alloc(subnet string) (net.IP, error)

func (*IpAddrManager) Release

func (ipam *IpAddrManager) Release(subnet string, ip net.IP) error

type Network

type Network struct {
	Name      string `json:"name"`
	Subnet    string `json:"subnet"`
	GatewayIp net.IP `json:"gateway_ip"`
	Driver    string `json:"driver"`
}

func (*Network) Dump

func (n *Network) Dump(path string) error

func (*Network) Load

func (n *Network) Load(path string) error

func (*Network) Remove

func (n *Network) Remove(path string) error

type NetworkDriver

type NetworkDriver interface {
	Name() string
	CreateNetwork(nwName, subnet string, gatewayIp net.IP) (*Network, error)
	// Only use network name as the parameter should still work?
	DeleteNetwork(nw *Network) error
	ConnectToNetwork(nw *Network, endpoint *Endpoint) error
	DisconnectFromNetwork(nw *Network, endpoint *Endpoint) error
}

Jump to

Keyboard shortcuts

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