# -*- coding: utf-8 -*-
defProperty('contr', 'node2-1', 'WiSHFUL Controller Node')
defProperty('agent', 'node1-1', 'WiSHUL Agent Node')
defProperty('path','/root/wishful/examples/simple/',"Path to WiSHFUL configuration directory")
defProperty('duration', 60, "Seconds to run the application")

defApplication('controller') do |app|
  app.description = 'WiSHFUL Simple Controller Program'
  app.path = property.path+'wishful_simple_controller'
  app.defProperty('config', 'Configuration file', '--config', {:type => :string})
end

defApplication('agent') do |app|
  app.description = 'WiSHFUL Simple Agent Program'
  app.path = property.path+'wishful_simple_agent'
  app.defProperty('config', 'Configuration file', '--config', {:type => :string})
end

defGroup( 'Controllers', property.contr ) do |node|
  info "Controller will be on #{property.contr}."
  node.addApplication( "controller" ) do |app|
    app.setProperty('config', property.path+'controller_config.yaml')
  end
end

defGroup( 'Agents', property.agent ) do |node|
  info "Agent will be on #{property.agent}."
  node.addApplication( "agent" ) do |app|
    app.setProperty('config', property.path+'agent_config.yaml')
  end
end

onEvent(:ALL_UP_AND_INSTALLED) do |event|
  info "Wait for all nodes to come up" 
  wait 10
  allGroups.startApplications
  info "Both controller and agent started..." 
  wait property.duration
  allGroups.stopApplications
  info "Both controller and agent stopped..." 
  Experiment.done
end

