Merge branch '2.0' into 2.1

This commit is contained in:
Julien Duponchelle committed 2017-05-15 15:46:50 +02:00
commit cd17ef6b12
34 files changed
+221 -74

No files matched your search

+1 -1
View File
@@ -160,7 +160,7 @@ class Controller:
for c in computes:
try:
yield from self.add_compute(**c)
except (aiohttp.web_exceptions.HTTPConflict):
except (aiohttp.web_exceptions.HTTPConflict, KeyError):
pass # Skip not available servers at loading
yield from self.load_projects()
try:
+4
View File
@@ -23,6 +23,7 @@ import json
import uuid
import sys
import io
from operator import itemgetter
from ..utils import parse_version
from ..utils.images import list_images
@@ -600,6 +601,9 @@ class Compute:
for local_image in list_images(type):
if local_image['filename'] not in [i['filename'] for i in images]:
images.append(local_image)
images = sorted(images, key=itemgetter('filename'))
else:
images = sorted(images, key=itemgetter('image'))
except OSError as e:
raise ComputeError("Can't list images: {}".format(str(e)))
return images
+2 -3
View File
@@ -190,6 +190,5 @@ def _export_images(project, image, z):
if os.path.exists(path):
arcname = os.path.join("images", directory, os.path.basename(image))
z.write(path, arcname)
break
else:
raise aiohttp.web.HTTPConflict(text="Topology could not be exported because the image {} is not available. If you use multiple server, we need a copy of the image on the main server.".format(path))
return
raise aiohttp.web.HTTPConflict(text="Topology could not be exported because the image {} is not available. If you use multiple server, we need a copy of the image on the main server.".format(image))
@@ -228,7 +228,7 @@ class VirtualBoxGNS3VM(BaseGNS3VM):
try:
resp = None
resp = yield from session.get('http://127.0.0.1:{}/v2/compute/network/interfaces'.format(api_port))
except (OSError, aiohttp.errors.ClientHttpProcessingError, TimeoutError):
except (OSError, aiohttp.errors.ClientHttpProcessingError, TimeoutError, asyncio.TimeoutError):
pass
if resp:
@@ -118,7 +118,10 @@ class VMwareGNS3VM(BaseGNS3VM):
if vmware_tools_state not in ("installed", "running"):
raise GNS3VMError("VMware tools are not installed in {}".format(self.vmname))
running = yield from self._is_running()
try:
running = yield from self._is_running()
except VMwareError as e:
raise GNS3VMError("Could not list VMware VMs: {}".format(str(e)))
if not running:
log.info("Update GNS3 VM settings")
# set the number of vCPUs and amount of RAM
+1 -1
View File
@@ -114,7 +114,7 @@ def import_project(controller, project_id, stream, location=None, name=None, kee
# unless it's a linux host without GNS3 VM
if not sys.platform.startswith("linux") or controller.has_compute("vm"):
for node in topology["topology"]["nodes"]:
if node["node_type"] in ("docker", "qemu", "iou"):
if node["node_type"] in ("docker", "qemu", "iou", "nat"):
node["compute_id"] = "vm"
else:
for node in topology["topology"]["nodes"]:
+4
View File
@@ -70,6 +70,10 @@ class Port:
return self._name
return self.short_name_type + "{}/{}".format(self._interface_number, self._port_number)
@short_name.setter
def short_name(self, val):
self._short_name = val
def __json__(self):
return {
"name": self._name,
+11 -3
View File
@@ -181,7 +181,9 @@ class DynamipsPortFactory:
ports = []
adapter_number = 0
wic_port_number = 16
wic_slot = 1
wic_port_number = wic_slot * 16
display_wic_port_number = 0
for name in sorted(properties.keys()):
if name.startswith("slot") and properties[name]:
port_class = cls.ADAPTER_MATRIX[properties[name]]["port"]
@@ -194,7 +196,13 @@ class DynamipsPortFactory:
port_class = cls.WIC_MATRIX[properties[name]]["port"]
if port_class:
for port_number in range(0, cls.WIC_MATRIX[properties[name]]["nb_ports"]):
name = "{}{}/{}".format(port_class.long_name_type(), 0, wic_port_number)
ports.append(port_class(name, 0, 0, wic_port_number))
name = "{}{}/{}".format(port_class.long_name_type(), 0, display_wic_port_number)
port = port_class(name, 0, 0, wic_port_number)
port.short_name = "{}{}/{}".format(port.short_name_type, 0, display_wic_port_number)
ports.append(port)
display_wic_port_number += 1
wic_port_number += 1
wic_slot += 1
wic_port_number = wic_slot * 16
return ports
+2
View File
@@ -55,6 +55,8 @@ class Symbols:
for file in os.listdir(directory):
if file.startswith('.'):
continue
if not os.path.isfile(os.path.join(directory, file)):
continue
symbol_id = file
symbols.append({
'symbol_id': symbol_id,
+13 -5
View File
@@ -125,7 +125,10 @@ def load_topology(path):
if "revision" not in topo or topo["revision"] < GNS3_FILE_FORMAT_REVISION:
# If it's an old GNS3 file we need to convert it
# first we backup the file
shutil.copy(path, path + ".backup{}".format(topo.get("revision", 0)))
try:
shutil.copy(path, path + ".backup{}".format(topo.get("revision", 0)))
except (OSError) as e:
raise aiohttp.web.HTTPConflict(text="Can't write backup of the topology {}: {}".format(path, str(e)))
changed = True
if "revision" not in topo or topo["revision"] < 5:
@@ -150,8 +153,11 @@ def load_topology(path):
raise e
if changed:
with open(path, "w+", encoding="utf-8") as f:
json.dump(topo, f, indent=4, sort_keys=True)
try:
with open(path, "w+", encoding="utf-8") as f:
json.dump(topo, f, indent=4, sort_keys=True)
except (OSError) as e:
raise aiohttp.web.HTTPConflict(text="Can't write the topology {}: {}".format(path, str(e)))
return topo
@@ -332,7 +338,7 @@ def _convert_1_3_later(topo, topo_path):
node["console_type"] = None
node["symbol"] = ":/symbols/hub.svg"
node["properties"]["ports_mapping"] = []
for port in old_node["ports"]:
for port in old_node.get("ports", []):
node["properties"]["ports_mapping"].append({
"name": "Ethernet{}".format(port["port_number"] - 1),
"port_number": port["port_number"] - 1
@@ -353,13 +359,15 @@ def _convert_1_3_later(topo, topo_path):
node["node_type"] = "frame_relay_switch"
node["symbol"] = ":/symbols/frame_relay_switch.svg"
node["console_type"] = None
elif old_node["type"] in ["C1700", "C2600", "C2691", "C3600", "C3725", "C3745", "C7200", "EtherSwitchRouter"]:
elif old_node["type"] in ["C1700", "C2600", "C2691", "C3600", "C3620", "C3640", "C3660", "C3725", "C3745", "C7200", "EtherSwitchRouter"]:
if node["symbol"] is None:
node["symbol"] = ":/symbols/router.svg"
node["node_type"] = "dynamips"
node["properties"]["dynamips_id"] = old_node.get("dynamips_id")
if "platform" not in node["properties"] and old_node["type"].startswith("C"):
node["properties"]["platform"] = old_node["type"].lower()
if node["properties"]["platform"].startswith("c36"):
node["properties"]["platform"] = "c3600"
if "ram" not in node["properties"] and old_node["type"].startswith("C"):
node["properties"]["ram"] = PLATFORMS_DEFAULT_RAM[old_node["type"].lower()]
elif old_node["type"] == "VMwareVM":