python examples, removed params common local module to avoid confusion, clean things up a bit and added a module doc to help explain the file

This commit is contained in:
Blake Harnden 2020-04-18 08:11:12 -07:00
parent 7da7ea5d62
commit d659a5c139
5 changed files with 57 additions and 93 deletions

View file

@ -1,10 +1,19 @@
"""
This is a script to run a small switch based scenario and depends on
the user running this script through the "Execute Python Script" option
in the GUI. The usage of globals() below allows this script to leverage the
same CoreEmu instance the GUI is using.
"""
import logging
from core.emulator.emudata import IpPrefixes
from core.emulator.enumerations import EventTypes, NodeTypes
NODES = 2
def example(nodes):
def main():
# ip generator for example
prefixes = IpPrefixes("10.83.0.0/16")
@ -19,7 +28,7 @@ def example(nodes):
switch = session.add_node(_type=NodeTypes.SWITCH)
# create nodes
for _ in range(nodes):
for _ in range(NODES):
node = session.add_node()
interface = prefixes.create_interface(node)
session.add_link(node.id, switch.id, interface_one=interface)
@ -30,4 +39,4 @@ def example(nodes):
if __name__ in {"__main__", "__builtin__"}:
logging.basicConfig(level=logging.INFO)
example(2)
main()