remove host-local-ptp plugin
This commit is contained in:
parent
7d8d6b2a7e
commit
60be55a7d1
4
build
4
build
@ -27,7 +27,3 @@ for d in $PLUGINS; do
|
|||||||
go install ${REPO_PATH}/$d
|
go install ${REPO_PATH}/$d
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ ! -h $GOBIN/host-local-ptp ]; then
|
|
||||||
ln -s host-local $GOBIN/host-local-ptp
|
|
||||||
fi
|
|
||||||
|
@ -133,50 +133,6 @@ func (a *IPAllocator) Get(id string) (*types.IPConfig, error) {
|
|||||||
return nil, fmt.Errorf("no IP addresses available in network: %s", a.conf.Name)
|
return nil, fmt.Errorf("no IP addresses available in network: %s", a.conf.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allocates both an IP and the Gateway IP, i.e. a /31
|
|
||||||
// This is used for Point-to-Point links
|
|
||||||
func (a *IPAllocator) GetPtP(id string) (*types.IPConfig, error) {
|
|
||||||
a.store.Lock()
|
|
||||||
defer a.store.Unlock()
|
|
||||||
|
|
||||||
for cur := a.start; !cur.Equal(a.end); cur = ip.NextIP(cur) {
|
|
||||||
// we're looking for unreserved even, odd pair
|
|
||||||
if !evenIP(cur) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
gw := cur
|
|
||||||
reserved, err := a.store.Reserve(id, gw)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if reserved {
|
|
||||||
cur = ip.NextIP(cur)
|
|
||||||
if cur.Equal(a.end) {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
reserved, err := a.store.Reserve(id, cur)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if reserved {
|
|
||||||
// found them both!
|
|
||||||
_, bits := a.conf.Subnet.Mask.Size()
|
|
||||||
mask := net.CIDRMask(bits-1, bits)
|
|
||||||
|
|
||||||
return &types.IPConfig{
|
|
||||||
IP: net.IPNet{cur, mask},
|
|
||||||
Gateway: gw,
|
|
||||||
Routes: a.conf.Routes,
|
|
||||||
}, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil, fmt.Errorf("no ip addresses available in network: %s", a.conf.Name)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Releases all IPs allocated for the container with given ID
|
// Releases all IPs allocated for the container with given ID
|
||||||
func (a *IPAllocator) Release(id string) error {
|
func (a *IPAllocator) Release(id string) error {
|
||||||
a.store.Lock()
|
a.store.Lock()
|
||||||
@ -204,15 +160,3 @@ func networkRange(ipnet *net.IPNet) (net.IP, net.IP, error) {
|
|||||||
}
|
}
|
||||||
return ipnet.IP, end, nil
|
return ipnet.IP, end, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func evenIP(ip net.IP) bool {
|
|
||||||
i := ip.To4()
|
|
||||||
if i == nil {
|
|
||||||
i = ip.To16()
|
|
||||||
if i == nil {
|
|
||||||
panic("IP is not v4 or v6")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return i[len(i)-1]%2 == 0
|
|
||||||
}
|
|
||||||
|
@ -15,8 +15,6 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
|
|
||||||
"github.com/appc/cni/plugins/ipam/host-local/backend/disk"
|
"github.com/appc/cni/plugins/ipam/host-local/backend/disk"
|
||||||
|
|
||||||
"github.com/appc/cni/pkg/skel"
|
"github.com/appc/cni/pkg/skel"
|
||||||
@ -51,17 +49,7 @@ func cmdAdd(args *skel.CmdArgs) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
var ipConf *types.IPConfig
|
ipConf, err := allocator.Get(args.ContainerID)
|
||||||
|
|
||||||
switch ipamConf.Type {
|
|
||||||
case "host-local":
|
|
||||||
ipConf, err = allocator.Get(args.ContainerID)
|
|
||||||
case "host-local-ptp":
|
|
||||||
ipConf, err = allocator.GetPtP(args.ContainerID)
|
|
||||||
default:
|
|
||||||
return errors.New("Unsupported IPAM plugin type")
|
|
||||||
}
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user