Changes between Version 5 and Version 6 of GEC22Agenda/LabWiki/ModuleA/Execute


Ignore:
Timestamp:
03/09/15 15:46:49 (4 years ago)
Author:
eswer18@gmail.com
Comment:

--

Legend:

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

    v5 v6  
    190190* Students can be asked to implement a particular functionality of the OpenFlow controller. A template should be given to them. [[BR]]
    191191* !LabWiki has a new feature that enables the instructor to auto-grade the students' experiments. LabWiki allows graders to write a user-defined event, which is triggered when an 
    192 experiment-generated measurement reaches a specific value. In the above script, an event will be triggered when Node A is able to ping all the other nodes in the topology. It will then trigger a ping event to itself on Node A. If a ping with the IP address of Node A is also seen on the graph, the experiment ran successfully.
     192experiment-generated measurement reaches a specific value. In the script below, MY_EVENT is the user-defined event. The function will be called every 0.5 seconds. It queries the specified stats and checks if Node A is able to ping all other nodes. The event will be triggered once that condition is satisfied. Then, ping application to itself is started on Node A. If a ping with the IP address of Node A is also seen on the graph, the experiment ran successfully.
     193
     194{{{
     195#!ruby
     196defEvent(:MY_EVENT, every: 0.5) do
     197# Query for some measurements...
     198  # returns an array where each element is a hash representing a row from the DB
     199  query = ms('ping').select { [ :remote] }
     200  data = defQuery(query)
     201  # Alternatively the above line could also be:
     202  # data = defQuery('select oml_ts_client, value from signalgen_sin')
     203  #
     204  # Also if you want to rename 'oml_ts_client' to 'ts'
     205  # query = ms('sin').select { [ oml_ts_client.as(:ts), :value ] }
     206  # data = defQuery('select oml_ts_client as ts, value from signalgen_sin')
     207
     208  triggered = false
     209  if !data.nil? && !(last_row = data.pop).nil? # Make sure we have some data
     210    next if peak_list.include?(last_row[:remote]) # Do nothing if we have seen this sample before
     211    if !peak_list.include?(last_row[:remote])
     212      peak_list << last_row[:remote] # record that sample, so we dont trigger on it again
     213    end
     214    if peak_list.include?('192.168.1.9')&&peak_list.include?('192.168.1.7')&&peak_list.include?('192.168.1.8')
     215     
     216      triggered = true
     217    end
     218  end
     219  triggered
     220end
     221onEvent :MY_EVENT do
     222  #group('switch').exec("ping www.google.com")
     223  group('Source3').startApplications
     224end
     225
     226}}}
    193227
    194228= [wiki:GEC22Agenda/LabWiki/ModuleA/Finish Next: Finish] =