GNS3 / gns3-server

GNS3 server
GNU General Public License v3.0
798 stars 262 forks source link

GNS3 Python API #353

Open julien-duponchelle opened 8 years ago

julien-duponchelle commented 8 years ago

From @grossmj on November 5, 2015 21:27

It would be great to have a python module to access GNS3 topology control, like:

Emulated Links. The data rate of each link is enforced by Linux Traffic Control (tc), which has a number of packet schedulers to shape traffic to a configured rate... ex: self.addLink(host, switch, bw=10, delay='5ms', loss=10, max_queue_size=1000)

Copied from original issue: GNS3/gns3-gui#790

julien-duponchelle commented 8 years ago

It's partially done with the REST Api. But the management of multiple servers make it hard to use for users.

boenrobot commented 8 years ago

I wouldn't mind a similar feature for importing/exporting configs out of VMs.

Because each VM could potentially be any type of guest OS, it would be great if the user could instruct GNS3 on what the guest OS is, and then based on that, enable the import/export of configurations.

3rd parties should be able to register one or more new types of guest OS-es that they can import/export configs for, and have those handlers executable from the GUI.

julien-duponchelle commented 8 years ago

Yes good remark

Le dim. 27 déc. 2015 18:58, Vasil Rangelov notifications@github.com a écrit :

I wouldn't mind a similar feature for importing/exporting configs out of VMs.

Because each VM could potentially be any type of guest OS, it would be great if the user could instruct GNS3 on what the guest OS is, and then based on that, enable the import/export of configurations.

3rd parties should be able to register one or more new types of guest OS-es that they can import/export configs for, and have those handlers executable from the GUI.

— Reply to this email directly or view it on GitHub https://github.com/GNS3/gns3-server/issues/353#issuecomment-167431046.

grossmj commented 8 years ago

We need a higher lever API which will come with https://github.com/GNS3/gns3-server/issues/417

mvdwoord commented 7 years ago

Hi, I was looking for this functionality and decided to give it a try to build something myself. It is very much just a beginning at the moment, only implemented some basic GET requests basically. I am not by any means a seasoned developer, only been using GNS3 for a week or two but figured it would be at the very least a useful experience for myself.

If any of you could have a look at the example notebook and let me know what you think.. that would be greatly appreciated. Link to full repo

If this is vaguely in the direction you have in mind I would be more than willing to invest some time in the upcoming weeks to build it out... otherwise I will focus just on scratching my own itch with this and stay out of your way.

Thanks! Maarten

grossmj commented 7 years ago

Hi @mvdwoord, we definitely welcome your contribution

I think this is a great start, keep it simple for users and clean :+1:

Let us know if you have questions.

mvdwoord commented 7 years ago

Cool.. I'd like to keep it simple enough for myself to use ;) Put it on PyPi for convenience... will try to keep it updated with progress. It is raining cats and dogs on my planned hiking holiday so should be able to get something done ;)

3 questions:

Thanks

grossmj commented 7 years ago

What is a good place for more questions? this issue? Forum?

Yes, please use this issue.

Is there a (machine readable) spec for the API?

We generate HTML files describing the API (the ones you can see on http://api.gns3.net) by using this script: https://github.com/GNS3/gns3-server/blob/master/scripts/documentation.sh

The script reads files containing Python dict in this directory https://github.com/GNS3/gns3-server/blob/master/gns3server/schemas/, these represent the API.

Who maintains the API for GNS3 and how can I contact?

We do, you can contact us here. If you need more active discussions we could invite you to our Slack discussion channel.

Just let us know.

mvdwoord commented 7 years ago

Perfect. The schema files will definitely be useful at a later stage.

I am working on implementing more and more of the classes in the Controller endpoint for now. Most of them still GET requests, and need to work on the Nodes next. I will wait until I have implemented all (or most) of that, and save up any questions for after that. In the mean time check out the Example Notebook to get an idea of the direction so far.

Just pushed out version 0.2.0dev to Github/PyPi Thanks.

grossmj commented 5 years ago

Python wrapper around GNS3 Server API https://davidban77.github.io/gns3fy/

grossmj commented 4 years ago

VIRL2 has an Python client. This could be good inspiration for us ;)

https://github.com/CiscoDevNet/virl2-client

ziajka commented 4 years ago

Once we introduce Swagger we can generate the client in many languages: https://github.com/swagger-api/swagger-codegen