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 +4 -4
- data/lib/topological_inventory/core/version.rb +1 -1
- data/lib/topological_inventory/schema/default.rb +20 -20
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7bafb3cb3b7789833d6fafd71e34da8e172039ae49f7fe03a16fac40cba7be4e
|
4
|
+
data.tar.gz: e642d51826923f406e0a24ca75ea57fea47af01386217b7c1d240e0dad7dded1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4728c1a6494e41e969d034f14ad64bd4bdb2ec1b1c2ce16bc61d00d327ae49b4fbde05d23dc313b773bb2b261af791b0882ab4803626b785e069f4e4e5f7bcf1
|
7
|
+
data.tar.gz: ac02e6f01322313ece2855c8876a3ae9224cf23a7c3bf86da66a597df76ee8affcfd43aef48693dc30752a8a9fce5b4df1035df08ba39e7beb9d7e4746b9b347
|
@@ -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 =>
|
157
|
+
:status => task_status,
|
158
158
|
:context => {
|
159
|
-
:remote_status => status,
|
160
159
|
:service_instance => {
|
161
|
-
:id
|
162
|
-
:
|
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
|
-
|
189
|
-
.pluck(:
|
190
|
-
|
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
|
-
|
198
|
-
|
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
|
-
|
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
|
|