wiki:Old/NodeHandler/LaunchApps

How to integrate your application with nodehandler

This tutorial is for users who want to use nodeHandler to launch their applications on the nodes. For example, we assume that you want to launch

   tcpdump -i eth1

on all the nodes in the experiment.

Three steps are needed

Step 1: Create application definition file

This 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

Think about this as a class definition for your application

  • Put this file in your home directory as test_app_tcpdump.rb
#
# Create an application representation from scratch
#

defApplication('test:app:tcpdump', "tcpdump") { |a|
  a.version(0, 0, 1)
  a.shortDescription = "Tcpdump application"
  a.description = <<TEXT
TCPDump application
TEXT

  #Here ?i means tcpdump will be launched with -i <interface> option
  a.defProperty('interface', 'Interface to run on', ?i, String, false)

  # Path of your application on the node/image.
  a.path = "/usr/sbin/tcpdump"
}

Step 2: Prototype definition

After informing nodeHandler about our new application, we then create a prototype using our application definition to allow for reuse.

Think about this as an instance of your above class

NOTE: Put this file in your home directory as test_proto_tcpdumper.rb

#
# Define a prototype
#


defPrototype("test:proto:tcpdumper", "TCPdump proto") { |p|
  p.description = "TCPdump"
  p.defProperty('interface', 'Interface to listen on')


  p.addApplication('tcpd', "test:app:tcpdump") { |tcpd|
    tcpd.bindProperty('interface')
  }
}

Step 3: Using this prototype in an actual script

The following example script uses our newly defined application definition.

##################################################
# TCPDump using nodeHandler
##################################################

Experiment.name = "tutorial-tcpdump"
Experiment.project = "orbit:tutorial"

#
# Define nodes used in experiment
#
defNodes('nodes', [[1,1],[1,2]]) {|ns|
  ns.prototype("test:proto:tcpdumper", {
    'interface' => 'eth1' #This is where we assign the interface for this specific instance
   })
  ns.net.w0 { |w|
    w.mode = "master"
    w.type = 'b'
    w.essid = "helloworld"
    w.ip = "%192.168.%x.%y"
  }
}

#
# Now, start the application
#
whenAllInstalled() {|node|
 # Launch TCPdump on all nodes

  #startApplications will launch all the applications defined for the group "nodes"
  nodes('nodes').startApplications

  wait 180

  Experiment.done
}

Last modified 19 years ago Last modified on Jun 2, 2006, 3:05:34 AM
Note: See TracWiki for help on using the wiki.