本文整理匯總了Golang中github.com/Juniper/contrail-go-api/types.FloatingIp.SetFloatingIpAddress方法的典型用法代碼示例。如果您正苦於以下問題:Golang FloatingIp.SetFloatingIpAddress方法的具體用法?Golang FloatingIp.SetFloatingIpAddress怎麽用?Golang FloatingIp.SetFloatingIpAddress使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/Juniper/contrail-go-api/types.FloatingIp
的用法示例。
在下文中一共展示了FloatingIp.SetFloatingIpAddress方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: LocateFloatingIp
func (m *NetworkManagerImpl) LocateFloatingIp(network *types.VirtualNetwork, resourceName, targetAddress string) (*types.FloatingIp, error) {
obj, err := m.client.FindByName("floating-ip-pool", makePoolName(network))
if err != nil {
glog.Errorf("Get floating-ip-pool %s: %v", network.GetName(), err)
return nil, err
}
pool := obj.(*types.FloatingIpPool)
fqn := AppendConst(pool.GetFQName(), resourceName)
obj, err = m.client.FindByName("floating-ip", strings.Join(fqn, ":"))
if err == nil {
fip := obj.(*types.FloatingIp)
if targetAddress != "" && fip.GetFloatingIpAddress() != targetAddress {
fip.SetFloatingIpAddress(targetAddress)
err = m.client.Update(fip)
if err != nil {
glog.Errorf("Update floating-ip %s: %v", resourceName, err)
return nil, err
}
}
return fip, nil
}
projectFQN := network.GetFQName()[0 : len(network.GetFQName())-1]
obj, err = m.client.FindByName("project", strings.Join(projectFQN, ":"))
if err != nil {
glog.Errorf("Get project %s: %v", projectFQN[len(projectFQN)-1], err)
return nil, err
}
project := obj.(*types.Project)
fip := new(types.FloatingIp)
fip.SetParent(pool)
fip.SetName(resourceName)
if targetAddress != "" {
fip.SetFloatingIpAddress(targetAddress)
}
fip.AddProject(project)
err = m.client.Create(fip)
if err != nil {
glog.Errorf("Create floating-ip %s: %v", resourceName, err)
return nil, err
}
if targetAddress == "" {
fip, err = types.FloatingIpByUuid(m.client, fip.GetUuid())
}
return fip, err
}