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
+10 -7
+10 -7
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 { } else if peerCount > 0 {
if peerCount > 0 {
log.Fatal("-initpeercount flag specified without -iprange") log.Fatal("-initpeercount flag specified without -iprange")
} } else {
}
}
if httpAddr == "" || iprangeCIDR == "" {
router.NewGossip("IPallocation", &ipam.DummyAllocator{}) router.NewGossip("IPallocation", &ipam.DummyAllocator{})
} }
router.Start() router.Start()
initiateConnections(router, peers) initiateConnections(router, peers)
// 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) go handleHTTP(router, httpAddr, allocator)
}
SignalHandlerLoop(router) SignalHandlerLoop(router)
} }