util

package
v0.0.0-...-cb6729e Latest Latest
Warning

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

Go to latest
Published: May 20, 2019 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PhysicalNetworkName is the name that maps to an OVS bridge that provides
	// access to physical/external network
	PhysicalNetworkName = "physnet"
)

Variables

This section is empty.

Functions

func BridgeToNic

func BridgeToNic(bridge string) error

BridgeToNic moves the IP address and routes of internal port of the bridge to underlying NIC interface and deletes the OVS bridge.

func FetchIfMacWindows

func FetchIfMacWindows(interfaceName string) (string, error)

FetchIfMacWindows gets the mac of the interfaceName via powershell commands There is a known issue with OVS not correctly picking up the physical network interface MAC address.

func GatewayCleanup

func GatewayCleanup(nodeName string) error

GatewayCleanup removes all the NB DB objects created for a node's gateway

func GatewayInit

func GatewayInit(clusterIPSubnet []string, nodeName, nicIP, physicalInterface,
	bridgeInterface, defaultGW, rampoutIPSubnet string, gatewayVLANId uint,
	gatewayLBEnable bool) error

GatewayInit creates a gateway router for the local chassis.

func GenerateMac

func GenerateMac() string

GenerateMac generates mac address.

func GetExec

func GetExec() kexec.Interface

GetExec returns the exec interface which can be used for running commands directly. Only use for passing an exec interface into pkg/config which cannot call this function directly because this module imports pkg/config already.

func GetK8sClusterRouter

func GetK8sClusterRouter() (string, error)

GetK8sClusterRouter returns back the OVN distibuted router

func GetK8sMgmtIntfName

func GetK8sMgmtIntfName(nodeName string) string

GetK8sMgmtIntfName returns the correct length interface name to be used as an OVS internal port on the node

func GetNicName

func GetNicName(brName string) string

GetNicName returns the physical NIC name, given an OVS bridge name configured by NicToBridge()

func IsServiceIPSet

func IsServiceIPSet(service *kapi.Service) bool

IsServiceIPSet checks if the service is an headless service or not

func NewClientset

func NewClientset(conf *config.KubernetesConfig) (*kubernetes.Clientset, error)

NewClientset creates a Kubernetes clientset from either a kubeconfig, TLS properties, or an apiserver URL

func NextIP

func NextIP(ip net.IP) net.IP

NextIP returns IP incremented by 1

func NicToBridge

func NicToBridge(iface string) (string, error)

NicToBridge creates a OVS bridge for the 'iface' and also moves the IP address and routes of 'iface' to OVS bridge.

func RawExec

func RawExec(cmdPath string, args ...string) (string, string, error)

RawExec runs the given command via the exec interface. Should only be used for early calls before configuration is read.

func RunIP

func RunIP(args ...string) (string, string, error)

RunIP runs a command via the iproute2 "ip" utility

func RunNetsh

func RunNetsh(args ...string) (string, string, error)

RunNetsh runs a command via the Windows netsh utility

func RunOVNNbctl

func RunOVNNbctl(args ...string) (string, string, error)

RunOVNNbctl runs a command via ovn-nbctl.

func RunOVNNbctlUnix

func RunOVNNbctlUnix(args ...string) (string, string, error)

RunOVNNbctlUnix runs command via ovn-nbctl, with ovn-nbctl using the unix domain sockets to connect to the ovsdb-server backing the OVN NB database.

func RunOVNNbctlWithTimeout

func RunOVNNbctlWithTimeout(timeout int, args ...string) (string, string,
	error)

RunOVNNbctlWithTimeout runs command via ovn-nbctl with a specific timeout

func RunOVSOfctl

func RunOVSOfctl(args ...string) (string, string, error)

RunOVSOfctl runs a command via ovs-ofctl.

func RunOVSVsctl

func RunOVSVsctl(args ...string) (string, string, error)

RunOVSVsctl runs a command via ovs-vsctl.

func RunPowershell

func RunPowershell(args ...string) (string, string, error)

RunPowershell runs a command via the Windows powershell utility

func RunRoute

func RunRoute(args ...string) (string, string, error)

RunRoute runs a command via the Windows route utility

func SetExec

func SetExec(exec kexec.Interface) error

SetExec validates executable paths and saves the given exec interface to be used for running various OVS and OVN utilites

func StringArg

func StringArg(context *cli.Context, name string) (string, error)

StringArg gets the named command-line argument or returns an error if it is empty

Types

type FakeIPTables

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

FakeIPTables is a mock implementation of go-iptables

func NewFakeWithProtocol

func NewFakeWithProtocol(proto iptables.Protocol) (*FakeIPTables, error)

NewFakeWithProtocol creates a new IPTablesHelper wrapping a mock iptables implementation that can be used in unit tests

func (*FakeIPTables) Exists

func (f *FakeIPTables) Exists(tableName, chainName string, rulespec ...string) (bool, error)

Exists checks if given rulespec in specified table/chain exists

func (*FakeIPTables) Insert

func (f *FakeIPTables) Insert(tableName, chainName string, pos int, rulespec ...string) error

Insert inserts a rule into the specified table/chain

func (*FakeIPTables) ListChains

func (f *FakeIPTables) ListChains(tableName string) ([]string, error)

ListChains returns the names of all chains in the table

func (*FakeIPTables) MatchState

func (f *FakeIPTables) MatchState(tables map[string]FakeTable) error

MatchState matches the expected state against the actual rules code under test added to iptables

func (*FakeIPTables) NewChain

func (f *FakeIPTables) NewChain(tableName, chainName string) error

NewChain creates a new chain in the specified table

type FakeTable

type FakeTable map[string][]string

FakeTable represents a mock iptables table and can be used for unit tests to verify that the code creates the expected rules

func (*FakeTable) String

func (t *FakeTable) String() string

type IPTablesHelper

type IPTablesHelper interface {
	// ListChains returns the names of all chains in the table
	ListChains(string) ([]string, error)
	// NewChain creates a new chain in the specified table
	NewChain(string, string) error
	// Exists checks if given rulespec in specified table/chain exists
	Exists(string, string, ...string) (bool, error)
	// Insert inserts a rule into the specified table/chain
	Insert(string, string, int, ...string) error
}

IPTablesHelper is an interface that wraps go-iptables to allow mock implementations for unti testing

func NewWithProtocol

func NewWithProtocol(proto iptables.Protocol) (IPTablesHelper, error)

NewWithProtocol creates a new IPTablesHelper wrapping "live" go-iptables

Jump to

Keyboard shortcuts

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