更新:即使我尝试创建共享虚拟机并更改该虚拟机的位置,问题仍然存在。
我试图D:\VMs\CentOS-Backup\CentOS-Secondary-Server.vmx
使用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。但没有执行任何与系统 PATH 添加相关的特定操作。如果我真的需要这样做,你能给我一个提示吗?
谢谢!