本文整理匯總了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
}