helper

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2021 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 8 more Imports: 20 Imported by: 0

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.

* 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.

* 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

This section is empty.

Variables

View Source
var (
	CNI_IFNAME   = "eth0"
	NetNS_PREFIX = "test_"
	NetNS_PATH   = "/var/run/netns"
)

Functions

func CheckContainerTopology

func CheckContainerTopology(nsPath, containerCidr, gwIP string)

CheckContainerTopology checks network topology is expected in container

func CleanupCNIData

func CleanupCNIData(networkName string) error

func CleanupDummy

func CleanupDummy() error

func CleanupIFace

func CleanupIFace(name ...string)

func CleanupNetNS

func CleanupNetNS()

func CmdAdd

func CmdAdd(containerId, ifaceCidr, argsStr, cniName, expectResult string, netConfStdin []byte) string

CmdAdd calls cni binary to do cmdAdd for container

func CmdDel

func CmdDel(containerId, cniName string, netConfStdin []byte)

CmdDel calls cni binary to do cmdDel for container

func Command

func Command(cmd string, args ...string) *exec.Cmd

func Curl

func Curl(ip, port string) ([]byte, error)

func DebugLog

func DebugLog(str ...string)

func DelNetNS

func DelNetNS(containerId string) error

func ExecCNI

func ExecCNI(cniName string, netConfStdin []byte, args *invoke.Args) error

func ExecCNIWithResult

func ExecCNIWithResult(cniName string, netConfStdin []byte, args *invoke.Args) (types.Result, error)

ip netns add ctn CNI_ARGS="IP=192.168.33.3" CNI_COMMAND="ADD" CNI_CONTAINERID=ctn1 CNI_NETNS=/var/run/netns/ctn CNI_IFNAME=eth0 CNI_PATH=`pwd`/bin galaxy-vlan < /etc/cni/net.d/10-mynet.conf

func Gateway

func Gateway(ipNet net.IPNet) net.IP

func IPInfo

func IPInfo(cidr string, vlan uint16) (string, error)

func IPInfos

func IPInfos(cidr string, vlan uint16, cidr2 string, vlan2 uint16) (string, error)

func NewContainerId

func NewContainerId() string

func NewNetNS

func NewNetNS(containerId string) (string, error)

func Ping

func Ping(ip string) ([]byte, error)

func ProjectDir

func ProjectDir() string

func SetupDummyDev

func SetupDummyDev(ifName, cidr string) error

func SetupVlanDev

func SetupVlanDev(ifName, parent, cidr string, vlanID int) error

Types

type LinkDevice

type LinkDevice struct {
	Parent *LinkDevice
	Master *LinkDevice
	Addr   *net.IPNet
	Type   string
	Name   string
}

func NewDummyVlan

func NewDummyVlan(cidrIPNet *net.IPNet, vlanId int) *LinkDevice

func NewLinkDevice

func NewLinkDevice(addr *net.IPNet, name, typeStr string) *LinkDevice

func (*LinkDevice) SetMaster

func (n *LinkDevice) SetMaster(master *LinkDevice) *LinkDevice

func (*LinkDevice) SetParent

func (n *LinkDevice) SetParent(parent *LinkDevice) *LinkDevice

type NetworkTopology

type NetworkTopology struct {
	LeaveDevices []*LinkDevice
	Routes       []Route

	Netns string // all these objects are in netns
	// contains filtered or unexported fields
}

func (*NetworkTopology) Verify

func (t *NetworkTopology) Verify() error

func (*NetworkTopology) VerifyNeighs

func (t *NetworkTopology) VerifyNeighs() []error

func (*NetworkTopology) VerifyRoutes

func (t *NetworkTopology) VerifyRoutes() []error

type Route

type Route struct {
	LinkName string
	netlink.Route
}

Jump to

Keyboard shortcuts

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