omf_ec 6.1.2 → 6.1.3.pre.1

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/Gemfile CHANGED
@@ -3,6 +3,8 @@ source "http://rubygems.org"
3
3
  # Specify your gem's dependencies in omf_ec.gemspec
4
4
  gemspec
5
5
 
6
+ gem 'omf_common', path: "../omf_common"
7
+
6
8
  group :test do
7
9
  gem 'rake'
8
10
  end
@@ -0,0 +1,6 @@
1
+ communication:
2
+ # Connect to AMQP server at localhost
3
+ url: amqp://localhost
4
+
5
+ # Use OML server located at localhost port 3003
6
+ oml_uri: tcp:localhost:3003
@@ -0,0 +1,29 @@
1
+ communication:
2
+ url: amqp://localhost
3
+
4
+ # By providing logging section, you can modify log message location and layout
5
+ #
6
+ # In this example, these setting are identical to EC default
7
+ logging:
8
+ level:
9
+ default: debug
10
+ appenders:
11
+ # To STDOUT
12
+ stdout:
13
+ level: info
14
+ date_pattern: "%H:%M:%S"
15
+ pattern: "%d %5l %c{2}: %m\n"
16
+ color_schema: default
17
+ # To Rolling log file, and log everything
18
+ rolling_file:
19
+ level: all
20
+ log_dir: /var/tmp
21
+ # max 50mb of each log file
22
+ size: 52428800
23
+ # keep a 5 logs in total
24
+ keep: 5
25
+ date_pattern: "%F %T %z"
26
+ pattern: "[%d] %-5l %c: %m\n"
27
+
28
+ # Use OML server located at localhost port 3003
29
+ oml_uri: tcp:localhost:3003
@@ -16,6 +16,7 @@ module OmfEc
16
16
  v5_style(:allGroups, base)
17
17
  v5_style(:allNodes!, base)
18
18
  v5_style(:defGraph, base)
19
+ v5_style(:defGroup, base)
19
20
  v5_style(:loadOEDL, base)
20
21
  v5_style(:ensureProperty, base)
21
22
  end
@@ -37,14 +38,6 @@ module OmfEc
37
38
  def_application(name,&block)
38
39
  end
39
40
 
40
- def defGroup(name, *members, &block)
41
- group = OmfEc::Group.new(name)
42
- OmfEc.experiment.add_group(group)
43
- group.add_resource(*members)
44
-
45
- block.call(group) if block
46
- end
47
-
48
41
  # Wait for some time before issuing more commands
49
42
  #
50
43
  # @param [Fixnum] duration Time to wait in seconds (can be
data/lib/omf_ec/dsl.rb CHANGED
@@ -49,7 +49,6 @@ module OmfEc
49
49
  end
50
50
  end
51
51
 
52
-
53
52
  # Use EM timer to execute after certain time
54
53
  #
55
54
  # @example do something after 2 seconds
@@ -78,16 +77,32 @@ module OmfEc
78
77
  #
79
78
  # @param [String] name name of the group
80
79
  #
81
- # @example add resource 'a' to group 'bob'
82
- # def_group('bob') do |g|
83
- # g.add_resource('a')
80
+ # @example add resource 'a', 'b' to group 'My_Pinger'
81
+ #
82
+ # defGroup('My_Pinger', 'a', 'b') do |g|
83
+ # g.addApplication("ping") do |app|
84
+ # app.setProperty('target', 'mytestbed.net')
85
+ # app.setProperty('count', 3)
86
+ # end
84
87
  # end
85
88
  #
86
- # @see OmfEc::Backward::DSL#defGroup
87
- def def_group(name, &block)
88
- group = OmfEc::Group.new(name, &block)
89
+ # # Or pass resources as an array
90
+ #
91
+ # res_array = ['a', 'b']
92
+ #
93
+ # defGroup('My_Pinger', res_array) do |g|
94
+ # g.addApplication("ping") do |app|
95
+ # app.setProperty('target', 'mytestbed.net')
96
+ # app.setProperty('count', 3)
97
+ # end
98
+ # end
99
+ #
100
+ def def_group(name, *members, &block)
101
+ group = OmfEc::Group.new(name)
89
102
  OmfEc.experiment.add_group(group)
90
- group
103
+ group.add_resource(*members)
104
+
105
+ block.call(group) if block
91
106
  end
92
107
 
93
108
  # Get a group instance
@@ -255,7 +270,7 @@ module OmfEc
255
270
  rescue Exception => e
256
271
  error "Fail loading built-in OEDL library '#{location}': #{e}"
257
272
  end
258
- when :file, :http
273
+ when :file, :http, :https
259
274
  begin
260
275
  file = Tempfile.new("oedl-#{Time.now.to_i}")
261
276
  # see: http://stackoverflow.com/questions/7578898
@@ -210,6 +210,7 @@ module OmfEc
210
210
  g.resources[type: 'application'].release unless g.app_contexts.empty?
211
211
  g.resources[type: 'net'].release unless g.net_ifs.find_all { |v| v.conf[:type] == 'net' }.empty?
212
212
  g.resources[type: 'wlan'].release unless g.net_ifs.find_all { |v| v.conf[:type] == 'wlan' }.empty?
213
+ g.resources.membership = { leave: g.address }
213
214
  end
214
215
 
215
216
  OmfCommon.el.after(4) do
data/lib/omf_ec/group.rb CHANGED
@@ -62,6 +62,7 @@ module OmfEc
62
62
  #
63
63
  # Resources to be added could be a list of resources, groups, or the mixture of both.
64
64
  def add_resource(*names)
65
+ names.flatten!
65
66
  synchronize do
66
67
  # Recording membership first, used for ALL_UP event
67
68
  names.each do |name|
@@ -75,7 +76,6 @@ module OmfEc
75
76
  end
76
77
  end
77
78
 
78
-
79
79
  # Create a set of new resources and add them to the group
80
80
  #
81
81
  # @param [String] name
data/lib/omf_ec/runner.rb CHANGED
@@ -25,6 +25,24 @@ module OmfEc
25
25
  @config_opts = Mash.new(
26
26
  environment: 'development',
27
27
  communication: { url: "amqp://localhost" },
28
+ logging: {
29
+ level: { default: 'debug' },
30
+ appenders: {
31
+ stdout: {
32
+ level: :info,
33
+ date_pattern: '%H:%M:%S',
34
+ pattern: '%d %5l %c{2}: %m\n'
35
+ },
36
+ rolling_file: {
37
+ level: :debug,
38
+ log_dir: '/var/tmp',
39
+ size: 1024*1024*50, # max 50mb of each log file
40
+ keep: 5, # keep a 5 logs in total
41
+ date_pattern: '%F %T %z',
42
+ pattern: '[%d] %-5l %c: %m\n'
43
+ },
44
+ }
45
+ }
28
46
  )
29
47
 
30
48
  @cmd_opts = Mash.new
@@ -113,7 +131,7 @@ module OmfEc
113
131
  exit
114
132
  end
115
133
 
116
- op.on("-d", "--debug", "Debug mode (printing debug logging messages)") do
134
+ op.on("-d", "--debug", "Debug mode (Set logging level in Stdout to :debug)") do
117
135
  @cmd_opts[:debug] = true
118
136
  remove_cmd_opts_from_argv("-d", "--debug")
119
137
  end
@@ -219,6 +237,8 @@ module OmfEc
219
237
 
220
238
  if @config_opts[:debug]
221
239
  Logging.logger.root.level = 'debug'
240
+ stdout_appender = Logging.logger.root.appenders.find { |a| a.class == Logging::Appenders::Stdout }
241
+ stdout_appender.level = 'debug' if stdout_appender
222
242
  else
223
243
  Logging.consolidate 'OmfCommon', 'OmfRc'
224
244
  end
@@ -280,7 +300,6 @@ module OmfEc
280
300
  def init
281
301
  oml_init
282
302
  setup_experiment
283
- #load_experiment
284
303
  end
285
304
 
286
305
  def run
@@ -20,6 +20,24 @@ describe OmfEc::DSL do
20
20
  OmfEc.unstub(:subscribe_and_monitor)
21
21
  end
22
22
 
23
+ describe "when calling defGroup" do
24
+ it "must be able to accept a list of arguments" do
25
+ @dsl.defGroup('bob', 'a', 'b') do |g|
26
+ g.members.keys.must_include 'a'
27
+ g.members.keys.must_include 'b'
28
+ g.must_be_kind_of OmfEc::Group
29
+ end
30
+ end
31
+
32
+ it "must be able to accept array as arguments" do
33
+ array = %w(c d)
34
+ @dsl.defGroup('bob', array) do |g|
35
+ g.members.keys.must_include 'c'
36
+ g.members.keys.must_include 'd'
37
+ g.must_be_kind_of OmfEc::Group
38
+ end
39
+ end
40
+ end
23
41
 
24
42
  describe "when included" do
25
43
  it "must respond to after and every" do
@@ -46,11 +64,6 @@ describe OmfEc::DSL do
46
64
  @dsl.group('bob').must_equal g
47
65
  end
48
66
 
49
- it "must respond to def_group" do
50
- block = proc { 1 }
51
- @dsl.def_group('bob', &block).must_be_kind_of OmfEc::Group
52
- end
53
-
54
67
  it "must respond to all_groups iterator" do
55
68
  block = proc { 1 }
56
69
  @dsl.all_groups(&block)
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omf_ec
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.1.2
5
- prerelease:
4
+ version: 6.1.3.pre.1
5
+ prerelease: 6
6
6
  platform: ruby
7
7
  authors:
8
8
  - NICTA
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-06-25 00:00:00.000000000 Z
12
+ date: 2014-07-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest
@@ -98,7 +98,7 @@ dependencies:
98
98
  requirements:
99
99
  - - '='
100
100
  - !ruby/object:Gem::Version
101
- version: 6.1.2
101
+ version: 6.1.3.pre.1
102
102
  type: :runtime
103
103
  prerelease: false
104
104
  version_requirements: !ruby/object:Gem::Requirement
@@ -106,7 +106,7 @@ dependencies:
106
106
  requirements:
107
107
  - - '='
108
108
  - !ruby/object:Gem::Version
109
- version: 6.1.2
109
+ version: 6.1.3.pre.1
110
110
  - !ruby/object:Gem::Dependency
111
111
  name: sequel
112
112
  requirement: !ruby/object:Gem::Requirement
@@ -136,6 +136,8 @@ files:
136
136
  - Gemfile
137
137
  - Rakefile
138
138
  - bin/omf_ec
139
+ - example/config/default.yml
140
+ - example/config/with_custom_logging.yml
139
141
  - example/engine_oedl.rb
140
142
  - example/engine_test.rb
141
143
  - example/test_exp/test00.rb
@@ -193,12 +195,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
193
195
  required_rubygems_version: !ruby/object:Gem::Requirement
194
196
  none: false
195
197
  requirements:
196
- - - ! '>='
198
+ - - ! '>'
197
199
  - !ruby/object:Gem::Version
198
- version: '0'
199
- segments:
200
- - 0
201
- hash: -2232053717488476374
200
+ version: 1.3.1
202
201
  requirements: []
203
202
  rubyforge_project: omf_ec
204
203
  rubygems_version: 1.8.23