1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #1226 from mavenugo/ag

Overlay driver's NetworkAllocate method must honor driver options
This commit is contained in:
Jana Radhakrishnan 2016-06-08 09:32:22 -07:00
commit dc9d01e670

View file

@ -8,6 +8,7 @@ import (
"strings" "strings"
"sync" "sync"
"github.com/Sirupsen/logrus"
"github.com/docker/libnetwork/datastore" "github.com/docker/libnetwork/datastore"
"github.com/docker/libnetwork/discoverapi" "github.com/docker/libnetwork/discoverapi"
"github.com/docker/libnetwork/driverapi" "github.com/docker/libnetwork/driverapi"
@ -80,17 +81,22 @@ func (d *driver) NetworkAllocate(id string, option map[string]string, ipV4Data,
subnets: []*subnet{}, subnets: []*subnet{},
} }
opts := make(map[string]string)
vxlanIDList := make([]uint32, 0, len(ipV4Data)) vxlanIDList := make([]uint32, 0, len(ipV4Data))
if val, ok := option[netlabel.OverlayVxlanIDList]; ok { for key, val := range option {
log.Println("overlay network option: ", val) if key == netlabel.OverlayVxlanIDList {
valStrList := strings.Split(val, ",") logrus.Debugf("overlay network option: %s", val)
for _, idStr := range valStrList { valStrList := strings.Split(val, ",")
vni, err := strconv.Atoi(idStr) for _, idStr := range valStrList {
if err != nil { vni, err := strconv.Atoi(idStr)
return nil, fmt.Errorf("invalid vxlan id value %q passed", idStr) if err != nil {
} return nil, fmt.Errorf("invalid vxlan id value %q passed", idStr)
}
vxlanIDList = append(vxlanIDList, uint32(vni)) vxlanIDList = append(vxlanIDList, uint32(vni))
}
} else {
opts[key] = val
} }
} }
@ -111,7 +117,6 @@ func (d *driver) NetworkAllocate(id string, option map[string]string, ipV4Data,
n.subnets = append(n.subnets, s) n.subnets = append(n.subnets, s)
} }
opts := make(map[string]string)
val := fmt.Sprintf("%d", n.subnets[0].vni) val := fmt.Sprintf("%d", n.subnets[0].vni)
for _, s := range n.subnets[1:] { for _, s := range n.subnets[1:] {
val = val + fmt.Sprintf(",%d", s.vni) val = val + fmt.Sprintf(",%d", s.vni)