seed-labs / seed-emulator

A Python framework for creating emulation of the Internet.
GNU General Public License v3.0
209 stars 79 forks source link

Get APIs for various core classes #29

Open kevin-w-du opened 3 years ago

kevin-w-du commented 3 years ago

It will be great if we can provide the APIs in each class to allow users to enumerate its direct internal elements. I do see some classes already have such APIs, but not all. These APIs will be very helpful for others to build on top of an existing base-layer component.

magicnat commented 3 years ago

The problem with these is that a lot of the information are not in the class themself. These API will not be possible unless you want them to available only after render.

Problem with the InternetExchange and AutonomousSystem class is that they do not know what ASes are connected to them (at least not before the emulator is rendered, as all peering are stored in the Ebgp layer)

Networks, too, do not know what hosts/routers are connected before rendered. There is a getAssociations to get a list of connected nodes after the render.

Router do know a list of names of the networks they have connected to before render, but those are just names, not the actual Network object.

The reason for using names instead of the actual object is to allow connecting to a network that does not exist yet - which can happen when using a component.

Host also cannot do getServices before render, but should be possible to add after render.

kevin-w-du commented 3 years ago

Returning names is fine.

It seems that adding these APIs is difficult. We will keep this issue open, and see whether we can come up with ideas to do it (maybe in other ways). The goal is to help users get an instance of an object without knowing names.

For example, after loading a base component, I would like to add a host to a network within an AS, but I don't want to be bothered with the name of the network (this name is supposed to be an internal name).