mirror of
https://github.com/GNS3/gns3-server
synced 2024-12-24 15:58:08 +00:00
Fix a crash in cloud
This commit is contained in:
parent
29563ed7bc
commit
41f12457e7
@ -48,8 +48,7 @@ class Cloud(BaseNode):
|
|||||||
# If the cloud is not configured we fill it with host interfaces
|
# If the cloud is not configured we fill it with host interfaces
|
||||||
if not ports or len(ports) == 0:
|
if not ports or len(ports) == 0:
|
||||||
self._ports_mapping = []
|
self._ports_mapping = []
|
||||||
network_interfaces = gns3server.utils.interfaces.interfaces()
|
for interface in self._interfaces():
|
||||||
for interface in network_interfaces:
|
|
||||||
if not interface["special"]:
|
if not interface["special"]:
|
||||||
self._ports_mapping.append({
|
self._ports_mapping.append({
|
||||||
"interface": interface["name"],
|
"interface": interface["name"],
|
||||||
@ -60,6 +59,9 @@ class Cloud(BaseNode):
|
|||||||
else:
|
else:
|
||||||
self._ports_mapping = ports
|
self._ports_mapping = ports
|
||||||
|
|
||||||
|
def _interfaces(self):
|
||||||
|
return gns3server.utils.interfaces.interfaces()
|
||||||
|
|
||||||
def __json__(self):
|
def __json__(self):
|
||||||
|
|
||||||
host_interfaces = []
|
host_interfaces = []
|
||||||
@ -172,7 +174,7 @@ class Cloud(BaseNode):
|
|||||||
if port_info["type"] in ("ethernet", "tap"):
|
if port_info["type"] in ("ethernet", "tap"):
|
||||||
|
|
||||||
if sys.platform.startswith("win"):
|
if sys.platform.startswith("win"):
|
||||||
windows_interfaces = interfaces()
|
windows_interfaces = self._interfaces()
|
||||||
npf = None
|
npf = None
|
||||||
for interface in windows_interfaces:
|
for interface in windows_interfaces:
|
||||||
if port_info["interface"] == interface["name"]:
|
if port_info["interface"] == interface["name"]:
|
||||||
@ -186,7 +188,7 @@ class Cloud(BaseNode):
|
|||||||
else:
|
else:
|
||||||
|
|
||||||
if port_info["type"] == "ethernet":
|
if port_info["type"] == "ethernet":
|
||||||
network_interfaces = [interface["name"] for interface in interfaces()]
|
network_interfaces = [interface["name"] for interface in self._interfaces()]
|
||||||
if not port_info["interface"] in network_interfaces:
|
if not port_info["interface"] in network_interfaces:
|
||||||
raise NodeError("Interface '{}' could not be found on this system".format(port_info["interface"]))
|
raise NodeError("Interface '{}' could not be found on this system".format(port_info["interface"]))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user