host register add version record, fix getBmAgentUrl

This commit is contained in:
wanyaoqi
2019-04-29 12:06:58 +08:00
parent ae7db24641
commit 40ed21b79e
2 changed files with 7 additions and 5 deletions
+5 -4
View File
@@ -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")
+2 -1
View File
@@ -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()