GNS3 / gns3-gui

GNS3 Graphical Network Simulator
http://www.gns3.com
GNU General Public License v3.0
2.17k stars 436 forks source link

[2.1] Unable to override non-custom VMware adapter #2414

Closed ghost closed 6 years ago

ghost commented 6 years ago

GNS3 version 2.1.4dev1 on Darwin (64-bit) with Python 3.6.4 Qt 5.9.3 and PyQt 5.9.2, Fusion 8.5.10

https://www.gns3.com/qa/unable-to-add-win-7-vm-to-gns3

A VMware VM should be connected to a router, the adapter is already in use by VMware. vmware

The Option "Allow GNS3 to override non-custom VMware adapter" is set, I've tried changing the node properties and changing the template before adding it into the project. In both cases trying to connect the VMware VM to the router results in the error message Error while creating link: Attachment 'nat' is configured on network adapter 0. Please stop VMware VM 'Win7-1' to link to this adapter and allow GNS3 to change the attachment type., here the entry from the log:

2018-02-04 10:39:19 INFO helpers.py:508 192.168.1.10 - - [04/Feb/2018:09:39:19 +0000] "POST /v2/compute/projects/7793042f-feb6-4802-9400-b465c8e988c9/ports/udp HTTP/1.1" 201 246 "-" "Python/3.6 aiohttp/2.2.5"
2018-02-04 10:39:19 INFO helpers.py:508 192.168.1.10 - - [04/Feb/2018:09:39:19 +0000] "POST /v2/compute/projects/7793042f-feb6-4802-9400-b465c8e988c9/ports/udp HTTP/1.1" 201 246 "-" "Python/3.6 aiohttp/2.2.5"
2018-02-04 10:39:19 ERROR route.py:210 Node error detected: VMwareError
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/gns3_server-2.1.4dev1_e5a4afa-py3.6.egg/gns3server/web/route.py", line 195, in control_schema
    yield from func(request, response)
  File "/usr/local/lib/python3.6/site-packages/gns3_server-2.1.4dev1_e5a4afa-py3.6.egg/gns3server/handlers/api/compute/vmware_handler.py", line 258, in create_nio
    yield from vm.adapter_add_nio_binding(int(request.match_info["adapter_number"]), nio)
  File "/usr/local/lib/python3.6/site-packages/gns3_server-2.1.4dev1_e5a4afa-py3.6.egg/gns3server/compute/vmware/vmware_vm.py", line 752, in adapter_add_nio_binding
    name=self.name))
gns3server.compute.vmware.vmware_error.VMwareError: Attachment 'nat' is configured on network adapter 0. Please stop VMware VM 'Win7-1' to link to this adapter and allow GNS3 to change the attachment type.
2018-02-04 10:39:19 INFO helpers.py:508 192.168.1.10 - - [04/Feb/2018:09:39:19 +0000] "POST /v2/compute/projects/7793042f-feb6-4802-9400-b465c8e988c9/vmware/nodes/8e2096ee-5806-4a02-8d22-b237e1fb0643/adapters/0/ports/0/nio HTTP/1.1" 409 519 "-" "Python/3.6 aiohttp/2.2.5"
2018-02-04 10:39:19 INFO helpers.py:508 192.168.1.10 - - [04/Feb/2018:09:39:19 +0000] "POST /v2/projects/7793042f-feb6-4802-9400-b465c8e988c9/links HTTP/1.1" 409 404 "-" "GNS3 QT Client v2.1.4dev1"

What's strange is, that this error message is send, when the adapter is in use and the VM is running. But it's definitely not running. Neither GNS3 nor VMware Fusion shows that it is running. The only running VM is the GNS3VM.

/Users/behlers# /Applications/VMware\ Fusion.app/Contents/Library/vmrun list
Total running VMs: 1
/Users/behlers/Documents/Virtual Machines.localized/GNS3VM.vmwarevm/GNS3VM.vmx
/Users/behlers#

After looking, how the check for a running VM is done, I noticed a difference to other invocations of self.is_running(). After changing that, it's working now.

diff --git a/gns3server/compute/vmware/vmware_vm.py b/gns3server/compute/vmware/vmware_vm.py
index 37311f5..3e2e58d 100644
--- a/gns3server/compute/vmware/vmware_vm.py
+++ b/gns3server/compute/vmware/vmware_vm.py
@@ -745,7 +745,7 @@ class VMwareVM(BaseNode):
                                       "Please remove it or allow VMware VM '{name}' to use any adapter.".format(attachment=self._vmx_pairs[connection_type],
                                                                                                                 adapter_number=adapter_number,
                                                                                                                 name=self.name))
-                elif self.is_running():
+                elif (yield from self.is_running()):
                     raise VMwareError("Attachment '{attachment}' is configured on network adapter {adapter_number}. "
                                       "Please stop VMware VM '{name}' to link to this adapter and allow GNS3 to change the attachment type.".format(attachment=self._vmx_pairs[connection_type],
                                                                                                                                                     adapter_number=adapter_number,
grossmj commented 6 years ago

Fixed by https://github.com/GNS3/gns3-server/commit/52b690b683d8b8f0a1fdc395b7d111f8d27f6f79

Thanks for catching and fixing this!