Changes between Version 6 and Version 7 of GEC22Agenda/LabWiki/ModuleC/Execute


Ignore:
Timestamp:
03/10/15 12:53:22 (9 years ago)
Author:
eswer18@gmail.com
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • GEC22Agenda/LabWiki/ModuleC/Execute

    v6 v7  
    2929{{{
    3030#!ruby
    31 defProperty('source1', "nodea-dbhatpostboot", "ID of a resource")
    32 defProperty('source2', "switch1-dbhatpostboot", "ID of a resource")
    33 defProperty('source3', "switch2-dbhatpostboot", "ID of a resource")
    34 
     31
     32defProperty('source1', "nodea-extend1", "ID of a resource")
     33defProperty('source2', "switch1-extend1", "ID of a resource")
     34defProperty('source3', "switch2-extend1", "ID of a resource")
     35peak_list = []
    3536
    3637defProperty('sinkaddr12', '192.168.1.7', "Ping destination address")
     
    4041defProperty('sinkaddr23', '192.168.1.14', "Ping destination address")
    4142defProperty('sinkaddr24', '192.168.1.15', "Ping destination address")
    42 
     43defProperty('sinkaddr11', '192.168.1.6', "Ping destination address")
    4344
    4445defApplication('ping') do |app|
     
    6566defApplication('trema') do |app|
    6667  app.description = 'This app runs trema from command line'
    67   app.binary_path = '/usr/bin/trema run /root/learning-switch.rb'
     68  app.binary_path = '/bin/sh /root/ovs-setup2.sh'
    6869end
    6970defGroup('Source2', property.source2, property.source3) do |node|
     
    103104end
    104105
    105 
    106 
    107 
    108 
    109 #defGroup('Sink1', property.sink1) do |node|
    110 #end
    111 
    112 #defGroup('Sink2', property.sink2) do |node|
    113 #end
    114 
    115 #defGroup('Sink3', property.sink3) do |node|
    116 #end
    117 
    118 #defGroup('Sink4', property.sink4) do |node|
    119 #end
    120 
    121 #defGroup('Sink5', property.sink5) do |node|
    122 #end
     106defGroup('Source3', property.source1) do |node|
     107  node.addApplication("ping") do |app|
     108    app.setProperty('target', property.sinkaddr11)
     109    app.setProperty('count', 30)
     110    #app.setProperty('interval', 1)
     111    app.measure('ping', :samples => 1)
     112  end
     113end
     114
     115defEvent(:MY_EVENT, every: 0.5) do
     116# Query for some measurements...
     117  # returns an array where each element is a hash representing a row from the DB
     118  query = ms('ping').select { [ :remote] }
     119  data = defQuery(query)
     120  # Alternatively the above line could also be:
     121  # data = defQuery('select oml_ts_client, value from signalgen_sin')
     122  #
     123  # Also if you want to rename 'oml_ts_client' to 'ts'
     124  # query = ms('sin').select { [ oml_ts_client.as(:ts), :value ] }
     125  # data = defQuery('select oml_ts_client as ts, value from signalgen_sin')
     126
     127  triggered = false
     128  if !data.nil? && !(last_row = data.pop).nil? # Make sure we have some data
     129    next if peak_list.include?(last_row[:remote]) # Do nothing if we have seen this sample before
     130    if !peak_list.include?(last_row[:remote])
     131      peak_list << last_row[:remote] # record that sample, so we dont trigger on it again
     132    end
     133    if peak_list.include?('192.168.1.7')&&peak_list.include?('192.168.1.8')&&peak_list.include?('192.168.1.13')&&peak_list.include?('192.168.1.14')&&peak_list.include?('192.168.1.15')
     134     
     135      triggered = true
     136    end
     137  end
     138  triggered
     139end
     140onEvent :MY_EVENT do
     141  #group('switch').exec("ping www.google.com")
     142  group('Source3').startApplications
     143end
    123144
    124145onEvent(:ALL_UP_AND_INSTALLED) do |event|
     
    127148    group('Source2').startApplications
    128149  end
    129   after 10 do
     150  after 20 do
    130151    group('Source1').startApplications
    131152  end
     
    145166  g.yaxis :legend => 'rtt', :ticks => {:format => 's'}
    146167end
     168
    147169}}}
    148170