Move peer http handlers from ipam to weaver
This commit is contained in:
1 parent
e2d644b86b
commit
768f89c3de
3 files changed
+22
-11
No files matched your search
@@ -198,17 +198,6 @@ func (alloc *Allocator) HandleHTTP(router *mux.Router, defaultSubnet address.CID
|
|||||||
w.WriteHeader(204)
|
w.WriteHeader(204)
|
||||||
})
|
})
|
||||||
|
|
||||||
router.Methods("DELETE").Path("/peer").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
||||||
alloc.Shutdown()
|
|
||||||
w.WriteHeader(204)
|
|
||||||
})
|
|
||||||
|
|
||||||
router.Methods("DELETE").Path("/peer/{id}").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
||||||
ident := mux.Vars(r)["id"]
|
|
||||||
transferred := alloc.AdminTakeoverRanges(ident)
|
|
||||||
fmt.Fprintf(w, "%d IPs taken over from %s\n", transferred, ident)
|
|
||||||
})
|
|
||||||
|
|
||||||
router.Methods("GET").Path("/ipinfo/tracker").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
router.Methods("GET").Path("/ipinfo/tracker").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
fmt.Fprintf(w, tracker)
|
fmt.Fprintf(w, tracker)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -8,6 +8,10 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/gorilla/mux"
|
||||||
|
|
||||||
|
"github.com/weaveworks/weave/ipam"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO: move these definitions somewhere more shareable
|
// TODO: move these definitions somewhere more shareable
|
||||||
@@ -64,3 +68,20 @@ func peerDiscoveryUpdate(discoveryEndpoint, token, peername, nickname string, ad
|
|||||||
err := do("POST", discoveryEndpoint, token, request, &updateResponse)
|
err := do("POST", discoveryEndpoint, token, request, &updateResponse)
|
||||||
return updateResponse.Addresses, err
|
return updateResponse.Addresses, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func HandleHTTPPeer(router *mux.Router, alloc *ipam.Allocator) {
|
||||||
|
router.Methods("DELETE").Path("/peer").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
if alloc != nil {
|
||||||
|
alloc.Shutdown()
|
||||||
|
}
|
||||||
|
w.WriteHeader(204)
|
||||||
|
})
|
||||||
|
|
||||||
|
router.Methods("DELETE").Path("/peer/{id}").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
ident := mux.Vars(r)["id"]
|
||||||
|
if alloc != nil {
|
||||||
|
transferred := alloc.AdminTakeoverRanges(ident)
|
||||||
|
fmt.Fprintf(w, "%d IPs taken over from %s\n", transferred, ident)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -372,6 +372,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
router.HandleHTTP(muxRouter)
|
router.HandleHTTP(muxRouter)
|
||||||
HandleHTTP(muxRouter, version, router, allocator, defaultSubnet, ns, dnsserver)
|
HandleHTTP(muxRouter, version, router, allocator, defaultSubnet, ns, dnsserver)
|
||||||
|
HandleHTTPPeer(muxRouter, allocator)
|
||||||
muxRouter.Methods("GET").Path("/metrics").Handler(metricsHandler(router, allocator, ns, dnsserver))
|
muxRouter.Methods("GET").Path("/metrics").Handler(metricsHandler(router, allocator, ns, dnsserver))
|
||||||
http.Handle("/", common.LoggingHTTPHandler(muxRouter))
|
http.Handle("/", common.LoggingHTTPHandler(muxRouter))
|
||||||
Log.Println("Listening for HTTP control messages on", httpAddr)
|
Log.Println("Listening for HTTP control messages on", httpAddr)
|
||||||
|
|||||||
Reference in new issue
Block a user