core

package
v0.0.0-09-22-2015.05-3... Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2015 License: Apache-2.0 Imports: 5 Imported by: 145

Documentation

Overview

Package core provides definition for a generic interface that helps provision networking for an endpoint (like a container, a vm or a bare-metal host). The interface is invoked (north-bound) by the 'daemon' or the extension-plugin (TBD) part of docker. The interface in turn invokes (south-bound) a driver-interface that provides hardware/kernel/device specific programming implementation, if any.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrIfKeyExists

func ErrIfKeyExists(err error) error

ErrIfKeyExists checks if the error message contains "Key not found".

Types

type Address

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

Address is a string represenation of a network address (mac, ip, dns-name, url etc)

type CommonState

type CommonState struct {
	StateDriver StateDriver `json:"-"`
	ID          string      `json:"id"`
}

CommonState defines the fields common to all core.State implementations. This struct shall be embedded as anonymous field in all structs that implement core.State

type Config

type Config struct {
	V interface{}
}

Config object parsed from a json styled config

type Driver

type Driver interface{}

Driver implements the programming logic

type Endpoint

type Endpoint interface {
	CreateEndpoint(id string) error
	DeleteEndpoint(id string) error
	FetchEndpoint(id string) (State, error)
}

Endpoint identifies an addressable entity in a network. An endpoint belongs to a single network.

type Error

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

Error is our custom error with description, file, and line.

func Errorf

func Errorf(f string, args ...interface{}) *Error

Errorf returns an *Error based on the format specification provided.

func (*Error) Error

func (e *Error) Error() string

Error() allows *core.Error to present the `error` interface.

type InstanceInfo

type InstanceInfo struct {
	StateDriver StateDriver `json:"-"`
	HostLabel   string      `json:"host-label"`
	VtepIP      string      `json:"vtep-ip"`
	VlanIntf    string      `json:"vlan-if"`
}

InstanceInfo encapsulates data that is specific to a running instance of netplugin like label of host on which it is started.

type Network

type Network interface {
	CreateNetwork(id string) error
	DeleteNetwork(id string) error
	FetchNetwork(id string) (State, error)
}

Network identifies a group of (addressable) endpoints that can comunicate.

type NetworkDriver

type NetworkDriver interface {
	Driver
	Init(config *Config, info *InstanceInfo) error
	Deinit()
	CreateNetwork(id string) error
	DeleteNetwork(id string) error
	CreateEndpoint(id string) error
	DeleteEndpoint(id string) error
	CreatePeerHost(id string) error
	DeletePeerHost(id string) error
}

NetworkDriver implements the programming logic for network and endpoints

type PeerHost

type PeerHost interface {
	CreatePeerHost(id string) error
	DeletePeerHost(id string) error
}

PeerHost identifies a peer which this node can communicate to Generally this info is used for network wide operations like setting up VTEP tunnels, synchronizing routes etc.

type Plugin

type Plugin interface {
	Init(configStr string) error
	Deinit()
	Network
	Endpoint
	PeerHost
}

Plugin brings together an implementation of a network, endpoint and state drivers. Along with implementing north-bound interfaces for network and endpoint operations

type Resource

type Resource interface {
	State
	Init(rsrcCfg interface{}) error
	Deinit()
	Description() string
	Allocate() (interface{}, error)
	Deallocate(interface{}) error
}

Resource defines a allocatable unit. A resource is uniquely identified by 'ID'. A resource description identifies the nature of the resource.

type ResourceManager

type ResourceManager interface {
	Init() error
	Deinit()
	DefineResource(id, desc string, rsrcCfg interface{}) error
	UndefineResource(id, desc string) error
	AllocateResourceVal(id, desc string) (interface{}, error)
	DeallocateResourceVal(id, desc string, value interface{}) error
}

ResourceManager provides mechanism to manage (define/undefine, allocate/deallocate) resources. Example, it may provide management in logically centralized manner in a distributed system

type State

type State interface {
	Read(id string) error
	ReadAll() ([]State, error)
	Write() error
	Clear() error
}

State identifies data uniquely identifiable by 'id' and stored in a (distributed) key-value store implemented by core.StateDriver.

type StateDriver

type StateDriver interface {
	Driver
	Init(config *Config) error
	Deinit()

	// XXX: the following raw versions of Read, Write, ReadAll and WatchAll
	// can perhaps be removed from core API, as no one uses them directly.
	Write(key string, value []byte) error
	Read(key string) ([]byte, error)
	ReadAll(baseKey string) ([][]byte, error)
	WatchAll(baseKey string, rsps chan [2][]byte) error

	WriteState(key string, value State,
		marshal func(interface{}) ([]byte, error)) error
	ReadState(key string, value State,
		unmarshal func([]byte, interface{}) error) error
	ReadAllState(baseKey string, stateType State,
		unmarshal func([]byte, interface{}) error) ([]State, error)
	// WatchAllState returns changes to a state from the point watch is started.
	// It's a blocking call.
	// XXX: This specification introduces a small time window where a few
	// updates might be missed that occurred just before watch was started.
	// May be watch shall return all existing state first and then subsequent
	// updates. Revisit if this enhancement is needed.
	WatchAllState(baseKey string, stateType State,
		unmarshal func([]byte, interface{}) error, rsps chan WatchState) error
	ClearState(key string) error
}

StateDriver provides the mechanism for reading/writing state for networks, endpoints and meta-data managed by the core. The state is assumed to be stored as key-value pairs with keys of type 'string' and value to be an opaque binary string, encoded/decoded by the logic specific to the high-level(consumer) interface.

type WatchState

type WatchState struct {
	Curr State
	Prev State
}

WatchState is used to provide a difference between core.State structs by providing both the current and previous state.

type WatchableState

type WatchableState interface {
	State
	WatchAll(rsps chan WatchState) error
}

WatchableState allows for the rest of core.State, plus the WatchAll call which allows the implementor to yield changes to a channel.

Jump to

Keyboard shortcuts

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