X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=examples%2Fomf%2Ftesting%2Fnepi_omf6_plexus_ping_with_traces.py;h=01125f3f72101331d14242e75b6e581355323f1a;hb=cb5d027b813a27d7de263653e1a8e0cef5490f0a;hp=1e76917ff481f4b1fd6612e0e92ba1caa629bbf4;hpb=00431238a3265413c51e3500423d6462e2ab0505;p=nepi.git
diff --git a/examples/omf/testing/nepi_omf6_plexus_ping_with_traces.py b/examples/omf/testing/nepi_omf6_plexus_ping_with_traces.py
index 1e76917f..01125f3f 100644
--- a/examples/omf/testing/nepi_omf6_plexus_ping_with_traces.py
+++ b/examples/omf/testing/nepi_omf6_plexus_ping_with_traces.py
@@ -1,27 +1,23 @@
-"""
- NEPI, a framework to manage network experiments
- Copyright (C) 2013 INRIA
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see .
-
- Author: Alina Quereilhac
- Julien Tribino
-
-
-"""
-
#!/usr/bin/env python
+#
+# NEPI, a framework to manage network experiments
+# Copyright (C) 2013 INRIA
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation;
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+#
+# Author: Alina Quereilhac
+# Julien Tribino
+
from nepi.execution.resource import ResourceFactory, ResourceAction, ResourceState
from nepi.execution.ec import ExperimentController
@@ -30,43 +26,43 @@ ec = ExperimentController()
# Create and Configure the Nodes
-node1 = ec.register_resource("OMFNode")
+node1 = ec.register_resource("omf::Node")
ec.set(node1, 'hostname', 'wlab12')
ec.set(node1, 'xmppServer', "xmpp-plexus.onelab.eu")
ec.set(node1, 'xmppUser', "nepi")
ec.set(node1, 'xmppPort', "5222")
ec.set(node1, 'xmppPassword', "1234")
-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")
ec.set(iface1, 'essid', "ping")
ec.set(iface1, 'ip', "192.168.0.12/24")
-node2 = ec.register_resource("OMFNode")
+node2 = ec.register_resource("omf::Node")
ec.set(node2, 'hostname', 'wlab49')
ec.set(node2, 'xmppServer', "xmpp-plexus.onelab.eu")
ec.set(node2, 'xmppUser', "nepi")
ec.set(node2, 'xmppPort', "5222")
ec.set(node2, 'xmppPassword', "1234")
-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")
ec.set(iface2, 'essid', "ping")
ec.set(iface2, 'ip', "192.168.0.49/24")
-chan = ec.register_resource("OMFChannel")
+chan = ec.register_resource("omf::Channel")
ec.set(chan, 'channel', "6")
# Create and Configure the Application
-app1 = ec.register_resource("OMFApplication")
+app1 = ec.register_resource("omf::Application")
ec.set(app1, 'command', '/bin/ping -c5 192.168.0.49')
ec.set(app1, 'env', "")
-app2 = ec.register_resource("OMFApplication")
+app2 = ec.register_resource("omf::Application")
ec.set(app2, 'command', '/bin/ping -c5 192.168.0.12')
ec.set(app2, 'env', "")
@@ -94,13 +90,11 @@ stdout_2 = ec.trace(app2, "stdout")
# Choose a directory to store the traces, by default
# It it the folder ehere you run Nepi.
-f = open("app1.txt", "w")
-f.write(stdout_1)
-f.close()
+with open("app1.txt", "w") as f:
+ f.write(stdout_1)
-g = open("app2.txt", "w")
-g.write(stdout_2)
-g.close()
+with open("app2.txt", "w") as g:
+ g.write(stdout_2)
# Stop Experiment
ec.shutdown()