# 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
# Alina Quereilhac <alina.quereilhac@inria.fr>
#
# Topology :
-#
+#
+# x.x.x.1 x.x.x.2
# Switch1 -------- Switch2
# / \
# / \
# / \
# Host1 Host2
-#
+# x.x.x.3 x.x.x.4
#
# Execution example:
#
# $ PYTHONPATH=$PYTHONPATH:src/ python examples/openvswitch/ovs_ping_2_switches.py -n "192.168.3.0/24" -C "1.1.1.1" -s <slicename> -i /~/.ssh/id_rsa
#
+from __future__ import print_function
+
from nepi.execution.ec import ExperimentController
import os
ec.set(tap, "ip", ip)
ec.set(tap, "prefix", prefix)
ec.set(tap, "pointopoint", pointopoint)
- ec.set(tap, "up", True)
ec.register_connection(tap, node)
return tap
switch1 = "planetlab2.virtues.fi"
switch2 = "planetlab2.upc.es"
- host1 = "planetlab2.ionio.gr"
+ host1 = "planetlab2.s3.kth.se"
host2 = "iraplab2.iralab.uni-karlsruhe.de"
parser = OptionParser(usage = usage)
ip3 = "%s.3" % ".".join(net_segs[:-1]) # x.x.x.3
ip4 = "%s.4" % ".".join(net_segs[:-1]) # x.x.x.4
+### Define topology
+
+# Add switches
s1_node = add_node(ec, switch1, slicename, pl_user, pl_pass, identity)
s2_node = add_node(ec, switch2, slicename, pl_user, pl_pass, identity)
port2 = add_port(ec, "nepi_port2", network, ovs2)
port4 = add_port(ec, "nepi_port4", network, ovs2)
+# Add hosts
h1_node = add_node(ec, host1, slicename, pl_user, pl_pass, identity)
h2_node = add_node(ec, host2, slicename, pl_user, pl_pass, identity)
+### Add overlay
# Add tap devices
tap1 = add_tap(ec, ip3, prefix, ip1, h1_node)
tap2 = add_tap(ec, ip4, prefix, ip2, h2_node)
tunnel2 = add_tunnel(ec, port2, tap2)
tunnel3 = add_tunnel(ec, port3, port4)
-# Ping switch 1 to switch2
-app1 = add_app(ec, "ping -c5 %s" % ip2, s1_node)
-# Ping switch 1 to host1
-app2 = add_app(ec, "ping -c5 %s" % ip3, s1_node)
-# Ping switch 1 to host2
-app3 = add_app(ec, "ping -c5 %s" % ip4, s1_node)
-
-# Ping switch 2 to switch1
-app4 = add_app(ec, "ping -c5 %s" % ip1, s2_node)
-# Ping switch 2 to host1
-app5 = add_app(ec, "ping -c5 %s" % ip3, s2_node)
-# Ping switch 2 to host2
-app6 = add_app(ec, "ping -c5 %s" % ip4, s2_node)
-
-# Ping host 1 to switch 1
-app7 = add_app(ec, "ping -c5 %s" % ip1, h1_node)
-# Ping host 1 to switch 2
-app8 = add_app(ec, "ping -c5 %s" % ip2, h1_node)
-# Ping host 1 to host 2
-app9 = add_app(ec, "ping -c5 %s" % ip4, h1_node)
-
-# Ping host 2 to switch 1
-app10 = add_app(ec, "ping -c5 %s" % ip1, h2_node)
-# Ping host 2 to switch 2
-app11 = add_app(ec, "ping -c5 %s" % ip2, h2_node)
-# Ping host 2 to host1
-app12 = add_app(ec, "ping -c5 %s" % ip3, h2_node)
+### Add Ping
+app = add_app(ec, "ping -c5 %s" % ip4, h1_node)
ec.deploy()
-ec.wait_finished([app1, app2, app3, app4, app5, app6,
- app7, app8, app9, app10, app11, app12])
+ec.wait_finished([app])
# Retreive ping results and save them in a file
-ping1 = ec.trace(app1, "stdout")
-ping2 = ec.trace(app2, "stdout")
-ping3 = ec.trace(app3, "stdout")
-ping4 = ec.trace(app4, "stdout")
-ping5 = ec.trace(app5, "stdout")
-ping6 = ec.trace(app6, "stdout")
-ping7 = ec.trace(app7, "stdout")
-ping8 = ec.trace(app8, "stdout")
-ping9 = ec.trace(app9, "stdout")
-ping10 = ec.trace(app10, "stdout")
-ping11 = ec.trace(app11, "stdout")
-ping12 = ec.trace(app12, "stdout")
-
-if not ping12:
- ec.shutdown()
- sys.exit("No ping found")
-
-f = open("ovs_ping_2_switches.txt", 'w')
-f.write("************ Ping From Switch 1 : %s ********************\n\n\n" % ip1)
-f.write(ping1)
-f.write("----------------------------------------\n\n")
-f.write(ping2)
-f.write("----------------------------------------\n\n")
-f.write(ping3)
-
-f.write("************ Ping From Switch 2 : %s ********************\n\n\n" % ip2)
-f.write(ping4)
-f.write("----------------------------------------\n\n")
-f.write(ping5)
-f.write("----------------------------------------\n\n")
-f.write(ping6)
-
-f.write("************ Ping From Host 1 : %s ********************\n\n\n" % ip3)
-f.write(ping7)
-f.write("----------------------------------------\n\n")
-f.write(ping8)
-f.write("----------------------------------------\n\n")
-f.write(ping9)
-
-f.write("************ Ping From Host 2 : %s ********************\n\n\n" % ip4)
-f.write(ping10)
-f.write("----------------------------------------\n\n")
-f.write(ping11)
-f.write("----------------------------------------\n\n")
-f.write(ping12)
-
-f.close()
+stdout = ec.trace(app, "stdout")
# Delete the overlay network
ec.shutdown()
-
+print(stdout)