更新:即使我尝试创建共享VM并更改该VM的位置,问题仍然存在。
我被困在使用PySphere访问位于PySphere中的虚拟机。
你能帮帮我吗?
到目前为止我试过的是:
from pysphere import VIServer
server = VIServer()
server.connect("127.0.0.1", "my_system_login", "my_system_password")
# prints 'VMware Workstation'
print server.get_server_type()
# prints '5.1'
print server.get_api_version()
# Exception
vm = server.get_vm_by_path(r"D:\VMs\CentOS-Backup\CentOS-Secondary-Server.vmx")
vm.power_on()提到的例外是:
Traceback (most recent call last):
File "C:\Program Files (x86)\JetBrains\PyCharm 2.7\helpers\pydev\pydevd.py", line 1473, in <module>
debugger.run(setup['file'], None, None)
File "C:\Program Files (x86)\JetBrains\PyCharm 2.7\helpers\pydev\pydevd.py", line 1117, in run
pydev_imports.execfile(file, globals, locals) #execute the script
File "D:/Projects/PyUnitTesting/pyunittest/launcher.py", line 13, in <module>
vm = server.get_vm_by_path(r"D:\VMs\CentOS-Backup\CentOS-Secondary-Server.vmx")
File "C:\dev\Python27\lib\site-packages\pysphere\vi_server.py", line 291, in get_vm_by_path
FaultTypes.OBJECT_NOT_FOUND)
pysphere.resources.vi_exception.VIException: [Object Not Found]: Could not find a VM with path 'D:\VMs\CentOS-Backup\CentOS-Secondary-Server.vmx'请注意,我也安装了VIX API。但没有执行任何与系统路径添加相关的特定操作。如果我真的需要这样做,你能给我一个提示吗?
谢谢!
发布于 2013-07-19 23:41:33
我终于想出来了!您需要确保VM是共享的。VM->Manage->共享.
然后,它们将出现在server.get_registered_vms()下面,然后您可以使用get_vm_by_name。
发布于 2013-03-18 19:05:33
根据文档,我认为您不应该向VM提供原始文件路径。我认为有一个内部路径值:
属性
它们的示例代码显示如下:
vm1 = server.get_vm_by_path("[DataStore1] Ubuntu/Ubuntu-10.vmx")https://stackoverflow.com/questions/14789425
复制相似问题