omf_rc 6.0.0.pre.3 → 6.0.0.pre.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -160,7 +160,7 @@ class OmfRc::ResourceProxy::AbstractResource
160
160
  inform_msg = OmfCommon::Message.inform(end_result[:context_id], 'CREATED') do |i|
161
161
  i.element('resource_id', new_uid)
162
162
  i.element('resource_address', new_uid)
163
- end.sign
163
+ end
164
164
  @comm.publish(end_result[:inform_to], inform_msg, host)
165
165
  end
166
166
  end
@@ -169,7 +169,7 @@ class OmfRc::ResourceProxy::AbstractResource
169
169
  end_result[:result].each_pair do |k, v|
170
170
  i.property(k, v)
171
171
  end
172
- end.sign
172
+ end
173
173
  @comm.publish(end_result[:inform_to], inform_msg, host)
174
174
 
175
175
  when :configure
@@ -177,7 +177,7 @@ class OmfRc::ResourceProxy::AbstractResource
177
177
  end_result[:result].each_pair do |k, v|
178
178
  i.property(k, v)
179
179
  end
180
- end.sign
180
+ end
181
181
  @comm.publish(end_result[:inform_to], inform_msg, host)
182
182
  when :release
183
183
  inform_msg = OmfCommon::Message.inform(end_result[:context_id], 'RELEASED') do |i|
@@ -198,7 +198,7 @@ class OmfRc::ResourceProxy::AbstractResource
198
198
  dp.errback do |e|
199
199
  inform_msg = OmfCommon::Message.inform(e.context_id, 'FAILED') do |i|
200
200
  i.element("error_message", e.message)
201
- end.sign
201
+ end
202
202
  @comm.publish(e.inform_to, inform_msg, host)
203
203
  end
204
204
 
@@ -5,11 +5,11 @@ module OmfRc::ResourceProxy::Mock
5
5
 
6
6
  utility :mock
7
7
 
8
- register_hook :before_ready do |resource|
8
+ hook :before_ready do |resource|
9
9
  logger.info "#{resource.uid} is now ready"
10
10
  end
11
11
 
12
- register_hook :before_release do |resource|
12
+ hook :before_release do |resource|
13
13
  logger.info "#{resource.uid} is to be released"
14
14
  end
15
15
  end
@@ -3,15 +3,15 @@ module OmfRc::ResourceProxy::Node
3
3
 
4
4
  register_proxy :node
5
5
 
6
- register_hook :before_ready do |resource|
6
+ hook :before_ready do |resource|
7
7
  logger.info "#{resource.uid} is now ready"
8
8
  end
9
9
 
10
- register_hook :before_release do |resource|
10
+ hook :before_release do |resource|
11
11
  logger.info "#{resource.uid} is now released"
12
12
  end
13
13
 
14
- register_request :proxies do
14
+ request :proxies do
15
15
  OmfRc::ResourceFactory.proxy_list
16
16
  end
17
17
  end
@@ -44,15 +44,15 @@ module OmfRc::ResourceProxyDSL
44
44
  #
45
45
  # register_proxy :node
46
46
  #
47
- # register_hook :before_ready do |resource|
47
+ # hook :before_ready do |resource|
48
48
  # logger.info "#{resource.uid} is now ready"
49
49
  # end
50
50
  #
51
- # register_hook :before_release do |resource|
51
+ # hook :before_release do |resource|
52
52
  # logger.info "#{resource.uid} is now released"
53
53
  # end
54
54
  # end
55
- def register_hook(name, &register_block)
55
+ def hook(name, &register_block)
56
56
  define_method(name) do
57
57
  register_block.call(self) if register_block
58
58
  end
@@ -115,20 +115,20 @@ module OmfRc::ResourceProxyDSL
115
115
  # module OmfRc::Util::Iw
116
116
  # include OmfRc::ResourceProxyDSL
117
117
  #
118
- # register_configure :freq do |resource, value|
118
+ # configure :freq do |resource, value|
119
119
  # Command.execute("iw #{resource.hrn} set freq #{value}")
120
120
  # end
121
121
  #
122
122
  # # or use iterator to define multiple properties
123
123
  # %w(freq channel type).each do |p|
124
- # register_configure p do |resource, value|
124
+ # configure p do |resource, value|
125
125
  # Command.execute("iw #{resource.hrn} set freq #{value}")
126
126
  # end
127
127
  # end
128
128
  #
129
129
  # # or we can try to parse iw's help page to extract valid properties and then automatically register them
130
130
  # Command.execute("iw help").chomp.gsub(/^\t/, '').split("\n").map {|v| v.match(/[phy|dev] <.+> set (\w+) .*/) && $1 }.compact.uniq.each do |p|
131
- # register_configure p do |resource, value|
131
+ # configure p do |resource, value|
132
132
  # Command.execute("iw #{resource.hrn} set #{p} #{value}")
133
133
  # end
134
134
  # end
@@ -136,7 +136,7 @@ module OmfRc::ResourceProxyDSL
136
136
  #
137
137
  # @see OmfCommon::Command.execute
138
138
  #
139
- def register_configure(name, &register_block)
139
+ def configure(name, &register_block)
140
140
  define_method("configure_#{name.to_s}") do |*args, &block|
141
141
  register_block.call(self, *args, block) if register_block
142
142
  end
@@ -144,13 +144,13 @@ module OmfRc::ResourceProxyDSL
144
144
 
145
145
  # Register a property that could be requested
146
146
  #
147
- # @param (see #register_configure)
147
+ # @param (see #configure)
148
148
  # @yieldparam [AbstractResource] resource pass the current resource object to the block
149
149
  # @example suppose we define a utility for iw command interaction
150
150
  # module OmfRc::Util::Iw
151
151
  # include OmfRc::ResourceProxyDSL
152
152
  #
153
- # register_request :freq do |resource|
153
+ # request :freq do |resource|
154
154
  # Command.execute("iw #{resource.hrn} link").match(/^(freq):\W*(.+)$/) && $2
155
155
  # end
156
156
  #
@@ -161,7 +161,7 @@ module OmfRc::ResourceProxyDSL
161
161
  # end
162
162
  # end
163
163
  # end
164
- def register_request(name, &register_block)
164
+ def request(name, &register_block)
165
165
  define_method("request_#{name.to_s}") do |*args|
166
166
  register_block.call(self) if register_block
167
167
  end
@@ -3,12 +3,12 @@ module OmfRc::Util::Iw
3
3
  include OmfRc::ResourceProxyDSL
4
4
 
5
5
  OmfCommon::Command.execute("iw help").chomp.gsub(/^\t/, '').split("\n").map {|v| v.match(/[phy|dev] <.+> set (\w+) .*/) && $1 }.compact.uniq.each do |p|
6
- register_configure p do |resource, value|
6
+ configure p do |resource, value|
7
7
  OmfCommon::Command.execute("#{IW_CMD} #{resource.hrn} set #{p} #{value}")
8
8
  end
9
9
  end
10
10
 
11
- register_request :link do |resource|
11
+ request :link do |resource|
12
12
  known_properties = Hashie::Mash.new
13
13
 
14
14
  OmfCommon::Command.execute("iw #{resource.hrn} link").chomp.gsub(/^\t/, '').split("\n").drop(1).each do |v|
@@ -3,25 +3,25 @@ module OmfRc::Util::Mock
3
3
 
4
4
  register_utility :mock
5
5
 
6
- register_request :nothing do |resource|
6
+ request :nothing do |resource|
7
7
  resource.uid
8
8
  end
9
9
 
10
- register_configure :nothing
10
+ configure :nothing
11
11
 
12
- register_configure :hrn do |resource, hrn|
12
+ configure :hrn do |resource, hrn|
13
13
  resource.hrn = hrn
14
14
  end
15
15
 
16
- register_request :resource_proxy_list do
16
+ request :resource_proxy_list do
17
17
  OmfRc::ResourceFactory.proxy_list
18
18
  end
19
19
 
20
- register_request :resource_utility_list do
20
+ request :resource_utility_list do
21
21
  OmfRc::ResourceFactory.utility_list
22
22
  end
23
23
 
24
- register_request :kernel_version do
24
+ request :kernel_version do
25
25
  OmfCommon::Command.execute("uname -r")
26
26
  end
27
27
  end
@@ -3,13 +3,13 @@ module OmfRc::Util::Mod
3
3
 
4
4
  register_utility :mod
5
5
 
6
- register_request :modules do
6
+ request :modules do
7
7
  OmfCommon::Command.execute('lsmod').split("\n").map do |v|
8
8
  v.match(/^(.+)\W*.+$/) && $1
9
9
  end.compact
10
10
  end
11
11
 
12
- register_configure :load_module do |resource, value|
12
+ configure :load_module do |resource, value|
13
13
  OmfCommon::Command.execute("modprobe #{value}")
14
14
  end
15
15
  end
@@ -5,15 +5,15 @@ module OmfRc::ResourceProxy::Package
5
5
 
6
6
  register_utility :package
7
7
 
8
- register_request :package_version do |resource|
8
+ request :package_version do |resource|
9
9
  OmfCommon::Command.execute("dpkg -l #{resource.hrn} | awk 'END { print $3 }'")
10
10
  end
11
11
 
12
- register_configure :install_package do |resource|
12
+ configure :install_package do |resource|
13
13
  OmfCommon::Command.execute("apt-get install -y --reinstall --allow-unauthenticated -qq #{resource.hrn}")
14
14
  end
15
15
 
16
- register_configure :remove_package do |resource|
16
+ configure :remove_package do |resource|
17
17
  OmfCommon::Command.execute("apt-get purge -y -qq #{resource.hrn}")
18
18
  end
19
19
  end
@@ -1,3 +1,3 @@
1
1
  module OmfRc
2
- VERSION = "6.0.0.pre.3"
2
+ VERSION = "6.0.0.pre.4"
3
3
  end
@@ -8,8 +8,8 @@ module OmfRc::ResourceProxy
8
8
  include OmfRc::ResourceProxyDSL
9
9
  register_proxy :node
10
10
 
11
- register_request :name
12
- register_configure :name
11
+ request :name
12
+ configure :name
13
13
  end
14
14
 
15
15
  module Interface
@@ -6,8 +6,8 @@ describe OmfRc::ResourceProxyDSL do
6
6
  module OmfRc::Util::MockUtility
7
7
  include OmfRc::ResourceProxyDSL
8
8
  register_utility :mock_utility
9
- register_configure :alpha
10
- register_request :alpha
9
+ configure :alpha
10
+ request :alpha
11
11
  end
12
12
 
13
13
  module OmfRc::ResourceProxy::MockProxy
@@ -16,12 +16,12 @@ describe OmfRc::ResourceProxyDSL do
16
16
  register_proxy :mock_proxy
17
17
  utility :mock_utility
18
18
 
19
- register_hook :before_ready do
19
+ hook :before_ready do
20
20
  "bob"
21
21
  end
22
- register_hook :before_release
23
- register_configure :bravo
24
- register_request :bravo
22
+ hook :before_release
23
+ configure :bravo
24
+ request :bravo
25
25
  end
26
26
  end
27
27
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omf_rc
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.0.pre.3
4
+ version: 6.0.0.pre.4
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-07 00:00:00.000000000 Z
12
+ date: 2012-07-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest
@@ -73,12 +73,6 @@ files:
73
73
  - Rakefile
74
74
  - bin/omf_rc
75
75
  - config/omf_rc.yml
76
- - integration_test/omf_rc/resource_proxy/app_spec.rb
77
- - integration_test/omf_rc/resource_proxy/interface_spec.rb
78
- - integration_test/omf_rc/resource_proxy/mock_spec.rb
79
- - integration_test/omf_rc/resource_proxy/node_spec.rb
80
- - integration_test/omf_rc/resource_proxy/wifi_spec.rb
81
- - integration_test/test_helper.rb
82
76
  - lib/omf_rc.rb
83
77
  - lib/omf_rc/deferred_process.rb
84
78
  - lib/omf_rc/message_process_error.rb
@@ -1,25 +0,0 @@
1
- require 'test_helper'
2
- require 'omf_rc/resource_proxy'
3
-
4
- include OmfRc::ResourceProxy
5
-
6
- describe App do
7
- before do
8
- @resource = AbstractResource.new(properties: { pubsub: "mytestbed.net" })
9
- @app1 = @resource.create(:type => 'app', :uid => 'zathura')
10
- @app2 = @resource.create(:type => 'app', :uid => 'bob')
11
- end
12
-
13
- describe "when configured with properties" do
14
- it "must run the underline commands" do
15
- end
16
- end
17
-
18
- describe "when properties requested" do
19
- it "must return an array with actual properties" do
20
- @resource.request([:version], {:uid => 'zathura'}).first.version.must_match /[\d|\.|-]+/
21
- @resource.request([:version], {:uid => 'bob'}).first.version.must_be_nil
22
- end
23
- end
24
- end
25
-
@@ -1,26 +0,0 @@
1
- require 'test_helper'
2
- require 'omf_rc/resource_proxy'
3
-
4
- include OmfRc::ResourceProxy
5
-
6
- describe Interface do
7
- before do
8
- @resource = AbstractResource.new(properties: { pubsub: "mytestbed.net" })
9
- @interface = @resource.create(:type => 'interface', :uid => 'eth0')
10
- end
11
-
12
- describe "when configured with properties" do
13
- it "must run the underline commands" do
14
- end
15
- end
16
-
17
- describe "when properties requested" do
18
- it "must return an array with actual properties" do
19
- @resource.request([:mac, :ip], {:type => 'interface'}).each do |interface|
20
- interface.mac.must_match /([\da-fA-F]+:){5}[\da-fA-F]+/
21
- interface.ip.must_match /([.\d]+\.){3}[.\d]+/
22
- end
23
- end
24
- end
25
- end
26
-
@@ -1,58 +0,0 @@
1
- require 'test_helper'
2
- require 'omf_rc/resource_factory'
3
-
4
- include OmfRc::ResourceProxy
5
-
6
- module OmfRc::Util::UMock
7
- include OmfRc::ResourceProxyDSL
8
-
9
- register_utility :u_mock
10
-
11
- register_configure :very_important_property do
12
- raise StandardError, 'We just did something very important, I need your attention'
13
- end
14
-
15
- register_request :very_important_property do
16
- "Very important property's value"
17
- end
18
- end
19
-
20
- module OmfRc::ResourceProxy::Mock
21
- include OmfRc::ResourceProxyDSL
22
-
23
- register_proxy :mock
24
-
25
- utility :u_mock
26
-
27
- register_bootstrap do
28
- logger.debug 'I am starting up, but have nothing to do there'
29
- end
30
-
31
- register_cleanup do
32
- logger.debug 'I am shutting down, but have nothing to do there'
33
- end
34
-
35
- def test
36
- end
37
- end
38
-
39
- describe Mock do
40
- before do
41
- @resource = OmfRc::ResourceFactory.new(:mock, :uid => 'suzuka', :properties => {:mock_property => "test"})
42
- end
43
-
44
- describe "when child resource with a known type" do
45
- it "must load methods from related module correctly" do
46
- @resource.create(:mock, uid: 'mock') do |mock|
47
- mock.must_respond_to :test
48
- mock.must_respond_to :configure_very_important_property
49
- mock.must_respond_to :request_very_important_property
50
- proc { mock.configure_very_important_property('test') }.must_raise StandardError
51
- mock.request_very_important_property do |value|
52
- value.must_equal "Very important property's value"
53
- end
54
- end
55
- end
56
- end
57
- end
58
-
@@ -1,26 +0,0 @@
1
- require 'test_helper'
2
- require 'omf_rc/resource_proxy'
3
-
4
- include OmfRc::ResourceProxy
5
-
6
- describe Node do
7
- before do
8
- @resource = AbstractResource.new(properties: { pubsub: "mytestbed.net" })
9
- @node = @resource.create(:type => 'node', :uid => 'monaco')
10
- end
11
-
12
- describe "when configured with properties" do
13
- it "must run the underline commands" do
14
- end
15
- end
16
-
17
- describe "when properties requested" do
18
- it "must return an array with actual properties" do
19
- @resource.request([:devices], {:uid => 'monaco'}).first.devices.each do |device|
20
- device.type.wont_be_nil
21
- device.name.wont_be_nil
22
- end
23
- end
24
- end
25
- end
26
-
@@ -1,30 +0,0 @@
1
- require 'test_helper'
2
- require 'omf_rc/resource_proxy'
3
-
4
- include OmfRc::ResourceProxy
5
-
6
- describe Wifi do
7
- before do
8
- @resource = AbstractResource.new(properties: { pubsub: "mytestbed.net" })
9
- @wifi = @resource.create(:type => 'wifi', :uid => 'wlan0')
10
- end
11
-
12
- describe "when configured with properties" do
13
- it "must run the underline commands" do
14
- end
15
- end
16
-
17
- describe "when properties requested" do
18
- it "must return an array with actual properties" do
19
- @resource.request([:ssid, :freq, :rx, :tx, :signal, :tx_bitrate], {:type => 'wifi'}).each do |wifi|
20
- wifi.ssid.wont_be_nil
21
- wifi.freq.wont_be_nil
22
- wifi.rx.wont_be_nil
23
- wifi.tx.wont_be_nil
24
- wifi.signal.wont_be_nil
25
- wifi.tx_bitrate.wont_be_nil
26
- end
27
- end
28
- end
29
- end
30
-
@@ -1,5 +0,0 @@
1
- gem 'minitest'
2
- require 'minitest/autorun'
3
- require 'minitest/pride'
4
-
5
- require 'omf_rc'