From 427cb05c2ad0ea80a89d70bd6773d5dc98a3fdf1 Mon Sep 17 00:00:00 2001 From: grossmj Date: Wed, 23 Mar 2016 10:54:45 -0600 Subject: [PATCH] Stop the VMware VM if there is an error while setting up the network connections or console. --- gns3server/modules/vmware/vmware_vm.py | 32 +++++++++++++++----------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/gns3server/modules/vmware/vmware_vm.py b/gns3server/modules/vmware/vmware_vm.py index 72a73278..354ee66b 100644 --- a/gns3server/modules/vmware/vmware_vm.py +++ b/gns3server/modules/vmware/vmware_vm.py @@ -454,21 +454,25 @@ class VMwareVM(BaseVM): else: yield from self._control_vm("start") - if self._use_ubridge and self._ubridge_hypervisor: - for adapter_number in range(0, self._adapters): - nio = self._ethernet_adapters[adapter_number].get_nio(0) - if nio: - yield from self._add_ubridge_connection(nio, adapter_number) + try: + if self._use_ubridge and self._ubridge_hypervisor: + for adapter_number in range(0, self._adapters): + nio = self._ethernet_adapters[adapter_number].get_nio(0) + if nio: + yield from self._add_ubridge_connection(nio, adapter_number) - if self._enable_remote_console and self._console is not None: - try: - if sys.platform.startswith("win"): - yield from wait_for_named_pipe_creation(self._get_pipe_name()) - else: - yield from wait_for_file_creation(self._get_pipe_name()) # wait for VMware to create the pipe file. - except asyncio.TimeoutError: - raise VMwareError('Pipe file "{}" for remote console has not been created by VMware'.format(self._get_pipe_name())) - self._start_remote_console() + if self._enable_remote_console and self._console is not None: + try: + if sys.platform.startswith("win"): + yield from wait_for_named_pipe_creation(self._get_pipe_name()) + else: + yield from wait_for_file_creation(self._get_pipe_name()) # wait for VMware to create the pipe file. + except asyncio.TimeoutError: + raise VMwareError('Pipe file "{}" for remote console has not been created by VMware'.format(self._get_pipe_name())) + self._start_remote_console() + except VMwareError: + yield from self.stop() + raise if self._get_vmx_setting("vhv.enable", "TRUE"): self._hw_virtualization = True