本文整理汇总了Golang中github.com/contiv/netplugin/drivers.OvsCfgEndpointState类的典型用法代码示例。如果您正苦于以下问题:Golang OvsCfgEndpointState类的具体用法?Golang OvsCfgEndpointState怎么用?Golang OvsCfgEndpointState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OvsCfgEndpointState类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: handleEndpointEvents
func handleEndpointEvents(netPlugin *plugin.NetPlugin, crt *crt.CRT,
opts cliOpts, retErr chan error) {
rsps := make(chan core.WatchState)
go processStateEvent(netPlugin, crt, opts, rsps)
cfg := drivers.OvsCfgEndpointState{}
cfg.StateDriver = netPlugin.StateDriver
retErr <- cfg.WatchAll(rsps)
return
}
示例2: allocSetEpAddress
func allocSetEpAddress(ep *intent.ConfigEP, epCfg *drivers.OvsCfgEndpointState,
nwCfg *drivers.OvsCfgNetworkState) (err error) {
var ipAddrValue uint
var found bool
ipAddress := ep.IPAddress
if ipAddress == "" {
if ipAddrValue, found = nwCfg.IPAllocMap.NextClear(0); !found {
log.Errorf("auto allocation failed - address exhaustion in subnet %s/%d",
nwCfg.SubnetIP, nwCfg.SubnetLen)
err = core.Errorf("auto allocation failed - address exhaustion in subnet %s/%d",
nwCfg.SubnetIP, nwCfg.SubnetLen)
return
}
ipAddress, err = netutils.GetSubnetIP(
nwCfg.SubnetIP, nwCfg.SubnetLen, 32, ipAddrValue)
if err != nil {
log.Errorf("create eps: error acquiring subnet ip. Error: %s", err)
return
}
} else if ipAddress != "" && nwCfg.SubnetIP != "" {
ipAddrValue, err = netutils.GetIPNumber(
nwCfg.SubnetIP, nwCfg.SubnetLen, 32, ipAddress)
if err != nil {
log.Errorf("create eps: error getting host id from hostIP %s Subnet %s/%d. Error: %s",
ipAddress, nwCfg.SubnetIP, nwCfg.SubnetLen, err)
return
}
}
epCfg.IPAddress = ipAddress
nwCfg.IPAllocMap.Set(ipAddrValue)
// Set mac address which is derived from IP address
ipAddr := net.ParseIP(ipAddress)
macAddr := fmt.Sprintf("02:02:%02x:%02x:%02x:%02x", ipAddr[12], ipAddr[13], ipAddr[14], ipAddr[15])
epCfg.MacAddress = macAddr
return
}
示例3: createInfraNetwork
func createInfraNetwork(epCfg *drivers.OvsCfgEndpointState) error {
if epCfg.NetID != "" {
return nil
}
nwCfg := &drivers.OvsCfgNetworkState{}
nwCfg.StateDriver = epCfg.StateDriver
if nwCfg.Read(epCfg.NetID) == nil {
return nil
}
nwCfg.ID = defaultInfraNetName
err := nwCfg.Write()
if err != nil {
return err
}
epCfg.NetID = defaultInfraNetName
return nil
}