topological_inventory-core 1.1.0 → 1.1.1

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: 14973202e680d9bf035a3c85d5ef856140bf11d934bfc488cbade6932c8239c1
4
- data.tar.gz: 7493112f3e945f0d0e20cb86385add9f45f623e2825c08b8a3a4ac2a62994822
3
+ metadata.gz: 7bafb3cb3b7789833d6fafd71e34da8e172039ae49f7fe03a16fac40cba7be4e
4
+ data.tar.gz: e642d51826923f406e0a24ca75ea57fea47af01386217b7c1d240e0dad7dded1
5
5
  SHA512:
6
- metadata.gz: '08de615e242bc7dd1ec6f4349386064855b947602986736a8095c3b4802adc0fbeabd5aeb03dcc3d965d3a882f8a989c646624482c45de5235a5457797cef871'
7
- data.tar.gz: fb1e4895ac6ecb98b6564ed411f5107417b5b2f68ee5a1346312f59b32598065d46d300ed158750fa0df2e85868958e7e347b2f82818e00d39db01cf1a414869
6
+ metadata.gz: 4728c1a6494e41e969d034f14ad64bd4bdb2ec1b1c2ce16bc61d00d327ae49b4fbde05d23dc313b773bb2b261af791b0882ab4803626b785e069f4e4e5f7bcf1
7
+ data.tar.gz: ac02e6f01322313ece2855c8876a3ae9224cf23a7c3bf86da66a597df76ee8affcfd43aef48693dc30752a8a9fce5b4df1035df08ba39e7beb9d7e4746b9b347
@@ -1,5 +1,5 @@
1
1
  module TopologicalInventory
2
2
  module Core
3
- VERSION = '1.1.0'
3
+ VERSION = '1.1.1'
4
4
  end
5
5
  end
@@ -147,19 +147,19 @@ module TopologicalInventory
147
147
  return if src_refs.blank?
148
148
 
149
149
  # Updating Tasks
150
- # service_instance_tasks_update_effective()
150
+ # service_instance_tasks_update_effective(source)
151
151
  service_instance_tasks_update_ineffective(source, src_refs)
152
152
  end
153
153
 
154
- def task_update_values(svc_instance_id, external_url, status, finished_timestamp)
154
+ def task_update_values(svc_instance_id, external_url, status, task_status, finished_timestamp)
155
155
  {
156
156
  :state => finished_timestamp.blank? ? 'running' : 'completed',
157
- :status => %w[error failed].include?(status) ? 'error' : 'ok', # TODO: ansible-tower specific, normalize in collector
157
+ :status => task_status,
158
158
  :context => {
159
- :remote_status => status,
160
159
  :service_instance => {
161
- :id => svc_instance_id,
162
- :url => external_url
160
+ :id => svc_instance_id,
161
+ :job_status => status,
162
+ :url => external_url
163
163
  }
164
164
  }
165
165
  }
@@ -175,7 +175,7 @@ module TopologicalInventory
175
175
  group.each do |svc_instance|
176
176
  next if tasks_by_source_ref[svc_instance.source_ref].nil?
177
177
 
178
- values = task_update_values(svc_instance.id, svc_instance.external_url, svc_instance.extra['status'], svc_instance.extra['finished'])
178
+ values = task_update_values(svc_instance.id, svc_instance.external_url, svc_instance.extra['status'], svc_instance.extra['task_status'], svc_instance.extra['finished'])
179
179
  tasks_by_source_ref[svc_instance.source_ref].update(values)
180
180
  end
181
181
  end
@@ -183,27 +183,27 @@ module TopologicalInventory
183
183
  end
184
184
 
185
185
  # This method is bulk updating by raw SQL query
186
- def service_instance_tasks_update_effective
186
+ def service_instance_tasks_update_effective(source)
187
187
  # Get running tasks
188
- tasks_values = Task.where(:state => 'running', :target_type => 'ServiceInstance', :source_id => source.id)
189
- .pluck(:id, :target_source_ref)
190
- tasks_id, tasks_source_ref = [], []
191
- tasks_values.each do |attrs|
192
- tasks_id << attrs[0]
193
- tasks_source_ref << attrs[1]
194
- end
188
+ tasks_source_ref = Task.where(:state => 'running', :target_type => 'ServiceInstance', :source_id => source.id)
189
+ .pluck(:target_source_ref)
190
+ return if tasks_source_ref.blank?
195
191
 
196
192
  # Load saved service instances (IDs needed)
197
- service_instances_values = ServiceInstance.where(:source_ref => tasks_source_ref).pluck(:id, :external_url, :source_ref, Arel.sql("extra->'finished'"), Arel.sql("extra->'status'"))
198
- return if service_instances_values.blank?
193
+ svc_instances_values = ServiceInstance.where(:source_ref => tasks_source_ref)
194
+ .pluck(:id, :external_url, :source_ref,
195
+ Arel.sql("extra->'finished'"),
196
+ Arel.sql("extra->'status'"),
197
+ Arel.sql("extra->'task_status'"))
198
+ return if svc_instances_values.blank?
199
199
 
200
200
  sql_update_values = []
201
201
 
202
202
  # Preparing SQL update values from loaded ServiceInstances
203
- service_instances_values.each do |attrs|
204
- id, external_url, source_ref, finished_timestamp, status = attrs[0], attrs[1], attrs[2], attrs[3], attrs[4]
203
+ svc_instances_values.each do |attrs|
204
+ id, external_url, source_ref, finished_timestamp, status, task_status = attrs[0], attrs[1], attrs[2], attrs[3], attrs[4], attrs[5]
205
205
 
206
- values = task_update_values(id, external_url, status, finished_timestamp)
206
+ values = task_update_values(id, external_url, status, task_status, finished_timestamp)
207
207
  sql_update_values << "('#{source_ref}', '#{values[:state]}', '#{values[:status]}', '#{values[:context].to_json}'::json)"
208
208
  end
209
209
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: topological_inventory-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Grare