Rationalize ipam arguments

- rename -defaultsubnet to -ipsubnet
- default subnet defaults to whole -iprange
- parse and check inside ipam package
- removes some error cases
This commit is contained in:
Bryan Boreham committed 2015-06-10 17:21:16 +01:00
1 parent f956a76455
commit 3a9af4413d
6 files changed
+67 -77

No files matched your search

-8
View File
@@ -50,10 +50,6 @@ func (alloc *Allocator) HandleHTTP(router *mux.Router) {
})
router.Methods("GET").Path("/ip/{id}").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if alloc.defaultSubnet.Blank() {
badRequest(w, fmt.Errorf("No subnet specified"))
return
}
addr, err := alloc.Lookup(mux.Vars(r)["id"], alloc.defaultSubnet)
if err != nil {
http.NotFound(w, r)
@@ -86,10 +82,6 @@ func (alloc *Allocator) HandleHTTP(router *mux.Router) {
})
router.Methods("POST").Path("/ip/{id}").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if alloc.defaultSubnet.Blank() {
badRequest(w, fmt.Errorf("No subnet specified"))
return
}
closedChan := w.(http.CloseNotifier).CloseNotify()
ident := mux.Vars(r)["id"]
newAddr, err := alloc.Allocate(ident, alloc.defaultSubnet, closedChan)