From 6e36687347e555af891f349da4ce24985e4e5b1e Mon Sep 17 00:00:00 2001 From: grossmj Date: Wed, 14 Oct 2015 21:39:17 -0600 Subject: [PATCH] Fixes issue when loading a project using VMware vmnet interfaces. Fixes #319. --- gns3server/handlers/api/vmware_handler.py | 5 ++++- gns3server/modules/vmware/vmware_vm.py | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/gns3server/handlers/api/vmware_handler.py b/gns3server/handlers/api/vmware_handler.py index b2ed9c44..b9f6f0b4 100644 --- a/gns3server/handlers/api/vmware_handler.py +++ b/gns3server/handlers/api/vmware_handler.py @@ -348,9 +348,10 @@ class VMwareHandler: @classmethod @Route.post( - r"/projects/{project_id}/vmware/interfaces/vmnet", + r"/projects/{project_id}/vmware/vms/{vm_id}/interfaces/vmnet", parameters={ "project_id": "The UUID of the project", + "vm_id": "UUID for the instance", }, status_codes={ 201: "VMnet interface allocated", @@ -359,7 +360,9 @@ class VMwareHandler: def allocate_vmnet(request, response): vmware_manager = VMware.instance() + vm = vmware_manager.get_vm(request.match_info["vm_id"], project_id=request.match_info["project_id"]) vmware_manager.refresh_vmnet_list(ubridge=False) vmnet = vmware_manager.allocate_vmnet() + vm.vmnets.append(vmnet) response.set_status(201) response.json({"vmnet": vmnet}) diff --git a/gns3server/modules/vmware/vmware_vm.py b/gns3server/modules/vmware/vmware_vm.py index 2cc9bef5..974401e2 100644 --- a/gns3server/modules/vmware/vmware_vm.py +++ b/gns3server/modules/vmware/vmware_vm.py @@ -820,7 +820,8 @@ class VMwareVM(BaseVM): raise VMwareError("Sorry, adding a link to a started VMware VM is not supported without uBridge enabled") self._vmx_pairs["ethernet{}.vnet".format(adapter_number)] = nio.vmnet self._write_vmx_file() - self._vmnets.append(nio.vmnet) + if nio.vmnet not in self._vmnets: + self._vmnets.append(nio.vmnet) adapter.add_nio(0, nio) if self._started and self._use_ubridge: yield from self._add_ubridge_connection(nio, adapter_number)