Changes between Initial Version and Version 1 of Old/omf-4-4/LaunchApp


Ignore:
Timestamp:
Nov 16, 2005, 11:03:28 PM (19 years ago)
Author:
Surya Satyavolu
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Old/omf-4-4/LaunchApp

    v1 v1  
     1= How to integrate your application with nodehandler =
     2
     3This tutorial is for users who want to use [wiki:NodeHandler nodeHandler] to launch their applications on the nodes. For example, we assume that you want to launch
     4{{{
     5   tcpdump -i eth1
     6}}}
     7on all the nodes in the experiment.
     8
     9Three steps are needed
     10
     11== Step 1: Create application definition file ==
     12This definition tells the nodehandler about your new application that you want to launch. It mainly includes details such as what are the command line options it takes and what are the statistics it returns. Here is a sample application definition for our above application
     13
     14'''Think about this as a class definition for your application'''
     15 * '''Put this file in your home directory as test_app_tcpdump.rb'''
     16
     17{{{
     18#
     19# Create an application representation from scratch
     20#
     21require 'handler/appDefinition'
     22
     23a = AppDefinition.create('test:app:tcpdump')
     24a.name = "tcpdump"
     25a.version(0, 0, 1)
     26a.shortDescription = "Tcpdump application"
     27a.description = <<TEXT
     28TCPDump application
     29TEXT
     30
     31# addProperty(name, description, mnemonic, type, isDynamic = false, constraints = nil)
     32
     33#Here ?i means tcpdump will be launched with -i <interface> option
     34a.addProperty('interface', 'Interface to run on', ?i, String, false)
     35
     36a.path = "/usr/sbin/tcpdump"
     37
     38if $0 == __FILE__
     39  require 'stringio'
     40  require 'rexml/document'
     41  include REXML
     42
     43  sio = StringIO.new()
     44  a.to_xml.write(sio, 2)
     45  sio.rewind
     46  puts sio.read
     47
     48  sio.rewind
     49  doc = Document.new(sio)
     50  t = AppDefinition.from_xml(doc.root)
     51
     52  puts
     53  puts "-------------------------"
     54  puts
     55  t.to_xml.write($stdout, 2)
     56
     57end
     58
     59}}}
     60 
     61
     62== Step 2: Prototype definition ==
     63After informing nodeHandler about our new application, we then need to create a prototype using our application definition.
     64
     65'''Think about this as an instance of your above class'''
     66 * '''Put this file in your home directory as test_proto_tcpdumper.rb'''
     67{{{
     68#
     69# Define a prototype
     70#
     71
     72require 'handler/prototype'
     73require 'handler/filter'
     74require 'handler/appDefinition'
     75
     76p = Prototype.create("test:proto:tcpdumper")
     77p.name = "TCPdump proto"
     78p.description = "TCPdump"
     79p.defProperty('interface', 'Interface to listen on')
     80
     81
     82tcpd = p.addApplication('aodvd', "test:app:tcpdump")
     83tcpd.bindProperty('interface')
     84
     85
     86
     87if $0 == __FILE__
     88  p.to_xml.write($stdout, 2)
     89  puts
     90end
     91
     92}}}
     93
     94== Step 3: Using this prototype in an actual script ==
     95
     96The following example script uses our newly defined application definition.
     97{{{
     98##################################################
     99# TCPDump using nodeHandler
     100##################################################
     101
     102Experiment.name = "tutorial-tcpdump"
     103Experiment.project = "orbit:tutorial"
     104
     105#
     106# Define nodes used in experiment
     107#
     108defNodes('nodes', [[1,1],[1,2]]) {|node|
     109  node.image = nil  # assume the right image to be on disk
     110
     111  node.prototype("test:proto:tcpdumper", {
     112    'interface' => 'eth1' #This is where we assign the interface for this specific instance
     113   })
     114  node.net.w0.mode = "master"
     115}
     116
     117
     118allNodes.net.w0 { |w|
     119  w.type = 'b'
     120  w.essid = "helloworld"
     121  w.ip = "%192.168.%x.%y"
     122}
     123
     124#
     125# Now, start the application
     126#
     127whenAllInstalled() {|node|
     128 # Launch TCPdump on all nodes
     129
     130  #startApplications will launch all the applications defined for the group "nodes"
     131  NodeSet['nodes'].startApplications
     132
     133 
     134
     135  wait 180
     136
     137  Experiment.done
     138}
     139
     140}}}