本文整理匯總了Golang中github.com/Juniper/contrail-go-api/types.FloatingIp.GetFloatingIpAddress方法的典型用法代碼示例。如果您正苦於以下問題:Golang FloatingIp.GetFloatingIpAddress方法的具體用法?Golang FloatingIp.GetFloatingIpAddress怎麽用?Golang FloatingIp.GetFloatingIpAddress使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/Juniper/contrail-go-api/types.FloatingIp
的用法示例。
在下文中一共展示了FloatingIp.GetFloatingIpAddress方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: purgeStaleServiceRefs
func (c *Controller) purgeStaleServiceRefs(fip *types.FloatingIp, refs contrail.ReferenceList, podIdMap map[string]*api.Pod) {
update := false
for _, ref := range refs {
vmi, err := types.VirtualMachineInterfaceByUuid(c.client, ref.Uuid)
if err != nil {
glog.Errorf("%v", err)
continue
}
instanceRefs, err := vmi.GetVirtualMachineRefs()
if err != nil {
glog.Errorf("%v", err)
continue
}
if len(instanceRefs) == 0 {
continue
}
if _, ok := podIdMap[instanceRefs[0].Uuid]; ok {
continue
}
glog.V(3).Infof("Delete reference from pod %s to %s", ref.Uuid, fip.GetFloatingIpAddress())
fip.DeleteVirtualMachineInterface(vmi.GetUuid())
update = true
}
if update {
err := c.client.Update(fip)
if err != nil {
glog.Errorf("%v", err)
}
}
}
示例2: updateServicePublicIP
func (c *Controller) updateServicePublicIP(service *api.Service) (*types.FloatingIp, error) {
var publicIp *types.FloatingIp = nil
var err error
resourceName := publicIpResourceName(service)
if service.Spec.ExternalIPs != nil {
// Allocate a floating-ip from the public pool.
publicIp, err = c.networkMgr.LocateFloatingIp(
c.networkMgr.GetPublicNetwork(), resourceName, service.Spec.ExternalIPs[0])
} else if service.Spec.Type == api.ServiceTypeLoadBalancer {
publicIp, err = c.networkMgr.LocateFloatingIp(c.networkMgr.GetPublicNetwork(), resourceName, "")
if err == nil {
status := api.LoadBalancerStatus{Ingress: []api.LoadBalancerIngress{
api.LoadBalancerIngress{IP: publicIp.GetFloatingIpAddress()},
}}
if !reflect.DeepEqual(service.Status.LoadBalancer, status) {
service.Status.LoadBalancer = status
_, err := c.kube.Services(service.Namespace).Update(service)
if err != nil {
glog.Infof("Update service %s LB status: %v", service.Name, err)
}
}
}
}
return publicIp, err
}