Update: the problem is still here even if I try to create Shared VMs and change location of that VMs.
I got stuck trying to get to the virtual machine located in D:\VMs\CentOS-Backup\CentOS-Secondary-Server.vmx
using PySphere.
Could you please help me?
All I tried so far is:
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()
Mentioned exception is:
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'
Please note, I installed VIX API as well. But didn't perform any specific actions related to system PATH additions. Could you give me a hint if I really need to do this?
Thanks!
I finally figured it out! You need to make sure the VMs are shared. VM->Manage->Share...
Then they'll show up under server.get_registered_vms() and you can then use get_vm_by_name.