diff --git a/gns3server/modules/vmware/vmware_vm.py b/gns3server/modules/vmware/vmware_vm.py index d1657b70..9d3d6cc0 100644 --- a/gns3server/modules/vmware/vmware_vm.py +++ b/gns3server/modules/vmware/vmware_vm.py @@ -127,6 +127,14 @@ class VMwareVM(BaseVM): except OSError as e: raise VMwareError('Could not write VMware VMX file "{}": {}'.format(self._vmx_path, e)) + @asyncio.coroutine + def is_running(self): + + result = yield from self.manager.execute("list", []) + if self._vmx_path in result: + return True + return False + @asyncio.coroutine def create(self): """ @@ -400,9 +408,8 @@ class VMwareVM(BaseVM): Starts this VMware VM. """ - # The lock dection is not working on OSX the .lck is never deleted - if os.path.exists(self._vmx_path + ".lck") and not sys.platform.startswith("darwin"): - raise VMwareError("VM locked, it is either running or being edited in VMware") + if (yield from self.is_running()): + raise VMwareError("The VM is already running in VMware") ubridge_path = self.ubridge_path if not ubridge_path or not os.path.isfile(ubridge_path):