mirror of
https://github.com/GNS3/gns3-server.git
synced 2024-11-16 16:54:51 +02:00
Fix wrong error when NAT interface is not allowed. Fixes #1943
This commit is contained in:
parent
92150fba71
commit
363fdb7d10
@ -35,13 +35,22 @@ class Nat(Cloud):
|
|||||||
|
|
||||||
def __init__(self, name, node_id, project, manager, ports=None):
|
def __init__(self, name, node_id, project, manager, ports=None):
|
||||||
|
|
||||||
|
allowed_interfaces = Config.instance().get_section_config("Server").get("allowed_interfaces", None)
|
||||||
|
if allowed_interfaces:
|
||||||
|
allowed_interfaces = allowed_interfaces.split(',')
|
||||||
if sys.platform.startswith("linux"):
|
if sys.platform.startswith("linux"):
|
||||||
nat_interface = Config.instance().get_section_config("Server").get("default_nat_interface", "virbr0")
|
nat_interface = Config.instance().get_section_config("Server").get("default_nat_interface", "virbr0")
|
||||||
|
if allowed_interfaces and nat_interface not in allowed_interfaces:
|
||||||
|
raise NodeError("NAT interface {} is not allowed be used on this server. "
|
||||||
|
"Please check the server configuration file.".format(nat_interface))
|
||||||
if nat_interface not in [interface["name"] for interface in gns3server.utils.interfaces.interfaces()]:
|
if nat_interface not in [interface["name"] for interface in gns3server.utils.interfaces.interfaces()]:
|
||||||
raise NodeError("NAT interface {} is missing, please install libvirt".format(nat_interface))
|
raise NodeError("NAT interface {} is missing, please install libvirt".format(nat_interface))
|
||||||
interface = nat_interface
|
interface = nat_interface
|
||||||
else:
|
else:
|
||||||
nat_interface = Config.instance().get_section_config("Server").get("default_nat_interface", "vmnet8")
|
nat_interface = Config.instance().get_section_config("Server").get("default_nat_interface", "vmnet8")
|
||||||
|
if allowed_interfaces and nat_interface not in allowed_interfaces:
|
||||||
|
raise NodeError("NAT interface {} is not allowed be used on this server. "
|
||||||
|
"Please check the server configuration file.".format(nat_interface))
|
||||||
interfaces = list(filter(lambda x: nat_interface in x.lower(),
|
interfaces = list(filter(lambda x: nat_interface in x.lower(),
|
||||||
[interface["name"] for interface in gns3server.utils.interfaces.interfaces()]))
|
[interface["name"] for interface in gns3server.utils.interfaces.interfaces()]))
|
||||||
if not len(interfaces):
|
if not len(interfaces):
|
||||||
|
Loading…
Reference in New Issue
Block a user