1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-12-02 21:28:10 +00:00

Search for correct VirtualBox network type

This commit is contained in:
grossmj 2023-05-31 20:19:13 +09:30
parent 73bcd019cc
commit c6d6fcfe66

View File

@ -159,7 +159,7 @@ class VirtualBoxGNS3VM(BaseGNS3VM):
return True return True
return False return False
async def _check_vboxnet_exists(self, vboxnet): async def _check_vboxnet_exists(self, vboxnet, vboxnet_type):
""" """
Check if the vboxnet interface exists Check if the vboxnet interface exists
@ -167,7 +167,7 @@ class VirtualBoxGNS3VM(BaseGNS3VM):
:returns: boolean :returns: boolean
""" """
properties = await self._execute("list", ["hostonlyifs"]) properties = await self._execute("list", ["{}".format(vboxnet_type)])
for prop in properties.splitlines(): for prop in properties.splitlines():
try: try:
name, value = prop.split(':', 1) name, value = prop.split(':', 1)
@ -233,12 +233,14 @@ class VirtualBoxGNS3VM(BaseGNS3VM):
if sys.platform.startswith("darwin") and parse_version(self._system_properties["API version"]) >= parse_version("7_0"): if sys.platform.startswith("darwin") and parse_version(self._system_properties["API version"]) >= parse_version("7_0"):
backend_type = "hostonly-network" backend_type = "hostonly-network"
backend_description = "host-only network" backend_description = "host-only network"
vboxnet_type = "hostonlyifs"
interface_number = await self._look_for_interface("hostonlynetwork") interface_number = await self._look_for_interface("hostonlynetwork")
if interface_number < 0: if interface_number < 0:
raise GNS3VMError('VM "{}" must have a network adapter attached to a host-only network in order to start'.format(self.vmname)) raise GNS3VMError('VM "{}" must have a network adapter attached to a host-only network in order to start'.format(self.vmname))
else: else:
backend_type = "hostonlyadapter" backend_type = "hostonlyadapter"
backend_description = "host-only adapter" backend_description = "host-only adapter"
vboxnet_type = "hostonlynets"
interface_number = await self._look_for_interface("hostonly") interface_number = await self._look_for_interface("hostonly")
if interface_number < 0: if interface_number < 0:
@ -248,7 +250,7 @@ class VirtualBoxGNS3VM(BaseGNS3VM):
if vboxnet is None: if vboxnet is None:
raise GNS3VMError('A VirtualBox host-only network could not be found on network adapter {} for "{}"'.format(interface_number, self._vmname)) raise GNS3VMError('A VirtualBox host-only network could not be found on network adapter {} for "{}"'.format(interface_number, self._vmname))
if not (await self._check_vboxnet_exists(vboxnet)): if not (await self._check_vboxnet_exists(vboxnet, vboxnet_type)):
if sys.platform.startswith("win") and vboxnet == "vboxnet0": if sys.platform.startswith("win") and vboxnet == "vboxnet0":
# The GNS3 VM is configured with vboxnet0 by default which is not available # The GNS3 VM is configured with vboxnet0 by default which is not available
# on Windows. Try to patch this with the first available vboxnet we find. # on Windows. Try to patch this with the first available vboxnet we find.