Last active
December 24, 2020 15:10
-
-
Save hadisfr/d7ea6ebab9433d139622285b6f9ddba5 to your computer and use it in GitHub Desktop.
convert GNS3 v2.2 project files to v2.1.21
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import json | |
from sys import stderr, argv | |
def process(topoplogy): | |
del topoplogy["drawing_grid_size"] | |
topoplogy["revision"] = 8 | |
topoplogy["version"] = "2.1.21" | |
for node in topoplogy["topology"]["nodes"]: | |
del node["console_auto_start"] | |
del node["custom_adapters"] | |
del node["locked"] | |
del node["template_id"] | |
if "usage" in node["properties"]: | |
del node["properties"]["usage"] | |
if "extra_volumes" in node["properties"]: | |
del node["properties"]["extra_volumes"] | |
return topoplogy | |
def read_gns3(addr): | |
with open(addr) as f: | |
return json.load(f) | |
def write_gns3(topoplogy, addr): | |
with open(addr, "w") as f: | |
json.dump(topoplogy, f, indent=4) | |
def main(): | |
if len(argv) < 2: | |
print("usage:\t%s <project.gns3>" % argv[0], file=stderr) | |
exit(2) | |
topoplogy = read_gns3(argv[1]) | |
topoplogy = process(topoplogy) | |
write_gns3(topoplogy, argv[1]) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment