diff --git a/nucleus/http.go b/nucleus/http.go index f350858c8d52b0b9a75ee4d4f642ac764a2b9d35..56ad4cb0af707662e72656e1a7b6a4fa0a88f046 100644 --- a/nucleus/http.go +++ b/nucleus/http.go @@ -61,8 +61,6 @@ func httpHandler(writer http.ResponseWriter, request *http.Request) { return } - var hasPnd bool - var hasSbi bool id, err := uuid.Parse(query.Get("uuid")) if err != nil { @@ -76,8 +74,6 @@ func httpHandler(writer http.ResponseWriter, request *http.Request) { if err.Error() != "invalid UUID length: 0" { log.Error(err) } - } else { - hasPnd = true } sid, err := uuid.Parse(query.Get("sbi")) @@ -85,13 +81,11 @@ func httpHandler(writer http.ResponseWriter, request *http.Request) { if err.Error() != "invalid UUID length: 0" { log.Error(err) } - } else { - hasSbi = true } var pnd PrincipalNetworkDomain var sbi SouthboundInterface - if hasSbi && hasPnd { + if query.Get("q") != "init" && query.Get("q") != "getIDs" { pnd, err = c.pndc.get(pid) if err != nil { log.Error(err) @@ -179,10 +173,17 @@ func httpHandler(writer http.ResponseWriter, request *http.Request) { fmt.Fprintf(writer, "%v: %v\n", i+1, id) } } - writeIDs("PNDs", c.pndc.UUIDs()) + pnds := c.pndc.UUIDs() + writeIDs("PNDs", pnds) writeIDs("SBIs", c.sbic.UUIDs()) - if pnd != nil { - writeIDs("Devices", pnd.(*pndImplementation).devices.UUIDs()) + for _,id := range pnds{ + p, err := c.pndc.get(id) + if err != nil { + writer.WriteHeader(http.StatusInternalServerError) + log.Error(err) + return + } + writeIDs("Devices", p.(*pndImplementation).devices.UUIDs()) } case "init": writeIDs := func(typ string, ids []uuid.UUID) {