mirror of
https://github.com/GNS3/gns3-server.git
synced 2024-11-16 16:54:51 +02:00
Update the GNS3 version in topology file if converted. Ref https://github.com/GNS3/gns3-gui/issues/2798
This commit is contained in:
parent
2289fd4a2f
commit
81a48df9bb
@ -128,17 +128,18 @@ def load_topology(path):
|
|||||||
raise aiohttp.web.HTTPConflict(text="Could not load topology {}: {}".format(path, str(e)))
|
raise aiohttp.web.HTTPConflict(text="Could not load topology {}: {}".format(path, str(e)))
|
||||||
|
|
||||||
if topo.get("revision", 0) > GNS3_FILE_FORMAT_REVISION:
|
if topo.get("revision", 0) > GNS3_FILE_FORMAT_REVISION:
|
||||||
raise aiohttp.web.HTTPConflict(text="This project is designed for a more recent version of GNS3 please update GNS3 to version {} or later".format(topo["version"]))
|
raise aiohttp.web.HTTPConflict(text="This project was created with more recent version of GNS3 (file revision: {}). Please upgrade GNS3 to version {} or later".format(topo["revision"], topo["version"]))
|
||||||
|
|
||||||
changed = False
|
changed = False
|
||||||
if "revision" not in topo or topo["revision"] < GNS3_FILE_FORMAT_REVISION:
|
if "revision" not in topo or topo["revision"] < GNS3_FILE_FORMAT_REVISION:
|
||||||
# If it's an old GNS3 file we need to convert it
|
# Convert the topology if this is an old one but backup the file first
|
||||||
# first we backup the file
|
|
||||||
try:
|
try:
|
||||||
shutil.copy(path, path + ".backup{}".format(topo.get("revision", 0)))
|
shutil.copy(path, path + ".backup{}".format(topo.get("revision", 0)))
|
||||||
except (OSError) as e:
|
except OSError as e:
|
||||||
raise aiohttp.web.HTTPConflict(text="Can't write backup of the topology {}: {}".format(path, str(e)))
|
raise aiohttp.web.HTTPConflict(text="Can't write backup of the topology {}: {}".format(path, str(e)))
|
||||||
changed = True
|
changed = True
|
||||||
|
# update the version because we converted the topology
|
||||||
|
topo["version"] = __version__
|
||||||
|
|
||||||
if "revision" not in topo or topo["revision"] < 5:
|
if "revision" not in topo or topo["revision"] < 5:
|
||||||
topo = _convert_1_3_later(topo, path)
|
topo = _convert_1_3_later(topo, path)
|
||||||
|
Loading…
Reference in New Issue
Block a user