How to use the autonetkit.NetworkModel function in autonetkit

To help you get started, we’ve selected a few autonetkit examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sk2 / autonetkit / tests / test_serialization.py View on Github external
automated = True # whether to open ksdiff, log to file...
    if __name__ == "__main__":
        automated = False

    dirname, filename = os.path.split(os.path.abspath(__file__))

    anm =  autonetkit.NetworkModel()
    input_file = os.path.join(dirname, "small_internet.graphml")
    input_graph = graphml.load_graphml(input_file)

    import autonetkit.build_network as build_network
    anm = build_network.initialise(input_graph)
    anm = build_network.apply_design_rules(anm)
    anm.save()
    anm_restored =  autonetkit.NetworkModel()
    anm_restored.restore_latest()
    g_phy_original = anm['phy']
    g_phy_restored = anm_restored['phy']
    assert(all(n in g_phy_restored for n in g_phy_original))

    #TODO: do more extensive deep check of parameters

    import autonetkit.workflow as workflow
    render_hostname = "localhost"

    nidb = workflow.create_nidb(anm)
    import autonetkit.compilers.platform.netkit as pl_netkit
    nk_compiler = pl_netkit.NetkitCompiler(nidb, anm, render_hostname)
    nk_compiler.compile()

    nidb.save()
github sk2 / autonetkit / tests / test_graphml.py View on Github external
def build_anm(topology_name):
    print "Building anm for %s" % topology_name
    dirname, filename = os.path.split(os.path.abspath(__file__))
    input_filename = os.path.join(dirname, "%s.graphml" % topology_name)

    anm =  autonetkit.NetworkModel()
    input_graph = graphml.load_graphml(input_filename)

    import autonetkit.build_network as build_network
    anm = build_network.initialise(input_graph)
    anm = build_network.apply_design_rules(anm)
    return anm
github sk2 / autonetkit / tests / test_anm.py View on Github external
def test():
    log.info("Testing ANM")

    anm = autonetkit.NetworkModel()

    g_in = anm.add_overlay("input")

    router_ids = ["r1", "r2", "r3", "r4", "r5"]
    g_in.add_nodes_from(router_ids)

    g_in.update(device_type = "router")
    g_in.update(asn = 1)

    positions = {'r3': (107, 250), 'r5': (380, 290), 'r1': (22, 50), 'r2': (377, 9), 'r4': (571, 229)}
    for node in g_in:
        node.x = positions[node][0]
        node.y = positions[node][1]
        eth0 = node.add_interface("eth0")
        eth0.speed = 100
github sk2 / autonetkit / tests / small_internet / test_small_internet.py View on Github external
def test():
    automated = True # whether to open ksdiff, log to file...
    if __name__ == "__main__":
        automated = False

    dirname, filename = os.path.split(os.path.abspath(__file__))

    anm =  autonetkit.NetworkModel()
    input_file = os.path.join(dirname, "small_internet.graphml")
    input_graph = graphml.load_graphml(input_file)

    import autonetkit.build_network as build_network
    anm = build_network.initialise(input_graph)
    anm = build_network.apply_design_rules(anm)

    import autonetkit.console_script as console_script
    render_hostname = "localhost"

    nidb = console_script.create_nidb(anm)
    import autonetkit.compilers.platform.netkit as pl_netkit
    nk_compiler = pl_netkit.NetkitCompiler(nidb, anm, render_hostname)
    nk_compiler.compile()

    import autonetkit.render
github sk2 / autonetkit / tests / webserver / test_webserver.py View on Github external
def test():
	automated = True # whether to open ksdiff, log to file...
	if __name__ == "__main__":
	    automated = False

	dirname, filename = os.path.split(os.path.abspath(__file__))
	parent_dir = os.path.abspath(os.path.join(dirname, os.pardir))

	anm =  autonetkit.NetworkModel()
	input_file = os.path.join(parent_dir, "small_internet.graphml")
	input_graph = graphml.load_graphml(input_file)

	import autonetkit.build_network as build_network
	anm = build_network.initialise(input_graph)
	anm = build_network.apply_design_rules(anm)



	try:
		from websocket import create_connection
	except ImportError:
		print "websocket-client package not installed"
	else:
		autonetkit.update_http(anm)
github sk2 / autonetkit / tests / test_save_json.py View on Github external
def setup_input():
    anm = autonetkit.NetworkModel()

    g_in = anm.add_overlay("input")

    r1 = g_in.add_node("r1", x=100, y=100)
    r2 = g_in.add_node("r2", x=250, y=250)

    g_in.update(device_type="router")
    g_in.update(asn=1)

    r1_eth0 = r1.add_interface("eth0", id="eth0")
    r2_eth0 = r2.add_interface("eth0", id="eth0")

    g_in.add_edge(r1_eth0, r2_eth0, type="physical")

    print g_in.edges()