本文整理汇总了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
}