我需要通过vShpere API获取有关VirtualMachine的一些详细信息,例如VM名称,DNS名称,资源池和主机。
我找到了一种搜索虚拟机的方法,但我不知道如何获取这些细节。
有没有人这样做过?
感谢你
斯蒂芬
答案 0 :(得分:0)
您可以按照此标准获取虚拟机信息
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);