mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #741 in YUNIONIO/onecloud from ~LIZEXI/onecloud:bugfix/lzx-host-sysinfo-nil to release/2.4.0
* commit 'b64c3b333371987aea51e25d6bc0104194e10ccb': region: specs panic when host sysinfo is nil
This commit is contained in:
@@ -733,16 +733,21 @@ func (self *SHost) GetSpec(statusCheck bool) *jsonutils.JSONDict {
|
||||
}
|
||||
}
|
||||
spec.Set("nic_count", jsonutils.NewInt(nicCount))
|
||||
manufacture, err := self.SysInfo.Get("manufacture")
|
||||
if err != nil {
|
||||
manufacture = jsonutils.NewString("Unknown")
|
||||
|
||||
var manufacture string
|
||||
var model string
|
||||
if self.SysInfo != nil {
|
||||
manufacture, _ = self.SysInfo.GetString("manufacture")
|
||||
model, _ = self.SysInfo.GetString("model")
|
||||
}
|
||||
spec.Set("manufacture", manufacture)
|
||||
model, err := self.SysInfo.Get("model")
|
||||
if err != nil {
|
||||
model = jsonutils.NewString("Unknown")
|
||||
if manufacture == "" {
|
||||
manufacture = "Unknown"
|
||||
}
|
||||
spec.Set("model", model)
|
||||
if model == "" {
|
||||
model = "Unknown"
|
||||
}
|
||||
spec.Set("manufacture", jsonutils.NewString(manufacture))
|
||||
spec.Set("model", jsonutils.NewString(model))
|
||||
return spec
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user