mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-28 11:18:11 +00:00
Avoid disconnecting valid VirtualBox VM adapter backends.
This commit is contained in:
parent
19c5fdb1fd
commit
631d7a1e25
@ -24,7 +24,7 @@ try:
|
|||||||
import raven
|
import raven
|
||||||
RAVEN_AVAILABLE = True
|
RAVEN_AVAILABLE = True
|
||||||
except ImportError:
|
except ImportError:
|
||||||
# raven is not installed with deb package in order to simplify packagin
|
# raven is not installed with deb package in order to simplify packaging
|
||||||
RAVEN_AVAILABLE = False
|
RAVEN_AVAILABLE = False
|
||||||
|
|
||||||
from .version import __version__
|
from .version import __version__
|
||||||
|
@ -959,7 +959,7 @@ class IOUVM(BaseVM):
|
|||||||
initial_config = initial_config.replace("%h", self._name)
|
initial_config = initial_config.replace("%h", self._name)
|
||||||
f.write(initial_config)
|
f.write(initial_config)
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
raise IOUError("Can't write initial configuration file '{}'".format(script_file))
|
raise IOUError("Can't write initial configuration file '{}': {}".format(script_file, e))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def initial_config_file(self):
|
def initial_config_file(self):
|
||||||
|
@ -647,7 +647,11 @@ class VirtualBoxVM(BaseVM):
|
|||||||
attachment = nic_attachments[adapter_number]
|
attachment = nic_attachments[adapter_number]
|
||||||
if attachment == "null":
|
if attachment == "null":
|
||||||
# disconnect the cable if no backend is attached.
|
# disconnect the cable if no backend is attached.
|
||||||
self._modify_vm("--cableconnected{} off".format(adapter_number + 1))
|
yield from self._modify_vm("--cableconnected{} off".format(adapter_number + 1))
|
||||||
|
if attachment == "none":
|
||||||
|
# set the backend to null to avoid a difference in the number of interfaces in the Guest.
|
||||||
|
yield from self._modify_vm("--nic{} null".format(adapter_number + 1))
|
||||||
|
yield from self._modify_vm("--cableconnected{} off".format(adapter_number + 1))
|
||||||
nio = self._ethernet_adapters[adapter_number].get_nio(0)
|
nio = self._ethernet_adapters[adapter_number].get_nio(0)
|
||||||
if nio:
|
if nio:
|
||||||
if not self._use_any_adapter and attachment not in ("none", "null", "generic"):
|
if not self._use_any_adapter and attachment not in ("none", "null", "generic"):
|
||||||
@ -683,10 +687,6 @@ class VirtualBoxVM(BaseVM):
|
|||||||
if nio.capturing:
|
if nio.capturing:
|
||||||
yield from self._modify_vm("--nictrace{} on".format(adapter_number + 1))
|
yield from self._modify_vm("--nictrace{} on".format(adapter_number + 1))
|
||||||
yield from self._modify_vm('--nictracefile{} "{}"'.format(adapter_number + 1, nio.pcap_output_file))
|
yield from self._modify_vm('--nictracefile{} "{}"'.format(adapter_number + 1, nio.pcap_output_file))
|
||||||
else:
|
|
||||||
yield from self._modify_vm("--nic{} null".format(adapter_number + 1))
|
|
||||||
yield from self._modify_vm("--cableconnected{} off".format(adapter_number + 1))
|
|
||||||
|
|
||||||
|
|
||||||
for adapter_number in range(self._adapters, self._maximum_adapters):
|
for adapter_number in range(self._adapters, self._maximum_adapters):
|
||||||
log.debug("disabling remaining adapter {}".format(adapter_number))
|
log.debug("disabling remaining adapter {}".format(adapter_number))
|
||||||
|
Loading…
Reference in New Issue
Block a user