vSphere WebServervice API获取VirtualMachine详细信息

时间:2014-09-23 15:00:53

标签: java web-services vmware vsphere

我需要通过vShpere API获取有关VirtualMachine的一些详细信息,例如VM名称,DNS名称,资源池和主机。

我找到了一种搜索虚拟机的方法,但我不知道如何获取这些细节。

有没有人这样做过?

感谢你

斯蒂芬

2 个答案:

答案 0 :(得分:0)

您可以按照此标准获取虚拟机信息

  1. 获取服务实例
  2. 从服务实例获取根文件夹
  3. 使用根文件夹中的vmname搜索虚拟机
  4. Sorted=($(sort -nk2 -t n <( echo ${FILES[@]}|tr " " "\n")))

答案 1 :(得分:-1)

    //    you can find this code to get some ResourcePool infomation 

          ComputeResource cresource = (ComputeResource) host.getParent();
                    ResourcePool[] resourcepools = cresource.getResourcePool().getResourcePools();


   // if you find a way to search one vm .so  you can write below code. 
    ServiceInstance si = null;
    si = new ServiceInstance(new URL(
                            "https://"+hostVal+"/sdk"), usernameVal,
                            passwordVal, true);
    VirtualMachine vm = (VirtualMachine) new InventoryNavigator(
                                    si.getRootFolder()).searchManagedEntity(
                                    "VirtualMachine", VM_NAME);