From 3c4a60cd0ae526ca2dce3c3e5ddcd6f27eaf722b Mon Sep 17 00:00:00 2001 From: grossmj Date: Mon, 25 May 2015 15:49:28 -0600 Subject: [PATCH] Check for VMware lock file. --- gns3server/modules/vmware/vmware_vm.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/gns3server/modules/vmware/vmware_vm.py b/gns3server/modules/vmware/vmware_vm.py index 2df012f0..44694476 100644 --- a/gns3server/modules/vmware/vmware_vm.py +++ b/gns3server/modules/vmware/vmware_vm.py @@ -21,10 +21,6 @@ VMware VM instance. import sys import os -import tempfile -import json -import socket -import re import subprocess import configparser import shutil @@ -33,7 +29,6 @@ import asyncio from gns3server.utils.asyncio import wait_for_process_termination from gns3server.utils.asyncio import monitor_process from collections import OrderedDict -from pkg_resources import parse_version from .vmware_error import VMwareError from ..nios.nio_udp import NIOUDP from ..adapters.ethernet_adapter import EthernetAdapter @@ -119,7 +114,7 @@ class VMwareVM(BaseVM): except OSError as e: raise VMwareError('Could not read VMware VMX file "{}": {}'.format(self._vmx_path, e)) - # first to some sanity checks + # first do some sanity checks for adapter_number in range(0, self._adapters): connected = "ethernet{}.startConnected".format(adapter_number) if self._get_vmx_setting(connected): @@ -331,6 +326,9 @@ class VMwareVM(BaseVM): Starts this VMware VM. """ + if os.path.exists(self._vmx_path + ".lck"): + raise VMwareError("VM locked, it is either running or being edited in VMware") + ubridge_path = self.ubridge_path if not ubridge_path or not os.path.isfile(ubridge_path): raise VMwareError("ubridge is necessary to start a VMware VM")