X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=examples%2Fomf%2Fnitos_omf6_ping.py;h=6deaf18e405cdccc46c17ad647275d034114c006;hb=039fbd9629d7570d4c175a5448d24badcd0f3aba;hp=1f6d87169479bf37e2cf98cf6251d5c4d4fe0b20;hpb=02869f33bedd89aa8371b84e8e3b059800e23f53;p=nepi.git diff --git a/examples/omf/nitos_omf6_ping.py b/examples/omf/nitos_omf6_ping.py index 1f6d8716..6deaf18e 100644 --- a/examples/omf/nitos_omf6_ping.py +++ b/examples/omf/nitos_omf6_ping.py @@ -6,9 +6,8 @@ # 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. +# 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 @@ -46,48 +45,60 @@ # - t3 (t2 + 2s) : Kill the application # +from __future__ import print_function + from nepi.execution.ec import ExperimentController from nepi.execution.resource import ResourceAction, ResourceState from optparse import OptionParser import os -usage = ("usage: %prog -x -z -s -c ") +usage = ("usage: %prog -x -y -c -u -g ") parser = OptionParser(usage = usage) parser.add_option("-x", "--nodex", dest="nodex", help="Nitos first reserved node " - "(e.g. hostname must be of form: node0XX)", + "(e.g. hostname must be of form: omf.nitos.node0XX)", type="str") -parser.add_option("-z", "--nodez", dest="nodez", +parser.add_option("-y", "--nodey", dest="nodey", help="Nitos second reserved node " - "(e.g. hostname must be of form: node0ZZ)", + "(e.g. hostname must be of form: omf.nitos.node0YY)", type="str") parser.add_option("-c", "--channel", dest="channel", help="Nitos reserved channel", type="str") -parser.add_option("-s", "--slice-name", dest="slicename", - help="Nitos slice name", type="str") +parser.add_option("-g", "--gateway", dest="gateway", + help="Nitos gateway hostname", + type="str", default="nitlab.inf.uth.gr") +parser.add_option("-u", "--slicename", dest="slicename", + help="Nitos gateway username (slicename)", + type="str") + (options, args) = parser.parse_args() -nodex = options.nodex -nodez = options.nodez +if not options.channel or not options.nodex or \ + not options.nodey or not options.slicename: + parser.error("Missing argument channel, nodex, nodey, or slicename!") + +nodex = options.nodex.split(".")[-1] +nodey = options.nodey.split(".")[-1] slicename = options.slicename chan = options.channel +gateway = options.gateway # Create the EC 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") +ec.set(node1, "xmppServer", gateway) 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") @@ -96,36 +107,36 @@ 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") -ec.set(node2, "hostname", nodez) +node2 = ec.register_resource("omf::Node") +ec.set(node2, "hostname", nodey) ec.set(node2, "xmppUser", slicename) -ec.set(node2, "xmppServer", "nitlab.inf.uth.gr") +ec.set(node2, "xmppServer", gateway) 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") ec.set(iface2, "essid", "ping") -ec.set(iface2, "ip", "192.168.0.%s/24" % nodez[-2:]) +ec.set(iface2, "ip", "192.168.0.%s/24" % nodey[-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") +ec.set(channel, "xmppServer", gateway) ec.set(channel, "xmppPort", "5222") ec.set(channel, "xmppPassword", "1234") 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.set(app1, "command", "/bin/ping -c3 192.168.0.%s" % nodey[-2:]) ec.register_connection(app1, node1) ## Make sure the ping stops after 30 seconds @@ -139,7 +150,7 @@ ec.wait_finished([app1]) # Retrieve the output of the ping command ping_output = ec.trace(app1, "stdout") -print "\n PING OUTPUT\n", ping_output, "\n" +print("\n PING OUTPUT\n", ping_output, "\n") # Stop Experiment ec.shutdown()