func (m *NetworkManagerImpl) LocateFloatingIpPool(network *types.VirtualNetwork) (*types.FloatingIpPool, error) { obj, err := m.client.FindByName("floating-ip-pool", makePoolName(network)) if err == nil { return obj.(*types.FloatingIpPool), nil } pool := new(types.FloatingIpPool) pool.SetName(network.GetName()) pool.SetParent(network) err = m.client.Create(pool) if err != nil { glog.Errorf("Create floating-ip-pool %s: %v", network.GetName(), err) return nil, err } return pool, nil }
func (m *NetworkManagerImpl) LocateFloatingIpPool( network *types.VirtualNetwork, subnet string) (*types.FloatingIpPool, error) { obj, err := m.client.FindByName( "floating-ip-pool", makePoolName(network)) if err == nil { return obj.(*types.FloatingIpPool), nil } address, prefixlen := PrefixToAddressLen(subnet) pool := new(types.FloatingIpPool) pool.SetName(network.GetName()) pool.SetParent(network) pool.SetFloatingIpPoolPrefixes( &types.FloatingIpPoolType{ Subnet: []types.SubnetType{types.SubnetType{address, prefixlen}}}) err = m.client.Create(pool) if err != nil { glog.Errorf("Create floating-ip-pool %s: %v", network.GetName(), err) return nil, err } return pool, nil }