mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-17 22:08:35 +00:00
parent
5555662b2c
commit
3ea5df7462
@ -215,6 +215,8 @@ class Cloud(BaseNode):
|
||||
yield from self._ubridge_send('bridge add_nio_fusion_vmnet {name} "{interface}"'.format(name=bridge_name,
|
||||
interface=port_info["interface"]))
|
||||
else:
|
||||
if not gns3server.utils.interfaces.has_netmask(port_info["interface"]):
|
||||
raise NodeError("Interface {} don't have a netmask".format(port_info["interface"]))
|
||||
yield from self._ubridge_send('bridge add_nio_ethernet {name} "{interface}"'.format(name=bridge_name,
|
||||
interface=port_info["interface"]))
|
||||
|
||||
|
@ -111,6 +111,22 @@ def get_windows_interfaces():
|
||||
return interfaces
|
||||
|
||||
|
||||
def has_netmask(interface_name):
|
||||
"""
|
||||
Checks if an interface has a netmask.
|
||||
|
||||
:param interface: interface name
|
||||
|
||||
:returns: boolean
|
||||
"""
|
||||
for interface in interfaces():
|
||||
if interface["name"] == interface_name:
|
||||
if interface["netmask"] and len(interface["netmask"]) > 0:
|
||||
return True
|
||||
return False
|
||||
return False
|
||||
|
||||
|
||||
def is_interface_up(interface):
|
||||
"""
|
||||
Checks if an interface is up.
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
import sys
|
||||
|
||||
from gns3server.utils.interfaces import interfaces, is_interface_up
|
||||
from gns3server.utils.interfaces import interfaces, is_interface_up, has_netmask
|
||||
|
||||
|
||||
def test_interfaces():
|
||||
@ -29,6 +29,16 @@ def test_interfaces():
|
||||
assert interface["special"]
|
||||
|
||||
|
||||
def test_has_netmask():
|
||||
if sys.platform.startswith("win"):
|
||||
# No loopback
|
||||
pass
|
||||
elif sys.platform.startswith("darwin"):
|
||||
assert has_netmask("lo0") is True
|
||||
else:
|
||||
assert has_netmask("lo") is True
|
||||
|
||||
|
||||
def test_is_interface_up():
|
||||
if sys.platform.startswith("win"):
|
||||
# is_interface_up() always returns True on Windows
|
||||
|
Loading…
Reference in New Issue
Block a user