change topology_rest.py and pingallm.py to use config file
diff --git a/web/config.json.hw b/web/config.json.hw
new file mode 100644
index 0000000..493a2b4
--- /dev/null
+++ b/web/config.json.hw
@@ -0,0 +1,25 @@
+{
+ "LB": false,
+ "ONOS_DEFAULT_HOST": "localhost",
+ "ONOS_GUI3_CONTROL_HOST": "http://10.128.4.11:9000",
+ "ONOS_GUI3_HOST": "http://10.128.4.11:9000",
+ "cluster_basename": "ONOS",
+ "controllers": [
+ "ONOS1",
+ "ONOS2",
+ "ONOS3",
+ "ONOS4",
+ "ONOS5",
+ "ONOS6",
+ "ONOS7",
+ "ONOS8"
+ ],
+ "core_switches": [
+ "00:00:00:00:ba:5e:ba:11",
+ "00:00:00:00:00:00:ba:12",
+ "00:00:20:4e:7f:51:8a:35",
+ "00:00:00:00:ba:5e:ba:13",
+ "00:00:00:08:a2:08:f9:01",
+ "00:01:00:16:97:08:9a:46"
+ ]
+}
diff --git a/web/config.json.sw b/web/config.json.sw
new file mode 100644
index 0000000..b1903c6
--- /dev/null
+++ b/web/config.json.sw
@@ -0,0 +1,25 @@
+{
+ "LB": false,
+ "ONOS_DEFAULT_HOST": "localhost",
+ "ONOS_GUI3_CONTROL_HOST": "http://devy-gui.onlab.us:8080",
+ "ONOS_GUI3_HOST": "http://devy-gui.onlab.us:8080",
+ "cluster_basename": "onosdevy",
+ "controllers": [
+ "onosdevy1",
+ "onosdevy2",
+ "onosdevy3",
+ "onosdevy4",
+ "onosdevy5",
+ "onosdevy6",
+ "onosdevy7",
+ "onosdevy8"
+ ],
+ "core_switches": [
+ "00:00:00:00:ba:5e:ba:11",
+ "00:00:00:00:00:00:ba:12",
+ "00:00:20:4e:7f:51:8a:35",
+ "00:00:00:00:ba:5e:ba:13",
+ "00:00:00:08:a2:08:f9:01",
+ "00:00:00:16:97:08:9a:46"
+ ]
+}
diff --git a/web/config.json.sw_dev b/web/config.json.sw_dev
new file mode 100644
index 0000000..57a1a3d
--- /dev/null
+++ b/web/config.json.sw_dev
@@ -0,0 +1,25 @@
+{
+ "LB": false,
+ "ONOS_DEFAULT_HOST": "localhost",
+ "ONOS_GUI3_CONTROL_HOST": "http://devy-gui.onlab.us:8080",
+ "ONOS_GUI3_HOST": "http://devy-gui.onlab.us:8080",
+ "cluster_basename": "onosdevy",
+ "controllers": [
+ "onosdevy1",
+ "onosdevy2",
+ "onosdevy3",
+ "onosdevy4",
+ "onosdevy5",
+ "onosdevy6",
+ "onosdevy7",
+ "onosdevy8"
+ ],
+ "core_switches": [
+ "00:00:00:00:00:00:01:01",
+ "00:00:00:00:00:00:01:02",
+ "00:00:00:00:00:00:01:03",
+ "00:00:00:00:00:00:01:04",
+ "00:00:00:00:00:00:01:05",
+ "00:00:00:00:00:00:01:06"
+ ]
+}
diff --git a/web/pingallm.py b/web/pingallm.py
index 43f10ad..db1f81c 100755
--- a/web/pingallm.py
+++ b/web/pingallm.py
@@ -3,12 +3,20 @@
import time
import os
import re
+import json
-hosts=['onosdevz1', 'onosdevz2', 'onosdevz3', 'onosdevz4', 'onosdevz5', 'onosdevz6', 'onosdevz7', 'onosdevz8']
ping_cnt=3
wait1=ping_cnt
wait2=10
+CONFIG_FILE=os.getenv("HOME") + "/ONOS/web/config.json"
+
+def read_config():
+ global controllers
+ f = open(CONFIG_FILE)
+ conf = json.load(f)
+ controllers = conf['controllers']
+ f.close()
def do_pingall():
@@ -20,8 +28,8 @@
nr_ping = 0
for line in f:
if line[0] != "#":
-# logfile="/tmp/ping.pid%d.%d" % (pid, fid)
fid=int(line.strip().split()[0])
+# logfile="/tmp/ping.pid%d.%d" % (pid, fid)
logfile="/tmp/ping.%d" % (fid)
src_dpid=line.strip().split()[2]
dst_dpid=line.strip().split()[4]
@@ -31,8 +39,8 @@
dst_hostid=int(dst_dpid.split(':')[-1], 16)
cmd="echo \"Pingall flow %d : 192.168.%d.%d -> 192.168.%d.%d\" > %s" % (fid, src_nwid, src_hostid, dst_nwid, dst_hostid,logfile)
os.popen(cmd)
- cmd="ssh %s \'${HOME}/ONOS/test-network/mininet/mrun host%d \'ping -c %d -W 1 192.168.%d.%d\'\' >> %s 2>&1 &" % (hosts[src_nwid-1], src_hostid, ping_cnt, dst_nwid, dst_hostid,logfile)
- # print cmd
+ cmd="ssh %s \'${HOME}/ONOS/test-network/mininet/mrun host%d \'ping -c %d -W 1 192.168.%d.%d\'\' >> %s 2>&1 &" % (controllers[src_nwid-1], src_hostid, ping_cnt, dst_nwid, dst_hostid,logfile)
+ print cmd
result = os.popen(cmd).read()
time.sleep(0.2)
nr_ping = nr_ping + 1
@@ -72,6 +80,7 @@
print "flow # %d %s : %s" % (i+1, flow_desc, result)
if __name__ == "__main__":
+ read_config()
nr_ping=do_pingall()
nr_done=wait_ping_finish(nr_ping)
report(nr_ping, nr_done)
diff --git a/web/topology_rest.py b/web/topology_rest.py
index 87bdeb0..b1ce2ca 100755
--- a/web/topology_rest.py
+++ b/web/topology_rest.py
@@ -13,28 +13,25 @@
from flask import Flask, json, Response, render_template, make_response, request
+
+CONFIG_FILE=os.getenv("HOME") + "/ONOS/web/config.json"
+
## Global Var for ON.Lab local REST ##
RestIP="localhost"
RestPort=8080
-
-LB=False #; True or False
ONOS_DEFAULT_HOST="localhost" ;# Has to set if LB=False
-TESTBED="hw"
DEBUG=1
-if (TESTBED == "hw"):
- # Settings for running on hardware testbed
- controllers=["ONOS1", "ONOS2", "ONOS3", "ONOS4", "ONOS5", "ONOS6", "ONOS7", "ONOS8"]
- core_switches=["00:00:00:00:ba:5e:ba:11", "00:00:00:00:00:00:ba:12", "00:00:20:4e:7f:51:8a:35", "00:00:00:00:ba:5e:ba:13", "00:00:00:08:a2:08:f9:01", "00:01:00:16:97:08:9a:46"]
- ONOS_GUI3_HOST="http://10.128.4.11:9000"
- ONOS_GUI3_CONTROL_HOST="http://10.128.4.11:9000"
-else:
- # Settings for running on software testbed
- controllers=["onosdevt1", "onosdevt2", "onosdevt3", "onosdevt4", "onosdevt5", "onosdevt6", "onosdevt7", "onosdevt8"]
-# core_switches=["00:00:00:00:ba:5e:ba:11", "00:00:00:00:00:00:ba:12", "00:00:20:4e:7f:51:8a:35", "00:00:00:00:ba:5e:ba:13", "00:00:00:08:a2:08:f9:01", "00:00:00:16:97:08:9a:46"]
- core_switches=["00:00:00:00:00:00:01:01", "00:00:00:00:00:00:01:02", "00:00:00:00:00:00:01:03", "00:00:00:00:00:00:01:04", "00:00:00:00:00:00:01:05", "00:00:00:00:00:00:01:06"]
- ONOS_GUI3_HOST="http://devt-gui.onlab.us:8080"
- ONOS_GUI3_CONTROL_HOST="http://devt-gui.onlab.us:8080"
+def read_config():
+ global LB, controllers, core_switches, ONOS_GUI3_HOST, ONOS_GUI3_CONTROL_HOST
+ f = open(CONFIG_FILE)
+ conf = json.load(f)
+ LB = conf['LB']
+ controllers = conf['controllers']
+ core_switcehs=conf['core_switches']
+ ONOS_GUI3_HOST=conf['ONOS_GUI3_HOST']
+ ONOS_GUI3_CONTROL_HOST=conf['ONOS_GUI3_CONTROL_HOST']
+ f.close()
pp = pprint.PrettyPrinter(indent=4)
app = Flask(__name__)
@@ -986,6 +983,7 @@
if __name__ == "__main__":
random.seed()
+ read_config()
if len(sys.argv) > 1 and sys.argv[1] == "-d":
# add_flow("00:00:00:00:00:00:02:02", 1, "00:00:00:00:00:00:03:02", 1, "00:00:00:00:02:02", "00:00:00:00:03:0c")
# link_change("up", "00:00:00:00:ba:5e:ba:11", 1, "00:00:00:00:00:00:00:00", 1)