omf_rc 6.1.4.pre.2 → 6.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1916ba4d7b83441e5b71cfe25c00b0e42890668a
4
+ data.tar.gz: 5e9b81f986a3e796feec8305524ea740e02e123a
5
+ SHA512:
6
+ metadata.gz: 064aaf15db1cc87f2f75aec5d6dc64533f2df0f7d0bcf1bc818e7256c20ba8a2de3972cedbf69acf94b5cd2bf12a4039b14478407bcb9844a04a6a545d44cb7a
7
+ data.tar.gz: 1bd1b9bc3858c1e40e590615507f73bba64124a21a06488d07d9607cbbf92a1573fab2ccd212cd61e5a1b467002bdba3d6db5754778ea0e284b816890441a43c
data/Gemfile CHANGED
@@ -4,8 +4,11 @@ source "http://rubygems.org"
4
4
  gemspec
5
5
 
6
6
  gem 'omf_common', path: "../omf_common"
7
- gem 'blather'
8
7
 
9
8
  group :test do
10
9
  gem 'rake'
11
10
  end
11
+
12
+ group :xmpp do
13
+ gem 'blather'
14
+ end
data/config/config.yml CHANGED
@@ -1,6 +1,11 @@
1
1
  ---
2
2
  # default topic name is this machine's hostname
3
3
  # this is to ensure that every RC has its own topic and AMQP account
4
- uid: <%= Socket.gethostname %>
5
- uri: amqp://localhost
6
4
  environment: production
5
+
6
+ communication:
7
+ url: amqp://localhost
8
+
9
+ resources:
10
+ - type: node
11
+ uid: <%= Socket.gethostname %>
@@ -1,21 +1,25 @@
1
1
  ---
2
- uri: xmpp://<%= "#{Socket.gethostname}-#{Process.pid}" %>:<%= "#{Socket.gethostname}-#{Process.pid}" %>@localhost
3
- environment: development
4
- debug: false
2
+ environment: production
3
+
4
+ communication:
5
+ url: amqp://localhost
5
6
 
6
7
  resources:
7
8
  - type: node
8
9
  uid: <%= Socket.gethostname %>
9
10
 
10
- add_default_factories: false # Not loading default type factories
11
+ # DO NOT load default factories
12
+ add_default_factories: false
11
13
 
12
- factories: # Additional resources which can be created by this RC
14
+ # Customise resources which can be created by this RC
15
+ factories:
13
16
  load: [
14
17
  'omf_rc/resource_proxy/node',
15
18
  'omf_rc/resource_proxy/net',
16
19
  'omf_rc/resource_proxy/wlan',
17
20
  'omf_rc/resource_proxy/application'
18
21
  ]
22
+ # Set default value of resource property
19
23
  defaults:
20
24
  node:
21
25
  topo_file: '/etc/topology.txt'
@@ -0,0 +1,34 @@
1
+ ---
2
+ environment: production
3
+
4
+ communication:
5
+ url: amqp://localhost
6
+
7
+ logging:
8
+ level:
9
+ default: debug
10
+ appenders:
11
+ # To Rolling log file, and log everything
12
+ rolling_file:
13
+ level: all
14
+ log_dir: /var/tmp
15
+ # max 10k of each log file
16
+ size: 10240
17
+ # keep 1 log in total
18
+ keep: 1
19
+ date_pattern: "%F %T %z"
20
+ pattern: "[%d] %-5l %c: %m\n"
21
+
22
+ resources:
23
+ - type: node
24
+ uid: <%= Socket.gethostname %>
25
+
26
+ # DO NOT load default factories
27
+ add_default_factories: false
28
+
29
+ # Customise resources which can be created by this RC
30
+ factories:
31
+ load: [
32
+ 'omf_rc/resource_proxy/node',
33
+ 'omf_rc/resource_proxy/application'
34
+ ]
@@ -28,6 +28,16 @@ class OmfRc::ResourceProxy::MPReceived < OML4R::MPBase
28
28
  param :mid, :type => :string # Unique ID this message
29
29
  end
30
30
 
31
+ # TODO This should probably go to common, together with same functionality from EC
32
+ # MP only used for injecting metadata
33
+ class OmfRc::MetaData < OML4R::MPBase
34
+ name :meta_data
35
+
36
+ param :domain, type: :string
37
+ param :key, type: :string
38
+ param :value, type: :string
39
+ end
40
+
31
41
  # @note Suppose you have read the {file:doc/DEVELOPERS.mkd DEVELOPERS GUIDE} which explains the basic the resource controller system.
32
42
  #
33
43
  # This is the abstract resource proxy class, which provides the base of all proxy implementations. When creating new resource instances, this abstract class will always be initialised first and then extended by one of the specific resource proxy modules.
@@ -233,6 +243,8 @@ class OmfRc::ResourceProxy::AbstractResource
233
243
 
234
244
  new_resource = OmfRc::ResourceFactory.create(type.to_sym, opts, creation_opts, &creation_callback)
235
245
 
246
+ log_metadata(self.uid, new_resource.uid, :create)
247
+
236
248
  call_hook(:after_create, self, new_resource)
237
249
 
238
250
  self.synchronize do
@@ -783,4 +795,8 @@ class OmfRc::ResourceProxy::AbstractResource
783
795
  def namespaced_property?(name)
784
796
  respond_to?(:namespace) && name =~ /^(.+)__(.+)$/
785
797
  end
798
+
799
+ def log_metadata(key, value, domain)
800
+ OmfRc::MetaData.inject(domain.to_s, key.to_s, value.to_s)
801
+ end
786
802
  end
@@ -561,7 +561,7 @@ module OmfRc::ResourceProxy::Application
561
561
  o = res.property.oml
562
562
  ofile = "/tmp/#{res.uid}-#{Time.now.to_i}.xml"
563
563
  of = File.open(ofile,'w')
564
- of << "<omlc experiment='#{o.experiment}' id='#{o.id}_#{res.uid}'>\n"
564
+ of << "<omlc experiment='#{o.experiment}' id='#{res.opts.parent.uid}_#{o.id}_#{res.uid}'>\n"
565
565
  o.collection.each do |c|
566
566
  of << " <collect url='#{c.url}'>\n"
567
567
  c.streams.each do |m|
@@ -217,10 +217,12 @@ module OmfRc::ResourceProxyDSL
217
217
  # end
218
218
  # end
219
219
  # end
220
- def configure(name, &register_block)
221
- define_method("configure_#{name.to_s}") do |*args, &block|
222
- args[0] = Hashie::Mash.new(args[0]) if args[0].class == Hash
223
- register_block.call(self, *args, block) if register_block
220
+ def configure(name, opts = {}, &register_block)
221
+ unless opts[:if] && !opts[:if].call
222
+ define_method("configure_#{name.to_s}") do |*args, &block|
223
+ args[0] = Hashie::Mash.new(args[0]) if args[0].class == Hash
224
+ register_block.call(self, *args, block) if register_block
225
+ end
224
226
  end
225
227
  end
226
228
 
@@ -267,10 +269,12 @@ module OmfRc::ResourceProxyDSL
267
269
  # end
268
270
  # end
269
271
  #
270
- def request(name, &register_block)
271
- define_method("request_#{name.to_s}") do |*args, &block|
272
- args[0] = Hashie::Mash.new(args[0]) if args[0].class == Hash
273
- register_block.call(self, *args, block) if register_block
272
+ def request(name, opts = {}, &register_block)
273
+ unless opts[:if] && !opts[:if].call
274
+ define_method("request_#{name.to_s}") do |*args, &block|
275
+ args[0] = Hashie::Mash.new(args[0]) if args[0].class == Hash
276
+ register_block.call(self, *args, block) if register_block
277
+ end
274
278
  end
275
279
  end
276
280
 
@@ -3,29 +3,8 @@
3
3
  # You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
4
4
  # By downloading or using this software you accept the terms and the liability disclaimer in the License.
5
5
 
6
- #
7
- # Copyright (c) 2012 National ICT Australia (NICTA), Australia
8
- #
9
- # Permission is hereby granted, free of charge, to any person obtaining a copy
10
- # of this software and associated documentation files (the "Software"), to deal
11
- # in the Software without restriction, including without limitation the rights
12
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
- # copies of the Software, and to permit persons to whom the Software is
14
- # furnished to do so, subject to the following conditions:
15
- #
16
- # The above copyright notice and this permission notice shall be included in
17
- # all copies or substantial portions of the Software.
18
- #
19
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25
- # THE SOFTWARE.
26
- #
6
+ require 'facter'
27
7
 
28
- #
29
8
  # This module defines a Utility with some common work blocks that could be
30
9
  # useful to any type of Resource Proxy (RP)
31
10
  #
@@ -55,9 +34,13 @@ module OmfRc::Util::CommonTools
55
34
  #
56
35
  # [Boolean] true or fals
57
36
  #
58
- work('boolean?') do |res,obj|
37
+ work('boolean?') do |res, obj|
59
38
  result = false
60
39
  result = true if obj.kind_of?(TrueClass) || obj.kind_of?(FalseClass)
61
40
  result
62
41
  end
42
+
43
+ def cmd_exists?(cmd)
44
+ !Facter::Core::Execution.which(cmd).nil?
45
+ end
63
46
  end
@@ -13,10 +13,12 @@ module OmfRc::Util::Mod
13
13
  include Hashie
14
14
  # @!macro extend_dsl
15
15
 
16
+ utility :common_tools
17
+
16
18
  # @!macro group_request
17
19
  # @!macro request
18
20
  # @!method request_modules
19
- request :modules do
21
+ request :modules, if: proc { cmd_exists?('lsmod') } do
20
22
  CommandLine.new('lsmod').run.split("\n").map do |v|
21
23
  v.match(/^(\w+).+$/) && $1
22
24
  end.compact.tap { |ary| ary.shift }
@@ -30,7 +32,7 @@ module OmfRc::Util::Mod
30
32
  # @param value name of the module to load
31
33
  # @!macro configure
32
34
  # @!method configure_load_module
33
- configure :load_module do |resource, value|
35
+ configure :load_module, if: proc { cmd_exists?('modprobe') } do |resource, value|
34
36
  raise ArgumentError, "Please provide at least module name" if value.name.nil?
35
37
 
36
38
  flags_string = nil
@@ -34,16 +34,10 @@ module OmfRc::Util::Sysfs
34
34
  device[:op_state] = (fo.read || '').chomp
35
35
  end
36
36
  # Let's see if the interface is already up
37
- # NOTE: THIS MAY NOT BE ROBUST
38
- s = `ifconfig #{File.basename(v)}`
39
- unless s.nil? || s.empty?
40
- if m = s.match(/inet addr:\s*([0-9.]+)/)
41
- device[:ip4] = m[1]
42
- end
43
- if m = s.match(/inet6 addr:\s*([0-9a-f.:\/]+)/)
44
- device[:ip6] = m[1]
45
- end
46
- end
37
+ ip = Facter.value("ipaddress_#{File.basename(v)}")
38
+ ip_v6 = Facter.value("ipaddress6_#{File.basename(v)}")
39
+ device[:ip4] = ip if ip
40
+ device[:ip6] = ip_v6 if ip_v6
47
41
  devices << device
48
42
  end
49
43
  end
@@ -35,6 +35,10 @@ describe OmfRc::ResourceProxyDSL do
35
35
  request :zulu do |resource, options|
36
36
  "You called zulu with: #{options.keys.join('|')}"
37
37
  end
38
+
39
+ request :xray, if: proc { false } do
40
+ "This property would NOT be registered"
41
+ end
38
42
  end
39
43
 
40
44
  module OmfRc::ResourceProxy::MockRootProxy
@@ -108,6 +112,16 @@ describe OmfRc::ResourceProxyDSL do
108
112
  mock_proxy.request_zulu(country: 'uk').must_equal "You called zulu with: country"
109
113
  end
110
114
 
115
+ it "wont define methods when restriction provided and failed to meet" do
116
+ begin
117
+ mock_proxy = OmfRc::ResourceFactory.create(:mock_proxy, uid: :mp0)
118
+ mock_proxy.request_xray
119
+ rescue => e
120
+ e.must_be_kind_of NoMethodError
121
+ e.message.must_match /request_xray/
122
+ end
123
+ end
124
+
111
125
  it "must be able to include utility" do
112
126
  Class.new do
113
127
  include OmfRc::ResourceProxyDSL
metadata CHANGED
@@ -1,126 +1,111 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omf_rc
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.1.4.pre.2
5
- prerelease: 6
4
+ version: 6.1.4
6
5
  platform: ruby
7
6
  authors:
8
7
  - NICTA
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-07-09 00:00:00.000000000 Z
11
+ date: 2014-08-19 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: minitest
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: pry
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: simplecov
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: mocha
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - '>='
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - '>='
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: omf_common
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
73
  - - '='
84
74
  - !ruby/object:Gem::Version
85
- version: 6.1.4.pre.2
75
+ version: 6.1.4
86
76
  type: :runtime
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
80
  - - '='
92
81
  - !ruby/object:Gem::Version
93
- version: 6.1.4.pre.2
82
+ version: 6.1.4
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: cocaine
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
- - - ! '>='
87
+ - - '>='
100
88
  - !ruby/object:Gem::Version
101
89
  version: '0'
102
90
  type: :runtime
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
- - - ! '>='
94
+ - - '>='
108
95
  - !ruby/object:Gem::Version
109
96
  version: '0'
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: facter
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
- - - ! '>='
101
+ - - '>='
116
102
  - !ruby/object:Gem::Version
117
103
  version: '0'
118
104
  type: :runtime
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
- - - ! '>='
108
+ - - '>='
124
109
  - !ruby/object:Gem::Version
125
110
  version: '0'
126
111
  description: Resource controller of OMF, a generic framework for controlling and managing
@@ -146,6 +131,7 @@ files:
146
131
  - config/config_with_authentication.yml.example
147
132
  - config/config_with_extensions.yml.example
148
133
  - config/instageni.yaml
134
+ - config/with_custom_logging.yml
149
135
  - init/angstrom
150
136
  - init/debian
151
137
  - init/fedora
@@ -211,26 +197,54 @@ files:
211
197
  homepage: http://omf.mytestbed.net
212
198
  licenses:
213
199
  - MIT
200
+ metadata: {}
214
201
  post_install_message:
215
202
  rdoc_options: []
216
203
  require_paths:
217
204
  - lib
218
205
  required_ruby_version: !ruby/object:Gem::Requirement
219
- none: false
220
206
  requirements:
221
- - - ! '>='
207
+ - - '>='
222
208
  - !ruby/object:Gem::Version
223
209
  version: 1.9.3
224
210
  required_rubygems_version: !ruby/object:Gem::Requirement
225
- none: false
226
211
  requirements:
227
- - - ! '>'
212
+ - - '>='
228
213
  - !ruby/object:Gem::Version
229
- version: 1.3.1
214
+ version: '0'
230
215
  requirements: []
231
216
  rubyforge_project: omf_rc
232
- rubygems_version: 1.8.23
217
+ rubygems_version: 2.0.14
233
218
  signing_key:
234
- specification_version: 3
219
+ specification_version: 4
235
220
  summary: OMF resource controller
236
- test_files: []
221
+ test_files:
222
+ - test/fixture/ip/addr_show
223
+ - test/fixture/iw/help
224
+ - test/fixture/iw/info
225
+ - test/fixture/iw/link
226
+ - test/fixture/lsmod
227
+ - test/fixture/omf_rc.simple.yml
228
+ - test/fixture/omf_rc.yml
229
+ - test/fixture/oml.hash
230
+ - test/fixture/oml.spec
231
+ - test/fixture/oml.xml
232
+ - test/fixture/sys/class/ieee80211/phy0/device/uevent
233
+ - test/fixture/sys/class/ieee80211/phy0/uevent
234
+ - test/fixture/sys/class/net/eth0/device/uevent
235
+ - test/fixture/sys/class/net/eth0/uevent
236
+ - test/fixture/sys/class/net/wlan0/device/uevent
237
+ - test/fixture/sys/class/net/wlan0/uevent
238
+ - test/omf_rc/message_process_error_spec.rb
239
+ - test/omf_rc/resource_factory_spec.rb
240
+ - test/omf_rc/resource_proxy/abstract_resource_spec.rb
241
+ - test/omf_rc/resource_proxy/application_spec.rb
242
+ - test/omf_rc/resource_proxy/node_spec.rb
243
+ - test/omf_rc/resource_proxy_dsl_spec.rb
244
+ - test/omf_rc/runner_spec.rb
245
+ - test/omf_rc/util/common_tools_spec.rb
246
+ - test/omf_rc/util/fact_spec.rb
247
+ - test/omf_rc/util/ip_spec.rb
248
+ - test/omf_rc/util/iw_spec.rb
249
+ - test/omf_rc/util/mod_spec.rb
250
+ - test/test_helper.rb