Changes between Version 7 and Version 8 of Old/NodeHandler/LaunchApps
- Timestamp:
- Jun 2, 2006, 3:05:34 AM (18 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Old/NodeHandler/LaunchApps
v7 v8 19 19 # Create an application representation from scratch 20 20 # 21 require 'handler/appDefinition'22 21 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 22 defApplication('test:app:tcpdump', "tcpdump") { |a| 23 a.version(0, 0, 1) 24 a.shortDescription = "Tcpdump application" 25 a.description = <<TEXT 28 26 TCPDump application 29 27 TEXT 30 28 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) 32 31 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 } 60 35 }}} 61 36 62 37 63 38 == Step 2: Prototype definition == 64 After informing nodeHandler about our new application, we then need to create a prototype using our application definition.39 After informing nodeHandler about our new application, we then create a prototype using our application definition to allow for reuse. 65 40 66 41 '''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''' 68 44 {{{ 69 45 # … … 71 47 # 72 48 73 require 'handler/prototype'74 require 'handler/filter'75 require 'handler/appDefinition'76 49 77 p = Prototype.create("test:proto:tcpdumper") 78 p.name = "TCPdump proto" 79 p.description = "TCPdump" 80 p.defProperty('interface', 'Interface to listen on') 50 defPrototype("test:proto:tcpdumper", "TCPdump proto") { |p| 51 p.description = "TCPdump" 52 p.defProperty('interface', 'Interface to listen on') 81 53 82 54 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 } 93 59 }}} 94 60 … … 107 73 # Define nodes used in experiment 108 74 # 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", { 75 defNodes('nodes', [[1,1],[1,2]]) {|ns| 76 ns.prototype("test:proto:tcpdumper", { 113 77 'interface' => 'eth1' #This is where we assign the interface for this specific instance 114 78 }) 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 } 123 85 } 124 86 … … 130 92 131 93 #startApplications will launch all the applications defined for the group "nodes" 132 NodeSet['nodes'].startApplications 133 134 94 nodes('nodes').startApplications 135 95 136 96 wait 180