Replies: 2 comments 5 replies
-
Related issue: #708 |
Beta Was this translation helpful? Give feedback.
1 reply
-
Is this possibly an opportunity for a feature? The ability to extend GNS3 functionality by having custom python scripts be added tot he tools menu by placing them in a specific folder or importing them? As long as the script does not use any libraries not already available from the GNS3 install, could the GNS3 binaries run the script without the host having python installed? Even then, could just be a thing that if people want to use extensions, they need to install python. |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I developed a solution, where programs / scripts stored in the
GNS3/tools
folder are available in the main "Tools" menu ...... and the context menu.
This is not part of the standard GNS3 program. You have to download the source of the GNS3 GUI with git, select branch "2.2", download the patches from https://github.com/grossmj/gns3-gui-tools and integrate them into the GUI source with
git am <path to patches>/*
. Then install the GUI withpip3 install .
. So that's only feasible for very experienced users.Tools are executables, that are called by the GNS3 GUI. They normally use the GNS3 API (https://gns3-server.readthedocs.io/) to query and/or modify the current project. The GNS3 GUI is automatically updated, when the project is changed. The programs are installed in the
GNS3/tools
directory. As the GNS3 GUI checks this directory only at startup, it has to be restarted after adding/removing tools. A short documentation can be found at https://github.com/grossmj/gns3-gui-tools/blob/master/tools.md.The tool can be accompanied by a JSON file, that allows to define some properties. I haven't done that within the GNS3 configuration menu, because I think, that the creator of a tool should define the parameters. The typical user should not be bothered with this.
The option "run in terminal" is mainly implemented to make debugging easy during development. But it also allows to integrate programs without a GUI. In Windows it's also needed to run Python scripts, Windows refuses to run them in GUI mode.
One major drawback is, that it's not easy to distribute these tools. If you want to distribute binaries, you need to create them for Windows, Linux and Mac OS X. If you're using a script language like Python, the user has to install that language. One solution could be a full Python 3 for Windows and OS X included in the GNS3 package. But that would significantly increase the size of GNS3.
Example: Close Project
The GNS3 GUI doesn't allow to close a project without opening a new one. But sometimes, when changing settings, I want to be sure that no project is open.
This Python script
close_project.py
closes a GNS3 project. It uses the GNS3 API module gns3api (https://github.com/b-ehlers/gns3api-python). The easiest way is to download gns3api.py and store it in theGNS3/tools
folder. No other non-standard modules are used.With the attached
close_project.json
it won't show up in the context menu. So it's only available in the main "Tools" menu.Windows only:
"terminal": true
toclose_project.json
.gns3api.json
with{ "menu": false, "context": false }
.More Examples
A collection of (mostly small) tools is available at https://github.com/Raizo62/gns3-tools-python.
Beta Was this translation helpful? Give feedback.
All reactions