Changes between Version 7 and Version 8 of Old/NodeHandler/LaunchApps


Ignore:
Timestamp:
Jun 2, 2006, 3:05:34 AM (18 years ago)
Author:
max
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Old/NodeHandler/LaunchApps

    v7 v8  
    1919# Create an application representation from scratch
    2020#
    21 require 'handler/appDefinition'
    2221
    23 a = AppDefinition.create('test:app:tcpdump')
    24 a.name = "tcpdump"
    25 a.version(0, 0, 1)
    26 a.shortDescription = "Tcpdump application"
    27 a.description = <<TEXT
     22defApplication('test:app:tcpdump', "tcpdump") { |a|
     23  a.version(0, 0, 1)
     24  a.shortDescription = "Tcpdump application"
     25  a.description = <<TEXT
    2826TCPDump application
    2927TEXT
    3028
    31 # addProperty(name, description, mnemonic, type, isDynamic = false, constraints = nil)
     29  #Here ?i means tcpdump will be launched with -i <interface> option
     30  a.defProperty('interface', 'Interface to run on', ?i, String, false)
    3231
    33 #Here ?i means tcpdump will be launched with -i <interface> option
    34 a.addProperty('interface', 'Interface to run on', ?i, String, false)
    35 
    36 # Path of your application on the node/image.
    37 a.path = "/usr/sbin/tcpdump"
    38 
    39 if $0 == __FILE__
    40   require 'stringio'
    41   require 'rexml/document'
    42   include REXML
    43 
    44   sio = StringIO.new()
    45   a.to_xml.write(sio, 2)
    46   sio.rewind
    47   puts sio.read
    48 
    49   sio.rewind
    50   doc = Document.new(sio)
    51   t = AppDefinition.from_xml(doc.root)
    52 
    53   puts
    54   puts "-------------------------"
    55   puts
    56   t.to_xml.write($stdout, 2)
    57 
    58 end
    59 
     32  # Path of your application on the node/image.
     33  a.path = "/usr/sbin/tcpdump"
     34}
    6035}}}
    6136 
    6237
    6338== Step 2: Prototype definition ==
    64 After informing nodeHandler about our new application, we then need to create a prototype using our application definition.
     39After informing nodeHandler about our new application, we then create a prototype using our application definition to allow for reuse.
    6540
    6641'''Think about this as an instance of your above class'''
    67  * '''Put this file in your home directory as test_proto_tcpdumper.rb'''
     42
     43'''NOTE: Put this file in your home directory as test_proto_tcpdumper.rb'''
    6844{{{
    6945#
     
    7147#
    7248
    73 require 'handler/prototype'
    74 require 'handler/filter'
    75 require 'handler/appDefinition'
    7649
    77 p = Prototype.create("test:proto:tcpdumper")
    78 p.name = "TCPdump proto"
    79 p.description = "TCPdump"
    80 p.defProperty('interface', 'Interface to listen on')
     50defPrototype("test:proto:tcpdumper", "TCPdump proto") { |p|
     51  p.description = "TCPdump"
     52  p.defProperty('interface', 'Interface to listen on')
    8153
    8254
    83 tcpd = p.addApplication('tcpd', "test:app:tcpdump")
    84 tcpd.bindProperty('interface')
    85 
    86 
    87 
    88 if $0 == __FILE__
    89   p.to_xml.write($stdout, 2)
    90   puts
    91 end
    92 
     55  p.addApplication('tcpd', "test:app:tcpdump") { |tcpd|
     56    tcpd.bindProperty('interface')
     57  }
     58}
    9359}}}
    9460
     
    10773# Define nodes used in experiment
    10874#
    109 defNodes('nodes', [[1,1],[1,2]]) {|node|
    110   node.image = nil  # assume the right image to be on disk
    111 
    112   node.prototype("test:proto:tcpdumper", {
     75defNodes('nodes', [[1,1],[1,2]]) {|ns|
     76  ns.prototype("test:proto:tcpdumper", {
    11377    'interface' => 'eth1' #This is where we assign the interface for this specific instance
    11478   })
    115   node.net.w0.mode = "master"
    116 }
    117 
    118 
    119 allNodes.net.w0 { |w|
    120   w.type = 'b'
    121   w.essid = "helloworld"
    122   w.ip = "%192.168.%x.%y"
     79  ns.net.w0 { |w|
     80    w.mode = "master"
     81    w.type = 'b'
     82    w.essid = "helloworld"
     83    w.ip = "%192.168.%x.%y"
     84  }
    12385}
    12486
     
    13092
    13193  #startApplications will launch all the applications defined for the group "nodes"
    132   NodeSet['nodes'].startApplications
    133 
    134  
     94  nodes('nodes').startApplications
    13595
    13696  wait 180