Tidy up IPAM setup

This commit is contained in:
David Wragg committed 2015-05-15 11:44:50 +01:00
1 parent f6ac069bc5
commit a027337be2
1 file changed
+14 -11
+14 -11
View File
@@ -129,23 +129,26 @@ func main() {
router := weave.NewRouter(config, name, nickName) router := weave.NewRouter(config, name, nickName)
log.Println("Our name is", router.Ourself) log.Println("Our name is", router.Ourself)
var allocator *ipam.Allocator var allocator *ipam.Allocator
if httpAddr != "" { if iprangeCIDR != "" {
if iprangeCIDR != "" { allocator = createAllocator(router, apiPath, iprangeCIDR, determineQuorum(peerCount, peers))
allocator = createAllocator(router, apiPath, iprangeCIDR, determineQuorum(peerCount, peers)) } else if peerCount > 0 {
} else { log.Fatal("-initpeercount flag specified without -iprange")
if peerCount > 0 { } else {
log.Fatal("-initpeercount flag specified without -iprange")
}
}
}
if httpAddr == "" || iprangeCIDR == "" {
router.NewGossip("IPallocation", &ipam.DummyAllocator{}) router.NewGossip("IPallocation", &ipam.DummyAllocator{})
} }
router.Start() router.Start()
initiateConnections(router, peers) initiateConnections(router, peers)
go handleHTTP(router, httpAddr, allocator)
// The weave script always waits for a status call to succeed,
// so there is no point in doing "weave launch -httpaddr ''".
// This is here to support stand-alone use of weaver.
if httpAddr != "" {
go handleHTTP(router, httpAddr, allocator)
}
SignalHandlerLoop(router) SignalHandlerLoop(router)
} }