omf_ec 6.0.2.pre.2 → 6.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/bin/omf_ec CHANGED
@@ -23,9 +23,9 @@ flag [:u, :uri]
23
23
  desc "Debug XMPP traffic mode (include XMPP debug logging messages under debug mode)."
24
24
  switch [:x, :xmpp]
25
25
 
26
- desc "Root certificate file"
27
- arg_name "cert", :optional
28
- flag [:root_cert]
26
+ desc "Directory containing root certificates"
27
+ arg_name "directory", :optional
28
+ flag [:root_cert_dir]
29
29
 
30
30
  desc "Your certificate"
31
31
  arg_name "cert", :optional
@@ -40,6 +40,7 @@ arg_name "directory"
40
40
  default_value "/tmp"
41
41
  flag [:log_file_dir]
42
42
 
43
+ # the path given here is relative to the user's home directory
43
44
  config_file(".config/omf_ec.yml")
44
45
 
45
46
  desc "Execute an experiment script"
@@ -196,16 +197,14 @@ on_error do |exception|
196
197
  end
197
198
 
198
199
  pre do |global_options, command, options, args|
200
+ #opts = OmfCommon.load_yaml(config_file_name) if File.exist?(config_file_name)
201
+ #opts.delete("commands")
202
+ #global_options.merge!(opts)
203
+
199
204
  unless global_options[:uri]
200
205
  help_now! "Incomplete options. Need communication URI"
201
206
  end
202
207
 
203
-
204
- # Import private key
205
- if global_options[:private_key]
206
- OmfCommon::Key.instance.import(global_options[:private_key])
207
- end
208
-
209
208
  # Check version
210
209
  if options[:check]
211
210
  File.open(args[0], 'r') do |f|
@@ -247,10 +246,6 @@ end
247
246
 
248
247
  def load_exp(exp_path, global_options = {} , options = {}, properties = {})
249
248
  begin
250
- if global_options[:root_cert] && File.exist?(global_options[:root_cert])
251
- root = OmfCommon::Auth::Certificate.create_from_x509(File.read(global_options[:root_cert]))
252
- end
253
-
254
249
  if global_options[:cert] && File.exist?(global_options[:cert]) &&
255
250
  global_options[:key] && File.exist?(global_options[:key])
256
251
 
@@ -273,7 +268,7 @@ def load_exp(exp_path, global_options = {} , options = {}, properties = {})
273
268
  }
274
269
  }
275
270
 
276
- opts[:communication][:auth] = { certs: [ root.to_pem_compact ] } if root
271
+ opts[:communication][:auth] = {} if entity
277
272
 
278
273
  OmfCommon.init(:development, opts) do |el|
279
274
  setup_logging(global_options)
@@ -282,7 +277,7 @@ def load_exp(exp_path, global_options = {} , options = {}, properties = {})
282
277
  info "Connected using #{comm.conn_info}"
283
278
  info "Start experiment: #{OmfEc.experiment.id}"
284
279
 
285
- OmfCommon::Auth::CertificateStore.instance.register(root) if root
280
+ OmfCommon::Auth::CertificateStore.instance.register_default_certs(global_options[:root_cert_dir]) if global_options[:root_cert_dir]
286
281
  OmfCommon::Auth::CertificateStore.instance.register(entity, OmfCommon.comm.local_address) if entity
287
282
 
288
283
  begin
@@ -1,15 +1,18 @@
1
+ # Copyright (c) 2012 National ICT Australia Limited (NICTA).
2
+ # This software may be used and distributed solely under the terms of the MIT license (License).
3
+ # You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
4
+ # By downloading or using this software you accept the terms and the liability disclaimer in the License.
5
+
1
6
  # OMF_VERSIONS = 6.0
2
7
  #
3
8
 
4
- def_property('name', 'garage', 'Name of garage')
5
-
6
- garage = prop.name
9
+ def_property('garage', 'garage', 'Name of garage')
7
10
 
8
11
  defEvent :engine_created do |state|
9
- # state holds list of resources, and automatically updated once OMF inform messages received.
12
+ # state is an array holds list of resources, and automatically updated once OMF inform messages received.
10
13
  state.find_all do |v|
11
- v[:type] == 'engine'
12
- end.size >= 1
14
+ v[:type] == 'engine' && !v[:membership].empty?
15
+ end.size > 0
13
16
  end
14
17
 
15
18
  defEvent :rpm_reached_4000 do |state|
@@ -19,34 +22,34 @@ defEvent :rpm_reached_4000 do |state|
19
22
  end
20
23
 
21
24
  # Define a group and add garages to it.
22
- defGroup('garages', garage)
25
+ defGroup('garages', prop.garage)
23
26
 
24
27
  # :ALL_UP is a pre-defined event,
25
28
  # triggered when all resources set to be part of groups are available and configured as members of the associated groups.
26
29
  onEvent :ALL_UP do
27
30
  group('garages') do |g|
28
- g.create_resource('primary_engine', type: 'engine', sn: rand(1000))
31
+ g.create_resource('my_engine', type: 'engine')
29
32
 
30
33
  onEvent :engine_created do
31
34
  info ">>> Accelerating all engines"
32
- g.resources[type: 'engine'][name: 'primary_engine'].throttle = 50
35
+ g.resources[type: 'engine'].throttle = 50
33
36
 
34
- g.resources[type: 'engine'][name: 'primary_engine'].sn
35
- g.resources[type: 'engine'][name: 'primary_engine'].membership
37
+ # We periodically check engine RPM
38
+ every 2.second do
39
+ g.resources[type: 'engine'].rpm
40
+ end
36
41
  end
37
42
 
38
43
  onEvent :rpm_reached_4000 do
39
44
  info ">>> Engine RPM reached 4000"
40
-
41
45
  info ">>> Reduce engine throttle"
42
46
  g.resources[type: 'engine'].throttle = 0
47
+ end
43
48
 
44
- after 7.seconds do
45
- info ">>> Release engines"
46
- g.resources[type: 'engine'].release
47
-
48
- done!
49
- end
49
+ after 20.seconds do
50
+ info ">>> Release engines"
51
+ g.resources[type: 'engine'].release
52
+ done!
50
53
  end
51
54
  end
52
55
  end
@@ -1,3 +1,8 @@
1
+ # Copyright (c) 2012 National ICT Australia Limited (NICTA).
2
+ # This software may be used and distributed solely under the terms of the MIT license (License).
3
+ # You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
4
+ # By downloading or using this software you accept the terms and the liability disclaimer in the License.
5
+
1
6
  # OMF_VERSIONS = 6.0
2
7
 
3
8
  def create_engine(garage)
@@ -42,19 +47,18 @@ def on_engine_created(engine)
42
47
  end
43
48
 
44
49
  # Monitor all status information from the engine
45
- engine.on_status do |msg|
46
- msg.each_property do |name, value|
47
- info "#{name} => #{value}"
50
+ engine.on_inform do |msg|
51
+ case msg.itype
52
+ when 'STATUS'
53
+ msg.each_property do |name, value|
54
+ info "#{name}: #{value}"
55
+ end
56
+ when 'ERROR'
57
+ error msg[:reason]
58
+ when 'WARN'
59
+ warn msg[:reason]
48
60
  end
49
61
  end
50
-
51
- engine.on_error do |msg|
52
- error msg[:reason]
53
- end
54
-
55
- engine.on_warn do |msg|
56
- warn msg[:reason]
57
- end
58
62
  end
59
63
 
60
64
  OmfCommon.comm.subscribe('garage') do |garage|
@@ -1,3 +1,8 @@
1
+ # Copyright (c) 2012 National ICT Australia Limited (NICTA).
2
+ # This software may be used and distributed solely under the terms of the MIT license (License).
3
+ # You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
4
+ # By downloading or using this software you accept the terms and the liability disclaimer in the License.
5
+
1
6
  # We can use communicator to interact with XMPP server
2
7
  #
3
8
  # Find all top level pubsub nodes
@@ -1,3 +1,8 @@
1
+ # Copyright (c) 2012 National ICT Australia Limited (NICTA).
2
+ # This software may be used and distributed solely under the terms of the MIT license (License).
3
+ # You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
4
+ # By downloading or using this software you accept the terms and the liability disclaimer in the License.
5
+
1
6
  #
2
7
  # Test 1
3
8
  #
@@ -1,3 +1,8 @@
1
+ # Copyright (c) 2012 National ICT Australia Limited (NICTA).
2
+ # This software may be used and distributed solely under the terms of the MIT license (License).
3
+ # You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
4
+ # By downloading or using this software you accept the terms and the liability disclaimer in the License.
5
+
1
6
  #
2
7
  # Test 2
3
8
  #
@@ -1,3 +1,8 @@
1
+ # Copyright (c) 2012 National ICT Australia Limited (NICTA).
2
+ # This software may be used and distributed solely under the terms of the MIT license (License).
3
+ # You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
4
+ # By downloading or using this software you accept the terms and the liability disclaimer in the License.
5
+
1
6
  #
2
7
  # Test 3
3
8
  #
@@ -1,3 +1,8 @@
1
+ # Copyright (c) 2012 National ICT Australia Limited (NICTA).
2
+ # This software may be used and distributed solely under the terms of the MIT license (License).
3
+ # You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
4
+ # By downloading or using this software you accept the terms and the liability disclaimer in the License.
5
+
1
6
  #
2
7
  # Test 6
3
8
  #
@@ -62,7 +67,7 @@ def check_outcome
62
67
  match2 = match1.grep(/AgentCommands/)
63
68
  result1 = (match2.length == 1) ? true : false
64
69
  # 2)
65
- match1 = lines.grep(/DONE\.OK/)
70
+ match1 = lines.grep(/EXIT/)
66
71
  match2 = match1.grep(/AgentCommands/)
67
72
  result2 = (match2.length >= 2) ? true : false
68
73
 
@@ -1,3 +1,8 @@
1
+ # Copyright (c) 2012 National ICT Australia Limited (NICTA).
2
+ # This software may be used and distributed solely under the terms of the MIT license (License).
3
+ # You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
4
+ # By downloading or using this software you accept the terms and the liability disclaimer in the License.
5
+
1
6
  #
2
7
  # Test 7
3
8
  #
@@ -1,3 +1,8 @@
1
+ # Copyright (c) 2012 National ICT Australia Limited (NICTA).
2
+ # This software may be used and distributed solely under the terms of the MIT license (License).
3
+ # You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
4
+ # By downloading or using this software you accept the terms and the liability disclaimer in the License.
5
+
1
6
  require 'securerandom'
2
7
 
3
8
  module OmfEc
@@ -1,3 +1,8 @@
1
+ # Copyright (c) 2012 National ICT Australia Limited (NICTA).
2
+ # This software may be used and distributed solely under the terms of the MIT license (License).
3
+ # You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
4
+ # By downloading or using this software you accept the terms and the liability disclaimer in the License.
5
+
1
6
  module OmfEc
2
7
  module Backward
3
8
  module AppDefinition
@@ -39,8 +44,25 @@ module OmfEc
39
44
  define_parameter(Hash[name,opts])
40
45
  end
41
46
 
42
- def defMetric(name,type)
43
- @fields << {:field => name, :type => type}
47
+ # Define metrics to measure
48
+ #
49
+ # @param [String] name of the metric
50
+ # @param [Symbol] type of the metric data. For all supporting metric data types, refers to http://oml.mytestbed.net/doc/oml/latest/oml2-scaffold.1.html#_mp_defmetric_name_type
51
+ # @param [Hash] opts additional options
52
+ #
53
+ # @option opts [String] :unit unit of measure of the metric
54
+ # @option opts [String] :description of the metric
55
+ # @option opts [Float] :precision precision of the metric value
56
+ # @option opts [Range] :range value range of the metric
57
+ #
58
+ # @example OEDL
59
+ # app.defMeasurement("power") do |mp|
60
+ # mp.defMetric('power', :double, unit: "W", precision: 0.1, description: 'Power')
61
+ # end
62
+ def defMetric(name,type, opts = {})
63
+ # the third parameter used to be a description string
64
+ opts = {:description => opts} if opts.class!=Hash
65
+ @fields << {:field => name, :type => type}.merge(opts)
44
66
  end
45
67
 
46
68
  # XXX: This should be provided by the omf-oml glue.
@@ -48,7 +70,7 @@ module OmfEc
48
70
  mp = {:mp => name, :fields => []}
49
71
  @fields = []
50
72
  # call the block with ourserlves to process its 'defMetric' statements
51
- block.call(self) if block
73
+ block.call(self) if block
52
74
  @fields.each { |f| mp[:fields] << f }
53
75
  define_measurement_point(mp)
54
76
  end
@@ -1,3 +1,8 @@
1
+ # Copyright (c) 2012 National ICT Australia Limited (NICTA).
2
+ # This software may be used and distributed solely under the terms of the MIT license (License).
3
+ # You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
4
+ # By downloading or using this software you accept the terms and the liability disclaimer in the License.
5
+
1
6
  class Array
2
7
  def startApplications
3
8
  if !self.empty? && self.all? { |v| v.class == OmfEc::Group }
@@ -1,3 +1,8 @@
1
+ # Copyright (c) 2012 National ICT Australia Limited (NICTA).
2
+ # This software may be used and distributed solely under the terms of the MIT license (License).
3
+ # You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
4
+ # By downloading or using this software you accept the terms and the liability disclaimer in the License.
5
+
1
6
  module OmfEc
2
7
  module Backward
3
8
  module DefaultEvents
@@ -9,9 +14,7 @@ module OmfEc
9
14
  def_event :ALL_UP do |state|
10
15
  all_groups? do |g|
11
16
  plan = g.members.uniq.sort
12
- actual = state.find_all do |v|
13
- v[:membership] && v[:membership].include?(g.id)
14
- end.map { |v| v[:address] }.sort
17
+ actual = state.find_all { |v| v.joined?(g.id) }.map { |v| v[:address] }.sort
15
18
 
16
19
  debug "Planned: #{g.name}(#{g.id}): #{plan}"
17
20
  debug "Actual: #{g.name}(#{g.id}): #{actual}"
@@ -49,10 +52,7 @@ module OmfEc
49
52
  def_event :ALL_INTERFACE_UP do |state|
50
53
  all_groups? do |g|
51
54
  plan = g.net_ifs.map { |v| v.conf[:if_name] }.uniq.size * g.members.uniq.size
52
- actual = state.find_all do |v|
53
- v[:membership] &&
54
- (v[:membership].include?("#{g.id}_wlan") || v[:membership].include?("#{g.id}_net"))
55
- end.size
55
+ actual = state.count { |v| v.joined?("#{g.id}_wlan", "#{g.id}_net") }
56
56
  plan == actual
57
57
  end
58
58
  end
@@ -60,13 +60,19 @@ module OmfEc
60
60
  def_event :ALL_UP_AND_INSTALLED do |state|
61
61
  all_groups? do |g|
62
62
  plan = g.app_contexts.size * g.members.uniq.size
63
- actual = state.find_all do |v|
64
- v[:membership] && v[:membership].include?("#{g.id}_application")
65
- end.size
63
+ actual = state.count { |v| v.joined?("#{g.id}_application") }
66
64
  plan == actual
67
65
  end
68
66
  end
69
67
 
68
+ def_event :ALL_APPS_DONE do |state|
69
+ all_groups? do |g|
70
+ plan = (g.execs.size + g.app_contexts.size) * g.members.uniq.size
71
+ actual = state.count { |v| v.joined?("#{g.id}_application") && v[:event] == 'EXIT' }
72
+ plan == 0 ? false : plan == actual
73
+ end
74
+ end
75
+
70
76
  end
71
77
  end
72
78
  end
@@ -1,3 +1,8 @@
1
+ # Copyright (c) 2012 National ICT Australia Limited (NICTA).
2
+ # This software may be used and distributed solely under the terms of the MIT license (License).
3
+ # You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
4
+ # By downloading or using this software you accept the terms and the liability disclaimer in the License.
5
+
1
6
  module OmfEc
2
7
  module Backward
3
8
  module DSL
@@ -1,3 +1,8 @@
1
+ # Copyright (c) 2012 National ICT Australia Limited (NICTA).
2
+ # This software may be used and distributed solely under the terms of the MIT license (License).
3
+ # You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
4
+ # By downloading or using this software you accept the terms and the liability disclaimer in the License.
5
+
1
6
  def create_app(testbed)
2
7
  testbed.create(:application, binary_path: @cmd) do |reply|
3
8
  if reply.success?
@@ -6,11 +11,11 @@ def create_app(testbed)
6
11
  app.on_subscribed do
7
12
  app.configure(state: :running)
8
13
 
9
- app.on_status do |m|
14
+ app.on_inform do |m|
10
15
  case m.itype
11
16
  when 'STATUS'
12
17
  if m[:status_type] == 'APP_EVENT'
13
- after(2) { OmfCommon.comm.disconnect } if m[:event] =~ /DONE.(OK|ERROR)/
18
+ after(2) { OmfCommon.comm.disconnect } if m[:event] =~ /EXIT/
14
19
  info m[:msg] if m[:msg]
15
20
  else
16
21
  m.each_property do |k, v|
@@ -1,3 +1,8 @@
1
+ # Copyright (c) 2012 National ICT Australia Limited (NICTA).
2
+ # This software may be used and distributed solely under the terms of the MIT license (License).
3
+ # You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
4
+ # By downloading or using this software you accept the terms and the liability disclaimer in the License.
5
+
1
6
  require 'securerandom'
2
7
 
3
8
  module OmfEc
@@ -12,10 +17,12 @@ module OmfEc
12
17
  # Create an application for the group and start it
13
18
  #
14
19
  def exec(name)
20
+ self.synchronize do
21
+ self.execs << name
22
+ end
15
23
  create_resource(name, type: 'application', binary_path: name)
16
24
 
17
25
  e_uid = SecureRandom.uuid
18
-
19
26
  e_name = "#{self.name}_application_#{name}_created_#{e_uid}"
20
27
 
21
28
  resource_group_name = "#{self.id}_application"
@@ -1,10 +1,16 @@
1
+ # Copyright (c) 2012 National ICT Australia Limited (NICTA).
2
+ # This software may be used and distributed solely under the terms of the MIT license (License).
3
+ # You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
4
+ # By downloading or using this software you accept the terms and the liability disclaimer in the License.
5
+
1
6
  module OmfEc::Context
7
+ # Holds application configuration
2
8
  class AppContext
3
9
  attr_accessor :name, :app_def, :param_values, :oml_collections
4
10
 
5
11
  # Keep track of contexts for each app, i.e. multiple contexts can share
6
- # the same app def. This happens for example when a group can have the
7
- # same applications added to it many times, but with different parameter
12
+ # the same app def. This happens for example when a group can have the
13
+ # same applications added to it many times, but with different parameter
8
14
  # values for each. Thus we need to distinguish these different context
9
15
  @@context_count = Hash.new
10
16
 
@@ -61,11 +67,11 @@ module OmfEc::Context
61
67
 
62
68
  def properties
63
69
  # deep copy the properties from the app definition
64
- original = Marshal.load(Marshal.dump(app_def.properties))
70
+ original = Marshal.load(Marshal.dump(app_def.properties))
65
71
  # now build the properties for this context
66
72
  # - use the properties from app definition as the base
67
- # - if this context's param_values has a property which also exists in
68
- # the app def and if that property has an assigned value, then
73
+ # - if this context's param_values has a property which also exists in
74
+ # the app def and if that property has an assigned value, then
69
75
  # use that value for the properties of this context
70
76
  p = original.merge({:type => 'application'})
71
77
  @param_values.each do |k,v|
@@ -77,9 +83,9 @@ module OmfEc::Context
77
83
  p[:use_oml] = true
78
84
  p[:oml][:id] = @name
79
85
  p[:oml][:experiment] = OmfEc.experiment.id
80
- p[:oml][:collection] = @oml_collections
86
+ p[:oml][:collection] = @oml_collections
81
87
  end
82
88
  p
83
- end
89
+ end
84
90
  end
85
91
  end
@@ -1,3 +1,8 @@
1
+ # Copyright (c) 2012 National ICT Australia Limited (NICTA).
2
+ # This software may be used and distributed solely under the terms of the MIT license (License).
3
+ # You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
4
+ # By downloading or using this software you accept the terms and the liability disclaimer in the License.
5
+
1
6
  module OmfEc::Context
2
7
  class DefAppContext
3
8
  attr_accessor :conf
@@ -1,4 +1,10 @@
1
+ # Copyright (c) 2012 National ICT Australia Limited (NICTA).
2
+ # This software may be used and distributed solely under the terms of the MIT license (License).
3
+ # You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
4
+ # By downloading or using this software you accept the terms and the liability disclaimer in the License.
5
+
1
6
  module OmfEc::Context
7
+ # Holds group configuration
2
8
  class GroupContext
3
9
  attr_accessor :group
4
10
  attr_accessor :guard
@@ -10,11 +16,32 @@ module OmfEc::Context
10
16
  self
11
17
  end
12
18
 
19
+ # Supports OEDL 6 syntax [] for setting FRCP guard
20
+ #
21
+ # @param [Hash] opts option hash which sets constraints
22
+ #
23
+ # @example Reduce throttle to zero for all resources of type 'engine' from group 'A'
24
+ #
25
+ # group('A') do |g|
26
+ # g.resources[type: 'engine'].throttle = 0
27
+ # end
28
+ #
13
29
  def [](opts = {})
14
30
  self.guard.merge!(opts)
15
31
  self
16
32
  end
17
33
 
34
+ # Calling standard methods or assignments will simply trigger sending a FRCP message
35
+ #
36
+ # @example OEDL
37
+ # # Will send FRCP CONFIGURE message
38
+ # g.resources[type: 'engine'].throttle = 0
39
+ #
40
+ # # Will send FRCP REQUEST message
41
+ # g.resources[type: 'engine'].rpm
42
+ #
43
+ # # Will send FRCP RELEASE message
44
+ # g.resources[type: 'engine'].release
18
45
  def method_missing(name, *args, &block)
19
46
  if name =~ /(.+)=/
20
47
  self.operation = :configure
@@ -27,6 +54,10 @@ module OmfEc::Context
27
54
  send_message(name, *args, &block)
28
55
  end
29
56
 
57
+ # Send FRCP message
58
+ #
59
+ # @param [String] name of the property
60
+ # @param [Object] value of the property, for configuring
30
61
  def send_message(name, value = nil, &block)
31
62
  if self.guard[:type]
32
63
  topic = self.group.resource_topic(self.guard[:type])
@@ -1,4 +1,10 @@
1
+ # Copyright (c) 2012 National ICT Australia Limited (NICTA).
2
+ # This software may be used and distributed solely under the terms of the MIT license (License).
3
+ # You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
4
+ # By downloading or using this software you accept the terms and the liability disclaimer in the License.
5
+
1
6
  module OmfEc::Context
7
+ # Holds network related configuration
2
8
  class NetContext
3
9
  # Wifi frequency channel matching
4
10
  FREQUENCY= {
@@ -18,6 +24,11 @@ module OmfEc::Context
18
24
  self
19
25
  end
20
26
 
27
+ # Property assignment will simply update configuration
28
+ #
29
+ # @example OEDL
30
+ # node.net.w0.mode = "adhoc"
31
+ # node.net.w0.essid = "helloworld"
21
32
  def method_missing(name, *args, &block)
22
33
  if name =~ /(.+)=/
23
34
  net_prop = $1.to_sym
@@ -33,6 +44,7 @@ module OmfEc::Context
33
44
  end
34
45
  end
35
46
 
47
+ # Interchange channel and frequency value
36
48
  def map_channel_freq
37
49
  if self.conf[:channel] && self.conf[:frequency].nil?
38
50
  self.conf[:frequency] = FREQUENCY[self.conf[:channel].to_s.to_i]
@@ -1,3 +1,8 @@
1
+ # Copyright (c) 2012 National ICT Australia Limited (NICTA).
2
+ # This software may be used and distributed solely under the terms of the MIT license (License).
3
+ # You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
4
+ # By downloading or using this software you accept the terms and the liability disclaimer in the License.
5
+
1
6
  require 'omf_ec/context/group_context'
2
7
  require 'omf_ec/context/net_context'
3
8
  require 'omf_ec/context/app_context'
@@ -0,0 +1,11 @@
1
+ # Copyright (c) 2013 National ICT Australia Limited (NICTA).
2
+ # This software may be used and distributed solely under the terms of the MIT license (License).
3
+ # You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
4
+ # By downloading or using this software you accept the terms and the liability disclaimer in the License.
5
+
6
+ class Hash
7
+ def joined?(*group_ids)
8
+ self[:membership] && group_ids.any? { |g_id| self[:membership].include?(g_id) }
9
+ end
10
+ end
11
+
data/lib/omf_ec/dsl.rb CHANGED
@@ -1,3 +1,8 @@
1
+ # Copyright (c) 2012 National ICT Australia Limited (NICTA).
2
+ # This software may be used and distributed solely under the terms of the MIT license (License).
3
+ # You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
4
+ # By downloading or using this software you accept the terms and the liability disclaimer in the License.
5
+
1
6
  require 'active_support/core_ext'
2
7
  require 'eventmachine'
3
8
 
@@ -148,7 +153,7 @@ module OmfEc
148
153
  # Check if any elements in array equals the value provided
149
154
  #
150
155
  def one_equal(array, value)
151
- array.any? ? false : array.all? { |v| v.to_s == value.to_s }
156
+ !array.any? ? false : array.any? { |v| v.to_s == value.to_s }
152
157
  end
153
158
 
154
159
  # Define an event
@@ -1,3 +1,8 @@
1
+ # Copyright (c) 2012 National ICT Australia Limited (NICTA).
2
+ # This software may be used and distributed solely under the terms of the MIT license (License).
3
+ # You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
4
+ # By downloading or using this software you accept the terms and the liability disclaimer in the License.
5
+
1
6
  require 'hashie'
2
7
  require 'singleton'
3
8
  require 'monitor'
@@ -14,6 +19,7 @@ module OmfEc
14
19
  attr_reader :groups, :sub_groups, :state
15
20
 
16
21
  def initialize
22
+ super
17
23
  @id = Time.now.utc.iso8601
18
24
  @state ||= [] #TODO: we need to keep history of all the events and not ovewrite them
19
25
  @groups ||= []
@@ -21,7 +27,6 @@ module OmfEc
21
27
  @app_definitions ||= Hash.new
22
28
  @sub_groups ||= []
23
29
  @cmdline_properties ||= Hash.new
24
- super
25
30
  end
26
31
 
27
32
  def property
@@ -143,8 +148,8 @@ module OmfEc
143
148
  self.synchronize do
144
149
  @events.find_all { |v| v[:callbacks] && !v[:callbacks].empty? }.each do |event|
145
150
  if event[:trigger].call(@state)
146
- info "Event triggered: '#{event[:name]}'"
147
151
  @events.delete(event) if event[:consume_event]
152
+ info "Event triggered: '#{event[:name]}'"
148
153
 
149
154
  # Last in first serve callbacks
150
155
  event[:callbacks].reverse.each do |callback|