ovncni

package
v0.0.0-...-316aa0a Latest Latest
Warning

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

Go to latest
Published: May 27, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultOvsBrName = "br-int"
)

Defaults that can be overwritten by CNI Args

Variables

View Source
var NbCtlCommand = func(path string, timeout int, args ...string) (string, error) {
	args = append([]string{fmt.Sprintf("--timeout=%d", timeout)}, args...)

	cmd := exec.Command(path, args...)
	cmd.Env = os.Environ()
	raw, err := cmd.CombinedOutput()

	return strings.Trim(strings.TrimSpace(string(raw)), `"`), err
}

NbCtlCommand function object wraps system call

View Source
var OvsVsctlExec = func(path string, args ...string) (string, error) {
	if path == "" {
		path = defaultOvsCtlPath
	}

	raw, err := exec.Command(path, args...).CombinedOutput()
	return strings.Trim(strings.TrimSpace(string(raw)), `"`), err
}

OvsVsctlExec function object wraps system call

Functions

func GetCNIArg

func GetCNIArg(key, cniArgs string) (string, error)

GetCNIArg searches cniArgs for key and returns key's value Expected format is alphanumeric key-value pairs separated by semicolons; for example, "FOO=BAR;ABC=123"

Types

type CNIConfig

type CNIConfig struct {
	types.NetConf
	IPAM IPAMConfig `json:"ipam"`
}

CNIConfig represents OVNCNI configuration structure

type CNIContext

type CNIContext struct {
	Cfg        CNIConfig
	Args       *skel.CmdArgs
	OVNCli     OVNClient
	OvsBrName  string
	HostIfName string
	IfMTU      uint64
	Subnet     string
	OvsCtlPath string
	OVNCtlPath string
	AppID      string
}

CNIContext CNI runtime context used for ADD/DEL/CHECK requests

func GetContext

func GetContext(args *skel.CmdArgs) (CNIContext, error)

GetContext parses args to provide CNIContext structure

func (*CNIContext) Add

func (c *CNIContext) Add() error

Add is called for ADD CNI requests NOTE: OVN port has to be already created for Add to succeed.

This package provides the following helper function to create an OVN port:
func CreatePort(lSwitch, id, ip string) (LPort, error)

func (*CNIContext) Check

func (c *CNIContext) Check() error

Check is called for CHECK CNI requests

func (*CNIContext) Del

func (c *CNIContext) Del() error

Del is called for DELETE CNI requests NOTE: OVN port has to be removed after calling CNI DELETE.

This package provides the following helper function to delete an OVN port:
func DeletePort(id string) error

type IPAMConfig

type IPAMConfig struct {
	Type    string        `json:"type"`
	Gateway net.IP        `json:"gateway"`
	Routes  []types.Route `json:"routes,omitempty"`
}

IPAMConfig represents IPAM configuration for OVNCNI It is used purely for setting the Gateway and Routes

type LPort

type LPort struct {
	ID  string
	MAC net.HardwareAddr
	IP  net.IP
	Net *net.IPNet
}

LPort represents a logical switch port in OVN

type OVNClient

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

OVNClient wraps ovn-nbctl calls to manage ports

func GetOVNClient

func GetOVNClient(nbCtlPath string, timeout int) OVNClient

GetOVNClient create OVN client

func (*OVNClient) CreatePort

func (c *OVNClient) CreatePort(lSwitch, id, ip string) (LPort, error)

CreatePort creates a logical (id) port in OVN (lSwitch) ip parameter is optional and a 'dynamic' value will be used if it is empty

func (*OVNClient) DeletePort

func (c *OVNClient) DeletePort(id string) error

DeletePort deletes a logical port from OVN

func (*OVNClient) GetNbCtlPath

func (c *OVNClient) GetNbCtlPath() string

GetNbCtlPath returns system path to executable

func (*OVNClient) GetPort

func (c *OVNClient) GetPort(lSwitch, id string) (LPort, error)

GetPort retrieves a logical switch port from OVN

Jump to

Keyboard shortcuts

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