我需要通过VirtualMachine API获得有关vShpere的一些细节,比如VM名称、DNS名称、资源池和主机。
我找到了一种搜索VM的方法,但我不知道如何获得这些细节。
有人做过这个吗?
谢谢你
斯蒂芬恩
发布于 2015-04-29 05:24:54
// 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);
发布于 2017-05-11 17:35:20
您可以按照以下方法获取VM信息
Folder rootFolder = serviceInstance.getRootFolder(); InventoryNavigator inventoryNavigator = new InventoryNavigator(rootFolder); vm = (VirtualMachine) inventoryNavigator.searchManagedEntity(VirtualMachine.class.getSimpleName(), vmName);
https://stackoverflow.com/questions/25998423
复制相似问题