From 57f9d875ca5c6473c508fd194e07e26166cf4745 Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Tue, 2 Jun 2015 16:27:48 +0200 Subject: [PATCH] Fix AttributeError: 'NIONAT' object has no attribute 'lport' for VirtualBox Fix #205 --- gns3server/modules/virtualbox/virtualbox_vm.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/gns3server/modules/virtualbox/virtualbox_vm.py b/gns3server/modules/virtualbox/virtualbox_vm.py index 546c2239..3c8d471a 100644 --- a/gns3server/modules/virtualbox/virtualbox_vm.py +++ b/gns3server/modules/virtualbox/virtualbox_vm.py @@ -805,12 +805,16 @@ class VirtualBoxVM(BaseVM): vm_state = yield from self._get_vm_state() if vm_state == "running": - # dynamically configure an UDP tunnel on the VirtualBox adapter - yield from self._control_vm("nic{} generic UDPTunnel".format(adapter_number + 1)) - yield from self._control_vm("nicproperty{} sport={}".format(adapter_number + 1, nio.lport)) - yield from self._control_vm("nicproperty{} dest={}".format(adapter_number + 1, nio.rhost)) - yield from self._control_vm("nicproperty{} dport={}".format(adapter_number + 1, nio.rport)) - yield from self._control_vm("setlinkstate{} on".format(adapter_number + 1)) + if isinstance(nio, NIOUDP): + # dynamically configure an UDP tunnel on the VirtualBox adapter + yield from self._control_vm("nic{} generic UDPTunnel".format(adapter_number + 1)) + yield from self._control_vm("nicproperty{} sport={}".format(adapter_number + 1, nio.lport)) + yield from self._control_vm("nicproperty{} dest={}".format(adapter_number + 1, nio.rhost)) + yield from self._control_vm("nicproperty{} dport={}".format(adapter_number + 1, nio.rport)) + yield from self._control_vm("setlinkstate{} on".format(adapter_number + 1)) + elif isinstance(nio, NIONAT): + yield from self._modify_vm("--nic{} nat".format(adapter_number + 1)) + yield from self._modify_vm("--cableconnected{} on".format(adapter_number + 1)) adapter.add_nio(0, nio) log.info("VirtualBox VM '{name}' [{id}]: {nio} added to adapter {adapter_number}".format(name=self.name,