2014-09-23 2 views

답변

-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); 
0

당신이 approah

  1. 를 따라 VM 정보를 얻을 수있는 서비스 인스턴스
  2. 검색에서 서비스 인스턴스
  3. 가져 오기 루트 폴더를 가져옵니다 루트 폴더에 vmname을 사용하는 가상 컴퓨터

Folder rootFolder = serviceInstance.getRootFolder(); InventoryNavigator inventoryNavigator = new InventoryNavigator(rootFolder); vm = (VirtualMachine) inventoryNavigator.searchManagedEntity(VirtualMachine.class.getSimpleName(), vmName);