diff --git a/api/ipam.go b/api/ipam.go index 9f1687dd..d061b420 100644 --- a/api/ipam.go +++ b/api/ipam.go @@ -33,8 +33,8 @@ func (client *Client) LookupIP(ID string) (*net.IPNet, error) { } // Claim a specific IP on behalf of the ID -func (client *Client) ClaimIP(ID string, addr net.IP) error { - _, err := client.httpVerb("PUT", fmt.Sprintf("/ip/%s/%s", ID, addr), nil) +func (client *Client) ClaimIP(ID string, cidr *net.IPNet) error { + _, err := client.httpVerb("PUT", fmt.Sprintf("/ip/%s/%s", ID, cidr), nil) return err } diff --git a/plugin/ipam/driver.go b/plugin/ipam/driver.go index 0a965abb..cd37e8d6 100644 --- a/plugin/ipam/driver.go +++ b/plugin/ipam/driver.go @@ -73,10 +73,10 @@ func (i *ipam) RequestAddress(poolID string, address net.IP, options map[string] return } if address != nil { // try to claim specific address requested - if err = i.weave.ClaimIP("_", address); err != nil { + ip = &net.IPNet{IP: address, Mask: subnet.Mask} + if err = i.weave.ClaimIP("_", ip); err != nil { return } - ip = &net.IPNet{IP: address, Mask: subnet.Mask} } else { if _, iprange, err = net.ParseCIDR(parts[2]); err != nil { return