cpee-instantiation 1.0 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4da02ad96d0a1feb31755f5217286eed93f5f1beabe3f535a7d749ab55eb8cb3
4
- data.tar.gz: 6b9b6f3ad0f463f050a81759f0685eea7ac69d57f282ec8c9b1f83a0a5bce17f
3
+ metadata.gz: 47642e0918914c6aacd0bd84affd6ed9876d6ca07130f6508dbdd39db113d93b
4
+ data.tar.gz: 797f1cfe4c470905255abab4a2484fc40aaa0ddd52fcfcdb30426203d38c89b8
5
5
  SHA512:
6
- metadata.gz: 48cfa7f1a307aabe48cfa73b08d0e9a0d79dc989ecaf30a2d4c871dffe6fcdfd6bb4563bec9da70d2c44c07efe248fe6f2d2a450c96eae47f0d89a791c9852b3
7
- data.tar.gz: 885d19ca953bd56e72cf43ea2fe27ea98f3575a0689dc37293b9f0348111d2735a91fbc909f98d541030308eea4278d631667e24b966baa569000e85fad43af0
6
+ metadata.gz: fc3f4212298d892a4bfeb3a6b38d27296349cdcd11971a2ac4ff78e70b7c0cebd0a693573b41aa9c9521a7d7de822c94680bddcbf52847f43a82866b10b63401
7
+ data.tar.gz: fb87fa147e0df510d6e9c805d26e85bda04a5c65c6e2ebe90ba36bc9a37f7b304c3d2cc670a65f1b3205796a68fef3bef61135015786eacaa27f1fbd27224877
data/README.md CHANGED
@@ -7,9 +7,9 @@ To install the instatiation service go to the commandline
7
7
  cpee-instantiation instantiation
8
8
  cd instantiation
9
9
  ./instantiation start
10
- ```
10
+ ```
11
11
 
12
- The service is running under port 9296. If this port has to be changed (or the
12
+ The service is running under port 9296. If this port has to be changed (or the
13
13
  host, or local-only access, ...), create a file instatiation.conf and add one
14
14
  or many of the following yaml keys:
15
15
 
@@ -28,7 +28,7 @@ To use the service try one of the following:
28
28
  curl -X POST -H "Content-Type: application/x-www-form-urlencoded" -d "behavior=wait_running&url=http%3A%2F%2Flink%2Fto%2Ftestset.xml" http://localhost:9296/url
29
29
  curl -X POST -H "Content-Type: application/x-www-form-urlencoded" -d "behavior=fork_running&url=http%3A%2F%2Flink%2Fto%2Ftestset.xml&init=%7B%20%22a%22%3A%2037%2C%20%22b%22%3A%20%22test%22%20%7D" http://localhost:9296/url
30
30
  curl -X POST -F "behavior=wait_running" -F "xml=@testset.xml" http://localhost:9296/xml
31
- ```
31
+ ```
32
32
 
33
33
  The behavior can be either: the process parent process is waiting (wait_) or is
34
34
  running in parallel (fork_), the subprocesss is either immediately starting
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "cpee-instantiation"
3
- s.version = "1.0"
3
+ s.version = "1.0.5"
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.license = "LGPL-3.0"
6
6
  s.summary = "Subprocess instantiation service for the cloud process execution engine (cpee.org)"
@@ -30,27 +30,27 @@ module CPEE
30
30
  SERVER = File.expand_path(File.join(__dir__,'instantiation.xml'))
31
31
 
32
32
  module Helpers #{{{
33
- def load_testset(tdoc,cpee,name=nil,stream=nil) #{{{
33
+ def load_testset(tdoc,cpee,name=nil,customization=nil) #{{{
34
34
  ins = -1
35
35
  uuid = nil
36
36
  XML::Smart.string(tdoc) do |doc|
37
37
  doc.register_namespace 'desc', 'http://cpee.org/ns/description/1.0'
38
38
  doc.register_namespace 'prop', 'http://cpee.org/ns/properties/2.0'
39
39
 
40
- srv = Riddl::Client.new(cpee, cpee + '?riddl-description')
40
+ srv = Riddl::Client.new(cpee, File.join(cpee,'?riddl-description'))
41
41
  res = srv.resource('/')
42
42
  if name
43
43
  doc.find('/*/prop:attributes/prop:info').each do |e|
44
44
  e.text = name
45
45
  end
46
46
  end
47
- if stream && !stream.empty?
48
- JSON.parse(stream).each do |e|
47
+ if customization && !customization.empty?
48
+ JSON.parse(customization).each do |e|
49
49
  begin
50
- stream = Typhoeus.get e['url']
51
- if stream.success?
52
- XML::Smart::string(stream.response_body) do |str|
53
- doc.find("//desc:call[@id=\"#{e['id']}\"]/desc:parameters/desc:stream").each do |ele|
50
+ customization = Typhoeus.get e['url']
51
+ if customization.success?
52
+ XML::Smart::string(customization.response_body) do |str|
53
+ doc.find("//desc:call[@id=\"#{e['id']}\"]/desc:parameters/desc:customization").each do |ele|
54
54
  ele.replace_by str.root
55
55
  end
56
56
  end
@@ -96,12 +96,11 @@ module CPEE
96
96
  def handle_waiting(cpee,instance,uuid,behavior,selfurl,cblist) #{{{
97
97
  if behavior =~ /^wait/
98
98
  condition = behavior.match(/_([^_]+)_/)&.[](1) || 'finished'
99
- @headers << Riddl::Header.new('CPEE-CALLBACK','true')
100
99
  cb = @h['CPEE_CALLBACK']
101
100
 
102
101
  if cb
103
102
  cbk = SecureRandom.uuid
104
- srv = Riddl::Client.new(cpee, cpee + '?riddl-description')
103
+ srv = Riddl::Client.new(cpee, File.join(cpee,'?riddl-description'))
105
104
  status, response = srv.resource("/#{instance}/notifications/subscriptions/").post [
106
105
  Riddl::Parameter::Simple.new('url',File.join(selfurl,'callback',cbk)),
107
106
  Riddl::Parameter::Simple.new('topic','state'),
@@ -118,7 +117,7 @@ module CPEE
118
117
  private :handle_waiting
119
118
  def handle_starting(cpee,instance,behavior) #{{{
120
119
  if behavior =~ /_running$/
121
- srv = Riddl::Client.new(cpee, cpee + '?riddl-description')
120
+ srv = Riddl::Client.new(cpee, File.join(cpee,'?riddl-description'))
122
121
  res = srv.resource("/#{instance}/properties/state")
123
122
  status, response = res.put [
124
123
  Riddl::Parameter::Simple.new('value','running')
@@ -128,11 +127,11 @@ module CPEE
128
127
  private :handle_starting
129
128
  def handle_data(cpee,instance,data) #{{{
130
129
  if data && !data.empty?
131
- content = XML::Smart.string('<dataelements xmlns="http://cpee.org/ns/properties/2.0">')
130
+ content = XML::Smart.string('<dataelements xmlns="http://cpee.org/ns/properties/2.0"/>')
132
131
  JSON::parse(data).each do |k,v|
133
132
  content.root.add(k,v)
134
133
  end
135
- srv = Riddl::Client.new(cpee, cpee + "?riddl-description")
134
+ srv = Riddl::Client.new(cpee, File.join(cpee,'?riddl-description'))
136
135
  res = srv.resource("/#{instance}/properties/dataelements/")
137
136
  status, response = res.patch [
138
137
  Riddl::Parameter::Complex.new('dataelements','text/xml',content.to_s)
@@ -141,11 +140,11 @@ module CPEE
141
140
  end #}}}
142
141
  def handle_endpoints(cpee,instance,data) #{{{
143
142
  if data && !data.empty?
144
- content = XML::Smart.string('<endpoints xmlns="http://cpee.org/ns/properties/2.0">')
143
+ content = XML::Smart.string('<endpoints xmlns="http://cpee.org/ns/properties/2.0"/>')
145
144
  JSON::parse(data).each do |k,v|
146
145
  content.root.add(k,v)
147
146
  end
148
- srv = Riddl::Client.new(cpee, cpee + "?riddl-description")
147
+ srv = Riddl::Client.new(cpee, File.join(cpee,'?riddl-description'))
149
148
  res = srv.resource("/#{instance}/properties/endpoints/")
150
149
  status, response = res.patch [
151
150
  Riddl::Parameter::Complex.new('endpoints','text/xml',content.to_s)
@@ -168,16 +167,18 @@ module CPEE
168
167
  else
169
168
  (@status = 500) && return
170
169
  end
171
- stream = @p.find{ |e| e.name == 'stream' }&.value
172
- if (instance, uuid = load_testset(tdoc,cpee,nil,stream)).first == -1
170
+ customization = @p.find{ |e| e.name == 'customization' }&.value
171
+ if (instance, uuid = load_testset(tdoc,cpee,nil,customization)).first == -1
173
172
  @status = 500
174
173
  else
175
- handle_data cpee, instance, @p[4]&.value if @p[4]&.name == 'init'
176
- handle_endpoints cpee, instance, @p[4]&.value if @p[4]&.name == 'endpoints'
177
- handle_endpoints cpee, instance, @p[5]&.value if @p[5]&.name == 'endpoints'
174
+ EM.defer do
175
+ handle_data cpee, instance, @p[4]&.value if @p[4]&.name == 'init'
176
+ handle_endpoints cpee, instance, @p[4]&.value if @p[4]&.name == 'endpoints'
177
+ handle_endpoints cpee, instance, @p[5]&.value if @p[5]&.name == 'endpoints'
178
178
 
179
- handle_waiting cpee, instance, uuid, @p[0].value, selfurl, cblist
180
- handle_starting cpee, instance, @p[0].value
179
+ handle_waiting cpee, instance, uuid, @p[0].value, selfurl, cblist
180
+ handle_starting cpee, instance, @p[0].value
181
+ end
181
182
 
182
183
  send = {
183
184
  'CPEE-INSTANCE' => instance,
@@ -185,6 +186,9 @@ module CPEE
185
186
  'CPEE-INSTANCE-UUID' => uuid,
186
187
  'CPEE-BEHAVIOR' => @p[0].value
187
188
  }
189
+ if @p[0].value =~ /^wait/
190
+ @headers << Riddl::Header.new('CPEE-CALLBACK','true')
191
+ end
188
192
  @headers << Riddl::Header.new('CPEE-INSTANTIATION',JSON::generate(send))
189
193
  Riddl::Parameter::Complex.new('instance','application/json',JSON::generate(send))
190
194
  end
@@ -206,16 +210,18 @@ module CPEE
206
210
  else
207
211
  (@status = 500) && return
208
212
  end
209
- stream = @p.find{ |e| e.name == 'stream' }&.value
210
- if (instance, uuid = load_testset(tdoc,cpee,name,stream)).first == -1
213
+ customization = @p.find{ |e| e.name == 'customization' }&.value
214
+ if (instance, uuid = load_testset(tdoc,cpee,name,customization)).first == -1
211
215
  @status = 500
212
216
  else
213
- handle_data cpee, instance, @p[2]&.value if @p[2]&.name == 'init'
214
- handle_endpoints cpee, instance, @p[2]&.value if @p[2]&.name == 'endpoints'
215
- handle_endpoints cpee, instance, @p[3]&.value if @p[3]&.name == 'endpoints'
217
+ EM.defer do
218
+ handle_data cpee, instance, @p[2]&.value if @p[2]&.name == 'init'
219
+ handle_endpoints cpee, instance, @p[2]&.value if @p[2]&.name == 'endpoints'
220
+ handle_endpoints cpee, instance, @p[3]&.value if @p[3]&.name == 'endpoints'
216
221
 
217
- handle_waiting cpee, instance, uuid, @p[0].value, selfurl, cblist
218
- handle_starting cpee, instance, @p[0].value
222
+ handle_waiting cpee, instance, uuid, @p[0].value, selfurl, cblist
223
+ handle_starting cpee, instance, @p[0].value
224
+ end
219
225
 
220
226
  send = {
221
227
  'CPEE-INSTANCE' => instance,
@@ -223,6 +229,9 @@ module CPEE
223
229
  'CPEE-INSTANCE-UUID' => uuid,
224
230
  'CPEE-BEHAVIOR' => @p[0].value
225
231
  }
232
+ if @p[0].value =~ /^wait/
233
+ @headers << Riddl::Header.new('CPEE-CALLBACK','true')
234
+ end
226
235
  @headers << Riddl::Header.new('CPEE-INSTANTIATION',JSON::generate(send))
227
236
  Riddl::Parameter::Complex.new('instance','application/json',JSON::generate(send))
228
237
  end
@@ -247,9 +256,11 @@ module CPEE
247
256
  if (instance, uuid = load_testset(tdoc,cpee)).first == -1
248
257
  @status = 500
249
258
  else
250
- handle_data cpee, instance, @p[data+1]&.value
251
- handle_waiting cpee, instance, uuid, behavior, selfurl, cblist
252
- handle_starting cpee, instance, behavior
259
+ EM.defer do
260
+ handle_data cpee, instance, @p[data+1]&.value
261
+ handle_waiting cpee, instance, uuid, behavior, selfurl, cblist
262
+ handle_starting cpee, instance, behavior
263
+ end
253
264
 
254
265
  send = {
255
266
  'CPEE-INSTANCE' => instance,
@@ -257,6 +268,9 @@ module CPEE
257
268
  'CPEE-INSTANCE-UUID' => uuid,
258
269
  'CPEE-BEHAVIOR' => behavior
259
270
  }
271
+ if @p[0].value =~ /^wait/
272
+ @headers << Riddl::Header.new('CPEE-CALLBACK','true')
273
+ end
260
274
  Riddl::Parameter::Complex.new('instance','application/json',JSON::generate(send))
261
275
  end
262
276
  end
@@ -271,7 +285,7 @@ module CPEE
271
285
  cblist = @a[2]
272
286
  instance = @p[1].value
273
287
 
274
- srv = Riddl::Client.new(cpee, cpee + "?riddl-description")
288
+ srv = Riddl::Client.new(cpee, File.join(cpee,'?riddl-description'))
275
289
  res = srv.resource("/#{instance}/properties/attributes/uuid")
276
290
  status, response = res.get
277
291
 
@@ -280,6 +294,9 @@ module CPEE
280
294
  handle_data cpee, instance, @p[2]&.value
281
295
  handle_waiting cpee, instance, uuid, @p[0].value, selfurl, cblist
282
296
  handle_starting cpee, instance, @p[0].value
297
+ if @p[0].value =~ /^wait/
298
+ @headers << Riddl::Header.new('CPEE-CALLBACK','true')
299
+ end
283
300
  return Riddl::Parameter::Simple.new("url",cpee + instance)
284
301
  end
285
302
  end
@@ -310,7 +327,7 @@ module CPEE
310
327
 
311
328
  if notification['content']['state'] == condition
312
329
  cblist.del(key)
313
- srv = Riddl::Client.new(cpee, cpee + "?riddl-description")
330
+ srv = Riddl::Client.new(cpee, File.join(cpee,'?riddl-description'))
314
331
  res = srv.resource("/#{instance}/properties/dataelements")
315
332
  status, response = res.get
316
333
  if status >= 200 && status < 300
@@ -34,7 +34,7 @@
34
34
  <parameter name="endpoints" type="string"/>
35
35
  </optional>
36
36
  <optional>
37
- <parameter name="stream" type="string"/>
37
+ <parameter name="customization" type="string"/>
38
38
  </optional>
39
39
  </message>
40
40
  <message name="url">
@@ -54,7 +54,7 @@
54
54
  <parameter name="endpoints" type="string"/>
55
55
  </optional>
56
56
  <optional>
57
- <parameter name="stream" type="string"/>
57
+ <parameter name="customization" type="string"/>
58
58
  </optional>
59
59
  </message>
60
60
  <message name="git">
@@ -76,7 +76,7 @@
76
76
  <parameter name="endpoints" type="string"/>
77
77
  </optional>
78
78
  <optional>
79
- <parameter name="stream" type="string"/>
79
+ <parameter name="customization" type="string"/>
80
80
  </optional>
81
81
  </message>
82
82
  <message name="instance">
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cpee-instantiation
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.0'
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juergen eTM Mangler
8
- autorequire:
8
+ autorequire:
9
9
  bindir: tools
10
10
  cert_chain: []
11
- date: 2020-09-28 00:00:00.000000000 Z
11
+ date: 2021-01-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: riddl
@@ -93,7 +93,7 @@ homepage: http://cpee.org/
93
93
  licenses:
94
94
  - LGPL-3.0
95
95
  metadata: {}
96
- post_install_message:
96
+ post_install_message:
97
97
  rdoc_options: []
98
98
  require_paths:
99
99
  - lib
@@ -108,8 +108,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
108
  - !ruby/object:Gem::Version
109
109
  version: '0'
110
110
  requirements: []
111
- rubygems_version: 3.1.2
112
- signing_key:
111
+ rubygems_version: 3.1.4
112
+ signing_key:
113
113
  specification_version: 4
114
114
  summary: Subprocess instantiation service for the cloud process execution engine (cpee.org)
115
115
  test_files: []