Changing ResourceManager naming for platform::ResourceName
[nepi.git] / examples / omf / nitos_omf6_ping.py
index 8626af6..5623a0e 100644 (file)
@@ -1,4 +1,6 @@
 #!/usr/bin/env python
+
+###############################################################################
 #
 #    NEPI, a framework to manage network experiments
 #    Copyright (C) 2013 INRIA
@@ -18,6 +20,8 @@
 #
 # Authors: Alina Quereilhac <alina.quereilhac@inria.fr>
 #         Julien Tribino <julien.tribino@inria.fr>
+#
+###############################################################################
       
 # Topology
 #
@@ -41,7 +45,6 @@
 #        - t2 (t1 + 10s) : Ping stop
 #        - t3 (t2 + 2s) : Kill the application
 #
-#
 
 from nepi.execution.ec import ExperimentController
 from nepi.execution.resource import ResourceAction, ResourceState
@@ -76,7 +79,7 @@ chan = options.channel
 ec = ExperimentController(exp_id="nitos_omf6_ping")
 
 # Create and Configure the Nodes
-node1 = ec.register_resource("OMFNode")
+node1 = ec.register_resource("omf::Node")
 ec.set(node1, "hostname", nodex)
 ec.set(node1, "xmppUser", slicename)
 ec.set(node1, "xmppServer", "nitlab.inf.uth.gr")
@@ -84,7 +87,7 @@ ec.set(node1, "xmppPort", "5222")
 ec.set(node1, "xmppPassword", "1234")
 
 # Create and Configure the Interfaces
-iface1 = ec.register_resource("OMFWifiInterface")
+iface1 = ec.register_resource("omf::WifiInterface")
 ec.set(iface1, "name", "wlan0")
 ec.set(iface1, "mode", "adhoc")
 ec.set(iface1, "hw_mode", "g")
@@ -93,7 +96,7 @@ ec.set(iface1, "ip", "192.168.0.%s/24" % nodex[-2:])
 ec.register_connection(node1, iface1)
 
 # Create and Configure the Nodes
-node2 = ec.register_resource("OMFNode")
+node2 = ec.register_resource("omf::Node")
 ec.set(node2, "hostname", nodez)
 ec.set(node2, "xmppUser", slicename)
 ec.set(node2, "xmppServer", "nitlab.inf.uth.gr")
@@ -101,7 +104,7 @@ ec.set(node2, "xmppPort", "5222")
 ec.set(node2, "xmppPassword", "1234")
 
 # Create and Configure the Interfaces
-iface2 = ec.register_resource("OMFWifiInterface")
+iface2 = ec.register_resource("omf::WifiInterface")
 ec.set(iface2, "name", "wlan0")
 ec.set(iface2, "mode", "adhoc")
 ec.set(iface2, "hw_mode", "g")
@@ -109,9 +112,8 @@ ec.set(iface2, "essid", "ping")
 ec.set(iface2, "ip", "192.168.0.%s/24" % nodez[-2:]) 
 ec.register_connection(node2, iface2)
 
-
 # Create and Configure the Channel
-channel = ec.register_resource("OMFChannel")
+channel = ec.register_resource("omf::Channel")
 ec.set(channel, "channel", chan)
 ec.set(channel, "xmppUser", slicename)
 ec.set(channel, "xmppServer", "nitlab.inf.uth.gr")
@@ -121,27 +123,23 @@ ec.register_connection(iface1, channel)
 ec.register_connection(iface2, channel)
 
 # Create and Configure the PING Application
-app1 = ec.register_resource("OMFApplication")
+app1 = ec.register_resource("omf::Application")
 ec.set(app1, "appid", "Ping#1")
 ec.set(app1, "command", "/bin/ping -c3 192.168.0.%s" % nodez[-2:])
 ec.register_connection(app1, node1)
 
-app2 = ec.register_resource("OMFApplication")
-ec.set(app2, "appid", "Kill#1")
-ec.set(app2, "command", "/usr/bin/killall ping")
-ec.register_connection(app2, node1)
-
-# User Behaviour
-ec.register_condition(app1, ResourceAction.STOP, app1, ResourceState.STARTED , "10s")
-ec.register_condition(app2, ResourceAction.START, app1, ResourceState.STARTED , "12s")
-ec.register_condition(app2, ResourceAction.STOP, app2, ResourceState.STARTED , "1s")
+## Make sure the ping stops after 30 seconds
+ec.register_condition(app1, ResourceAction.STOP, app1, 
+        ResourceState.STARTED , "30s")
 
 # Deploy
 ec.deploy()
 
-ec.wait_finished([app1, app2])
+ec.wait_finished([app1])
 
-print ec.trace(app1, "stdout")
+# Retrieve the output of the ping command
+ping_output = ec.trace(app1, "stdout")
+print "\n PING OUTPUT\n", ping_output, "\n"
 
 # Stop Experiment
 ec.shutdown()