cni

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: May 20, 2026 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CNI

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

CNI implements network.Network using CNI plugins with per-VM netns + bridge + tap.

func New

func New(conf *config.Config) (*CNI, error)

New creates a CNI provider; conflist loading is best-effort so Delete/Inspect/List still work when none are available — Add fails in that case.

func (*CNI) Add added in v0.4.0

func (c *CNI) Add(ctx context.Context, vmID string, vmCfg *types.VMConfig, specs ...network.AddSpec) (configs []*types.NetworkConfig, retErr error)

Add creates the netns (if absent) and allocates each NIC's CNI plumbing.

func (*CNI) Delete

func (c *CNI) Delete(ctx context.Context, vmIDs []string) ([]string, error)

Delete tears down all NICs for each VM and removes the netns. Best-effort.

func (*CNI) GCModule

func (c *CNI) GCModule() gc.Module[cniSnapshot]

GCModule returns the GC module for orphan netns and stale CNI record cleanup.

func (*CNI) Inspect

func (c *CNI) Inspect(ctx context.Context, id string) (*types.Network, error)

Inspect returns the network record for a single network ID. Returns (nil, nil) if not found.

func (*CNI) List

func (c *CNI) List(ctx context.Context) ([]*types.Network, error)

List returns all known network records.

func (*CNI) Prepare added in v0.4.0

func (c *CNI) Prepare(_ context.Context, vmID string, _ *types.VMConfig) (string, error)

Prepare creates the per-VM netns; returns "" with no conflist.

func (*CNI) RegisterGC

func (c *CNI) RegisterGC(orch *gc.Orchestrator)

RegisterGC registers the CNI GC module with the given Orchestrator.

func (*CNI) Remove added in v0.4.0

func (c *CNI) Remove(ctx context.Context, vmID string, indices ...int) error

Remove tears down NIC plumbing for the given indices; preserves the netns. Always sweeps DB records for picked indices so resize-up to the same index isn't stale; CNI/TAP errors still propagate.

func (*CNI) Type

func (c *CNI) Type() string

Type returns the network provider identifier.

func (*CNI) Verify

func (c *CNI) Verify(_ context.Context, vmID string) error

Verify checks whether the network namespace for a VM exists.

type Config

type Config struct {
	*config.Config
}

func (*Config) CacheDir

func (c *Config) CacheDir() string

func (*Config) EnsureDirs

func (c *Config) EnsureDirs() error

func (*Config) IndexFile

func (c *Config) IndexFile() string

func (*Config) IndexLock

func (c *Config) IndexLock() string

Jump to

Keyboard shortcuts

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