cpee-instantiation 1.0.10 → 1.0.18

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: 4d4f2d6bb294992580a51fe2e5f4c5c122506fe31a327fcbae1e88845964e02f
4
- data.tar.gz: f2046e8bc78d8ff5d69feed0ba54ffc23d35da3afba9f58bf6417fe8963e01a2
3
+ metadata.gz: 025e4ba070e685921b00e57887d8f979a3d6434b74b16efbaa6adb310534a7d7
4
+ data.tar.gz: 9a84e081c68f000c4519054a116b9caa93ce5f7f1920dd88f993478ef1f86a01
5
5
  SHA512:
6
- metadata.gz: 316d7c396535c85ba2030750591c3152e15a99142120925ed3b6758d0f755a1276e1b3da6c074caab507ae38f8159fdcd5843d556a7417a408e12396b72564e8
7
- data.tar.gz: 96dfd842fd444518894bc782c48eb6ca69bca06bb02077c64a1af503843f1bec454bfc4bbdb666b2477ae4bbbc040862586e02e6a3f5cb4a12205c1a8ace949d
6
+ metadata.gz: d1d447f2bbc430412f369f267ff3b1078d299e65f3613b5a1b40e79b8964ec864ccb8690c8db19bf329a970b5fda8951cfb569b91dd9d2caf442d1d8b7ede905
7
+ data.tar.gz: '0692514bb3af3b5162d0d7b8d1f97fecc1a1ff04556f5e78cf282f035829e7e307b00636e5b43aeac1a2f6f5d55cf188286144bbabf7b20e37d1093695706648'
data/AUTHORS CHANGED
@@ -1 +1,2 @@
1
1
  Jürgen Mangler <juergen.mangler@gmail.com>
2
+ Heinrich Fenkart <hnrch02@gmail.com>
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "cpee-instantiation"
3
- s.version = "1.0.10"
3
+ s.version = "1.0.18"
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)"
@@ -15,13 +15,13 @@ Gem::Specification.new do |s|
15
15
 
16
16
  s.required_ruby_version = '>=2.4.0'
17
17
 
18
- s.authors = ['Juergen eTM Mangler']
18
+ s.authors = ['Juergen eTM Mangler', 'Heinrich Fenkart']
19
19
 
20
20
  s.email = 'juergen.mangler@gmail.com'
21
21
  s.homepage = 'http://cpee.org/'
22
22
 
23
23
  s.add_runtime_dependency 'riddl', '~> 0.99'
24
24
  s.add_runtime_dependency 'json', '~> 2.1'
25
- s.add_runtime_dependency 'redis', '~> 4.1'
25
+ s.add_runtime_dependency 'redis', '~> 5.0'
26
26
  s.add_runtime_dependency 'cpee', '~> 2.1', '>= 2.1.4'
27
27
  end
@@ -30,73 +30,100 @@ 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,customization=nil) #{{{
33
+ def add_to_testset(tdoc,what,data)
34
+ if data && !data.empty?
35
+ JSON::parse(data).each do |k,v|
36
+ ele = tdoc.find("/*/prop:#{what}/prop:#{k}")
37
+ if ele.any?
38
+ ele.first.text = CPEE::ValueHelper::generate(v)
39
+ else
40
+ ele = tdoc.find("/*/prop:#{what}")
41
+ ele.first.add(k,CPEE::ValueHelper::generate(v)) if ele.any?
42
+ end
43
+ end
44
+ end
45
+ end
46
+
47
+ def augment_testset(tdoc,p)
48
+ tdoc = XML::Smart.string(tdoc)
49
+ tdoc.register_namespace 'desc', 'http://cpee.org/ns/description/1.0'
50
+ tdoc.register_namespace 'prop', 'http://cpee.org/ns/properties/2.0'
51
+ tdoc.register_namespace 'sub', 'http://riddl.org/ns/common-patterns/notifications-producer/2.0'
52
+
53
+ if data = p.find{ |e| e.name == 'init' }&.value
54
+ add_to_testset(tdoc,'dataelements',data)
55
+ end
56
+ if data = p.find{ |e| e.name == 'endpoints' }&.value
57
+ add_to_testset(tdoc,'endpoints',data)
58
+ end
59
+ if data = p.find{ |e| e.name == 'attributes' }&.value
60
+ add_to_testset(tdoc,'attributes',data)
61
+ end
62
+ tdoc
63
+ end
64
+
65
+ def load_testset(doc,cpee,name=nil,customization=nil) #{{{
34
66
  ins = -1
35
67
  uuid = nil
36
- XML::Smart.string(tdoc) do |doc|
37
- doc.register_namespace 'desc', 'http://cpee.org/ns/description/1.0'
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'
40
68
 
41
- srv = Riddl::Client.new(cpee, File.join(cpee,'?riddl-description'))
42
- res = srv.resource('/')
43
- if name
44
- doc.find('/*/prop:attributes/prop:info').each do |e|
45
- e.text = name
46
- end
69
+ srv = Riddl::Client.new(cpee, File.join(cpee,'?riddl-description'))
70
+ res = srv.resource('/')
71
+ if name
72
+ doc.find('/*/prop:attributes/prop:info').each do |e|
73
+ e.text = name
47
74
  end
48
- if customization && !customization.empty?
49
- JSON.parse(customization).each do |e|
50
- begin
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|
55
- ele.replace_by str.root
56
- end
75
+ end
76
+ if customization && !customization.empty?
77
+ JSON.parse(customization).each do |e|
78
+ begin
79
+ customization = Typhoeus.get e['url']
80
+ if customization.success?
81
+ XML::Smart::string(customization.response_body) do |str|
82
+ doc.find("//desc:call[@id=\"#{e['id']}\"]/desc:parameters/desc:customization").each do |ele|
83
+ ele.replace_by str.root
57
84
  end
58
85
  end
59
- rescue => e
60
- puts e.message
61
- puts e.backtrace
62
86
  end
87
+ rescue => e
88
+ puts e.message
89
+ puts e.backtrace
63
90
  end
64
91
  end
92
+ end
93
+
94
+ status, response, headers = res.post Riddl::Parameter::Simple.new('info',doc.find('string(/*/prop:attributes/prop:info)'))
65
95
 
66
- status, response, headers = res.post Riddl::Parameter::Simple.new('info',doc.find('string(/*/prop:attributes/prop:info)'))
96
+ if status == 200
97
+ ins = response.first.value
98
+ uuid = headers['CPEE_INSTANCE_UUID']
67
99
 
68
- if status == 200
69
- ins = response.first.value
70
- uuid = headers['CPEE_INSTANCE_UUID']
100
+ inp = XML::Smart::string('<properties xmlns="http://cpee.org/ns/properties/2.0"/>')
101
+ inp.register_namespace 'prop', 'http://cpee.org/ns/properties/2.0'
102
+ %w{executionhandler positions dataelements endpoints attributes description transformation}.each do |item|
103
+ ele = doc.find("/*/prop:#{item}")
104
+ inp.root.add(ele.first) if ele.any?
105
+ end
71
106
 
72
- inp = XML::Smart::string('<properties xmlns="http://cpee.org/ns/properties/2.0"/>')
73
- inp.register_namespace 'prop', 'http://cpee.org/ns/properties/2.0'
74
- %w{executionhandler positions dataelements endpoints attributes description transformation}.each do |item|
75
- ele = doc.find("/*/prop:#{item}")
76
- inp.root.add(ele.first) if ele.any?
107
+ res = srv.resource("/#{ins}/properties").put Riddl::Parameter::Complex.new('properties','application/xml',inp.to_s)
108
+ # TODO new versions
109
+ doc.find('/*/sub:subscriptions/sub:subscription').each do |s|
110
+ parts = []
111
+ if id = s.attributes['id']
112
+ parts << Riddl::Parameter::Simple.new('id', id)
77
113
  end
78
- res = srv.resource("/#{ins}/properties").put Riddl::Parameter::Complex.new('properties','application/xml',inp.to_s)
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)
114
+ parts << Riddl::Parameter::Simple.new('url', s.attributes['url'])
115
+ s.find('sub:topic').each do |t|
116
+ if (evs = t.find('sub:event').map{ |e| e.text }.join(',')).length > 0
117
+ parts << Riddl::Parameter::Simple.new('topic', t.attributes['id'])
118
+ parts << Riddl::Parameter::Simple.new('events', evs)
84
119
  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
120
+ if (vos = t.find('sub:vote').map{ |e| e.text }.join(',')).length > 0
121
+ parts << Riddl::Parameter::Simple.new('topic', t.attributes['id'])
122
+ parts << Riddl::Parameter::Simple.new('votes', vos)
96
123
  end
97
- status,body = Riddl::Client::new(cpee+ins+'/notifications/subscriptions/').post parts
98
- end rescue nil # in case just no subs are there
99
- end
124
+ end
125
+ status,body = Riddl::Client::new(cpee+ins+'/notifications/subscriptions/').post parts
126
+ end rescue nil # in case just no subs are there
100
127
  end
101
128
  [ins, uuid]
102
129
  end #}}}
@@ -125,6 +152,7 @@ module CPEE
125
152
  private :handle_waiting
126
153
  def handle_starting(cpee,instance,behavior) #{{{
127
154
  if behavior =~ /_running$/
155
+ sleep 0.5
128
156
  srv = Riddl::Client.new(cpee, File.join(cpee,'?riddl-description'))
129
157
  res = srv.resource("/#{instance}/properties/state")
130
158
  status, response = res.put [
@@ -137,7 +165,7 @@ module CPEE
137
165
  if data && !data.empty?
138
166
  content = XML::Smart.string('<dataelements xmlns="http://cpee.org/ns/properties/2.0"/>')
139
167
  JSON::parse(data).each do |k,v|
140
- content.root.add(k,v)
168
+ content.root.add(k,CPEE::ValueHelper::generate(v))
141
169
  end
142
170
  srv = Riddl::Client.new(cpee, File.join(cpee,'?riddl-description'))
143
171
  res = srv.resource("/#{instance}/properties/dataelements/")
@@ -159,6 +187,19 @@ module CPEE
159
187
  ]
160
188
  end rescue nil
161
189
  end #}}}
190
+ def handle_attributes(cpee,instance,data) #{{{
191
+ if data && !data.empty?
192
+ content = XML::Smart.string('<attributes xmlns="http://cpee.org/ns/properties/2.0"/>')
193
+ JSON::parse(data).each do |k,v|
194
+ content.root.add(k,v)
195
+ end
196
+ srv = Riddl::Client.new(cpee, File.join(cpee,'?riddl-description'))
197
+ res = srv.resource("/#{instance}/properties/attributes/")
198
+ status, response = res.patch [
199
+ Riddl::Parameter::Complex.new('attributes','text/xml',content.to_s)
200
+ ]
201
+ end rescue nil
202
+ end #}}}
162
203
  end #}}}
163
204
 
164
205
  class InstantiateGit < Riddl::Implementation #{{{
@@ -176,14 +217,12 @@ module CPEE
176
217
  (@status = 500) && return
177
218
  end
178
219
  customization = @p.find{ |e| e.name == 'customization' }&.value
220
+
221
+ tdoc = augment_testset(tdoc,@p)
179
222
  if (instance, uuid = load_testset(tdoc,cpee,nil,customization)).first == -1
180
223
  @status = 500
181
224
  else
182
225
  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'
186
-
187
226
  handle_waiting cpee, instance, uuid, @p[0].value, selfurl, cblist
188
227
  handle_starting cpee, instance, @p[0].value
189
228
  end
@@ -219,14 +258,12 @@ module CPEE
219
258
  (@status = 500) && return
220
259
  end
221
260
  customization = @p.find{ |e| e.name == 'customization' }&.value
261
+
262
+ tdoc = augment_testset(tdoc,@p)
222
263
  if (instance, uuid = load_testset(tdoc,cpee,name,customization)).first == -1
223
264
  @status = 500
224
265
  else
225
266
  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'
229
-
230
267
  handle_waiting cpee, instance, uuid, @p[0].value, selfurl, cblist
231
268
  handle_starting cpee, instance, @p[0].value
232
269
  end
@@ -261,11 +298,11 @@ module CPEE
261
298
  @p[data].value.read
262
299
  end
263
300
 
301
+ tdoc = augment_testset(tdoc,@p)
264
302
  if (instance, uuid = load_testset(tdoc,cpee)).first == -1
265
303
  @status = 500
266
304
  else
267
305
  EM.defer do
268
- handle_data cpee, instance, @p[data+1]&.value
269
306
  handle_waiting cpee, instance, uuid, behavior, selfurl, cblist
270
307
  handle_starting cpee, instance, behavior
271
308
  end
@@ -293,19 +330,29 @@ module CPEE
293
330
  cblist = @a[2]
294
331
  instance = @p[1].value
295
332
 
296
- srv = Riddl::Client.new(cpee, File.join(cpee,'?riddl-description'))
297
- res = srv.resource("/#{instance}/properties/attributes/uuid")
333
+ srv = Riddl::Client.new(cpee)
334
+ res = srv.resource("/#{instance}/properties/attributes/uuid/")
298
335
  status, response = res.get
299
336
 
300
337
  if status >= 200 && status < 300
301
- uuid = XML::Smart::string(response.first.value).root.text
338
+ uuid = response.first.value
302
339
  handle_data cpee, instance, @p[2]&.value
303
340
  handle_waiting cpee, instance, uuid, @p[0].value, selfurl, cblist
304
341
  handle_starting cpee, instance, @p[0].value
342
+
343
+ send = {
344
+ 'CPEE-INSTANCE' => instance,
345
+ 'CPEE-INSTANCE-URL' => File.join(cpee,instance),
346
+ 'CPEE-INSTANCE-UUID' => uuid,
347
+ 'CPEE-BEHAVIOR' => @p[0].value
348
+ }
349
+
305
350
  if @p[0].value =~ /^wait/
306
351
  @headers << Riddl::Header.new('CPEE-CALLBACK','true')
307
352
  end
308
- return Riddl::Parameter::Simple.new("url",cpee + instance)
353
+ Riddl::Parameter::Complex.new('instance','application/json',JSON::generate(send))
354
+ else
355
+ @status = 500
309
356
  end
310
357
  end
311
358
  end #}}}
@@ -375,7 +422,7 @@ module CPEE
375
422
  run InstantiateGit, opts[:cpee], opts[:self], opts[:cblist] if post 'git'
376
423
  end
377
424
  on resource 'instance' do
378
- run HandleInstance, opts[:cpee] if post 'instance'
425
+ run HandleInstance, opts[:cpee], opts[:self], opts[:cblist] if post 'instance'
379
426
  end
380
427
  on resource 'callback' do
381
428
  on resource do
@@ -33,6 +33,9 @@
33
33
  <optional>
34
34
  <parameter name="endpoints" type="string"/>
35
35
  </optional>
36
+ <optional>
37
+ <parameter name="attributes" type="string"/>
38
+ </optional>
36
39
  <optional>
37
40
  <parameter name="customization" type="string"/>
38
41
  </optional>
@@ -53,6 +56,9 @@
53
56
  <optional>
54
57
  <parameter name="endpoints" type="string"/>
55
58
  </optional>
59
+ <optional>
60
+ <parameter name="attributes" type="string"/>
61
+ </optional>
56
62
  <optional>
57
63
  <parameter name="customization" type="string"/>
58
64
  </optional>
@@ -41,7 +41,7 @@ else
41
41
  end
42
42
 
43
43
  insta = "#{curpath}/../server/"
44
- if !File.exists?(p1)
44
+ if !File.exist?(p1)
45
45
  FileUtils.cp_r(insta,p1)
46
46
  else
47
47
  FileUtils.cp_r(Dir.glob(File.join(insta,'*')).delete_if{|e| e =~ /\.conf/ },p1,remove_destination: true)
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cpee-instantiation
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.10
4
+ version: 1.0.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juergen eTM Mangler
8
+ - Heinrich Fenkart
8
9
  autorequire:
9
10
  bindir: tools
10
11
  cert_chain: []
11
- date: 2021-06-17 00:00:00.000000000 Z
12
+ date: 2023-04-21 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: riddl
@@ -44,14 +45,14 @@ dependencies:
44
45
  requirements:
45
46
  - - "~>"
46
47
  - !ruby/object:Gem::Version
47
- version: '4.1'
48
+ version: '5.0'
48
49
  type: :runtime
49
50
  prerelease: false
50
51
  version_requirements: !ruby/object:Gem::Requirement
51
52
  requirements:
52
53
  - - "~>"
53
54
  - !ruby/object:Gem::Version
54
- version: '4.1'
55
+ version: '5.0'
55
56
  - !ruby/object:Gem::Dependency
56
57
  name: cpee
57
58
  requirement: !ruby/object:Gem::Requirement
@@ -108,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
109
  - !ruby/object:Gem::Version
109
110
  version: '0'
110
111
  requirements: []
111
- rubygems_version: 3.1.6
112
+ rubygems_version: 3.3.26
112
113
  signing_key:
113
114
  specification_version: 4
114
115
  summary: Subprocess instantiation service for the cloud process execution engine (cpee.org)