本文整理汇总了Golang中github.com/contiv/netplugin/drivers.OvsCfgEndpointState.MacAddress方法的典型用法代码示例。如果您正苦于以下问题:Golang OvsCfgEndpointState.MacAddress方法的具体用法?Golang OvsCfgEndpointState.MacAddress怎么用?Golang OvsCfgEndpointState.MacAddress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/contiv/netplugin/drivers.OvsCfgEndpointState
的用法示例。
在下文中一共展示了OvsCfgEndpointState.MacAddress方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: 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
}