String vCenterUserName ="administrator"; String vCenterPassword = "_SKYC123!"; String vCenterAddress = "172.16.211.38"; ServiceInstance si = new ServiceInstance(new URL("https://"+vCenterAddress+"/sdk"), vCenterUserName, vCenterPassword, true); //查询名称为Test-datacenter 的数据中心 String datacenterName = "Test-datacenter"; Datacenter dcObj = (Datacenter) new InventoryNavigator(si.getRootFolder()).searchManagedEntity("Datacenter", datacenterName); //查询所有数据中心 ManagedEntity []dcObjs = new InventoryNavigator(si.getRootFolder()).searchManagedEntities("Datacenter"); //在datacenter下查询对应名称为Test-cluster的集群 String clusterName ="Test-cluster"; ClusterComputeResource clusterObj =(ClusterComputeResource) new InventoryNavigator(dcObj).searchManagedEntity("ClusterComputeResource", clusterName ); String hostname ="172.16.201.11"; //查询单个物理机器 HostSystem host =(HostSystem) new InventoryNavigator(clusterObj).searchManagedEntity("HostSystem", hostname );