network

package
v1.4.3-rc1 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2018 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultBridgeName = "bridge"
)
View Source
const NilPort = Port("")

Variables

This section is empty.

Functions

func Init

func ScopedAliasName

func ScopedAliasName(scope string, container string, alias string) string

ScopedAliasName returns the fully qualified name of an alias, scoped to the scope and optionally a container

Types

type AddContainerOptions

type AddContainerOptions struct {
	Scope   string
	IP      net.IP
	Aliases []string
	Ports   []string
}

type AddressSpace

type AddressSpace struct {
	Parent  *AddressSpace
	Network *net.IPNet
	Pool    *ip.Range
	// contains filtered or unexported fields
}

An AddressSpace is a collection of IP address ranges

func NewAddressSpaceFromNetwork

func NewAddressSpaceFromNetwork(ipRange *net.IPNet) *AddressSpace

NewAddressSpaceFromNetwork creates a new AddressSpace from a network specification.

func NewAddressSpaceFromRange

func NewAddressSpaceFromRange(firstIP net.IP, lastIP net.IP) *AddressSpace

NewAddressSpaceFromRange creates a new AddressSpace from a range of IP addresses.

func (*AddressSpace) Defragment

func (s *AddressSpace) Defragment() error

func (*AddressSpace) Equal

func (s *AddressSpace) Equal(other *AddressSpace) bool

Equal compares two address spaces for equality.

func (*AddressSpace) NextIP4Net

func (s *AddressSpace) NextIP4Net(mask net.IPMask) (*net.IPNet, error)

func (*AddressSpace) ReleaseIP4

func (s *AddressSpace) ReleaseIP4(ip net.IP) error

ReleaseIP4 releases the given IPv4 address.

func (*AddressSpace) ReleaseIP4Range

func (s *AddressSpace) ReleaseIP4Range(space *AddressSpace) error

ReleaseIP4Range releases a sub address space into the parent address space. Sub address space has to have only a single available range.

func (*AddressSpace) ReserveIP4

func (s *AddressSpace) ReserveIP4(ip net.IP) error

ReserveIP4 reserves the given IPv4 address.

func (*AddressSpace) ReserveIP4Net

func (s *AddressSpace) ReserveIP4Net(ipNet *net.IPNet) (*AddressSpace, error)

ReserveIP4Net reserves a new sub address space given an IP and mask. Mask is required. If IP is nil or "0.0.0.0", same as calling ReserveNextIP4Net with the mask.

func (*AddressSpace) ReserveIP4Range

func (s *AddressSpace) ReserveIP4Range(firstIP net.IP, lastIP net.IP) (*AddressSpace, error)

ReserveIP4Range reserves a sub address space given a first and last IP.

func (*AddressSpace) ReserveNextIP4

func (s *AddressSpace) ReserveNextIP4() (net.IP, error)

ReserveNextIP4 reserves the next available IPv4 address.

func (*AddressSpace) ReserveNextIP4Net

func (s *AddressSpace) ReserveNextIP4Net(mask net.IPMask) (*AddressSpace, error)

ReserveNextIP4Net reserves a new sub address space within the given address space, given a bitmask specifying the "width" of the requested space.

type Configuration

type Configuration struct {

	// Turn on debug logging
	DebugLevel int `vic:"0.1" scope:"read-only" key:"init/diagnostics/debug"`

	// Port Layer - network
	config.Network `vic:"0.1" scope:"read-only" key:"network"`

	// The bridge link
	BridgeLink Link `vic:"0.1" scope:"read-only" recurse:"depth=0"`

	// the vsphere portgroups corresponding to container network configuration
	PortGroups map[string]object.NetworkReference `vic:"0.1" scope:"read-only" recurse:"depth=0"`
	// contains filtered or unexported fields
}

func (*Configuration) Decode

func (c *Configuration) Decode()

func (*Configuration) Encode

func (c *Configuration) Encode()

type Container

type Container struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*Container) Endpoint

func (c *Container) Endpoint(s *Scope) *Endpoint

func (*Container) Endpoints

func (c *Container) Endpoints() []*Endpoint

func (*Container) ID

func (c *Container) ID() uid.UID

func (*Container) Name

func (c *Container) Name() string

func (*Container) Refresh

func (c *Container) Refresh(ctx context.Context) error

func (*Container) Scopes

func (c *Container) Scopes() []*Scope

type Context

type Context struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Context denotes a network context that represents a set of scopes, endpoints, and containers. Each context has its own separate IPAM.

var (
	DefaultContext *Context
)

func NewContext

func NewContext(config *Configuration, kv kvstore.KeyValueStore) (*Context, error)

func (*Context) AddContainer

func (c *Context) AddContainer(h *exec.Handle, options *AddContainerOptions) error

AddContainer add a container to the specified scope, optionally specifying an ip address for the container in the scope

func (*Context) BindContainer

func (c *Context) BindContainer(op trace.Operation, h *exec.Handle) ([]*Endpoint, error)

func (*Context) Container

func (c *Context) Container(key string) *Container

func (*Context) ContainerByAddr

func (c *Context) ContainerByAddr(addr net.IP) *Endpoint

func (*Context) ContainersByAlias

func (c *Context) ContainersByAlias(alias string) []*Container

func (*Context) DefaultScope

func (c *Context) DefaultScope() *Scope

func (*Context) DeleteScope

func (c *Context) DeleteScope(ctx context.Context, name string) error

func (*Context) NewScope

func (c *Context) NewScope(ctx context.Context, scopeData *ScopeData) (*Scope, error)

func (*Context) RemoveContainer

func (c *Context) RemoveContainer(h *exec.Handle, scope string) error

func (*Context) RemoveIDFromScopes

func (c *Context) RemoveIDFromScopes(op trace.Operation, id string) ([]*Endpoint, error)

RemoveIDFromScopes removes the container from the scopes but doesn't touch the runtime state Because of that it requires an id

func (*Context) Scopes

func (c *Context) Scopes(ctx context.Context, idName *string) ([]*Scope, error)

func (*Context) UnbindContainer

func (c *Context) UnbindContainer(op trace.Operation, h *exec.Handle) ([]*Endpoint, error)

UnbindContainer removes the container from the scopes and clears out the assigned IP Because of that, it requires a handle

type DuplicateResourceError

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

func (DuplicateResourceError) Error

func (e DuplicateResourceError) Error() string

type Endpoint

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

func (*Endpoint) Container

func (e *Endpoint) Container() *Container

func (*Endpoint) Gateway

func (e *Endpoint) Gateway() net.IP

func (*Endpoint) ID

func (e *Endpoint) ID() uid.UID

func (*Endpoint) IP

func (e *Endpoint) IP() net.IP

func (*Endpoint) Name

func (e *Endpoint) Name() string

func (*Endpoint) Ports

func (e *Endpoint) Ports() []Port

func (*Endpoint) Scope

func (e *Endpoint) Scope() *Scope

func (*Endpoint) Subnet

func (e *Endpoint) Subnet() *net.IPNet
type Link interface {
	AddrAdd(net.IPNet) error
	AddrDel(net.IPNet) error
	Attrs() *LinkAttrs
}

func LinkByAlias

func LinkByAlias(alias string) (Link, error)

func LinkByName

func LinkByName(name string) (Link, error)

type LinkAttrs

type LinkAttrs struct {
	Name string
}

type Port

type Port string

func ParsePort

func ParsePort(p string) (Port, error)

func PortFromMapping

func PortFromMapping(mapping nat.PortMapping) Port

PortFromMapping constructs the full form of a port mapping This has been added to help migrate towards consistent data returns for Endpoint structures

func (Port) FullString

func (p Port) FullString() string

func (Port) Port

func (p Port) Port() (uint16, error)

func (Port) Proto

func (p Port) Proto() string

func (Port) String

func (p Port) String() string

type ResourceNotFoundError

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

type Scope

type Scope struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*Scope) AddContainer

func (s *Scope) AddContainer(con *Container, e *Endpoint) error

func (*Scope) Annotations

func (s *Scope) Annotations() map[string]string

func (*Scope) Container

func (s *Scope) Container(id uid.UID) *Container

func (*Scope) ContainerByAddr

func (s *Scope) ContainerByAddr(addr net.IP) *Endpoint

func (*Scope) Containers

func (s *Scope) Containers() []*Container

func (*Scope) DNS

func (s *Scope) DNS() []net.IP

func (*Scope) Endpoints

func (s *Scope) Endpoints() []*Endpoint

func (*Scope) Gateway

func (s *Scope) Gateway() net.IP

func (*Scope) ID

func (s *Scope) ID() uid.UID

func (*Scope) Internal

func (s *Scope) Internal() bool

func (*Scope) MarshalJSON

func (s *Scope) MarshalJSON() ([]byte, error)

func (*Scope) Name

func (s *Scope) Name() string

func (*Scope) Network

func (s *Scope) Network() object.NetworkReference

func (*Scope) Pools

func (s *Scope) Pools() []*ip.Range

func (*Scope) RemoveContainer

func (s *Scope) RemoveContainer(con *Container) error

func (*Scope) Subnet

func (s *Scope) Subnet() *net.IPNet

func (*Scope) TrustLevel

func (s *Scope) TrustLevel() executor.TrustLevel

func (*Scope) Type

func (s *Scope) Type() string

func (*Scope) UnmarshalJSON

func (s *Scope) UnmarshalJSON(data []byte) error

type ScopeData

type ScopeData struct {
	ScopeType   string
	Name        string
	Subnet      *net.IPNet
	Gateway     net.IP
	DNS         []net.IP
	TrustLevel  executor.TrustLevel
	Pools       []string
	Annotations map[string]string
	Internal    bool
}

ScopeData holds fields used to create a new scope

Jump to

Keyboard shortcuts

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