From 60be55a7d1ea49913cb3953b60d1eb5aabd879f1 Mon Sep 17 00:00:00 2001 From: Eugene Yakubovich Date: Thu, 17 Sep 2015 14:56:13 -0700 Subject: [PATCH] remove host-local-ptp plugin --- build | 4 -- plugins/ipam/host-local/allocator.go | 56 ---------------------------- plugins/ipam/host-local/main.go | 14 +------ 3 files changed, 1 insertion(+), 73 deletions(-) diff --git a/build b/build index 99f42fb4..e2bb47ab 100755 --- a/build +++ b/build @@ -27,7 +27,3 @@ for d in $PLUGINS; do go install ${REPO_PATH}/$d fi done - -if [ ! -h $GOBIN/host-local-ptp ]; then - ln -s host-local $GOBIN/host-local-ptp -fi diff --git a/plugins/ipam/host-local/allocator.go b/plugins/ipam/host-local/allocator.go index 56c79479..9756a117 100644 --- a/plugins/ipam/host-local/allocator.go +++ b/plugins/ipam/host-local/allocator.go @@ -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) } -// 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 func (a *IPAllocator) Release(id string) error { a.store.Lock() @@ -204,15 +160,3 @@ func networkRange(ipnet *net.IPNet) (net.IP, net.IP, error) { } 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 -} diff --git a/plugins/ipam/host-local/main.go b/plugins/ipam/host-local/main.go index 18c97561..06c95c9c 100644 --- a/plugins/ipam/host-local/main.go +++ b/plugins/ipam/host-local/main.go @@ -15,8 +15,6 @@ package main import ( - "errors" - "github.com/appc/cni/plugins/ipam/host-local/backend/disk" "github.com/appc/cni/pkg/skel" @@ -51,17 +49,7 @@ func cmdAdd(args *skel.CmdArgs) error { return err } - var ipConf *types.IPConfig - - 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") - } - + ipConf, err := allocator.Get(args.ContainerID) if err != nil { return err }