Tutorials/a0Basic/Tutorial4: wishful_simple.rb

File wishful_simple.rb, 1.4 KB (added by seskar, 19 months ago)

WiSHFUL Platform Illustration Tutorial Script

Line 
1# -*- coding: utf-8 -*-
2defProperty('contr', 'node2-1', 'WiSHFUL Controller Node')
3defProperty('agent', 'node1-1', 'WiSHUL Agent Node')
4defProperty('path','/root/wishful/examples/simple/',"Path to WiSHFUL configuration directory")
5defProperty('duration', 60, "Seconds to run the application")
6
7defApplication('controller') do |app|
8  app.description = 'WiSHFUL Simple Controller Program'
9  app.path = property.path+'wishful_simple_controller'
10  app.defProperty('config', 'Configuration file', '--config', {:type => :string})
11end
12
13defApplication('agent') do |app|
14  app.description = 'WiSHFUL Simple Agent Program'
15  app.path = property.path+'wishful_simple_agent'
16  app.defProperty('config', 'Configuration file', '--config', {:type => :string})
17end
18
19defGroup( 'Controllers', property.contr ) do |node|
20  info "Controller will be on #{property.contr}."
21  node.addApplication( "controller" ) do |app|
22    app.setProperty('config', property.path+'controller_config.yaml')
23  end
24end
25
26defGroup( 'Agents', property.agent ) do |node|
27  info "Agent will be on #{property.agent}."
28  node.addApplication( "agent" ) do |app|
29    app.setProperty('config', property.path+'agent_config.yaml')
30  end
31end
32
33onEvent(:ALL_UP_AND_INSTALLED) do |event|
34  info "Wait for all nodes to come up" 
35  wait 10
36  allGroups.startApplications
37  info "Both controller and agent started..." 
38  wait property.duration
39  allGroups.stopApplications
40  info "Both controller and agent stopped..." 
41  Experiment.done
42end
43