omf_common 6.0.0 → 6.0.2.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 +4 -0
- data/bin/file_broadcaster.rb +56 -0
- data/bin/file_receiver.rb +62 -0
- data/bin/omf_keygen +21 -0
- data/bin/{monitor_topic.rb → omf_monitor_topic} +21 -8
- data/bin/omf_send_create +118 -0
- data/bin/{send_request.rb → omf_send_request} +12 -7
- data/example/engine_alt.rb +23 -24
- data/example/ls_app.yaml +21 -0
- data/lib/omf_common.rb +73 -12
- data/lib/omf_common/auth.rb +15 -0
- data/lib/omf_common/auth/certificate.rb +174 -0
- data/lib/omf_common/auth/certificate_store.rb +72 -0
- data/lib/omf_common/auth/ssh_pub_key_convert.rb +80 -0
- data/lib/omf_common/comm.rb +66 -9
- data/lib/omf_common/comm/amqp/amqp_communicator.rb +40 -13
- data/lib/omf_common/comm/amqp/amqp_file_transfer.rb +259 -0
- data/lib/omf_common/comm/amqp/amqp_topic.rb +14 -21
- data/lib/omf_common/comm/local/local_communicator.rb +31 -2
- data/lib/omf_common/comm/local/local_topic.rb +19 -3
- data/lib/omf_common/comm/topic.rb +48 -34
- data/lib/omf_common/comm/xmpp/communicator.rb +19 -10
- data/lib/omf_common/comm/xmpp/topic.rb +22 -81
- data/lib/omf_common/default_logging.rb +11 -0
- data/lib/omf_common/eventloop.rb +14 -0
- data/lib/omf_common/eventloop/em.rb +39 -6
- data/lib/omf_common/eventloop/local_evl.rb +15 -0
- data/lib/omf_common/exec_app.rb +29 -15
- data/lib/omf_common/message.rb +53 -5
- data/lib/omf_common/message/json/json_message.rb +149 -39
- data/lib/omf_common/message/xml/message.rb +112 -39
- data/lib/omf_common/protocol/6.0.rnc +5 -1
- data/lib/omf_common/protocol/6.0.rng +12 -0
- data/lib/omf_common/version.rb +1 -1
- data/omf_common.gemspec +7 -2
- data/test/fixture/omf_test.cert.pem +15 -0
- data/test/fixture/omf_test.pem +15 -0
- data/test/fixture/omf_test.pub +1 -0
- data/test/fixture/omf_test.pub.pem +6 -0
- data/test/omf_common/auth/certificate_spec.rb +113 -0
- data/test/omf_common/auth/ssh_pub_key_convert_spec.rb +13 -0
- data/test/omf_common/comm/topic_spec.rb +175 -0
- data/test/omf_common/comm/xmpp/communicator_spec.rb +15 -16
- data/test/omf_common/comm/xmpp/topic_spec.rb +63 -10
- data/test/omf_common/comm_spec.rb +66 -9
- data/test/omf_common/message/xml/message_spec.rb +43 -13
- data/test/omf_common/message_spec.rb +14 -0
- data/test/test_helper.rb +25 -0
- metadata +78 -15
- data/bin/send_create.rb +0 -94
@@ -17,10 +17,11 @@ describe OmfCommon::Message::XML::Message do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
it "must be able to be serialised as XML" do
|
20
|
-
@message.to_xml
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
xml_payload = @message.marshall[1].to_xml
|
21
|
+
xml_payload.must_match /^<create(.+)create>$/m
|
22
|
+
xml_payload.must_match /<rtype>bob<\/rtype>/m
|
23
|
+
xml_payload.must_match /<props(.+)props>/m
|
24
|
+
xml_payload.must_match /<guard(.+)guard>/m
|
24
25
|
end
|
25
26
|
end
|
26
27
|
|
@@ -35,9 +36,10 @@ describe OmfCommon::Message::XML::Message do
|
|
35
36
|
end
|
36
37
|
|
37
38
|
it "must be able to be serialised as XML" do
|
38
|
-
@message.to_xml
|
39
|
-
|
40
|
-
|
39
|
+
xml_payload = @message.marshall[1].to_xml
|
40
|
+
xml_payload.must_match /^<release(.+)release>$/m
|
41
|
+
xml_payload.must_match /<res_id>bob<\/res_id>/m
|
42
|
+
xml_payload.must_match /<guard(.+)guard>/m
|
41
43
|
end
|
42
44
|
end
|
43
45
|
|
@@ -53,9 +55,9 @@ describe OmfCommon::Message::XML::Message do
|
|
53
55
|
false: false,
|
54
56
|
empty: nil,
|
55
57
|
boolean_array: [false, true] },
|
56
|
-
{ rtype: 'vm', guard: { os_type: 'linux' } }).to_xml
|
58
|
+
{ rtype: 'vm', guard: { os_type: 'linux' } }).marshall[1].to_xml
|
57
59
|
|
58
|
-
|
60
|
+
Message::XML::Message.parse(@xml) { |v| @message = v }
|
59
61
|
end
|
60
62
|
|
61
63
|
it "must create the object correctly" do
|
@@ -119,18 +121,46 @@ describe OmfCommon::Message::XML::Message do
|
|
119
121
|
|
120
122
|
describe "when parsing inform message" do
|
121
123
|
it "must validate against inform message schema" do
|
122
|
-
|
124
|
+
raw_xml = <<-XML
|
123
125
|
<inform xmlns="http://schema.mytestbed.net/omf/6.0/protocol" mid="bob">
|
124
126
|
<src>xmpp://bob@localhost</src>
|
125
127
|
<ts>100</ts>
|
126
128
|
<itype>CREATION.OK</itype>
|
127
129
|
</inform>
|
128
130
|
XML
|
131
|
+
Message::XML::Message.parse(raw_xml) do |parsed_msg|
|
132
|
+
parsed_msg.ts.must_equal "100"
|
133
|
+
parsed_msg.itype.must_equal "CREATION.OK"
|
129
134
|
|
130
|
-
|
131
|
-
|
135
|
+
parsed_msg.valid?.must_equal true
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
describe "when authentication enabled and certificate provided" do
|
141
|
+
it "must generate an envelope for the message" do
|
142
|
+
Message.stub(:authenticate?, true) do
|
143
|
+
OmfCommon::Auth.init
|
144
|
+
|
145
|
+
comm = mock
|
146
|
+
topic = OmfCommon::Comm::Topic.create("bob_topic")
|
147
|
+
topic.stubs(:address).returns('bob')
|
148
|
+
OmfCommon.stubs(:comm).returns(comm)
|
149
|
+
comm.expects(:create_topic).returns(topic)
|
132
150
|
|
133
|
-
|
151
|
+
cert = OmfCommon::Auth::Certificate.create(nil, 'sa', 'auth')
|
152
|
+
bob_cert = cert.create_for('bob', 'bob', 'bob')
|
153
|
+
|
154
|
+
message = Message::XML::Message.create(:create,
|
155
|
+
{ type: 'bob', p1: 'p1_value'},
|
156
|
+
{ rtype: 'bob', src: 'bob'})
|
157
|
+
|
158
|
+
# m indicates multiple lines
|
159
|
+
message.marshall[1].to_xml.must_match /<env(.+)env>/m
|
160
|
+
message.valid?.must_equal true
|
161
|
+
|
162
|
+
OmfCommon.comm.unstub(:comm)
|
163
|
+
end
|
134
164
|
end
|
135
165
|
end
|
136
166
|
end
|
@@ -53,5 +53,19 @@ describe OmfCommon::Message do
|
|
53
53
|
{ itype: 'STATUS' })
|
54
54
|
@message.print_app_event.must_equal "APP_EVENT (app100, #1, DONE.OK): Everything will be OK"
|
55
55
|
end
|
56
|
+
|
57
|
+
it "must return inform type (itype), formatted" do
|
58
|
+
@message.itype = 'CREATION.OK'
|
59
|
+
|
60
|
+
@message.itype.must_equal 'CREATION.OK'
|
61
|
+
@message.itype(:ruby).must_equal 'creation_ok'
|
62
|
+
@message.itype(:frcp).must_equal 'CREATION.OK'
|
63
|
+
|
64
|
+
@message.itype = :creation_ok
|
65
|
+
|
66
|
+
@message.itype.must_equal :creation_ok
|
67
|
+
@message.itype(:ruby).must_equal 'creation_ok'
|
68
|
+
@message.itype(:frcp).must_equal 'CREATION.OK'
|
69
|
+
end
|
56
70
|
end
|
57
71
|
end
|
data/test/test_helper.rb
CHANGED
@@ -6,10 +6,35 @@ require 'minitest/autorun'
|
|
6
6
|
require 'minitest/pride'
|
7
7
|
require 'minitest/spec'
|
8
8
|
require 'minitest/mock'
|
9
|
+
require 'em/minitest/spec'
|
10
|
+
require 'mocha/setup'
|
9
11
|
|
10
12
|
require 'omf_common'
|
13
|
+
require 'blather/client/dsl'
|
14
|
+
|
15
|
+
require 'singleton'
|
11
16
|
|
12
17
|
OmfCommon::Message.init(type: :xml)
|
13
18
|
|
14
19
|
# Shut up all the loggers
|
15
20
|
Logging.logger.root.clear_appenders
|
21
|
+
|
22
|
+
# Add reset to singleton classes
|
23
|
+
#
|
24
|
+
class OmfCommon::Comm
|
25
|
+
def self.reset
|
26
|
+
@@instance = nil
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
class OmfCommon::Eventloop
|
31
|
+
def self.reset
|
32
|
+
@@instance = nil
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
class OmfCommon::Auth::CertificateStore
|
37
|
+
def self.reset
|
38
|
+
@@instance = nil
|
39
|
+
end
|
40
|
+
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omf_common
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.0.
|
5
|
-
prerelease:
|
4
|
+
version: 6.0.2.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: 2013-
|
12
|
+
date: 2013-04-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: minitest
|
@@ -59,6 +59,38 @@ dependencies:
|
|
59
59
|
- - ! '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: pry
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: mocha
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
62
94
|
- !ruby/object:Gem::Dependency
|
63
95
|
name: eventmachine
|
64
96
|
requirement: !ruby/object:Gem::Requirement
|
@@ -130,7 +162,7 @@ dependencies:
|
|
130
162
|
requirements:
|
131
163
|
- - ~>
|
132
164
|
- !ruby/object:Gem::Version
|
133
|
-
version: 2.
|
165
|
+
version: 2.9.1
|
134
166
|
type: :runtime
|
135
167
|
prerelease: false
|
136
168
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -138,29 +170,38 @@ dependencies:
|
|
138
170
|
requirements:
|
139
171
|
- - ~>
|
140
172
|
- !ruby/object:Gem::Version
|
141
|
-
version: 2.
|
173
|
+
version: 2.9.1
|
142
174
|
description: Common library of OMF, a generic framework for controlling and managing
|
143
175
|
networking testbeds.
|
144
176
|
email:
|
145
177
|
- omf-user@lists.nicta.com.au
|
146
178
|
executables:
|
147
|
-
-
|
148
|
-
-
|
149
|
-
-
|
179
|
+
- omf_monitor_topic
|
180
|
+
- omf_send_request
|
181
|
+
- omf_send_create
|
150
182
|
extensions: []
|
151
183
|
extra_rdoc_files: []
|
152
184
|
files:
|
153
185
|
- .gitignore
|
154
186
|
- Gemfile
|
155
187
|
- Rakefile
|
156
|
-
- bin/
|
157
|
-
- bin/
|
158
|
-
- bin/
|
188
|
+
- bin/file_broadcaster.rb
|
189
|
+
- bin/file_receiver.rb
|
190
|
+
- bin/omf_keygen
|
191
|
+
- bin/omf_monitor_topic
|
192
|
+
- bin/omf_send_create
|
193
|
+
- bin/omf_send_request
|
159
194
|
- example/engine_alt.rb
|
195
|
+
- example/ls_app.yaml
|
160
196
|
- example/vm_alt.rb
|
161
197
|
- lib/omf_common.rb
|
198
|
+
- lib/omf_common/auth.rb
|
199
|
+
- lib/omf_common/auth/certificate.rb
|
200
|
+
- lib/omf_common/auth/certificate_store.rb
|
201
|
+
- lib/omf_common/auth/ssh_pub_key_convert.rb
|
162
202
|
- lib/omf_common/comm.rb
|
163
203
|
- lib/omf_common/comm/amqp/amqp_communicator.rb
|
204
|
+
- lib/omf_common/comm/amqp/amqp_file_transfer.rb
|
164
205
|
- lib/omf_common/comm/amqp/amqp_topic.rb
|
165
206
|
- lib/omf_common/comm/local/local_communicator.rb
|
166
207
|
- lib/omf_common/comm/local/local_topic.rb
|
@@ -186,7 +227,14 @@ files:
|
|
186
227
|
- lib/omf_common/protocol/6.0.rng
|
187
228
|
- lib/omf_common/version.rb
|
188
229
|
- omf_common.gemspec
|
230
|
+
- test/fixture/omf_test.cert.pem
|
231
|
+
- test/fixture/omf_test.pem
|
232
|
+
- test/fixture/omf_test.pub
|
233
|
+
- test/fixture/omf_test.pub.pem
|
189
234
|
- test/fixture/pubsub.rb
|
235
|
+
- test/omf_common/auth/certificate_spec.rb
|
236
|
+
- test/omf_common/auth/ssh_pub_key_convert_spec.rb
|
237
|
+
- test/omf_common/comm/topic_spec.rb
|
190
238
|
- test/omf_common/comm/xmpp/communicator_spec.rb
|
191
239
|
- test/omf_common/comm/xmpp/topic_spec.rb
|
192
240
|
- test/omf_common/comm_spec.rb
|
@@ -211,14 +259,29 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
211
259
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
212
260
|
none: false
|
213
261
|
requirements:
|
214
|
-
- - ! '
|
262
|
+
- - ! '>'
|
215
263
|
- !ruby/object:Gem::Version
|
216
|
-
version:
|
264
|
+
version: 1.3.1
|
217
265
|
requirements: []
|
218
266
|
rubyforge_project: omf_common
|
219
267
|
rubygems_version: 1.8.25
|
220
268
|
signing_key:
|
221
269
|
specification_version: 3
|
222
270
|
summary: Common library of OMF
|
223
|
-
test_files:
|
224
|
-
|
271
|
+
test_files:
|
272
|
+
- test/fixture/omf_test.cert.pem
|
273
|
+
- test/fixture/omf_test.pem
|
274
|
+
- test/fixture/omf_test.pub
|
275
|
+
- test/fixture/omf_test.pub.pem
|
276
|
+
- test/fixture/pubsub.rb
|
277
|
+
- test/omf_common/auth/certificate_spec.rb
|
278
|
+
- test/omf_common/auth/ssh_pub_key_convert_spec.rb
|
279
|
+
- test/omf_common/comm/topic_spec.rb
|
280
|
+
- test/omf_common/comm/xmpp/communicator_spec.rb
|
281
|
+
- test/omf_common/comm/xmpp/topic_spec.rb
|
282
|
+
- test/omf_common/comm_spec.rb
|
283
|
+
- test/omf_common/command_spec.rb
|
284
|
+
- test/omf_common/core_ext/string_spec.rb
|
285
|
+
- test/omf_common/message/xml/message_spec.rb
|
286
|
+
- test/omf_common/message_spec.rb
|
287
|
+
- test/test_helper.rb
|
data/bin/send_create.rb
DELETED
@@ -1,94 +0,0 @@
|
|
1
|
-
#
|
2
|
-
DESCR = %{
|
3
|
-
Send a create to a specific resource (topic) and print out any replies.
|
4
|
-
|
5
|
-
Any additional command line arguments are interpreted as paramters to
|
6
|
-
the create.
|
7
|
-
}
|
8
|
-
|
9
|
-
require 'omf_common'
|
10
|
-
|
11
|
-
OP_MODE = :development
|
12
|
-
|
13
|
-
opts = {
|
14
|
-
communication: {
|
15
|
-
# url: 'amqp://srv.mytestbed.net'
|
16
|
-
},
|
17
|
-
eventloop: { type: :em},
|
18
|
-
logging: {
|
19
|
-
level: 'info'
|
20
|
-
}
|
21
|
-
}
|
22
|
-
|
23
|
-
resource_url = nil
|
24
|
-
resource_type = nil
|
25
|
-
|
26
|
-
op = OptionParser.new
|
27
|
-
op.banner = "Usage: #{op.program_name} [options] type pname1: val1 pname2: val2 ...\n#{DESCR}\n"
|
28
|
-
op.on '-r', '--resource-url URL', "URL of resource" do |url|
|
29
|
-
resource_url = url
|
30
|
-
end
|
31
|
-
op.on '-t', '--type TYPE', "Type of resource to create" do |type|
|
32
|
-
resource_type = type
|
33
|
-
end
|
34
|
-
op.on '-d', '--debug', "Set logging to DEBUG level" do
|
35
|
-
opts[:logging][:level] = 'debug'
|
36
|
-
end
|
37
|
-
op.on_tail('-h', "--help", "Show this message") { $stderr.puts op; exit }
|
38
|
-
rest = op.parse(ARGV) || []
|
39
|
-
|
40
|
-
unless resource_url || resource_type
|
41
|
-
$stderr.puts 'Missing --resource-url --type or'
|
42
|
-
$stderr.puts op
|
43
|
-
exit(-1)
|
44
|
-
end
|
45
|
-
|
46
|
-
r = resource_url.split('/')
|
47
|
-
resource = r.pop
|
48
|
-
opts[:communication][:url] = r.join('/')
|
49
|
-
|
50
|
-
copts = {}
|
51
|
-
key = nil
|
52
|
-
def err_exit
|
53
|
-
$stderr.puts("Options need to be of the 'key: value' type")
|
54
|
-
exit(-1)
|
55
|
-
end
|
56
|
-
rest.each do |s|
|
57
|
-
sa = s.split(':')
|
58
|
-
if sa.length == 2
|
59
|
-
err_exit if key
|
60
|
-
copts[sa[0]] = sa[1]
|
61
|
-
else
|
62
|
-
if s.end_with?(':')
|
63
|
-
err_exit if key
|
64
|
-
key = s[0]
|
65
|
-
else
|
66
|
-
err_exit unless key
|
67
|
-
copts[key] = s[0]
|
68
|
-
key = nil
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
err_exit if key
|
73
|
-
|
74
|
-
OmfCommon.init(OP_MODE, opts) do |el|
|
75
|
-
OmfCommon.comm.on_connected do |comm|
|
76
|
-
comm.subscribe(resource) do |topic|
|
77
|
-
# topic.on_inform do |msg|
|
78
|
-
# puts "#{resource} <#{msg.type}(#{msg.itype})> #{msg.inspect}"
|
79
|
-
# msg.each_property do |name, value|
|
80
|
-
# puts " #{name}: #{value}"
|
81
|
-
# end
|
82
|
-
# puts "------"
|
83
|
-
# end
|
84
|
-
|
85
|
-
topic.create(resource_type, copts) do |msg|
|
86
|
-
puts "#{resource} <#{msg.type}(#{msg.itype})> #{msg.inspect}"
|
87
|
-
msg.each_property do |name, value|
|
88
|
-
puts " #{name}: #{value}"
|
89
|
-
end
|
90
|
-
puts "------"
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|