From 6ffb3653ae9e2010bbdb06d5521573a8e78b2fb5 Mon Sep 17 00:00:00 2001 From: zhaoxiangchun <1422928955@qq.com> Date: Sat, 16 May 2020 21:15:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=97=A0=E6=B3=95=E8=8E=B7?= =?UTF-8?q?=E5=8F=96vmware=E5=AE=BF=E4=B8=BB=E6=9C=BA=E7=9B=91=E6=8E=A7?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/multicloud/esxi/monitor.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/multicloud/esxi/monitor.go b/pkg/multicloud/esxi/monitor.go index fbac4353c4..8ef4692d7a 100644 --- a/pkg/multicloud/esxi/monitor.go +++ b/pkg/multicloud/esxi/monitor.go @@ -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