Documentation ¶
Index ¶
- Constants
- Variables
- func CreateVeth(vethPair *VethPair) error
- func GetCommonDriver(cfg *ini.File, phyNw, PortType string) (string, error)
- func GetDriverFromSection(section *ini.Section, phyNw string) (string, error)
- func GetDriverbyPortType(cfg *ini.File, phyNw, PortType string) (string, error)
- func GetLinkByName(name string) (netlink.Link, error)
- func GetMappingKey(section *ini.Section) string
- func GetNormalDriver(cfg *ini.File, phyNw string) (string, error)
- func GetPhyNwOvsMapStr(confPath string) (string, error)
- func GetPhyNwOvsPair(phyNwStr string) (*map[string]string, error)
- func GetSectionName(PortType string) string
- func GetSriovDriver(cfg *ini.File, phyNw string) (string, error)
- func GetVethMac(vethName string) (string, error)
- func GetVethPairMacs(vethPair *VethPair) error
- func GetrandSuffix() string
- func InitConfig(confPath string) (*ini.File, error)
- func WaitOvsUsable() error
- type VethPair
Constants ¶
View Source
const ( ASCII0 = 48 ASCIIA = 65 ASCIIa = 97 NumRange = 10 LetterRange = 26 )
View Source
const MaxTimesRetryCreateVeth int = 10
View Source
const MaxTimesRetryFindVeth int = 10
Variables ¶
View Source
var DeleteVethPair = func(vethPair VethPair) error { link, err := GetLinkByName(vethPair.VethNameOfPod) if err == nil { err := netlink.LinkDel(link) if err != nil { klog.Errorf("Delete veth [%v] error: %v", link, err) return err } return nil } klog.Errorf("Cannot find veth [%v] error: %v", vethPair.VethNameOfPod, err) link, err = GetLinkByName(vethPair.VethNameOfBridge) if err == nil { err := netlink.LinkDel(link) if err != nil { klog.Errorf("Delete veth [%v] error: %v", link, err) return err } return nil } klog.Errorf("Cannot find veth [%v] error: %v", vethPair.VethNameOfBridge, err) return errors.New("cannot find veth pair error") }
To delete a veth pair
View Source
var GetNwMechDriver = func(phyNw, PortType, confPath string) (string, error) { cfg, err := InitConfig(confPath) if err != nil { klog.Errorf("Init config from [%v] error! %v", confPath, err) return "", err } driver, err := GetDriverbyPortType(cfg, phyNw, PortType) if err != nil { klog.Errorf("GetDriverbyPortType VnicType:%v, PhyNw:%v, return err:%v", PortType, phyNw, err) return "", err } if strings.Contains(driver, "sriov_nic") { driver = strings.TrimRight(driver, "_nic") } return driver, nil }
To get driver name by physical network
View Source
var GetOvsBrg = func(phyNw string, confPath string) (string, error) { phyNwStr, err := GetPhyNwOvsMapStr(confPath) if err != nil { klog.Errorf("GetOvsBrg: GetBrgMaps() error! %v", err) return "", err } phyNwOvsPair, err := GetPhyNwOvsPair(phyNwStr) if err != nil { klog.Errorf("GetOvsBrg: GetPhyNwOvsPair(phyNwStr) error %v, ", err) return "", err } if len(*phyNwOvsPair) == 1 && phyNw == "" { klog.Info("phyNw is nil and ovs has configure one bridge!") for _, ovsBrg := range *phyNwOvsPair { return ovsBrg, nil } } ovsBrg, err1 := (*phyNwOvsPair)[phyNw] if err1 == false { klog.Errorf("Never configured [%v] in config file!", phyNw) return "", errors.New("phyNet does not exist error") } return ovsBrg, nil }
To get ovs bridge by phyNet
View Source
var TimeSleepFunc = func(d time.Duration) { time.Sleep(d) }
Functions ¶
func CreateVeth ¶
func GetDriverFromSection ¶
func GetDriverbyPortType ¶
func GetMappingKey ¶
func GetPhyNwOvsMapStr ¶
To get phyNet-ovs map string
func GetPhyNwOvsPair ¶
To get phyNet-ovs pair
func GetSectionName ¶
func GetVethPairMacs ¶
func GetrandSuffix ¶
func GetrandSuffix() string
func InitConfig ¶
To init a config by config file
func WaitOvsUsable ¶
func WaitOvsUsable() error
Types ¶
Click to show internal directories.
Click to hide internal directories.