1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-15 04:49:10 +00:00

Merge pull request #1168 from GNS3/nat-on-windows

Fixes NAT node not working on Windows (#1163)
This commit is contained in:
Julien Duponchelle 2017-08-21 14:24:05 +02:00 committed by GitHub
commit 4fc29504f2
2 changed files with 23 additions and 1 deletions

View File

@ -36,7 +36,9 @@ class Nat(Cloud):
raise NodeError("virbr0 is missing. You need to install libvirt")
interface = "virbr0"
else:
if "vmnet8" not in [interface["name"] for interface in gns3server.utils.interfaces.interfaces()]:
names = filter(lambda x: 'vmnet8' in x.lower(),
[interface["name"] for interface in gns3server.utils.interfaces.interfaces()])
if not len(list(names)):
raise NodeError("vmnet8 is missing. You need to install VMware or use the NAT node on GNS3 VM")
interface = "vmnet8"

View File

@ -59,3 +59,23 @@ def test_json_darwin(darwin_platform, project):
}
]
}
def test_json_windows_with_full_name_of_interface(windows_platform, project):
with patch("gns3server.utils.interfaces.interfaces", return_value=[
{"name": "VMware Network Adapter VMnet8", "special": True, "type": "ethernet"}]):
nat = Nat("nat1", str(uuid.uuid4()), project, MagicMock())
assert nat.__json__() == {
"name": "nat1",
"node_id": nat.id,
"project_id": project.id,
"status": "started",
"ports_mapping": [
{
"interface": "vmnet8",
"name": "nat0",
"port_number": 0,
"type": "ethernet"
}
]
}