X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=emuvim%2Fexample_topology.py;h=2342fd10cd8d7b745ca90fda689b055f8d299dbb;hb=4854f59e1bc2ea4d5b3495880940b52f6823affe;hp=109808cbfdc6de6c118655ffb146c60c450c35e3;hpb=5b844a1abb3fa789d1d72f74c86d8e47c28b2dac;p=osm%2Fvim-emu.git diff --git a/emuvim/example_topology.py b/emuvim/example_topology.py old mode 100644 new mode 100755 index 109808c..2342fd1 --- a/emuvim/example_topology.py +++ b/emuvim/example_topology.py @@ -17,10 +17,12 @@ The original Mininet API has to be completely hidden and not be used by this script. """ import logging +from mininet.log import setLogLevel from dcemulator.net import DCNetwork from api.zerorpcapi import ZeroRpcApiEndpoint +from api.zerorpcapi_DCNetwork import ZeroRpcApiEndpointDCNetwork -logging.basicConfig(level=logging.DEBUG) +logging.basicConfig(level=logging.INFO) def create_topology1(): @@ -29,15 +31,23 @@ def create_topology1(): """ net = DCNetwork() + """ + 1b. add a monitoring agent to the DCNetwork + """ + mon_api = ZeroRpcApiEndpointDCNetwork("0.0.0.0", 5151) + mon_api.connectDCNetwork(net) + mon_api.start() """ 2. Add (logical) data centers to the topology (each data center is one "bigswitch" in our simplified first prototype) """ - dc1 = net.addDatacenter("dc1") - dc2 = net.addDatacenter("dc2") - dc3 = net.addDatacenter("dc3") - dc4 = net.addDatacenter("dc4") + dc1 = net.addDatacenter("datacenter1") + dc2 = net.addDatacenter("datacenter2") + dc3 = net.addDatacenter("long_data_center_name3") + dc4 = net.addDatacenter( + "datacenter4", + metadata={"mydata": "we can also add arbitrary metadata to each DC"}) """ 3. You can add additional SDN switches for data center @@ -51,9 +61,9 @@ def create_topology1(): These links can use Mininet's features to limit bw, add delay or jitter. """ net.addLink(dc1, dc2) - net.addLink("dc1", s1) - net.addLink(s1, "dc3") - net.addLink(s1, dc4) + net.addLink("datacenter1", s1) + net.addLink(s1, dc3) + net.addLink(s1, "datacenter4") """ 5. We want to access and control our data centers from the outside, @@ -70,12 +80,14 @@ def create_topology1(): # connect data centers to this endpoint zapi1.connectDatacenter(dc1) zapi1.connectDatacenter(dc2) + zapi1.connectDatacenter(dc3) + zapi1.connectDatacenter(dc4) # run API endpoint server (in another thread, don't block) zapi1.start() """ 5.1. For our example, we create a second endpoint to illustrate that - this is support by our design. This feature allows us to have + this is supported by our design. This feature allows us to have one API endpoint for each data center. This makes the emulation environment more realistic because you can easily create one OpenStack-like REST API endpoint for *each* data center. @@ -97,10 +109,13 @@ def create_topology1(): net.start() net.CLI() # when the user types exit in the CLI, we stop the emulator + # we need to explicitly stop the monitoring api, so the Ryu controller is also terminated + mon_api.stop() net.stop() def main(): + setLogLevel('info') # set Mininet loglevel create_topology1()