mirror of
https://github.com/GNS3/gns3-server.git
synced 2024-12-22 06:07:51 +00:00
Warn users if the GNS3 VM and local server are not in the same subnet. Fixes #1231.
This commit is contained in:
parent
1699ce5d1c
commit
cfe8e9e85c
@ -19,6 +19,7 @@ import sys
|
|||||||
import copy
|
import copy
|
||||||
import asyncio
|
import asyncio
|
||||||
import aiohttp
|
import aiohttp
|
||||||
|
import ipaddress
|
||||||
|
|
||||||
from ...utils.asyncio import locked_coroutine
|
from ...utils.asyncio import locked_coroutine
|
||||||
from .vmware_gns3_vm import VMwareGNS3VM
|
from .vmware_gns3_vm import VMwareGNS3VM
|
||||||
@ -296,6 +297,37 @@ class GNS3VM:
|
|||||||
user=self.user,
|
user=self.user,
|
||||||
password=self.password)
|
password=self.password)
|
||||||
|
|
||||||
|
yield from self._check_network(compute)
|
||||||
|
|
||||||
|
@asyncio.coroutine
|
||||||
|
def _check_network(self, compute):
|
||||||
|
"""
|
||||||
|
Check that the VM is in the same subnet as the local server
|
||||||
|
"""
|
||||||
|
|
||||||
|
vm_interfaces = yield from compute.interfaces()
|
||||||
|
vm_interface_netmask = None
|
||||||
|
for interface in vm_interfaces:
|
||||||
|
if interface["ip_address"] == self.ip_address:
|
||||||
|
vm_interface_netmask = interface["netmask"]
|
||||||
|
break
|
||||||
|
if vm_interface_netmask:
|
||||||
|
vm_network = ipaddress.ip_interface("{}/{}".format(compute.host_ip, vm_interface_netmask)).network
|
||||||
|
for compute_id in self._controller.computes:
|
||||||
|
if compute_id == "local":
|
||||||
|
compute = self._controller.get_compute(compute_id)
|
||||||
|
interfaces = yield from compute.interfaces()
|
||||||
|
netmask = None
|
||||||
|
for interface in interfaces:
|
||||||
|
if interface["ip_address"] == compute.host_ip:
|
||||||
|
netmask = interface["netmask"]
|
||||||
|
break
|
||||||
|
if netmask:
|
||||||
|
compute_network = ipaddress.ip_interface("{}/{}".format(compute.host_ip, netmask)).network
|
||||||
|
if vm_network.compare_networks(compute_network) != 0:
|
||||||
|
msg = "The GNS3 VM ({}) is not on the same network as the {} server ({}), please make sure the local server binding is in the same network as the GNS3 VM".format(vm_network, compute_id, compute_network)
|
||||||
|
self._controller.notification.emit("log.warning", {"message": msg})
|
||||||
|
|
||||||
@locked_coroutine
|
@locked_coroutine
|
||||||
def _suspend(self):
|
def _suspend(self):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user