cpee-instantiation 1.0.2 → 1.0.8

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: 54e2fbfea39571218c38e9d1afb4a81689439d11cad30c988d7db9f5d523aaca
4
- data.tar.gz: 9ca8330ce8f3ea4f7a5e3e1523afa44067eaa4d660f3db5135be0c60e79794ab
3
+ metadata.gz: 8bc55ea88a7ce4e1bc6ef44f168bf6da2b20b77e2959d6b52d6cbb1b218fc140
4
+ data.tar.gz: a696d35bf0d432a516fc41152c593fc4f673111d94f1312785024c2c233f50f4
5
5
  SHA512:
6
- metadata.gz: e15d2bfdd3d31de04223c8799b61cdd5e38c7c99bf342bac736767a2f60d78dc320717bffa7650c5fc5bb2afd1ce8c16e6b4573d877ecf475d228081a42ea430
7
- data.tar.gz: 5f5b2f07bc686d05e47571e638330f2da1dbc57a14472ee6d9c04bcaeae6f5003de6b253622aec7c3d98ab25d40cec7edb21e77bd66eb8215272e20922cd9caf
6
+ metadata.gz: 2e8d8ef73155472996b1069d274670b29934e9ac4c4873f7de23ed16201a58cc2e2d8b7d635a5c79de079054bf634ceeca4aa944ee1aba39160bbe2f15c193dd
7
+ data.tar.gz: 815e7fc7d79314b0da18c9f5e2dd7fa348453894784ef3b909698d1300d3da517d50398733d1a3ab9dbbe8aeb05719950ca16c15611e864d9289773b84cef0bb
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "cpee-instantiation"
3
- s.version = "1.0.2"
3
+ s.version = "1.0.8"
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)"
@@ -23,5 +23,5 @@ Gem::Specification.new do |s|
23
23
  s.add_runtime_dependency 'riddl', '~> 0.99'
24
24
  s.add_runtime_dependency 'json', '~> 2.1'
25
25
  s.add_runtime_dependency 'redis', '~> 4.1'
26
- s.add_runtime_dependency 'cpee', '~> 1', '>= 1.5'
26
+ s.add_runtime_dependency 'cpee', '~> 2.1', '>= 2.1.4'
27
27
  end
@@ -30,12 +30,13 @@ 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
+ doc.register_namespace 'sub', 'http://riddl.org/ns/common-patterns/notifications-producer/2.0'
39
40
 
40
41
  srv = Riddl::Client.new(cpee, File.join(cpee,'?riddl-description'))
41
42
  res = srv.resource('/')
@@ -44,13 +45,13 @@ module CPEE
44
45
  e.text = name
45
46
  end
46
47
  end
47
- if stream && !stream.empty?
48
- JSON.parse(stream).each do |e|
48
+ if customization && !customization.empty?
49
+ JSON.parse(customization).each do |e|
49
50
  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|
51
+ customization = Typhoeus.get e['url']
52
+ if customization.success?
53
+ XML::Smart::string(customization.response_body) do |str|
54
+ doc.find("//desc:call[@id=\"#{e['id']}\"]/desc:parameters/desc:customization").each do |ele|
54
55
  ele.replace_by str.root
55
56
  end
56
57
  end
@@ -70,23 +71,30 @@ module CPEE
70
71
 
71
72
  inp = XML::Smart::string('<properties xmlns="http://cpee.org/ns/properties/2.0"/>')
72
73
  inp.register_namespace 'prop', 'http://cpee.org/ns/properties/2.0'
73
- %w{handlerwrapper positions dataelements endpoints attributes description transformation}.each do |item|
74
+ %w{executionhandler positions dataelements endpoints attributes description transformation}.each do |item|
74
75
  ele = doc.find("/*/prop:#{item}")
75
76
  inp.root.add(ele.first) if ele.any?
76
77
  end
77
78
  res = srv.resource("/#{ins}/properties").put Riddl::Parameter::Complex.new('properties','application/xml',inp.to_s)
78
- doc.find('/*/prop:handlers/prop:handler').each do |han|
79
- url = han.attributes['url']
80
- inp = 'url=' + URI.encode_www_form_component(url)
81
- inp = inp + '&topic=' + han.children.first.attributes['topic']
82
- inp = inp + '&' + han.children.first.qname.to_s + '=' + han.children.first.to_s
83
- status,body = Riddl::Client::new(cpee+ins+'/notifications/subscriptions/').post(
84
- [
85
- Riddl::Parameter::Simple.new('url',han.attributes['url']),
86
- Riddl::Parameter::Simple.new('topic',han.children.first.attributes['topic']),
87
- Riddl::Parameter::Simple.new(han.children.first.qname.to_s,han.children.first.to_s)
88
- ]
89
- )
79
+ # TODO new versions
80
+ doc.find('/*/sub:subscriptions/sub:subscription').each do |s|
81
+ parts = []
82
+ if id = s.attributes['id']
83
+ parts << Riddl::Parameter::Simple.new('id', id)
84
+ end
85
+ parts << Riddl::Parameter::Simple.new('url', s.attributes['url'])
86
+ s.find('sub:topic').each do |t|
87
+ p s.find('sub:event').map{ |e| e.text }
88
+ if (evs = t.find('sub:event').map{ |e| e.text }.join(',')).length > 0
89
+ parts << Riddl::Parameter::Simple.new('topic', t.attributes['id'])
90
+ parts << Riddl::Parameter::Simple.new('events', evs)
91
+ end
92
+ if (vos = t.find('sub:vote').map{ |e| e.text }.join(',')).length > 0
93
+ parts << Riddl::Parameter::Simple.new('topic', t.attributes['id'])
94
+ parts << Riddl::Parameter::Simple.new('votes', vos)
95
+ end
96
+ end
97
+ status,body = Riddl::Client::new(cpee+ins+'/notifications/subscriptions/').post parts
90
98
  end
91
99
  end
92
100
  end
@@ -96,7 +104,6 @@ module CPEE
96
104
  def handle_waiting(cpee,instance,uuid,behavior,selfurl,cblist) #{{{
97
105
  if behavior =~ /^wait/
98
106
  condition = behavior.match(/_([^_]+)_/)&.[](1) || 'finished'
99
- @headers << Riddl::Header.new('CPEE-CALLBACK','true')
100
107
  cb = @h['CPEE_CALLBACK']
101
108
 
102
109
  if cb
@@ -168,16 +175,18 @@ module CPEE
168
175
  else
169
176
  (@status = 500) && return
170
177
  end
171
- stream = @p.find{ |e| e.name == 'stream' }&.value
172
- if (instance, uuid = load_testset(tdoc,cpee,nil,stream)).first == -1
178
+ customization = @p.find{ |e| e.name == 'customization' }&.value
179
+ if (instance, uuid = load_testset(tdoc,cpee,nil,customization)).first == -1
173
180
  @status = 500
174
181
  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'
182
+ EM.defer do
183
+ handle_data cpee, instance, @p[4]&.value if @p[4]&.name == 'init'
184
+ handle_endpoints cpee, instance, @p[4]&.value if @p[4]&.name == 'endpoints'
185
+ handle_endpoints cpee, instance, @p[5]&.value if @p[5]&.name == 'endpoints'
178
186
 
179
- handle_waiting cpee, instance, uuid, @p[0].value, selfurl, cblist
180
- handle_starting cpee, instance, @p[0].value
187
+ handle_waiting cpee, instance, uuid, @p[0].value, selfurl, cblist
188
+ handle_starting cpee, instance, @p[0].value
189
+ end
181
190
 
182
191
  send = {
183
192
  'CPEE-INSTANCE' => instance,
@@ -185,6 +194,9 @@ module CPEE
185
194
  'CPEE-INSTANCE-UUID' => uuid,
186
195
  'CPEE-BEHAVIOR' => @p[0].value
187
196
  }
197
+ if @p[0].value =~ /^wait/
198
+ @headers << Riddl::Header.new('CPEE-CALLBACK','true')
199
+ end
188
200
  @headers << Riddl::Header.new('CPEE-INSTANTIATION',JSON::generate(send))
189
201
  Riddl::Parameter::Complex.new('instance','application/json',JSON::generate(send))
190
202
  end
@@ -206,16 +218,18 @@ module CPEE
206
218
  else
207
219
  (@status = 500) && return
208
220
  end
209
- stream = @p.find{ |e| e.name == 'stream' }&.value
210
- if (instance, uuid = load_testset(tdoc,cpee,name,stream)).first == -1
221
+ customization = @p.find{ |e| e.name == 'customization' }&.value
222
+ if (instance, uuid = load_testset(tdoc,cpee,name,customization)).first == -1
211
223
  @status = 500
212
224
  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'
225
+ EM.defer do
226
+ handle_data cpee, instance, @p[2]&.value if @p[2]&.name == 'init'
227
+ handle_endpoints cpee, instance, @p[2]&.value if @p[2]&.name == 'endpoints'
228
+ handle_endpoints cpee, instance, @p[3]&.value if @p[3]&.name == 'endpoints'
216
229
 
217
- handle_waiting cpee, instance, uuid, @p[0].value, selfurl, cblist
218
- handle_starting cpee, instance, @p[0].value
230
+ handle_waiting cpee, instance, uuid, @p[0].value, selfurl, cblist
231
+ handle_starting cpee, instance, @p[0].value
232
+ end
219
233
 
220
234
  send = {
221
235
  'CPEE-INSTANCE' => instance,
@@ -223,6 +237,9 @@ module CPEE
223
237
  'CPEE-INSTANCE-UUID' => uuid,
224
238
  'CPEE-BEHAVIOR' => @p[0].value
225
239
  }
240
+ if @p[0].value =~ /^wait/
241
+ @headers << Riddl::Header.new('CPEE-CALLBACK','true')
242
+ end
226
243
  @headers << Riddl::Header.new('CPEE-INSTANTIATION',JSON::generate(send))
227
244
  Riddl::Parameter::Complex.new('instance','application/json',JSON::generate(send))
228
245
  end
@@ -247,9 +264,11 @@ module CPEE
247
264
  if (instance, uuid = load_testset(tdoc,cpee)).first == -1
248
265
  @status = 500
249
266
  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
267
+ EM.defer do
268
+ handle_data cpee, instance, @p[data+1]&.value
269
+ handle_waiting cpee, instance, uuid, behavior, selfurl, cblist
270
+ handle_starting cpee, instance, behavior
271
+ end
253
272
 
254
273
  send = {
255
274
  'CPEE-INSTANCE' => instance,
@@ -257,6 +276,9 @@ module CPEE
257
276
  'CPEE-INSTANCE-UUID' => uuid,
258
277
  'CPEE-BEHAVIOR' => behavior
259
278
  }
279
+ if @p[0].value =~ /^wait/
280
+ @headers << Riddl::Header.new('CPEE-CALLBACK','true')
281
+ end
260
282
  Riddl::Parameter::Complex.new('instance','application/json',JSON::generate(send))
261
283
  end
262
284
  end
@@ -280,6 +302,9 @@ module CPEE
280
302
  handle_data cpee, instance, @p[2]&.value
281
303
  handle_waiting cpee, instance, uuid, @p[0].value, selfurl, cblist
282
304
  handle_starting cpee, instance, @p[0].value
305
+ if @p[0].value =~ /^wait/
306
+ @headers << Riddl::Header.new('CPEE-CALLBACK','true')
307
+ end
283
308
  return Riddl::Parameter::Simple.new("url",cpee + instance)
284
309
  end
285
310
  end
@@ -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">
@@ -30,7 +30,7 @@ ARGV.options { |opt|
30
30
  opt.on("Options:")
31
31
  opt.on("--help", "-h", "This text") { puts opt; exit }
32
32
  opt.on("")
33
- opt.on(wrap("[DIR] scaffolds a sample instantiation service. Post a testset to a model to keep going in one operation."))
33
+ opt.on(wrap("[DIR] scaffolds a sample instantiation service. Post a testset to a model to keep going in one operation."))
34
34
  opt.parse!
35
35
  }
36
36
  if (ARGV.length != 1)
@@ -40,8 +40,10 @@ else
40
40
  p1 = ARGV[0]
41
41
  end
42
42
 
43
+ insta = "#{curpath}/../server/"
43
44
  if !File.exists?(p1)
44
- FileUtils.cp_r("#{curpath}/../server/",p1)
45
+ FileUtils.cp_r(insta,p1)
45
46
  else
46
- puts 'Directory already exists.'
47
+ FileUtils.cp_r(Dir.glob(File.join(insta,'*')).delete_if{|e| e =~ /\.conf/ })
48
+ puts 'Directory already exists, updating ...'
47
49
  end
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.2
4
+ version: 1.0.8
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-10-13 00:00:00.000000000 Z
11
+ date: 2021-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: riddl
@@ -58,20 +58,20 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '1'
61
+ version: '2.1'
62
62
  - - ">="
63
63
  - !ruby/object:Gem::Version
64
- version: '1.5'
64
+ version: 2.1.4
65
65
  type: :runtime
66
66
  prerelease: false
67
67
  version_requirements: !ruby/object:Gem::Requirement
68
68
  requirements:
69
69
  - - "~>"
70
70
  - !ruby/object:Gem::Version
71
- version: '1'
71
+ version: '2.1'
72
72
  - - ">="
73
73
  - !ruby/object:Gem::Version
74
- version: '1.5'
74
+ version: 2.1.4
75
75
  description: see http://cpee.org
76
76
  email: juergen.mangler@gmail.com
77
77
  executables:
@@ -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.6
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: []