From 40ed21b79ecd28fa8058061f1bd55dcd04d886f1 Mon Sep 17 00:00:00 2001 From: wanyaoqi Date: Mon, 29 Apr 2019 12:06:58 +0800 Subject: [PATCH] host register add version record, fix getBmAgentUrl --- pkg/compute/misc/handler.go | 9 +++++---- pkg/hostman/hostinfo/hostinfo.go | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/pkg/compute/misc/handler.go b/pkg/compute/misc/handler.go index 241367b0cd..6aca17199d 100644 --- a/pkg/compute/misc/handler.go +++ b/pkg/compute/misc/handler.go @@ -42,12 +42,13 @@ func addHandler(method, prefix string, f appsrv.FilterHandler, app *appsrv.Appli } func getBmAgentUrl(ctx context.Context, w http.ResponseWriter, r *http.Request) { - body, _ := appsrv.FetchJSON(r) - if body == nil || !body.Contains("ip") { - httperrors.InputParameterError(w, "Missing ip ?") + _, query, _ := appsrv.FetchEnv(ctx, w, r) + ipAddr, err := query.GetString("ip") + if err != nil { + httperrors.MissingParameterError(w, "ip") return } - ipAddr, _ := body.GetString("ip") + n, _ := models.NetworkManager.GetOnPremiseNetworkOfIP(ipAddr, "baremetal", tristate.None) if n == nil { httperrors.NotFoundError(w, "Network not found") diff --git a/pkg/hostman/hostinfo/hostinfo.go b/pkg/hostman/hostinfo/hostinfo.go index 42bb658188..0ae52d8cc0 100644 --- a/pkg/hostman/hostinfo/hostinfo.go +++ b/pkg/hostman/hostinfo/hostinfo.go @@ -27,6 +27,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/util/version" "yunion.io/x/pkg/utils" api "yunion.io/x/onecloud/pkg/apis/compute" @@ -750,7 +751,7 @@ func (h *SHostInfo) updateHostRecord(hostId string) { content.Set("slots", jsonutils.NewString(options.HostOptions.Slots)) } content.Set("__meta__", jsonutils.Marshal(h.getSysInfo())) - // content.Set("version", GetVersion()) + content.Set("version", jsonutils.NewString(version.GetShortString())) body := jsonutils.NewDict() body.Set("host", content) session := h.GetSession()