//Allocate allocates a new avaliable ip
Allocate allocates a new avaliable ip
// Allocate allocates a new avaliable ip
func (i *Ipam) AllocateVIP(s *types.Service) error {
	if i.rangeCursor == nil {
		return ErrNoVipAvailable
	}
	for pos := i.rangeCursor.Next(); pos != nil; pos = i.rangeCursor.Next() {
		if pos.IP.To4()[3] == 0 {
			pos = i.rangeCursor.Next()
		}
		assigned := i.ipIsAssigned(pos.IP.String(), i.state)
		if !assigned {
			i.rangeCursor.Set(i.rangeCursor.First())
			s.Address = pos.IP.String()
			return nil
		}
	}
	return ErrNoVipAvailable
}
func ( i * Ipam ) AllocateVIP ( s * types . Service ) error { if i . rangeCursor == nil { return ErrNoVipAvailable } for pos := i . rangeCursor . Next ( ) ; pos != nil ; pos = i . rangeCursor . Next ( ) { if pos . IP . To4 ( ) [ 3 ] == 0 { pos = i . rangeCursor . Next ( ) } assigned := i . ipIsAssigned ( pos . IP . String ( ) , i . state ) if ! assigned { i . rangeCursor . Set ( i . rangeCursor . First ( ) ) s . Address = pos . IP . String ( ) return nil } } return ErrNoVipAvailable }
Allocate allocates a new avaliable ip
Allocate allocates a new avaliable ip
//TODO: make it compatible if IPv6 // Verifies if it is a base IP address. example: 10.0.100.0; 192.168.1.0