omf_sfa 0.1.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.
Files changed (152) hide show
  1. data/.gitignore +24 -0
  2. data/Gemfile +6 -0
  3. data/README.md +211 -0
  4. data/Rakefile +23 -0
  5. data/bin/parse_rspec.rb +167 -0
  6. data/etc/omf-sfa/omf-sfa-am.yaml +12 -0
  7. data/examples/exogeni5nodemanifest.rspec +105 -0
  8. data/examples/instageni5nodemanifest.rspec +150 -0
  9. data/lib/omf-sfa/am/am-rest/REST_API.md +301 -0
  10. data/lib/omf-sfa/am/am-rest/account_handler.rb +145 -0
  11. data/lib/omf-sfa/am/am-rest/am_rest_server.rb +255 -0
  12. data/lib/omf-sfa/am/am-rest/api_template.html +48 -0
  13. data/lib/omf-sfa/am/am-rest/config.ru +110 -0
  14. data/lib/omf-sfa/am/am-rest/resource_handler.rb +178 -0
  15. data/lib/omf-sfa/am/am-rest/rest_handler.rb +573 -0
  16. data/lib/omf-sfa/am/am-rest/session_authenticator.rb +130 -0
  17. data/lib/omf-sfa/am/am-rpc/abstract_rpc_service.rb +60 -0
  18. data/lib/omf-sfa/am/am-rpc/am_authorizer.rb +161 -0
  19. data/lib/omf-sfa/am/am-rpc/am_rpc_api.rb +450 -0
  20. data/lib/omf-sfa/am/am-rpc/am_rpc_service.rb +402 -0
  21. data/lib/omf-sfa/am/am_liaison.rb +93 -0
  22. data/lib/omf-sfa/am/am_manager.rb +859 -0
  23. data/lib/omf-sfa/am/am_runner.rb +108 -0
  24. data/lib/omf-sfa/am/am_scheduler.rb +146 -0
  25. data/lib/omf-sfa/am/am_server.rb +194 -0
  26. data/lib/omf-sfa/am/config.ru +122 -0
  27. data/lib/omf-sfa/am/credential.rb +145 -0
  28. data/lib/omf-sfa/am/default_authorizer.rb +44 -0
  29. data/lib/omf-sfa/am/privilege_credential.rb +76 -0
  30. data/lib/omf-sfa/am/signature.rb +37 -0
  31. data/lib/omf-sfa/am/user_credential.rb +56 -0
  32. data/lib/omf-sfa/am.rb +7 -0
  33. data/lib/omf-sfa/model/abstract_prop_description.rb +87 -0
  34. data/lib/omf-sfa/model/model_class_description.rb +145 -0
  35. data/lib/omf-sfa/model/model_data_prop_description.rb +28 -0
  36. data/lib/omf-sfa/model/model_obj_prop_description.rb +49 -0
  37. data/lib/omf-sfa/model/ontology.rb +169 -0
  38. data/lib/omf-sfa/resource/README.md +24 -0
  39. data/lib/omf-sfa/resource/channel.rb +49 -0
  40. data/lib/omf-sfa/resource/comp_group.rb +41 -0
  41. data/lib/omf-sfa/resource/component_lease.rb +10 -0
  42. data/lib/omf-sfa/resource/constants.rb +24 -0
  43. data/lib/omf-sfa/resource/group_component.rb +35 -0
  44. data/lib/omf-sfa/resource/group_membership.rb +17 -0
  45. data/lib/omf-sfa/resource/gurn.rb +187 -0
  46. data/lib/omf-sfa/resource/interface.rb +78 -0
  47. data/lib/omf-sfa/resource/ip.rb +48 -0
  48. data/lib/omf-sfa/resource/link.rb +29 -0
  49. data/lib/omf-sfa/resource/node.rb +75 -0
  50. data/lib/omf-sfa/resource/oaccount.rb +94 -0
  51. data/lib/omf-sfa/resource/ocomponent.rb +134 -0
  52. data/lib/omf-sfa/resource/ogroup.rb +106 -0
  53. data/lib/omf-sfa/resource/olease.rb +61 -0
  54. data/lib/omf-sfa/resource/oproperty.rb +178 -0
  55. data/lib/omf-sfa/resource/oreference.rb +15 -0
  56. data/lib/omf-sfa/resource/oresource.rb +491 -0
  57. data/lib/omf-sfa/resource/project.rb +28 -0
  58. data/lib/omf-sfa/resource/project_membership.rb +13 -0
  59. data/lib/omf-sfa/resource/sfa_base.rb +544 -0
  60. data/lib/omf-sfa/resource/user.rb +25 -0
  61. data/lib/omf-sfa/resource.rb +20 -0
  62. data/lib/omf-sfa/util/create_sample_testbed.rb +68 -0
  63. data/lib/omf-sfa/util/load_from_sfa_xml.rb +65 -0
  64. data/lib/omf-sfa/version.rb +4 -0
  65. data/lib/omf_sfa.rb +5 -0
  66. data/omf_sfa.gemspec +46 -0
  67. data/owl/README +3 -0
  68. data/owl/ben-6509.rdf +1377 -0
  69. data/owl/ben-dell.rdf +586 -0
  70. data/owl/ben-dtn.rdf +1698 -0
  71. data/owl/ben.rdf +1335 -0
  72. data/owl/collections.owl +309 -0
  73. data/owl/compute.owl +1486 -0
  74. data/owl/domain.owl +444 -0
  75. data/owl/dtn.owl +1165 -0
  76. data/owl/ec2.owl +385 -0
  77. data/owl/ethernet.owl +466 -0
  78. data/owl/eucalyptus.owl +431 -0
  79. data/owl/id-mp-Request1.rdf +247 -0
  80. data/owl/itu-grid.owl +147 -0
  81. data/owl/kansei.owl +511 -0
  82. data/owl/layer.owl +645 -0
  83. data/owl/location.owl +117 -0
  84. data/owl/mass.rdf +608 -0
  85. data/owl/nlr.rdf +901 -0
  86. data/owl/orca.owl +181 -0
  87. data/owl/planetlab.owl +124 -0
  88. data/owl/protogeni.owl +467 -0
  89. data/owl/request-6509-2.rdf +150 -0
  90. data/owl/request-6509-3.rdf +158 -0
  91. data/owl/request-6509.rdf +199 -0
  92. data/owl/request.owl +222 -0
  93. data/owl/storage.owl +511 -0
  94. data/owl/topology.owl +608 -0
  95. data/schema/rspec-v3/ad-common.xsd +269 -0
  96. data/schema/rspec-v3/ad-reservation.rnc +12 -0
  97. data/schema/rspec-v3/ad-reservation.rng +28 -0
  98. data/schema/rspec-v3/ad-reservation.xsd +13 -0
  99. data/schema/rspec-v3/ad.rnc +151 -0
  100. data/schema/rspec-v3/ad.xsd +77 -0
  101. data/schema/rspec-v3/any-extension-schema.xsd +38 -0
  102. data/schema/rspec-v3/any-extension.rnc +30 -0
  103. data/schema/rspec-v3/common.rnc +185 -0
  104. data/schema/rspec-v3/manifest-common.xsd +244 -0
  105. data/schema/rspec-v3/manifest-request.xsd +95 -0
  106. data/schema/rspec-v3/manifest.rnc +62 -0
  107. data/schema/rspec-v3/manifest.xsd +34 -0
  108. data/schema/rspec-v3/request-common.xsd +219 -0
  109. data/schema/rspec-v3/request-reservation.rnc +12 -0
  110. data/schema/rspec-v3/request-reservation.xsd +13 -0
  111. data/schema/rspec-v3/request.rnc +118 -0
  112. data/schema/rspec-v3/request.xsd +94 -0
  113. data/share/assets/css/default.css +147 -0
  114. data/share/assets/css/rest_api.css +0 -0
  115. data/share/assets/network.html +28 -0
  116. data/share/assets/network.js +82 -0
  117. data/spec/am/am-rest/common.rb +29 -0
  118. data/spec/am/am-rest/resource_group_handler_XspecX.rb +97 -0
  119. data/spec/am/am-rest/resource_handler_spec.rb +204 -0
  120. data/spec/am/am-rpc/sfa_methods_spec.rb +150 -0
  121. data/spec/am/am_manager_spec.rb +307 -0
  122. data/spec/am/am_scheduler_spec.rb +57 -0
  123. data/spec/am/common.rb +24 -0
  124. data/spec/resource/common.rb +31 -0
  125. data/spec/resource/node_spec.rb +171 -0
  126. data/spec/resource/oaccount_spec.rb +92 -0
  127. data/spec/resource/ocomponent_spec.rb +225 -0
  128. data/spec/resource/ogroup_spec.rb +93 -0
  129. data/spec/resource/oresource_spec.rb +208 -0
  130. data/spec/resource_and_leases_spec.rb +377 -0
  131. data/test/OLD_FILES/assertion1.xml +117 -0
  132. data/test/OLD_FILES/greeter_spec.rb +15 -0
  133. data/test/OLD_FILES/mongo_test.rb +45 -0
  134. data/test/OLD_FILES/req-sfa-2.xml +6 -0
  135. data/test/OLD_FILES/req-sfa-g.xml +8 -0
  136. data/test/OLD_FILES/req-sfa-g2.xml +10 -0
  137. data/test/OLD_FILES/req-sfa-g3.xml +14 -0
  138. data/test/OLD_FILES/req-sfa.xml +6 -0
  139. data/test/OLD_FILES/req1.xml +22 -0
  140. data/test/OLD_FILES/req1b.xml +15 -0
  141. data/test/OLD_FILES/rspec-test.xml +1867 -0
  142. data/test/OLD_FILES/test.rb +67 -0
  143. data/test/OLD_FILES/test2.rb +32 -0
  144. data/test/am/am_manager_rspec_tests.rb +378 -0
  145. data/test/am/am_manager_tests.rb +518 -0
  146. data/test/am/am_scheduler_tests.rb +173 -0
  147. data/test/resource/olease_test.rb +74 -0
  148. data/test/sfa_requests/request.xml +5 -0
  149. data/test/sfa_requests/request1.xml +5 -0
  150. data/test/sfa_requests/request2.xml +5 -0
  151. data/test/sfa_requests/request3.xml +5 -0
  152. metadata +601 -0
@@ -0,0 +1,377 @@
1
+ require 'uuid'
2
+ require 'omf-sfa/am/am_manager'
3
+ require 'omf-sfa/am/am_scheduler'
4
+ require 'omf-sfa/resource'
5
+ require 'dm-migrations'
6
+ require 'omf_common/lobject'
7
+ require 'omf_common/load_yaml'
8
+
9
+ include OMF::SFA::AM
10
+
11
+ def init_dm
12
+ # setup database
13
+ DataMapper::Logger.new($stdout, :info)
14
+
15
+ DataMapper.setup(:default, 'sqlite::memory:')
16
+ #DataMapper.setup(:default, 'sqlite:///tmp/am_test.db')
17
+ DataMapper::Model.raise_on_save_failure = true
18
+ DataMapper.finalize
19
+
20
+ DataMapper.auto_migrate!
21
+ end
22
+
23
+ def init_logger
24
+ OMF::Common::Loggable.init_log 'am_manager', :searchPath => File.join(File.dirname(__FILE__), 'am_manager')
25
+ @config = OMF::Common::YAML.load('omf-sfa-am', :path => [File.dirname(__FILE__) + '/../etc/omf-sfa'])[:omf_sfa_am]
26
+ end
27
+
28
+
29
+ describe AMManager do
30
+
31
+ init_dm
32
+
33
+ init_logger
34
+
35
+ before :each do
36
+ DataMapper.auto_migrate! # reset database
37
+ # @r1 = OMF::SFA::Resource::Node.new(:name => 'r1')
38
+ # @r2 = OMF::SFA::Resource::Node.new(:name => 'r2')
39
+ # @r1.uuid = UUID.generate
40
+ # @r2.uuid = UUID.generate
41
+ end
42
+
43
+ context 'leases' do
44
+
45
+ let (:scheduler) { double('scheduler') }
46
+
47
+ let (:auth) { double('authorizer') }
48
+
49
+ let (:manager) { AMManager.new(scheduler) }
50
+
51
+ it 'will create a lease from rspec' do
52
+
53
+ rspec = %{
54
+ <rspec xmlns="http://www.protogeni.net/resources/rspec/2" xmlns:omf="http://schema.mytestbed.net/sfa/rspec/1" xmlns:olx="http://schema.ict-openlab.eu/sfa/rspec/1" type="request">
55
+ <olx:lease lease_name="l1" olx:valid_from="1338847200" olx:valid_until="1338850800"/>
56
+ <node component_name="r1" uuid="#{UUID.generate}" olx:lease_name="l1">
57
+ </node>
58
+ <node component_name="r2" uuid="#{UUID.generate}" olx:lease_name="l1">
59
+ </node>
60
+ </rspec>
61
+ }
62
+ req = Nokogiri.XML(rspec)
63
+
64
+ auth.should_receive(:can_create_lease?)
65
+
66
+ lease_elements = req.xpath('//ol:lease', 'ol' => OL_NAMESPACE)
67
+ lease = manager.update_lease_from_rspec(lease_elements.first, auth)
68
+ lease.should be_a_kind_of(OMF::SFA::Resource::OLease)
69
+ lease.name.should eq("l1")
70
+ lease.valid_from == 1338847200
71
+ lease.valid_until == 1338850800
72
+ end
73
+
74
+
75
+
76
+ it 'will modify lease from rspec' do
77
+
78
+ #l = OMF::SFA::Resource::OLease.create({ :name => "l1", :valid_from => "1338847200", :valid_until => "1338850800"})
79
+ l = OMF::SFA::Resource::OLease.new({ :name => "l1"})
80
+ l.valid_from = "1338847200"
81
+ l.valid_until = "1338850800"
82
+ l.save
83
+ l.should be_saved
84
+ l.should == OMF::SFA::Resource::OLease.first({ :name => "l1" })
85
+ rspec = %{
86
+ <rspec xmlns="http://www.protogeni.net/resources/rspec/2" xmlns:omf="http://schema.mytestbed.net/sfa/rspec/1" xmlns:ol="http://schema.ict-openlab.eu/sfa/rspec/1" type="request">
87
+ <ol:lease uuid="#{l.uuid}" ol:valid_from="1338847200" ol:valid_until="1338852600"/>
88
+ </rspec>
89
+ }
90
+ req = Nokogiri.XML(rspec)
91
+
92
+ auth.should_receive(:can_view_lease?)
93
+ auth.should_receive(:can_modify_lease?)
94
+
95
+ lease_elements = req.xpath('//ol:lease')
96
+ lease = manager.update_lease_from_rspec(lease_elements.first, auth)
97
+ lease.should be_a_kind_of(OMF::SFA::Resource::OLease)
98
+ lease.name.should eq("l1")
99
+ lease.valid_from == 1338847200
100
+ lease.valid_until == 1338852600
101
+ end
102
+
103
+ it 'will create two different leases from rspec' do
104
+
105
+ rspec = %{
106
+ <rspec xmlns="http://www.protogeni.net/resources/rspec/2" xmlns:omf="http://schema.mytestbed.net/sfa/rspec/1" xmlns:ol="http://schema.ict-openlab.eu/sfa/rspec/1" type="request">
107
+ <ol:lease ol:lease_name="l1" ol:valid_from="1338847200" ol:valid_until="1338850800"/>
108
+ <ol:lease ol:lease_name="l2" ol:valid_from="1338854400" ol:valid_until="1338858000"/>
109
+ </rspec>
110
+ }
111
+ req = Nokogiri.XML(rspec)
112
+
113
+ auth.should_receive(:can_create_lease?).exactly(2).times
114
+
115
+ lease_elements = req.xpath('//ol:lease')
116
+
117
+ leases = []
118
+ lease_elements.each do |l|
119
+ leases << manager.update_lease_from_rspec(l, auth)
120
+ end
121
+
122
+ leases[0].name.should eq('l1')
123
+ leases[0].valid_from.should eq('1338847200')
124
+ leases[0].valid_until.should eq('1338850800')
125
+
126
+ leases[1].name.should eq('l2')
127
+ leases[1].valid_from.should eq('1338854400')
128
+ leases[1].valid_until.should eq('1338858000')
129
+
130
+ end
131
+ end # context leases
132
+
133
+ describe AMScheduler do
134
+
135
+ let (:scheduler) { AMScheduler.new }
136
+
137
+ let (:manager) { AMManager.new(scheduler) }
138
+
139
+ let (:account) { OMF::SFA::Resource::OAccount.new(:name => 'a') }
140
+
141
+ let(:auth) do
142
+ auth = double('authorizer')
143
+ auth.stub(:account) { account }
144
+ auth
145
+ end
146
+
147
+ context 'resources' do
148
+
149
+ it 'will release a resource of type Node' do
150
+
151
+ r = OMF::SFA::Resource::Node.create({:name => 'r1', :account => account})
152
+
153
+ OMF::SFA::Resource::Node.first(:name => 'r1').should be_eql(r)
154
+
155
+ auth.should_receive(:can_release_resource?).with(r)
156
+ manager.release_resource(r, auth)
157
+
158
+ OMF::SFA::Resource::Node.first(:name => 'r1').should be_nil
159
+ end
160
+
161
+ it 'will release a resource that is not listed in the RSpecs' do
162
+
163
+ r1 = OMF::SFA::Resource::Node.create({:name => 'r1', :account => account})
164
+
165
+ rspec = %{
166
+ <rspec xmlns="http://www.protogeni.net/resources/rspec/2" xmlns:omf="http://schema.mytestbed.net/sfa/rspec/1" xmlns:ol="http://schema.ict-openlab.eu/sfa/rspec/1" type="request">
167
+ <node component_id="urn:publicid:IDN+openlab+node+node1" component_name="node1">
168
+ </node>
169
+ </rspec>
170
+ }
171
+ req = Nokogiri.XML(rspec)
172
+
173
+
174
+ auth.should_receive(:can_view_resource?).exactly(2).times
175
+ auth.should_receive(:can_release_resource?)
176
+ auth.should_receive(:can_create_resource?)
177
+
178
+ r = manager.update_resources_from_rspec(req.root, true, auth)
179
+
180
+ OMF::SFA::Resource::Node.first(:name => 'r1').should be_nil
181
+
182
+ r.length.should be_eql(1)
183
+ r.first.name.should be_eql('node1')
184
+ end
185
+ end # context resources
186
+
187
+ context 'combining leases with resources' do
188
+
189
+ it 'will release a resource with a lease attached to it' do
190
+
191
+ r = OMF::SFA::Resource::Node.create({:name => 'r1', :account => account})
192
+
193
+ l = OMF::SFA::Resource::OLease.create(:name => 'l1')
194
+
195
+ r.leases << l
196
+ r.save
197
+
198
+ r.should be_saved
199
+
200
+ auth.should_receive(:can_release_resource?).with(r)
201
+
202
+ manager.release_resource(r, auth)
203
+
204
+ OMF::SFA::Resource::Node.first(:name => 'r1').should be_nil
205
+ end
206
+
207
+
208
+ it 'can create a node with a lease attached to it' do
209
+
210
+ #l = OMF::SFA::Resource::OLease.create({ :name => "l1", :valid_from => "1338847200", :valid_until => "1338850800", :account => account})
211
+ l = OMF::SFA::Resource::OLease.new({ :name => "l1", :account => account})
212
+ l.valid_from = '1338847200'
213
+ l.valid_until = '1338850800'
214
+ l.save
215
+
216
+ rspec = %{
217
+ <rspec xmlns="http://www.protogeni.net/resources/rspec/2" xmlns:omf="http://schema.mytestbed.net/sfa/rspec/1" xmlns:ol="http://schema.ict-openlab.eu/sfa/rspec/1" type="request">
218
+ <node component_id="urn:publicid:IDN+openlab+node+node1" component_name="node1" ol:lease_uuid="#{l.uuid}">
219
+ </node>
220
+ </rspec>
221
+ }
222
+ req = Nokogiri.XML(rspec)
223
+
224
+ auth.should_receive(:can_view_lease?)
225
+ auth.should_receive(:can_create_resource?)
226
+
227
+ r = manager.update_resources_from_rspec(req.root, false, auth)
228
+
229
+ node = r.first
230
+ node.should be_kind_of(OMF::SFA::Resource::Node)
231
+ node.name.should be_eql('node1')
232
+ node.resource_type.should be_eql('node')
233
+
234
+ account = node.account
235
+ account.name.should be_eql('a')
236
+
237
+ lease = node.leases.first
238
+ lease.should be_kind_of(OMF::SFA::Resource::OLease)
239
+ lease.name.should be_eql('l1')
240
+ lease.valid_from.should be_eql('1338847200')
241
+ lease.valid_until.should be_eql('1338850800')
242
+ lease.components.first.should be_kind_of(OMF::SFA::Resource::Node)
243
+ end
244
+
245
+ it 'can create a node with an already known lease attached to it' do
246
+
247
+ rspec = %{
248
+ <rspec xmlns="http://www.protogeni.net/resources/rspec/2" xmlns:omf="http://schema.mytestbed.net/sfa/rspec/1" xmlns:ol="http://schema.ict-openlab.eu/sfa/rspec/1" type="request">
249
+ <ol:lease ol:lease_name="l1" ol:valid_from="1338847200" ol:valid_until="1338850800"/>
250
+ <node component_id="urn:publicid:IDN+openlab+node+node1" component_name="node1" ol:lease_name="l1">
251
+ </node>
252
+ </rspec>
253
+ }
254
+ req = Nokogiri.XML(rspec)
255
+
256
+ end
257
+
258
+ end # combining leases with resources
259
+
260
+ context 'clean state' do
261
+
262
+ it 'will create a new node and lease without deleting the previous' do
263
+
264
+ #l = OMF::SFA::Resource::OLease.create({ :name => "l1", :valid_from => "1338847200", :valid_until => "1338850800", :account => account})
265
+ l = OMF::SFA::Resource::OLease.create({ :name => "l1", :account => account})
266
+ l.valid_from = '1338847200'
267
+ l.valid_until = '1338850800'
268
+ l.save
269
+
270
+ r = OMF::SFA::Resource::Node.create({:name => 'r1', :account => account})
271
+ r.leases << l
272
+ r.save
273
+
274
+ r.should be_saved
275
+
276
+ rspec = %{
277
+ <rspec xmlns="http://www.protogeni.net/resources/rspec/2" xmlns:omf="http://schema.mytestbed.net/sfa/rspec/1" xmlns:ol="http://schema.ict-openlab.eu/sfa/rspec/1" type="request">
278
+ <ol:lease ol:lease_name="l2" ol:valid_from="1338847200" ol:valid_until="1338850800"/>
279
+ <node component_id="urn:publicid:IDN+openlab+node+node1" component_name="node1" ol:lease_name="l2">
280
+ </node>
281
+ </rspec>
282
+ }
283
+ req = Nokogiri.XML(rspec)
284
+
285
+ auth.should_receive(:can_create_lease?)
286
+ auth.should_receive(:can_create_resource?)
287
+
288
+ res = manager.update_resources_from_rspec(req.root, false, auth)
289
+
290
+ res.length == 1
291
+ res = res.first
292
+ res.name.should be_eql('node1')
293
+ res.leases.first.name.should be_eql('l2')
294
+
295
+ OMF::SFA::Resource::OLease.first(:name => 'l1').should_not be_nil
296
+ OMF::SFA::Resource::Node.first(:name => 'r1').should_not be_nil
297
+ end
298
+
299
+ it 'will unlink a node from a lease and release the node' do
300
+
301
+ #l = OMF::SFA::Resource::OLease.create({:name => "l1", :valid_from => "1338847200", :valid_until => "1338850800", :account => account})
302
+ l = OMF::SFA::Resource::OLease.create({:name => "l1", :account => account})
303
+ l.valid_from = '1338847200'
304
+ l.valid_until = '1338850800'
305
+ l.save
306
+
307
+ r = OMF::SFA::Resource::Node.create({:name => 'r1', :account => account})
308
+ r.leases << l
309
+ r.save
310
+
311
+ r.should be_saved
312
+
313
+ l.components.first.should be_eql(r)
314
+
315
+ rspec = %{
316
+ <rspec xmlns="http://www.protogeni.net/resources/rspec/2" xmlns:omf="http://schema.mytestbed.net/sfa/rspec/1" xmlns:ol="http://schema.ict-openlab.eu/sfa/rspec/1" type="request">
317
+ <ol:lease uuid="#{l.uuid}" ol:valid_from="1338847200" ol:valid_until="1338850800"/>
318
+ </rspec>
319
+ }
320
+ req = Nokogiri.XML(rspec)
321
+
322
+ auth.should_receive(:can_view_resource?)
323
+ auth.should_receive(:can_view_lease?).exactly(2).times
324
+ auth.should_receive(:can_modify_lease?)
325
+ auth.should_receive(:can_release_resource?).with(r)
326
+
327
+ r = manager.update_resources_from_rspec(req.root, true, auth)
328
+
329
+ r.should == []
330
+ OMF::SFA::Resource::Node.first(:name => 'r1').should be_nil
331
+
332
+ l.reload
333
+ l.components.first.should be_nil
334
+
335
+ OMF::SFA::Resource::OLease.first(:name => 'l1').should_not be_nil
336
+ end
337
+
338
+ it 'will release a node and a lease' do
339
+
340
+ #l = OMF::SFA::Resource::OLease.create({ :name => "l1", :valid_from => "1338847200", :valid_until => "1338850800", :account => account})
341
+ l = OMF::SFA::Resource::OLease.create({ :name => "l1", :account => account})
342
+ l.valid_from = '1338847200'
343
+ l.valid_until = '1338850800'
344
+ l.save
345
+
346
+ r = OMF::SFA::Resource::Node.create({:name => 'r1', :account => account})
347
+ r.leases << l
348
+ r.save
349
+
350
+ r.should be_saved
351
+
352
+ l.components.first.should be_eql(r)
353
+
354
+ rspec = %{
355
+ <rspec xmlns="http://www.protogeni.net/resources/rspec/2" xmlns:omf="http://schema.mytestbed.net/sfa/rspec/1" xmlns:ol="http://schema.ict-openlab.eu/sfa/rspec/1" type="request">
356
+ </rspec>
357
+ }
358
+ req = Nokogiri.XML(rspec)
359
+
360
+ auth.should_receive(:can_view_resource?)
361
+ auth.should_receive(:can_view_lease?).with(l)
362
+ auth.should_receive(:can_release_lease?).with(l)
363
+ auth.should_receive(:can_release_resource?).with(r)
364
+ #auth.should_receive(:can_release_resource?).with(l)
365
+
366
+ r = manager.update_resources_from_rspec(req.root, true, auth)
367
+
368
+ r.should == []
369
+ OMF::SFA::Resource::Node.first(:name => 'r1').should be_nil
370
+ OMF::SFA::Resource::OLease.first(:name => 'l1').should be_nil
371
+
372
+ end
373
+
374
+ end # context clean state
375
+ end
376
+ end
377
+
@@ -0,0 +1,117 @@
1
+
2
+ <saml:Assertion xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" Version="2.0" ID="s2b7afe8e21a0910d027dfbc94ec4b862e1fbbd9ab" IssueInstant="2007-12-10T11:39:48Z">
3
+ <saml:Issuer>
4
+ max.feide.no
5
+ </saml:Issuer>
6
+ <saml:Subject>
7
+ <saml:NameID NameQualifier="max.feide.no" SPNameQualifier="urn:mace:feide.no:services:no.feide.moodle" Format="urn:oasis:names:tc:SAML:2.0:nameid-format:persistent">
8
+ UB/WJAaKAPrSHbqlbcKWu7JktcKY
9
+ </saml:NameID>
10
+ <saml:SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer">
11
+ <saml:SubjectConfirmationData NotOnOrAfter="2007-12-10T19:39:48Z" InResponseTo="_bec424fa5103428909a30ff1e31168327f79474984" Recipient="http://moodle.bridge.feide.no/simplesaml/saml2/sp/AssertionConsumerService.php">
12
+ </saml:SubjectConfirmationData>
13
+ </saml:SubjectConfirmation>
14
+ </saml:Subject>
15
+ <saml:Conditions NotBefore="2007-12-10T11:29:48Z" NotOnOrAfter="2007-12-10T19:39:48Z">
16
+ <saml:AudienceRestriction>
17
+ <saml:Audience>
18
+ urn:mace:feide.no:services:no.feide.moodle
19
+ </saml:Audience>
20
+ </saml:AudienceRestriction>
21
+ </saml:Conditions>
22
+ <saml:AuthnStatement AuthnInstant="2007-12-10T11:39:48Z" SessionIndex="s259fad9cad0cf7d2b3b68f42b17d0cfa6668e0201">
23
+ <saml:AuthnContext>
24
+ <saml:AuthnContextClassRef>
25
+ urn:oasis:names:tc:SAML:2.0:ac:classes:Password
26
+ </saml:AuthnContextClassRef>
27
+ </saml:AuthnContext>
28
+ </saml:AuthnStatement>
29
+ <saml:AttributeStatement>
30
+ <saml:Attribute Name="givenName">
31
+ <saml:AttributeValue xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">
32
+ RkVJREUgVGVzdCBVc2VyIChnaXZlbk5hbWUpIMO4w6bDpcOYw4bDhQ==
33
+ </saml:AttributeValue>
34
+ </saml:Attribute>
35
+ <saml:Attribute Name="eduPersonPrincipalName">
36
+ <saml:AttributeValue xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">
37
+ dGVzdEBmZWlkZS5ubw==
38
+ </saml:AttributeValue>
39
+ </saml:Attribute>
40
+ <saml:Attribute Name="o">
41
+ <saml:AttributeValue xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">
42
+ VU5JTkVUVA==
43
+ </saml:AttributeValue>
44
+ </saml:Attribute>
45
+ <saml:Attribute Name="ou">
46
+ <saml:AttributeValue xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">
47
+ VU5JTkVUVA==
48
+ </saml:AttributeValue>
49
+ </saml:Attribute>
50
+ <saml:Attribute Name="eduPersonOrgDN">
51
+ <saml:AttributeValue xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">
52
+ ZGM9dW5pbmV0dCxkYz1ubw==
53
+ </saml:AttributeValue>
54
+ </saml:Attribute>
55
+ <saml:Attribute Name="eduPersonPrimaryAffiliation">
56
+ <saml:AttributeValue xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">
57
+ c3R1ZGVudA==
58
+ </saml:AttributeValue>
59
+ </saml:Attribute>
60
+ <saml:Attribute Name="mail">
61
+ <saml:AttributeValue xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">
62
+ bW9yaWEtc3VwcG9ydEB1bmluZXR0Lm5v
63
+ </saml:AttributeValue>
64
+ </saml:Attribute>
65
+ <saml:Attribute Name="preferredLanguage">
66
+ <saml:AttributeValue xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">
67
+ bm8=
68
+ </saml:AttributeValue>
69
+ </saml:Attribute>
70
+ <saml:Attribute Name="eduPersonOrgUnitDN">
71
+ <saml:AttributeValue xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">
72
+ b3U9dW5pbmV0dCxvdT1vcmdhbml6YXRpb24sZGM9dW5pbmV0dCxkYz1ubw==
73
+ </saml:AttributeValue>
74
+ </saml:Attribute>
75
+ <saml:Attribute Name="sn">
76
+ <saml:AttributeValue xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">
77
+ RkVJREUgVGVzdCBVc2VyIChzbikgw7jDpsOlw5jDhsOF
78
+ </saml:AttributeValue>
79
+ </saml:Attribute>
80
+ <saml:Attribute Name="cn">
81
+ <saml:AttributeValue xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">
82
+ RkVJREUgVGVzdCBVc2VyIChjbikgw7jDpsOlw5jDhsOF
83
+ </saml:AttributeValue>
84
+ </saml:Attribute>
85
+ <saml:Attribute Name="eduPersonAffiliation">
86
+ <saml:AttributeValue xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">
87
+ ZW1wbG95ZWU=_c3RhZmY=_c3R1ZGVudA==
88
+ </saml:AttributeValue>
89
+ </saml:Attribute>
90
+ </saml:AttributeStatement>
91
+ <Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
92
+ <SignedInfo>
93
+ <CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
94
+ <SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />
95
+ <Reference URI="#s2b7afe8e21a0910d027dfbc94ec4b862e1fbbd9ab">
96
+ <Transforms>
97
+ <Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
98
+ <Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
99
+ </Transforms>
100
+ <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
101
+ <DigestValue>
102
+ k7z/t3iPKiyY9P7B87FIsMxnlnk=
103
+ </DigestValue>
104
+ </Reference>
105
+ </SignedInfo>
106
+ <SignatureValue>
107
+ KvUrzGcwGsu8WMNogIRfAxxWlO4uKXhJrouOYaadkzUHvz1xbVURH35si6U8084utNAjXTjZyxfj qurEX7VgCw6Xn7Fxn4nJxD6FOP5x/iRk8KqCufipRNHwICq/VufqPkrP7sVLdymJyZ2Cu5QrEU23 qaIzjFf84Kfp4LVnlJY=
108
+ </SignatureValue>
109
+ <KeyInfo>
110
+ <X509Data>
111
+ <X509Certificate>
112
+ MIIB/jCCAWcCBEbzjNswDQYJKoZIhvcNAQEFBQAwRjELMAkGA1UEBhMCTk8xEDAOBgNVBAoTB1VO SU5FVFQxDjAMBgNVBAsTBUZlaWRlMRUwEwYDVQQDEwxtYXguZmVpZGUubm8wHhcNMDcwOTIxMDky MDI3WhcNMDcxMjIwMDkyMDI3WjBGMQswCQYDVQQGEwJOTzEQMA4GA1UEChMHVU5JTkVUVDEOMAwG A1UECxMFRmVpZGUxFTATBgNVBAMTDG1heC5mZWlkZS5ubzCBnzANBgkqhkiG9w0BAQEFAAOBjQAw gYkCgYEAvZlBzQ2jGM6Q9STBJ6tqtugkOBMEU/kpvvwOlT6c1X5UIXMwApL+NV2Eaqk+oA0N+M42 J7Sy0dLDqKVCwsh7qpsIYlDS/omyUMdy6AzvptRUUhLLhC6zQFFAU+6rcUKEiSkER5eziB4M3ae0 EkW0drm1rOZwb22tr8NJ65q3gnsCAwEAATANBgkqhkiG9w0BAQUFAAOBgQCmVSta9TWin/wvvGOi e8Cq7cEg0MJLkBWLofNNzrzh6hiQgfuz9KMom/kh9JuGEjyE7rIDbXp2ilxSHgZSaVfEkwnMfQ51 vuHUrtRolD/skysIocm+HJKbsmPMjSRfUFyzBh4RNjPoCvZvTdnyBfMP/i/H39njAdBRi+49aopc vw==
113
+ </X509Certificate>
114
+ </X509Data>
115
+ </KeyInfo>
116
+ </Signature>
117
+ </saml:Assertion>
@@ -0,0 +1,15 @@
1
+
2
+
3
+ class RSpecGreeter
4
+ def greet
5
+ "Hello RSpec!"
6
+ end
7
+ end
8
+
9
+ describe "RSpec Greeter" do
10
+ it "should say 'Hello RSpec!' when it receives the greet() message" do
11
+ greeter = RSpecGreeter.new
12
+ greeting = greeter.greet
13
+ greeting.should == "Hello RSpec!"
14
+ end
15
+ end
@@ -0,0 +1,45 @@
1
+ require 'rubygems'
2
+ require 'data_mapper'
3
+
4
+ DataMapper.setup(:default,
5
+ :adapter => 'mongo',
6
+ :database => 'my_mongo_db'
7
+ )
8
+
9
+ # Define resources
10
+ class Student
11
+ include DataMapper::Mongo::Resource
12
+
13
+ property :id, ObjectId
14
+ property :name, String
15
+ property :age, Integer
16
+ end
17
+
18
+ class Course
19
+ include DataMapper::Mongo::Resource
20
+
21
+ property :id, ObjectId
22
+ property :name, String
23
+ end
24
+
25
+ # No need to (auto_)migrate!
26
+ biology = Course.create(:name => "Biology")
27
+ english = Course.create(:name => "English")
28
+
29
+ # Queries
30
+ Student.all(:age.gte => 20, :name => /oh/, :limit => 20, :order => [:age.asc])
31
+
32
+ # Array and Hash as a property
33
+ class Zoo
34
+ include DataMapper::Mongo::Resource
35
+
36
+ property :id, ObjectId
37
+ property :opening_hours, Hash
38
+ property :animals, Array
39
+ end
40
+
41
+ Zoo.create(
42
+ :opening_hours => { :weekend => '9am-8pm', :weekdays => '11am-8pm' },
43
+ :animals => [ "Marty", "Alex", "Gloria" ])
44
+
45
+ Zoo.all(:animals => 'Alex')
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0"?>
2
+ <rspec xmlns="http://www.protogeni.net/resources/rspec/2" xmlns:omf="http://schema.mytestbed.net/sfa/rspec/1" type="request">
3
+ <node id="70dce487-582e-5e56-a3ed-a1541ed73826" omf:href="/resources/70dce487-582e-5e56-a3ed-a1541ed73826" component_id="urn:publicid:IDN+mytestbed.net+node+n1" component_manager_id="authority+am" component_name="n1">
4
+ <available now="true"/>
5
+ </node>
6
+ </rspec>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0"?>
2
+ <rspec xmlns="http://www.protogeni.net/resources/rspec/2" xmlns:omf="http://schema.mytestbed.net/sfa/rspec/1" type="request">
3
+ <group component_id="urn:publicid:IDN+mytestbed.net+group+g1" component_manager_id="authority+am" component_name="g1">
4
+ <node id="70dce487-582e-5e56-a3ed-a1541ed73826" omf:href="/resources/70dce487-582e-5e56-a3ed-a1541ed73826" component_id="urn:publicid:IDN+mytestbed.net+node+n1" component_manager_id="authority+am" component_name="n1">
5
+ <available now="true"/>
6
+ </node>
7
+ </group>
8
+ </rspec>
@@ -0,0 +1,10 @@
1
+ <?xml version="1.0"?>
2
+ <rspec xmlns="http://www.protogeni.net/resources/rspec/2" xmlns:omf="http://schema.mytestbed.net/sfa/rspec/1" type="request">
3
+ <group component_id="urn:publicid:IDN+mytestbed.net+group+g1" component_manager_id="authority+am" component_name="g1">
4
+ <group component_id="urn:publicid:IDN+mytestbed.net+group+g2" component_manager_id="authority+am" component_name="g2">
5
+ <node id="70dce487-582e-5e56-a3ed-a1541ed73826" omf:href="/resources/70dce487-582e-5e56-a3ed-a1541ed73826" component_id="urn:publicid:IDN+mytestbed.net+node+n1" component_manager_id="authority+am" component_name="n1">
6
+ <available now="true"/>
7
+ </node>
8
+ </group>
9
+ </group>
10
+ </rspec>
@@ -0,0 +1,14 @@
1
+ <?xml version="1.0"?>
2
+ <rspec xmlns="http://www.protogeni.net/resources/rspec/2" xmlns:omf="http://schema.mytestbed.net/sfa/rspec/1" type="request">
3
+ <group component_id="urn:publicid:IDN+mytestbed.net+group+g1" component_manager_id="authority+am" component_name="g1">
4
+ <group component_id="urn:publicid:IDN+mytestbed.net+group+g2" component_manager_id="authority+am" component_name="g2">
5
+ <node id="70dce487-582e-5e56-a3ed-a1541ed73826" omf:href="/resources/70dce487-582e-5e56-a3ed-a1541ed73826" component_id="urn:publicid:IDN+mytestbed.net+node+n1" component_manager_id="authority+am" component_name="n1">
6
+ <available now="true"/>
7
+ </node>
8
+ </group>
9
+ </group>
10
+ <group component_id="urn:publicid:IDN+mytestbed.net+group+g3" component_manager_id="authority+am" component_name="g3">
11
+ <node idref="70dce487-582e-5e56-a3ed-a1541ed73826" />
12
+ </group>
13
+
14
+ </rspec>
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0"?>
2
+ <rspec xmlns="http://www.protogeni.net/resources/rspec/2" xmlns:omf="http://schema.mytestbed.net/sfa/rspec/1" type="request">
3
+ <node id="aea0b9a5-e90e-5fd6-9224-847f0a1b37cb" omf:href="/resources/aea0b9a5-e90e-5fd6-9224-847f0a1b37cb" component_id="urn:publicid:IDN+mytestbed.net+node+node0" component_manager_id="authority+am" component_name="node0">
4
+ <available now="true"/>
5
+ </node>
6
+ </rspec>
@@ -0,0 +1,22 @@
1
+
2
+ <components xmlns="http://schema.mytestbed.net/am_rest/0.1">
3
+ <node component_id="urn:publicid:IDN+mytestbed.net+node+r0">
4
+ <interface_ref component_id="urn:publicid:IDN+mytestbed.net+interface+interface0"/>
5
+ <interface_ref component_id="urn:publicid:IDN+mytestbed.net+interface+interface2"/>
6
+ </node>
7
+ <node component_id="urn:publicid:IDN+mytestbed.net+node+c0_0">
8
+ <interface_ref component_id="urn:publicid:IDN+mytestbed.net+interface+interface1"/>
9
+ </node>
10
+ <node component_id="urn:publicid:IDN+mytestbed.net+node+c0_1">
11
+ <interface_ref component_id="urn:publicid:IDN+mytestbed.net+interface+interface3"/>
12
+ </node>
13
+ <link component_id="urn:publicid:IDN+mytestbed.net+link+la0_0">
14
+ <interface_ref component_id="urn:publicid:IDN+mytestbed.net+interface+interface0"/>
15
+ <interface_ref component_id="urn:publicid:IDN+mytestbed.net+interface+interface1"/>
16
+ </link>
17
+ <link component_id="urn:publicid:IDN+mytestbed.net+link+la0_1">
18
+ <interface_ref component_id="urn:publicid:IDN+mytestbed.net+interface+interface2"/>
19
+ <interface_ref component_id="urn:publicid:IDN+mytestbed.net+interface+interface3"/>
20
+ </link>
21
+ </components>
22
+
@@ -0,0 +1,15 @@
1
+
2
+ <components xmlns="http://schema.mytestbed.net/am_rest/0.1">
3
+ <node component_id="urn:publicid:IDN+mytestbed.net+node+r0">
4
+ <interface_ref component_id="urn:publicid:IDN+mytestbed.net+interface+interface0"/>
5
+ <interface_ref component_id="urn:publicid:IDN+mytestbed.net+interface+interface2"/>
6
+ </node>
7
+ <node component_id="urn:publicid:IDN+mytestbed.net+node+c0_0">
8
+ <interface_ref component_id="urn:publicid:IDN+mytestbed.net+interface+interface1"/>
9
+ </node>
10
+ <link component_id="urn:publicid:IDN+mytestbed.net+link+la0_0">
11
+ <interface_ref component_id="urn:publicid:IDN+mytestbed.net+interface+interface0"/>
12
+ <interface_ref component_id="urn:publicid:IDN+mytestbed.net+interface+interface1"/>
13
+ </link>
14
+ </components>
15
+