本文整理匯總了Golang中github.com/cilium/cilium/pkg/endpoint.Endpoint.IsLibnetwork方法的典型用法代碼示例。如果您正苦於以下問題:Golang Endpoint.IsLibnetwork方法的具體用法?Golang Endpoint.IsLibnetwork怎麽用?Golang Endpoint.IsLibnetwork使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cilium/cilium/pkg/endpoint.Endpoint
的用法示例。
在下文中一共展示了Endpoint.IsLibnetwork方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: allocateIPs
func (d *Daemon) allocateIPs(ep *endpoint.Endpoint) error {
allocateIP := func(ep *endpoint.Endpoint, ipamReq ipam.IPAMReq) (resp *ipam.IPAMRep, err error) {
if ep.IsCNI() {
resp, err = d.AllocateIP(ipam.CNIIPAMType, ipamReq)
} else if ep.IsLibnetwork() {
resp, err = d.AllocateIP(ipam.LibnetworkIPAMType, ipamReq)
}
return
}
releaseIP := func(ep *endpoint.Endpoint, ipamReq ipam.IPAMReq) (err error) {
if ep.IsCNI() {
err = d.ReleaseIP(ipam.CNIIPAMType, ipamReq)
} else if ep.IsLibnetwork() {
err = d.ReleaseIP(ipam.LibnetworkIPAMType, ipamReq)
}
return
}
_, err := allocateIP(ep, ep.IPv6.IPAMReq())
if err != nil {
// TODO if allocation failed reallocate a new IP address and setup veth
// pair accordingly
return fmt.Errorf("unable to reallocate IPv6 address: %s", err)
} else {
log.Infof("EP %d's IPv6 successfully reallocated", ep.ID)
}
defer func(ep *endpoint.Endpoint) {
if err != nil {
releaseIP(ep, ep.IPv6.IPAMReq())
}
}(ep)
if d.conf.IPv4Enabled {
if ep.IPv4 != nil {
_, err := allocateIP(ep, ep.IPv4.IPAMReq())
if err != nil {
return fmt.Errorf("unable to reallocate IPv4 address: %s", err)
} else {
log.Infof("EP %d's IPv4 successfully reallocated", ep.ID)
}
}
}
return nil
}