Changes between Version 4 and Version 5 of GEC21Agenda/LabWiki/ModuleA/Execute


Ignore:
Timestamp:
03/09/15 13:41:23 (9 years ago)
Author:
eswer18@gmail.com
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • GEC21Agenda/LabWiki/ModuleA/Execute

    v4 v5  
    2424#!ruby
    2525
    26 defProperty('resource1', "nodea", "ID of a resource")
    27 defProperty('resource2', "switch", "ID of a resource")
     26defProperty('source1', "nodea-learningswitch", "ID of a resource")
     27defProperty('source2', "switch-learningswitch", "ID of a resource")
    2828
    2929
     
    3232
    3333defProperty('sinkaddr21', '192.168.1.9', "Ping destination address")
    34 
     34defProperty('sinkaddr11', '192.168.1.6', "Ping destination address")
     35peak_list = []
    3536
    3637defApplication('ping') do |app|
     
    5960  app.binary_path = '/bin/sh /root/ovs-setup2.sh'
    6061end
    61 defGroup('Source2', property.resource2) do |node|
     62defGroup('Source2', property.source2) do |node|
    6263  node.addApplication("trema")
    6364end
    64 defGroup('Source1', property.resource1) do |node|
     65defGroup('Source1', property.source1) do |node|
    6566  node.addApplication("ping") do |app|
    6667    app.setProperty('target', property.sinkaddr12)
     
    8384end
    8485
     86defGroup('Source3', property.source1) do |node|
     87  node.addApplication("ping") do |app|
     88    app.setProperty('target', property.sinkaddr11)
     89    app.setProperty('count', 30)
     90    #app.setProperty('interval', 1)
     91    app.measure('ping', :samples => 1)
     92  end
     93end
     94
     95defEvent(:MY_EVENT, every: 0.5) do
     96# Query for some measurements...
     97  # returns an array where each element is a hash representing a row from the DB
     98  query = ms('ping').select { [ :remote] }
     99  data = defQuery(query)
     100  # Alternatively the above line could also be:
     101  # data = defQuery('select oml_ts_client, value from signalgen_sin')
     102  #
     103  # Also if you want to rename 'oml_ts_client' to 'ts'
     104  # query = ms('sin').select { [ oml_ts_client.as(:ts), :value ] }
     105  # data = defQuery('select oml_ts_client as ts, value from signalgen_sin')
     106
     107  triggered = false
     108  if !data.nil? && !(last_row = data.pop).nil? # Make sure we have some data
     109    next if peak_list.include?(last_row[:remote]) # Do nothing if we have seen this sample before
     110    if !peak_list.include?(last_row[:remote])
     111      peak_list << last_row[:remote] # record that sample, so we dont trigger on it again
     112    end
     113    if peak_list.include?('192.168.1.9')&&peak_list.include?('192.168.1.7')&&peak_list.include?('192.168.1.8')
     114     
     115      triggered = true
     116    end
     117  end
     118  triggered
     119end
     120onEvent :MY_EVENT do
     121  #group('switch').exec("ping www.google.com")
     122  group('Source3').startApplications
     123end
    85124
    86125onEvent(:ALL_UP_AND_INSTALLED) do |event|
     
    107146  g.yaxis :legend => 'rtt', :ticks => {:format => 's'}
    108147end
     148
    109149
    110150}}}