# 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
# - 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 <nodex> -z <nodez> -s <slice-name> -c <channel>")
+usage = ("usage: %prog -x <nodex> -y <nodey> -c <channel> -u <slicename> -g <nitos-gateway>")
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")
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 Nodes
node2 = ec.register_resource("omf::Node")
-ec.set(node2, "hostname", nodez)
+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")
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("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)
# Create and Configure the PING Application
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
# 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()