Fixes issue when loading a project using VMware vmnet interfaces. Fixes #319.

This commit is contained in:
grossmj 2015-10-14 21:39:17 -06:00
parent 57bbd63085
commit 6e36687347
2 changed files with 6 additions and 2 deletions

View File

@ -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})

View File

@ -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)