fix host register info (#7401)

This commit is contained in:
wanyaoqi
2020-07-31 18:01:01 +08:00
committed by GitHub
parent fd2f1c0e36
commit ae0bd556ca
2 changed files with 13 additions and 3 deletions
+7
View File
@@ -175,6 +175,11 @@ type HostDetails struct {
// isolated device count
IsolatedDeviceCount int
// host init warnning
SysWarn string `json:"sys_warn"`
// host init error info
SysError string `json:"sys_error"`
// 标签
Metadata map[string]string `json:"metadata"`
}
@@ -240,6 +245,8 @@ type HostRegisterMetadata struct {
OnKubernetes bool `json:"on_kubernetes"`
Hostname string `json:"hostname"`
SysError string `json:"sys_error,allowempty"`
SysWarn string `json:"sys_warn,allowempty"`
}
type HostAccessAttributes struct {
+6 -3
View File
@@ -997,10 +997,13 @@ func (h *SHostInfo) updateHostMetadata(hostname string) error {
OnKubernetes: onK8s,
Hostname: hostname,
}
if len(h.SysError) > 0 {
meta.SysError = jsonutils.Marshal(h.SysError).String()
}
if len(h.SysWarning) > 0 {
meta.SysWarn = jsonutils.Marshal(h.SysWarning).String()
}
data := meta.JSON(meta)
data.Set("__sys_error", jsonutils.Marshal(h.SysError))
data.Set("__sys_warning", jsonutils.Marshal(h.SysWarning))
_, err := modules.Hosts.SetMetadata(h.GetSession(), h.HostId, data)
return err
}