-"""
- 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 <http://www.gnu.org/licenses/>.
+#!/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 <http://www.gnu.org/licenses/>.
+#
+# Author: Alina Quereilhac <alina.quereilhac@inria.fr>
+# Julien Tribino <julien.tribino@inria.fr>
- Author: Alina Quereilhac <alina.quereilhac@inria.fr>
- Julien Tribino <julien.tribino@inria.fr>
+"""
Example :
- Testbed : Nitos
"""
-#!/usr/bin/env python
from nepi.execution.resource import ResourceFactory, ResourceAction, ResourceState
from nepi.execution.ec import ExperimentController
### Define OMF Method to simplify definition of resources ###
def add_node(ec, hostname, xmppServer, xmppUser, xmppPort = "5222", xmppPassword = "1234"):
- node = ec.register_resource("OMFNode")
+ node = ec.register_resource("omf::Node")
ec.set(node, 'hostname', hostname)
ec.set(node, 'xmppServer', xmppServer)
ec.set(node, 'xmppUser', xmppUser)
def add_interface(ec, ip, xmppServer, xmppUser, essid = "ccn", name = "wlan0", mode = "adhoc",
typ = "g", xmppPort = "5222", xmppPassword = "1234"):
- iface = ec.register_resource("OMFWifiInterface")
+ iface = ec.register_resource("omf::WifiInterface")
ec.set(iface, 'name', name)
ec.set(iface, 'mode', mode)
ec.set(iface, 'hw_mode', typ)
return iface
def add_channel(ec, channel, xmppServer, xmppUser, xmppPort = "5222", xmppPassword = "1234"):
- chan = ec.register_resource("OMFChannel")
+ chan = ec.register_resource("omf::Channel")
ec.set(chan, 'channel', channel)
ec.set(chan, 'xmppServer', xmppServer)
ec.set(chan, 'xmppUser', xmppUser)
def add_app(ec, host, appid, command, env, xmppServer, xmppUser,
xmppPort = "5222", xmppPassword = "1234"):
- app = ec.register_resource("OMFApplication")
+ app = ec.register_resource("omf::Application")
ec.set(app, 'appid', appid)
ec.set(app, 'command', command)
ec.set(app, 'env', env)
nodes = dict()
chann = add_channel(ec, channel, xmpp_slice, xmpp_host)
- for i in xrange(len(all_hosts)):
- node = add_node(ec,all_hosts[i], xmpp_slice, xmpp_host)
+ for i, host in enumerate(all_hosts):
+ node = add_node(ec ,host, xmpp_slice, xmpp_host)
iface = add_interface(ec, all_ip[i], xmpp_slice, xmpp_host)
ec.register_connection(node, iface)
ec.register_connection(iface, chann)
- nodes[all_hosts[i]] = node
+ nodes[host] = node
# CCN setup for the node
ccnds = dict()
ccnrs = dict()
- for i in xrange(len(all_hosts)):
- ccndstart = add_app(ec, nodes[all_hosts[i]], "#ccndstart", "ccndstart &",
+ for i, host in enumerate(all_hosts):
+ ccndstart = add_app(ec, nodes[host], "#ccndstart", "ccndstart &",
env, xmpp_slice, xmpp_host)
- ccnr = add_app(ec, nodes[all_hosts[i]], "#ccnr", "ccnr &",
+ ccnr = add_app(ec, nodes[host], "#ccnr", "ccnr &",
env, xmpp_slice, xmpp_host)
- ccnds[all_hosts[i]] = ccndstart
- ccnrs[all_hosts[i]] = ccnr
+ ccnds[host] = ccndstart
+ ccnrs[host] = ccnr
ec.register_condition(ccnr, ResourceAction.START, ccndstart, ResourceState.STARTED, "1s")
# CCNDC setup
link = [l1u, l1d, l2u, l2d, l3u, l3d, l4u, l4d, l5u, l5d, b1u, b1d, b2u, b2d]
# List of condition
- for i in xrange(len(all_hosts)):
- ec.register_condition(ccnrs[all_hosts[i]], ResourceAction.START, ccnds[all_hosts[i]], ResourceState.STARTED, "1s")
- ec.register_condition(link, ResourceAction.START, ccnrs[all_hosts[i]], ResourceState.STARTED, "1s")
+ for host in all_hosts:
+ ec.register_condition(ccnrs[host], ResourceAction.START, ccnds[host], ResourceState.STARTED, "1s")
+ ec.register_condition(link, ResourceAction.START, ccnrs[host], ResourceState.STARTED, "1s")
# Streaming Server
pub = add_publish(ec, nodes[host5], movie, xmpp_slice, xmpp_host)
# Cleaning when the experiment stop
ccndstops = []
- for i in xrange(len(all_hosts)):
- ccndstop = add_app(ec, nodes[all_hosts[i]], "#ccndstop", "ccndstop", env, xmpp_slice, xmpp_host)
+ for host all_hosts:
+ ccndstop = add_app(ec, nodes[host], "#ccndstop", "ccndstop", env, xmpp_slice, xmpp_host)
ccndstops.append(ccndstop)
killall = add_app(ec, nodes[host6], "#kill", "killall sh", "", xmpp_slice, xmpp_host)
# Condition to stop and clean the experiment
apps = []
- for i in xrange(len(all_hosts)):
- apps.append(ccnds[all_hosts[i]])
- apps.append(ccnrs[all_hosts[i]])
+ for host in all_hosts:
+ apps.append(ccnds[host])
+ apps.append(ccnrs[host])
apps += link
apps.append(pub)
apps.append(stream)