vsphere API - searchManagedEntity 函数始终 returns null

vsphere API - searchManagedEntity function always returns null

searchManagedEntity 函数总是 returns 无效,我在网上尝试了很多解决方案,但不幸的是,其中 none 有效。

这是我的代码片段:

ServiceInstance serviceInstance = authentification.connexionExsi();
Folder rootFolder = serviceInstance.getRootFolder();
System.out.println("Host" + (HostSystem) new InventoryNavigator(rootFolder).searchManagedEntity("HostSystem","192.168.1.44"));

提前感谢您的帮助<3

我终于找到了解决这个问题的方法,你必须使用 ESXI 主机的名称而不是 IP(ESXI 名称 = ESXI 主机名 + 域名):

代码:

ServiceInstance serviceInstance =  authentification.connexionExsi();
Folder rootFolder = serviceInstance.getRootFolder();
System.out.println("Host"+new InventoryNavigator(rootFolder).searchManagedEntity("HostSystem","rabatos.Home").getName());

您可以在Dns & Routing中找到主机和域名,如下图所示:

Esxi Name