mirror of
https://github.com/GNS3/gns3-server.git
synced 2025-01-18 07:23:47 +02:00
Check if the VirtualBox host-only network exists when starting a GNS3 VM running on VirtualBox. Ref https://github.com/GNS3/gns3-vm/issues/102
This commit is contained in:
parent
2e586f56ca
commit
4d57a3befa
@ -107,7 +107,6 @@ class VirtualBoxGNS3VM(BaseGNS3VM):
|
|||||||
Check if the DHCP server associated with a vboxnet is enabled.
|
Check if the DHCP server associated with a vboxnet is enabled.
|
||||||
|
|
||||||
:param vboxnet: vboxnet name
|
:param vboxnet: vboxnet name
|
||||||
|
|
||||||
:returns: boolean
|
:returns: boolean
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -125,6 +124,25 @@ class VirtualBoxGNS3VM(BaseGNS3VM):
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@asyncio.coroutine
|
||||||
|
def _check_vboxnet_exists(self, vboxnet):
|
||||||
|
"""
|
||||||
|
Check if the vboxnet interface exists
|
||||||
|
|
||||||
|
:param vboxnet: vboxnet name
|
||||||
|
:returns: boolean
|
||||||
|
"""
|
||||||
|
|
||||||
|
properties = yield from self._execute("list", ["hostonlyifs"])
|
||||||
|
for prop in properties.splitlines():
|
||||||
|
try:
|
||||||
|
name, value = prop.split(':', 1)
|
||||||
|
except ValueError:
|
||||||
|
continue
|
||||||
|
if name.strip() == "Name" and value.strip() == vboxnet:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def _check_vbox_port_forwarding(self):
|
def _check_vbox_port_forwarding(self):
|
||||||
"""
|
"""
|
||||||
@ -158,18 +176,23 @@ class VirtualBoxGNS3VM(BaseGNS3VM):
|
|||||||
# get a NAT interface number
|
# get a NAT interface number
|
||||||
nat_interface_number = yield from self._look_for_interface("nat")
|
nat_interface_number = yield from self._look_for_interface("nat")
|
||||||
if nat_interface_number < 0:
|
if nat_interface_number < 0:
|
||||||
raise GNS3VMError("The GNS3 VM: {} must have a NAT interface configured in order to start".format(self.vmname))
|
raise GNS3VMError('The VM "{}" must have a NAT interface configured in order to start'.format(self.vmname))
|
||||||
|
|
||||||
hostonly_interface_number = yield from self._look_for_interface("hostonly")
|
hostonly_interface_number = yield from self._look_for_interface("hostonly")
|
||||||
if hostonly_interface_number < 0:
|
if hostonly_interface_number < 0:
|
||||||
raise GNS3VMError("The GNS3 VM: {} must have a host only interface configured in order to start".format(self.vmname))
|
raise GNS3VMError('The VM "{}" must have a host-only interface configured in order to start'.format(self.vmname))
|
||||||
|
|
||||||
vboxnet = yield from self._look_for_vboxnet(hostonly_interface_number)
|
vboxnet = yield from self._look_for_vboxnet(hostonly_interface_number)
|
||||||
if vboxnet is None:
|
if vboxnet is None:
|
||||||
raise GNS3VMError("VirtualBox host-only network could not be found for interface {} on GNS3 VM".format(hostonly_interface_number))
|
raise GNS3VMError('A VirtualBox host-only network could not be found on network adapter {} for "{}"'.format(hostonly_interface_number, self._vmname))
|
||||||
|
|
||||||
|
if not (yield from self._check_vboxnet_exists(vboxnet)):
|
||||||
|
raise GNS3VMError('VirtualBox host-only network "{}" does not exist, please make the sure the network adapter {} configuration is valid for "{}"'.format(vboxnet,
|
||||||
|
hostonly_interface_number,
|
||||||
|
self._vmname))
|
||||||
|
|
||||||
if not (yield from self._check_dhcp_server(vboxnet)):
|
if not (yield from self._check_dhcp_server(vboxnet)):
|
||||||
raise GNS3VMError("DHCP must be enabled on VirtualBox host-only network: {} for GNS3 VM".format(vboxnet))
|
raise GNS3VMError('DHCP must be enabled on VirtualBox host-only network "{}"'.format(vboxnet))
|
||||||
|
|
||||||
vm_state = yield from self._get_state()
|
vm_state = yield from self._get_state()
|
||||||
log.info('"{}" state is {}'.format(self._vmname, vm_state))
|
log.info('"{}" state is {}'.format(self._vmname, vm_state))
|
||||||
|
Loading…
Reference in New Issue
Block a user