Changes between Initial Version and Version 1 of Old/NodeHandler/LaunchApps


Ignore:
Timestamp:
Nov 10, 2005, 2:24:55 AM (19 years ago)
Author:
Surya Satyavolu
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Old/NodeHandler/LaunchApps

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