Skip to content

Commit

Permalink
修复无法获取vmware宿主机监控数据的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaoxiangchun committed May 16, 2020
1 parent d8560a0 commit 6ffb365
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pkg/multicloud/esxi/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,17 +122,19 @@ func (cli *SESXiClient) getManagerEntityofVm(server jsonutils.JSONObject) (*mo.M
}

func (cli *SESXiClient) getManagerEntityofHost(host jsonutils.JSONObject) (*mo.ManagedEntity, error) {
name, _ := host.GetString("name")
extId, _ := host.GetString("external_id")
hostSystems, err := cli.GetHostSystem()
if err != nil {
return nil, err
}
for _, hostSystem := range hostSystems {
if strings.Contains(hostSystem.Name, name) || strings.Contains(name, hostSystem.Name) {
host := NewHost(cli, &hostSystem, nil)
ip := host.GetGlobalId()
if ip == extId {
return hostSystem.Entity(), nil
}
}
return nil, fmt.Errorf("No ManagerEntiry for %s host", name)
return nil, fmt.Errorf("No VMware ManagerEntiry for %s host", extId)
}

//根据perfCounterInfos装载metricIdTable、metricNameTable、metricIdNameTable
Expand Down

0 comments on commit 6ffb365

Please sign in to comment.