cniutil

package

Documentation

Overview

* Tencent is pleased to support the open source community by making TKEStack available. * * Copyright (C) 2012-2019 Tencent. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use * this file except in compliance with the License. You may obtain a copy of the * License at * * https://opensource.org/licenses/Apache-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	// CNI_ARGS="IP=192.168.33.3"
	// CNI_COMMAND="ADD"
	// CNI_CONTAINERID=ctn1
	// CNI_NETNS=/var/run/netns/ctn
	// CNI_IFNAME=eth0
	// CNI_PATH=$CNI_PATH
	CNI_ARGS        = "CNI_ARGS"
	CNI_COMMAND     = "CNI_COMMAND"
	CNI_CONTAINERID = "CNI_CONTAINERID"
	CNI_NETNS       = "CNI_NETNS"
	CNI_IFNAME      = "CNI_IFNAME"
	CNI_PATH        = "CNI_PATH"

	COMMAND_ADD = "ADD"
	COMMAND_DEL = "DEL"
)

Variables

This section is empty.

Functions

func BuildCNIArgs

func BuildCNIArgs(args map[string]string) string

BuildCNIArgs builds cni args as string such as key1=val1;key2=val2

func CmdAdd

func CmdAdd(cmdArgs *skel.CmdArgs, networkInfos []*NetworkInfo) (types.Result, error)

CmdAdd saves networkInfos to disk and executes each cni binary to setup network

func CmdDel

func CmdDel(cmdArgs *skel.CmdArgs, lastIdx int) error

CmdDel restores networkInfos from disk and executes each cni binary to delete network

func ConfigureIface

func ConfigureIface(ifName string, res *t020.Result) error

ConfigureIface takes the result of IPAM plugin and applies to the ifName interface

func DelegateAdd

func DelegateAdd(netconf map[string]interface{}, args *skel.CmdArgs, ifName string) (types.Result, error)

DelegateAdd calles delegate cni binary to execute cmdAdd

func DelegateDel

func DelegateDel(netconf map[string]interface{}, args *skel.CmdArgs, ifName string) error

DelegateDel calles delegate cni binary to execute cmdDEL

func GetNetworkConfig

func GetNetworkConfig(networkName, confdir string) ([]byte, error)

func IPInfoToResult

func IPInfoToResult(ipInfo *constant.IPInfo) *t020.Result

IPInfoToResult converts IPInfo to Result

func ParseCNIArgs

func ParseCNIArgs(args string) (map[string]string, error)

ParseCNIArgs parses `key1=val1;key2=val2` format cni args from string

Types

type NetworkInfo

type NetworkInfo struct {
	NetworkType string
	Args        map[string]string
	Conf        map[string]interface{}
	IfName      string
}

NetworkInfo wraps network infos which are needed for cni plugin to setup network

func NewNetworkInfo

func NewNetworkInfo(networkType string, conf map[string]interface{}, ifName string) *NetworkInfo

NewNetworkInfo creates a NetworkInfo

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL