update example_topology.py
[osm/vim-emu.git] / emuvim / example_topology.py
old mode 100644 (file)
new mode 100755 (executable)
index 3c49f99..35c87af
@@ -30,6 +30,13 @@ 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
@@ -37,8 +44,10 @@ def create_topology1():
     """
     dc1 = net.addDatacenter("datacenter1")
     dc2 = net.addDatacenter("datacenter2")
-    dc3 = net.addDatacenter("a_very_long_data_center_name3")
-    dc4 = net.addDatacenter("datacenter4")
+    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
@@ -71,6 +80,8 @@ 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()
 
@@ -98,6 +109,8 @@ 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()