omf_web 0.9.7 → 0.9.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. data/.gitignore +1 -0
  2. data/README.md +1 -1
  3. data/bin/omf_web_demo +3 -0
  4. data/bin/omf_web_demo.sh +0 -0
  5. data/doc/tutorial/tut01/hello_world.rb +27 -0
  6. data/doc/tutorial/tut02/hello_graph.rb +85 -0
  7. data/doc/tutorial/tut03/hello_database.rb +69 -0
  8. data/doc/tutorial/tut03/nmetric.sq3 +0 -0
  9. data/example/bridge/config.ru +2 -1
  10. data/example/demo/data_sources/downloads.csv +96 -1
  11. data/example/demo/demo_viz_server.rb +46 -28
  12. data/example/openflow-gec15/README.md +2 -0
  13. data/example/openflow-gec15/doc/gec15_topo.png +0 -0
  14. data/example/openflow-gec15/exp_source.rb +48 -9
  15. data/example/openflow-gec15/of_viz_server.rb +1 -1
  16. data/example/openflow-gec15/repository/of-exp.rb +117 -12
  17. data/example/openflow-gec15/repository/trema-ctl6.rb +2 -2
  18. data/example/simple/README.md +29 -1
  19. data/example/simple/data_sources/ping_source.rb +2 -2
  20. data/lib/irods4r/directory.rb +49 -0
  21. data/lib/irods4r/file.rb +53 -0
  22. data/lib/irods4r/icommands.rb +63 -0
  23. data/lib/irods4r.rb +34 -0
  24. data/lib/omf-web/content/content_proxy.rb +14 -5
  25. data/lib/omf-web/content/file_repository.rb +36 -75
  26. data/lib/omf-web/content/git_repository.rb +39 -35
  27. data/lib/omf-web/content/irods_repository.rb +191 -0
  28. data/lib/omf-web/content/repository.rb +84 -21
  29. data/lib/omf-web/content/static_repository.rb +61 -0
  30. data/lib/omf-web/data_source_proxy.rb +3 -3
  31. data/lib/omf-web/rack/session_authenticator.rb +67 -35
  32. data/lib/omf-web/rack/tab_mapper.rb +2 -1
  33. data/lib/omf-web/rack/websocket_handler.rb +49 -10
  34. data/lib/omf-web/session_store.rb +9 -8
  35. data/lib/omf-web/theme/bright/page.rb +1 -1
  36. data/lib/omf-web/thin/runner.rb +18 -5
  37. data/lib/omf-web/version.rb +1 -1
  38. data/lib/omf-web/widget/text/maruku/output/to_html.rb +8 -2
  39. data/lib/omf_web.rb +17 -2
  40. data/omf_web.gemspec +0 -1
  41. data/share/htdocs/graph/js/abstract_widget.js +3 -1
  42. data/share/htdocs/graph/js/barchart_brush.js +240 -0
  43. data/share/htdocs/js/data_source2.js +4 -1
  44. data/share/htdocs/js/mustache.js +17 -11
  45. data/share/htdocs/theme/bright/css/bright.css +1 -1
  46. data/share/htdocs/vendor/{bootstrap-2.1.1 → bootstrap-2.3.1}/css/bootstrap-responsive.css +56 -5
  47. data/share/htdocs/vendor/bootstrap-2.3.1/css/bootstrap-responsive.min.css +9 -0
  48. data/share/htdocs/vendor/{bootstrap-2.1.1 → bootstrap-2.3.1}/css/bootstrap.css +856 -472
  49. data/share/htdocs/vendor/bootstrap-2.3.1/css/bootstrap.min.css +9 -0
  50. data/share/htdocs/vendor/{bootstrap-2.1.1 → bootstrap-2.3.1}/img/glyphicons-halflings-white.png +0 -0
  51. data/share/htdocs/vendor/{bootstrap-2.1.1 → bootstrap-2.3.1}/img/glyphicons-halflings.png +0 -0
  52. data/share/htdocs/vendor/{bootstrap-2.1.1 → bootstrap-2.3.1}/js/bootstrap.js +427 -178
  53. data/share/htdocs/vendor/bootstrap-2.3.1/js/bootstrap.min.js +6 -0
  54. data/share/htdocs/vendor/jquery-tipsy/css/tipsy.css +25 -0
  55. data/share/htdocs/vendor/jquery-tipsy/js/jquery.tipsy.js +258 -0
  56. metadata +27 -14
  57. data/bin/omf-web-basic +0 -235
  58. data/share/htdocs/vendor/.DS_Store +0 -0
  59. data/share/htdocs/vendor/bootstrap-2.1.1/css/bootstrap-responsive.min.css +0 -9
  60. data/share/htdocs/vendor/bootstrap-2.1.1/css/bootstrap.min.css +0 -9
  61. data/share/htdocs/vendor/bootstrap-2.1.1/js/bootstrap.min.js +0 -6
  62. data/share/htdocs/vendor/jquery-ui-1.8.23/index.html +0 -383
data/.gitignore CHANGED
@@ -26,3 +26,4 @@ UNUSED/
26
26
  .DS_Store
27
27
 
28
28
  share/htdocs/vendor/jquery-ui-1.8.23/development-bundle
29
+ example/wimax
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # OMF Web
2
2
 
3
- This gem provides the componetes for building a web-based data visualization service.
3
+ This Ruby 1.9 gem provides the components for building a web-based data visualization service.
4
4
  The typical use case is to allow a user to investigate a data set stored in one or more databases
5
5
  as well as life data streams.
6
6
 
data/bin/omf_web_demo ADDED
@@ -0,0 +1,3 @@
1
+
2
+ load File.join(File.dirname(__FILE__), '../example/demo/demo_viz_server.rb')
3
+ OmfWebDemo.start
data/bin/omf_web_demo.sh CHANGED
File without changes
@@ -0,0 +1,27 @@
1
+
2
+ site_description = {
3
+ id: 'top',
4
+ top_level: true,
5
+ type: 'layout/one_column',
6
+ widgets: [
7
+ name: "Welcome",
8
+ type: 'text',
9
+ content: {text: 'Hello World'}
10
+ ]
11
+ }
12
+
13
+
14
+
15
+ # Configure the web server
16
+ #
17
+ opts = {
18
+ :app_name => 'tut01',
19
+ :page_title => 'Tutorial01: Hello World'
20
+ }
21
+
22
+ require 'omf_common/lobject'
23
+ OMF::Common::Loggable.init_log 'tut01'
24
+
25
+ require 'omf_web'
26
+ OMF::Web.register_widget(site_description)
27
+ OMF::Web.start(opts)
@@ -0,0 +1,85 @@
1
+ require 'omf_common/lobject'
2
+ require 'omf_web'
3
+ require 'omf_oml/table'
4
+
5
+ OMF::Common::Loggable.init_log 'tut02'
6
+
7
+
8
+ # Create a table containing 'amplitude' measurements taken at a certain time for two different
9
+ # devices.
10
+ #
11
+ schema = [[:t, :float], [:device, :string], [:amplitude, :float], [:x, :float], [:y, :float]]
12
+ table = OMF::OML::OmlTable.new 'generator', schema
13
+
14
+ # Register the table with the web framework
15
+ OMF::Web.register_datasource table
16
+
17
+ # Fill it with some data
18
+ samples = 30
19
+ ctxt = {
20
+ :timeOffset => Time.now.to_i,
21
+ :timeScale => 300, # Measure every 10 minutes
22
+ :radius => 10,
23
+ :fluctuation => 0.1, # max disturbance of sample
24
+ :rad => 2 * Math::PI / samples
25
+ }
26
+
27
+ def measure(i, table, ctxt)
28
+ t = ctxt[:timeOffset] + ctxt[:timeScale] * i
29
+ angle = i * ctxt[:rad]
30
+ measure_device('Gen 1', t, angle, table, ctxt)
31
+ measure_device('Gen 2', t, angle + ctxt[:rad] + 0.2 * (rand() - 0.5), table, ctxt)
32
+ end
33
+
34
+ def measure_device(name, t, angle, table, ctxt)
35
+ r = ctxt[:radius] * (1 + (rand() - 0.5) * ctxt[:fluctuation])
36
+ table.add_row [t, name, r, r * Math.sin(angle), r * Math.cos(angle)]
37
+ end
38
+
39
+ samples.times {|i| measure(i, table, ctxt) }
40
+
41
+ # Now describe a site with two widgets side by side, one showing the data
42
+ # in a table, and the other as a line graph
43
+ #
44
+ site_description = {
45
+ id: 'top',
46
+ top_level: true,
47
+ name: "Main",
48
+ type: 'layout/two_columns/50_50', # two columns equal width
49
+ left: [
50
+ name: 'Line Chart',
51
+ type: 'data/line_chart3',
52
+ data_source: { name: 'generator' },
53
+ mapping: {
54
+ x_axis: 't',
55
+ y_axis: {
56
+ property: 'x',
57
+ min: -10.5,
58
+ max: 10.5
59
+ },
60
+ group_by: 'device'
61
+ },
62
+ axis: {
63
+ x: {
64
+ ticks: { type: 'date', format: '%I:%M' },
65
+ legend: 'Time (hours)'
66
+ },
67
+ y: { legend: 'Voltage (V)' }
68
+ }
69
+ ],
70
+ right: [
71
+ name: 'Table',
72
+ type: 'data/table2',
73
+ data_source: { name: 'generator' }
74
+ ]
75
+ }
76
+
77
+ # Configure the web server
78
+ #
79
+ opts = {
80
+ :app_name => 'tut02',
81
+ :page_title => 'Tutorial02: Hello Graph'
82
+ }
83
+
84
+ OMF::Web.register_widget(site_description)
85
+ OMF::Web.start(opts)
@@ -0,0 +1,69 @@
1
+ require 'omf_common/lobject'
2
+ require 'omf_web'
3
+ require 'omf_oml/table'
4
+ require 'omf_oml/sql_source'
5
+ include OMF::OML
6
+ OMF::Common::Loggable.init_log 'tut03'
7
+
8
+ # Name of database to visualize
9
+ DB_URL = "sqlite://#{File.dirname(__FILE__)}/nmetric.sq3"
10
+
11
+ # Create a table containing measurements fetched from a database
12
+ # devices.
13
+ #
14
+ ep = OMF::OML::OmlSqlSource.new(DB_URL)
15
+ opts = {
16
+ max_size: 1000, # max rows to maintain in table (FIFO)
17
+ include_oml_internals: false, # don't add the OML header columns to the table
18
+ limit: 100, # to slow things down, fetch 100 rows at a time
19
+ query_interval: 0.5 # ... and wait that many seconds before fetching the next batch
20
+ }
21
+ ds = ep.create_table('traffic', opts)
22
+ OMF::Web.register_datasource ds
23
+
24
+ # Now describe a site with two widgets side by side, one showing the data
25
+ # in a table, and the other as a line graph
26
+ #
27
+ site_description = {
28
+ id: 'top',
29
+ top_level: true,
30
+ name: "Main",
31
+ type: 'layout/two_columns/50_50', # two columns equal width
32
+ left: [
33
+ name: 'Line Chart',
34
+ type: 'data/line_chart3',
35
+ data_source: { name: 'traffic' },
36
+ mapping: {
37
+ x_axis: 'ts',
38
+ y_axis: {
39
+ property: 'tx_byte_rate',
40
+ # min: -10.5,
41
+ # max: 10.5
42
+ },
43
+ group_by: 'name'
44
+ },
45
+ axis: {
46
+ x: {
47
+ #ticks: { type: 'date', format: '%I:%M' },
48
+ legend: 'Time (s)',
49
+ ticks: { format: ',s' }
50
+ },
51
+ y: { legend: 'Rate (bytes)', ticks: { format: ',s' }}
52
+ }
53
+ ],
54
+ right: [
55
+ name: 'Table',
56
+ type: 'data/table2',
57
+ data_source: { name: 'traffic' }
58
+ ]
59
+ }
60
+
61
+ # Configure the web server
62
+ #
63
+ opts = {
64
+ :app_name => 'tut02',
65
+ :page_title => 'Tutorial03: Hello Database'
66
+ }
67
+
68
+ OMF::Web.register_widget(site_description)
69
+ OMF::Web.start(opts)
Binary file
@@ -59,7 +59,7 @@ end
59
59
  map '/login' do
60
60
  handler = Proc.new do |env|
61
61
  req = ::Rack::Request.new(env)
62
- #puts ">>> post?: #{req.post?} - #{req.params.inspect}"
62
+ puts ">>> post?: #{req.post?} - #{req.params.inspect}"
63
63
  if req.post?
64
64
  email = req.params["email"]
65
65
  pw = req.params["password"]
@@ -73,6 +73,7 @@ end
73
73
 
74
74
  map '/logout' do
75
75
  handler = Proc.new do |env|
76
+ puts ">>>> LOGOUT"
76
77
  OMF::Web::Rack::SessionAuthenticator.logout
77
78
  [301, {'Location' => '/tab', "Content-Type" => ""}, ['Next window!']]
78
79
  end
@@ -1 +1,96 @@
1
- time,actual,smoothed,a,b,c,d,upper,lower
1
+ time,actual,smoothed,a,b,c,d,upper,lower
2
+ 39507,16378.7524,16378.7524,0,0,0,0,0,0
3
+ 39508,59302.80493,3275.75048,1637.87524,163.787524,1474.087716,5602.705445,3275.75048,3275.75048
4
+ 39509,29786.48846,14644.94889,7404.368209,724.0580685,6516.522616,6556.588857,28651.7125,638.1852819
5
+ 39510,8219.494354,18397.31488,9642.580234,875.4734641,7879.261177,6918.712023,34788.78702,2005.842733
6
+ 39511,38137.24785,17237.22424,9500.271646,773.6952589,6963.25733,8316.843182,34534.00429,-59.5558231
7
+ 39512,35975.56127,22190.92422,12363.96927,982.6954951,8844.259456,8863.622569,42983.03217,1398.816261
8
+ 39513,60403.89954,25930.54712,14725.12847,1120.541866,10084.87679,11424.59555,48089.60355,3771.490699
9
+ 39514,14495.10358,33945.75947,19293.00557,1465.27539,13187.47851,12227.20159,62507.24836,5384.270586
10
+ 39515,33778.81513,31520.90368,18813.21537,1270.768831,11436.91948,11230.27257,62088.90765,952.8997117
11
+ 39516,41467.90768,33243.2548,20309.77535,1293.347945,11640.13151,10929.7106,61318.93624,5167.573367
12
+ 39517,33412.98738,36181.53332,22425.58858,1375.594474,12380.35027,10113.59414,63505.80984,8857.256812
13
+ 39518,45433.88563,37003.41861,23524.32846,1347.909015,12131.18113,9945.281426,62287.40396,11719.43326
14
+ 39519,10370.75331,40037.42103,25715.28418,1432.213685,12889.92316,11917.42006,64900.62459,15174.21746
15
+ 39520,6429.918228,35536.30117,24180.83109,1135.547008,10219.92307,13636.31634,65329.85131,5742.751029
16
+ 39521,16430.86643,30850.57159,22405.73981,844.4831782,7600.348604,13714.65523,64941.36245,-3240.219273
17
+ 39522,12461.38896,28811.11373,21808.25247,700.2861266,6302.57514,13978.16218,63097.7518,-5475.524331
18
+ 39523,16443.26147,26241.45491,20873.56612,536.7888789,4831.09991,13560.16531,61186.86036,-8703.950546
19
+ 39524,42565.38232,24818.6051,20430.53565,438.8069446,3949.262501,13978.8265,58719.01836,-9081.808166
20
+ 39525,44926.70801,28806.76749,22644.02032,616.2747168,5546.472452,14192.9379,63753.83373,-6140.298756
21
+ 39526,26323.97404,32647.03031,24872.28909,777.474122,6997.267098,13405.94974,68129.37506,-2835.314441
22
+ 39527,14252.13965,32159.89318,25017.45758,714.2435593,6428.192034,13856.13012,65674.76752,-1354.981165
23
+ 39528,105565.1001,29292.58603,23940.92579,535.166024,4816.494216,20097.76851,63932.91132,-5347.739259
24
+ 39529,1443.90564,45082.25486,32103.34322,1297.891164,11681.02048,22451.82658,95326.67613,-5162.166408
25
+ 39530,54702.30566,37652.47618,29037.39946,861.5076722,7753.569049,21911.62687,93782.04263,-18477.09027
26
+ 39531,16381.97656,41923.94975,31603.89008,1032.005967,9288.053703,22274.6615,96703.01692,-12855.11742
27
+ 39532,24127.57379,37847.56108,30081.69873,776.5862351,6989.276116,21419.19408,93534.21483,-17839.09267
28
+ 39533,7395.563253,35880.14986,29486.28623,639.3863622,5754.47726,22125.73333,89428.13506,-17667.83534
29
+ 39534,25937.52421,30822.6189,27277.21394,354.5404962,3190.864466,20401.66947,86136.95223,-24491.71443
30
+ 39535,55918.67496,30200.14046,27143.24496,305.6895493,2751.205944,20933.35597,81204.31413,-20804.03321
31
+ 39536,16808.07212,35649.53691,30020.78796,562.8748943,5065.874049,20724.16685,87982.92683,-16683.85302
32
+ 39537,19270.19019,32444.11884,28699.51638,374.4602464,3370.142218,19969.14303,84254.53597,-19366.29829
33
+ 39538,116687.8905,30183.79336,27756.58376,242.7209598,2184.488639,26622.63844,80106.65094,-19739.06423
34
+ 39539,30423.44326,47727.33374,36649.71443,1107.761931,9969.857378,25690.76364,114283.9298,-18829.26236
35
+ 39540,36513.4115,45374.31757,36027.08731,934.7230261,8412.507235,24007.77789,109601.2267,-18852.59154
36
+ 39541,36626.26271,44536.85939,36075.71973,846.1139654,7615.025688,22398.05977,104556.3041,-15482.58533
37
+ 39542,53286.80167,43800.85402,36130.77403,767.0079987,6903.071988,21106.84855,99796.00343,-12194.2954
38
+ 39543,26793.474,46465.05155,37846.37679,861.8674752,7756.807277,20963.32145,99232.17293,-6302.069841
39
+ 39544,31120.1192,43392.60351,36741.08651,665.1516998,5986.365298,20094.23774,95800.90715,-9015.700123
40
+ 39545,42586.39165,41603.25835,36178.98978,542.4268566,4881.841709,18183.1273,91838.8527,-8632.336002
41
+ 39546,191693.8747,42342.31187,36819.72997,552.2581896,4970.323706,31299.97085,87800.13011,-3115.506376
42
+ 39547,29235.16858,72764.88262,52307.14444,2045.773818,18411.96436,32522.94517,151014.8097,-5485.044503
43
+ 39548,85353.18654,66104.71363,49999.94685,1610.476677,14494.2901,31195.49794,147412.0765,-15202.64929
44
+ 39549,165434.3529,71564.88489,53535.27082,1802.961407,16226.65266,37462.89495,149553.6297,-6423.859965
45
+ 39550,43163.41525,92141.7399,64725.17903,2741.656087,24674.90478,38614.43792,185798.9773,-1515.497474
46
+ 39551,24303.76183,85087.73105,62569.00265,2251.87284,20266.85556,40831.39105,181623.8258,-11448.36374
47
+ 39552,27663.16908,75182.81005,58742.47857,1644.033148,14796.29833,41500.21604,177261.2877,-26895.66757
48
+ 39553,77015.94392,67322.915,55634.54762,1168.836738,10519.53064,38319.49733,171073.4551,-36427.6251
49
+ 39554,78420.97978,70430.35752,57772.68725,1265.767027,11391.90325,35286.60982,166229.1008,-25368.3858
50
+ 39555,47501.43846,73294.249,59837.5165,1345.67325,12111.05925,34337.22989,161510.7736,-14922.27555
51
+ 39556,35970.29131,69481.36014,58603.9087,1087.745144,9789.7063,34254.61379,155324.4349,-16361.71459
52
+ 39557,33732.86028,63866.89152,56340.54696,752.6344562,6773.710105,33842.55553,149503.426,-21769.64295
53
+ 39558,1574.705673,58592.71973,54079.77829,451.2941437,4061.647293,36160.10139,143199.1086,-26013.6691
54
+ 39559,57608.82319,47640.41106,48829.27103,-118.8859968,-1069.973972,33540.93246,138040.6645,-42759.8424
55
+ 39560,10088.23547,49515.20749,49707.22625,-19.20187559,-172.8168803,34129.53642,133367.5386,-34337.12366
56
+ 39561,47914.92468,41610.61121,45745.32717,-413.4715958,-3721.244362,31347.01412,126934.4522,-43713.22983
57
+ 39562,3988.72604,42458.00231,45962.28692,-350.4284611,-3153.85615,32059.24034,120825.5376,-35909.53299
58
+ 39563,55799.76426,34413.71859,41764.93083,-735.1212238,-6616.091014,30991.92087,114561.8194,-45734.38224
59
+ 39564,20444.05346,37955.8065,43168.41417,-521.2607671,-4691.346904,29643.90409,115435.6087,-39523.99567
60
+ 39565,52540.01142,33932.19513,40895.9781,-696.3782975,-6267.404678,28540.29531,108041.9553,-40177.56509
61
+ 39566,6249.661515,36957.38009,42060.38144,-510.3001346,-4592.701211,28757.03763,108308.1184,-34393.35818
62
+ 39567,42032.84101,30305.53624,38479.30944,-817.3773203,-7356.395883,27054.06435,102198.1303,-41587.05784
63
+ 39568,42537.65958,31833.61987,38834.6626,-700.1042727,-6300.938454,25419.06188,99468.78074,-35801.54099
64
+ 39569,64966.97272,33274.32354,39204.9623,-593.0638756,-5337.57488,26046.42061,96821.97825,-30273.33116
65
+ 39570,22953.14566,39019.7895,41781.16334,-276.1373838,-2485.236455,25048.44293,104135.841,-26096.26203
66
+ 39571,58608.34065,35530.32335,39898.36157,-436.8038222,-3931.2344,24851.40037,98151.43069,-27090.78399
67
+ 39572,13009.19189,39709.12299,41769.35948,-206.0236492,-1854.212843,25036.25344,101837.6239,-22419.37794
68
+ 39573,20601.86596,34163.11312,38893.34272,-473.0229602,-4257.206641,23888.75281,96753.74673,-28427.52049
69
+ 39574,43189.09059,30977.84073,37064.19505,-608.6354318,-5477.718886,22721.00252,90699.72276,-28744.04131
70
+ 39575,36477.39214,32811.45527,37676.6846,-486.5229331,-4378.706398,20815.49595,89613.96157,-23991.05103
71
+ 39576,44555.25315,33058.11971,37556.75535,-449.8635644,-4048.77208,19883.6597,85096.85959,-18980.62018
72
+ 39577,36085.67447,34907.68283,38256.60513,-334.89223,-3014.03007,18013.0929,84616.83209,-14801.46642
73
+ 39578,23316.31896,34808.38893,38039.51207,-323.1123136,-2908.010822,17360.9906,79841.12117,-10224.34331
74
+ 39579,49186.15144,32186.86262,36567.19276,-438.0330133,-3942.29712,17324.82043,75589.33913,-11215.61389
75
+ 39580,31557.85485,35148.68737,37829.08863,-268.0401251,-2412.361126,15951.42164,78460.73844,-8163.36369
76
+ 39581,65510.2966,34162.48074,37201.96525,-303.9484503,-2735.536053,17491.06106,74041.03483,-5716.073343
77
+ 39582,80525.79372,40128.09547,40032.79838,9.529708267,85.7673744,19781.72478,83855.74811,-3599.557178
78
+ 39583,68365.96248,48217.16482,44082.09792,413.5066908,3721.560217,19818.43206,97671.47677,-1237.147118
79
+ 39584,56253.36649,52660.43105,46510.48437,614.9946673,5534.952006,18195.8824,102206.5112,3114.350885
80
+ 39585,83309.47475,53994.0128,47484.77258,650.9240217,5858.316196,19307.84036,99483.71881,8504.306796
81
+ 39586,38579.61929,60508.02921,51067.2428,944.0786412,8496.707771,19569.89731,108777.6301,12238.42832
82
+ 39587,29767.23803,57066.42587,49818.48045,724.7945419,6523.150877,20342.82637,105991.1692,8141.682584
83
+ 39588,33254.65345,52331.38284,47813.35621,451.8026635,4066.223972,20216.21667,103188.4488,1474.316926
84
+ 39589,15554.32368,48967.83963,46357.48593,261.0353696,2349.318326,21535.9466,99508.3813,-1572.702047
85
+ 39590,37993.2485,42546.17181,43277.16971,-73.09978994,-657.8981095,19837.64427,96386.0383,-11293.69469
86
+ 39591,39624.34677,41562.48735,42748.77758,-118.629023,-1067.661207,18047.6939,91156.59803,-8031.623318
87
+ 39592,31145.61768,41056.23021,42436.3345,-138.0104289,-1242.09386,17233.98576,86175.46497,-4063.004536
88
+ 39593,38384.76427,38936.09728,41307.26282,-237.1165542,-2134.048988,15565.72049,82021.06169,-4148.867131
89
+ 39594,34303.07486,38588.71412,41015.01297,-242.6298844,-2183.668959,14437.71237,77503.01534,-325.5870998
90
+ 39595,19024.69714,37488.95638,40343.81915,-285.486277,-2569.376493,14840.36705,73583.2373,1394.675469
91
+ 39596,69006.2048,33510.61826,38211.90695,-470.1288694,-4231.159825,16905.889,70611.53589,-3590.299376
92
+ 39597,32417.08188,40139.6067,41291.33674,-115.173004,-1036.557036,15987.55258,82404.32921,-2125.115809
93
+ 39598,76430.03319,38479.92873,40403.91125,-192.3982522,-1731.58427,18183.80777,78448.81019,-1488.952731
94
+ 39599,61975.26521,45877.55137,44006.52345,187.1027924,1683.925131,17975.19838,91337.0708,418.0319398
95
+ 39600,22867.2208,49284.19693,45803.39762,348.0799308,3132.719377,18819.37615,94222.19288,4346.200983
96
+ 39601,133257.8277,44348.88163,43509.77994,83.91016947,755.1915253,25828.33314,91397.32202,-2699.55875
@@ -1,41 +1,59 @@
1
-
1
+ #ENV['BUNDLE_GEMFILE'] = "#{File.dirname(__FILE__)}/../../Gemfile"
2
+ #require 'bundler/setup'
2
3
  require 'omf_common/lobject'
3
4
  OMF::Common::Loggable.init_log 'demo', :searchPath => File.dirname(__FILE__)
4
5
 
5
6
 
6
7
  require 'omf_oml/table'
8
+ require 'omf_web'
7
9
 
8
- def load_environment
9
- require 'omf-web/content/file_repository'
10
- OMF::Web::FileContentRepository.register_file_repo(:demo, File.join(File.dirname(__FILE__), 'repository'), true)
11
-
10
+ class OmfWebDemo
11
+
12
+ # Configure the web server
13
+ #
14
+ OPTS = {
15
+ :app_name => 'demo',
16
+ :page_title => 'Vizualisation Demo',
17
+ :static_dirs_pre => ["#{File.dirname(__FILE__)}/htdocs"],
18
+ :handlers => {
19
+ # delay connecting to databases to AFTER we may run as daemon
20
+ :pre_rackup => lambda { OmfWebDemo.load_environment },
21
+ }
22
+ }
12
23
 
13
- Dir.glob("#{File.dirname(__FILE__)}/data_sources/*.rb").each do |fn|
14
- load fn
24
+ def self.start(opts = OPTS)
25
+ #self.load_environemnt()
26
+ OMF::Web.start(opts)
15
27
  end
16
-
17
- require 'yaml'
18
- Dir.glob("#{File.dirname(__FILE__)}/widgets/*.yaml").each do |fn|
19
- h = YAML.load_file(fn)
20
- if w = h['widget']
21
- OMF::Web.register_widget w
22
- else
23
- MObject.error "Don't know what to do with '#{fn}'"
28
+
29
+ def self.load_environment
30
+ #require 'omf-web/content/file_repository'
31
+ #OMF::Web::FileContentRepository.register_file_repo(:demo, File.join(File.dirname(__FILE__), 'repository'), true)
32
+ require 'omf-web/content/repository'
33
+ OMF::Web::ContentRepository.register_repo(:demo, :type => :file, :top_dir => File.join(File.dirname(__FILE__), 'repository'))
34
+
35
+
36
+ Dir.glob("#{File.dirname(__FILE__)}/data_sources/*.rb").each do |fn|
37
+ load fn
38
+ end
39
+
40
+ require 'yaml'
41
+ Dir.glob("#{File.dirname(__FILE__)}/widgets/*.yaml").each do |fn|
42
+ h = YAML.load_file(fn)
43
+ if w = h['widget']
44
+ OMF::Web.register_widget w
45
+ else
46
+ MObject.error "Don't know what to do with '#{fn}'"
47
+ end
24
48
  end
25
49
  end
26
50
  end
27
51
 
52
+ if __FILE__ == $0
53
+ OmfWebDemo.start
54
+ end
55
+
56
+
57
+
58
+
28
59
 
29
- # Configure the web server
30
- #
31
- opts = {
32
- :app_name => 'demo',
33
- :page_title => 'Vizualisation Demo',
34
- :static_dirs_pre => ["#{File.dirname(__FILE__)}/htdocs"],
35
- :handlers => {
36
- # delay connecting to databases to AFTER we may run as daemon
37
- :pre_rackup => lambda { load_environment },
38
- }
39
- }
40
- require 'omf_web'
41
- OMF::Web.start(opts)
@@ -16,6 +16,8 @@ This will start a web server at port 3000. Point your browser there and you shou
16
16
  Clicking on the 'Code' tab will show the 'OIDL' script describing the experiment, and the 'Trema' code of the Openflow controller
17
17
  used in the experiment.
18
18
 
19
+ For reference, this is the topology used in the experiment:
19
20
 
21
+ ![Topology](https://raw.github.com/mytestbed/omf_web/master/example/openflow-gec15/doc/gec15_topo.png "Topology")
20
22
 
21
23
 
@@ -60,8 +60,8 @@ class ExpDB < OMF::Common::LObject
60
60
  end
61
61
 
62
62
  stream.on_new_tuple() do |v|
63
- r = v.to_a(true)
64
- #puts "RRR >> #{r.inspect}"
63
+ r = v.to_a(schema)
64
+
65
65
  t.add_row(r)
66
66
  ts = r[ts_i]; name = r[name_i].to_sym; tx = r[tx_i]; rx = r[rx_i]
67
67
  #puts "VVV(#{ts}) >> #{v.row.inspect}"
@@ -89,15 +89,54 @@ class ExpDB < OMF::Common::LObject
89
89
  OMF::Web.register_datasource t
90
90
  end
91
91
 
92
- def run
93
- ep = OMF::OML::OmlSqlSource.new(@db_opts, :check_interval => 3.0)
94
- ep.on_new_stream() do |stream|
95
- info "Stream: #{stream.stream_name}"
96
- if stream.stream_name == 'nmetrics_net_if'
97
- setup_nmetric(stream)
92
+ def process_nmetric(table)
93
+ schema = table.schema
94
+ ts_i = schema.index_for_col(:oml_ts_server)
95
+ name_i = schema.index_for_col(:name)
96
+ tx_i = schema.index_for_col(:tx_bytes)
97
+ rx_i = schema.index_for_col(:rx_bytes)
98
+
99
+ def process(l, ts, bytes, max_rate)
100
+ if (delta_t = ts - l[:ts]) > 0
101
+ old_v = l[:bytes]
102
+ delta_v = bytes >= old_v ? bytes - old_v : bytes
103
+ l[:ts] = ts
104
+ l[:bytes] = bytes
105
+ l[:rate] = rate = 1.0 * delta_v / delta_t
106
+ #l[:rate] = rate = 230000
107
+ l[:load] = 1.0 * rate / max_rate
108
+ end
109
+ end
110
+
111
+ table.on_row_added(self) do |r|
112
+ ts = r[ts_i]; name = r[name_i].to_sym; tx = r[tx_i]; rx = r[rx_i]
113
+ @nw.transaction do
114
+ case name
115
+ when :eth0
116
+ process @links[:l20], ts, tx, 120e3 #1e6
117
+ when :wlan0
118
+ process @links[:l21], ts, tx, 4e6
119
+ process @links[:l10], ts, tx, 4e6
120
+ when :wlan1
121
+ process @links[:l32], ts, rx, 4e6
122
+ end
98
123
  end
124
+ sleep 0.5 if ts > 7300
99
125
  end
100
- ep.run
126
+ OMF::Web.register_datasource table, name: 'nmetric'
127
+ end
128
+
129
+ def run
130
+ ep = OMF::OML::OmlSqlSource.new(@db_opts, :check_interval => 3.0)
131
+ t = ep.create_table('nmetrics_net_if', include_oml_internals: true, max_size: 1000)
132
+ process_nmetric(t)
133
+ # ep.on_new_stream() do |stream|
134
+ # info "Stream: #{stream.stream_name}"
135
+ # if stream.stream_name == 'nmetrics_net_if'
136
+ # setup_nmetric(stream)
137
+ # end
138
+ # end
139
+ # ep.run
101
140
  self
102
141
  end
103
142
 
@@ -10,7 +10,7 @@ $oml_database = 'postgres://norbit.npc.nicta.com.au/openflow-demo?user=oml2&pass
10
10
 
11
11
  def load_environment
12
12
  require 'omf-web/content/file_repository'
13
- OMF::Web::FileContentRepository.register_file_repo(:code, File.join(File.dirname(__FILE__), 'repository'), true)
13
+ OMF::Web::ContentRepository.register_repo(:code, type: 'file', path: File.join(File.dirname(__FILE__), 'repository'))
14
14
 
15
15
 
16
16
  Dir.glob("#{File.dirname(__FILE__)}/*_source.rb").each do |fn|