cosmos 5.0.2.pre.beta2 → 5.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/cosmos +1 -1
- data/data/config/microservice.yaml +47 -35
- data/data/config/plugins.yaml +3 -150
- data/data/config/target.yaml +70 -0
- data/data/config/tool.yaml +37 -31
- data/lib/cosmos/api/api.rb +1 -25
- data/lib/cosmos/api/cmd_api.rb +17 -6
- data/lib/cosmos/api/config_api.rb +10 -4
- data/lib/cosmos/api/limits_api.rb +1 -1
- data/lib/cosmos/api/settings_api.rb +19 -7
- data/lib/cosmos/api/target_api.rb +2 -2
- data/lib/cosmos/api/tlm_api.rb +69 -41
- data/lib/cosmos/config/config_parser.rb +19 -22
- data/lib/cosmos/config/meta_config_parser.rb +1 -1
- data/lib/cosmos/conversions/generic_conversion.rb +2 -2
- data/lib/cosmos/conversions/polynomial_conversion.rb +5 -8
- data/lib/cosmos/conversions/segmented_polynomial_conversion.rb +26 -9
- data/lib/cosmos/io/json_drb.rb +5 -1
- data/lib/cosmos/logs/log_writer.rb +2 -2
- data/lib/cosmos/microservices/cleanup_microservice.rb +28 -29
- data/lib/cosmos/microservices/decom_microservice.rb +1 -1
- data/lib/cosmos/microservices/interface_microservice.rb +0 -1
- data/lib/cosmos/microservices/microservice.rb +3 -3
- data/lib/cosmos/microservices/reducer_microservice.rb +12 -10
- data/lib/cosmos/models/cvt_model.rb +6 -6
- data/lib/cosmos/models/gem_model.rb +3 -3
- data/lib/cosmos/models/info_model.rb +1 -1
- data/lib/cosmos/models/interface_status_model.rb +1 -1
- data/lib/cosmos/models/metadata_model.rb +42 -216
- data/lib/cosmos/models/metric_model.rb +2 -2
- data/lib/cosmos/models/microservice_model.rb +1 -1
- data/lib/cosmos/models/microservice_status_model.rb +1 -1
- data/lib/cosmos/models/model.rb +16 -16
- data/lib/cosmos/models/note_model.rb +124 -0
- data/lib/cosmos/models/ping_model.rb +2 -1
- data/lib/cosmos/models/plugin_model.rb +1 -1
- data/lib/cosmos/models/process_status_model.rb +1 -1
- data/lib/cosmos/models/scope_model.rb +9 -26
- data/lib/cosmos/models/settings_model.rb +55 -0
- data/lib/cosmos/models/sorted_model.rb +165 -0
- data/lib/cosmos/models/target_model.rb +120 -13
- data/lib/cosmos/models/tool_config_model.rb +38 -0
- data/lib/cosmos/models/tool_model.rb +1 -1
- data/lib/cosmos/models/widget_model.rb +1 -1
- data/lib/cosmos/operators/microservice_operator.rb +2 -1
- data/lib/cosmos/packets/packet.rb +23 -0
- data/lib/cosmos/packets/packet_config.rb +2 -2
- data/lib/cosmos/packets/packet_item.rb +57 -0
- data/lib/cosmos/packets/packet_item_limits.rb +14 -2
- data/lib/cosmos/packets/parsers/packet_item_parser.rb +1 -1
- data/lib/cosmos/packets/parsers/packet_parser.rb +1 -1
- data/lib/cosmos/packets/parsers/xtce_parser.rb +1 -1
- data/lib/cosmos/packets/structure_item.rb +10 -1
- data/lib/cosmos/script/api_shared.rb +30 -25
- data/lib/cosmos/script/calendar.rb +26 -15
- data/lib/cosmos/script/commands.rb +5 -7
- data/lib/cosmos/script/script.rb +19 -39
- data/lib/cosmos/script/storage.rb +92 -105
- data/lib/cosmos/system/system.rb +2 -1
- data/lib/cosmos/tools/table_manager/table_item.rb +1 -1
- data/lib/cosmos/top_level.rb +5 -1
- data/lib/cosmos/topics/autonomic_topic.rb +2 -2
- data/lib/cosmos/topics/calendar_topic.rb +1 -1
- data/lib/cosmos/topics/command_decom_topic.rb +35 -1
- data/lib/cosmos/topics/command_topic.rb +6 -4
- data/lib/cosmos/topics/interface_topic.rb +8 -8
- data/lib/cosmos/topics/limits_event_topic.rb +5 -3
- data/lib/cosmos/topics/notifications_topic.rb +1 -1
- data/lib/cosmos/topics/router_topic.rb +9 -9
- data/lib/cosmos/topics/telemetry_decom_topic.rb +5 -1
- data/lib/cosmos/topics/telemetry_topic.rb +1 -1
- data/lib/cosmos/topics/timeline_topic.rb +1 -1
- data/lib/cosmos/topics/topic.rb +23 -8
- data/lib/cosmos/utilities/logger.rb +4 -3
- data/lib/cosmos/utilities/metric.rb +32 -26
- data/lib/cosmos/utilities/s3.rb +61 -0
- data/lib/cosmos/utilities/s3_file_cache.rb +12 -6
- data/lib/cosmos/utilities/store.rb +1 -0
- data/lib/cosmos/utilities/store_autoload.rb +25 -134
- data/lib/cosmos/version.rb +6 -5
- data/templates/plugin-template/plugin.gemspec +0 -2
- metadata +9 -6
- data/lib/cosmos/models/narrative_model.rb +0 -280
@@ -51,12 +51,20 @@ module Cosmos
|
|
51
51
|
attr_accessor :id
|
52
52
|
attr_accessor :cmd_log_cycle_time
|
53
53
|
attr_accessor :cmd_log_cycle_size
|
54
|
+
attr_accessor :cmd_log_retain_time
|
54
55
|
attr_accessor :cmd_decom_log_cycle_time
|
55
56
|
attr_accessor :cmd_decom_log_cycle_size
|
57
|
+
attr_accessor :cmd_decom_log_retain_time
|
56
58
|
attr_accessor :tlm_log_cycle_time
|
57
59
|
attr_accessor :tlm_log_cycle_size
|
60
|
+
attr_accessor :tlm_log_retain_time
|
58
61
|
attr_accessor :tlm_decom_log_cycle_time
|
59
62
|
attr_accessor :tlm_decom_log_cycle_size
|
63
|
+
attr_accessor :tlm_decom_log_retain_time
|
64
|
+
attr_accessor :reduced_minute_log_retain_time
|
65
|
+
attr_accessor :reduced_hour_log_retain_time
|
66
|
+
attr_accessor :reduced_day_log_retain_time
|
67
|
+
attr_accessor :cleanup_poll_time
|
60
68
|
attr_accessor :needs_dependencies
|
61
69
|
|
62
70
|
# NOTE: The following three class methods are used by the ModelController
|
@@ -97,6 +105,11 @@ module Cosmos
|
|
97
105
|
result
|
98
106
|
end
|
99
107
|
|
108
|
+
# @return [Array>Hash>] All packet hashes under the target_name
|
109
|
+
def self.all_packet_name_descriptions(target_name, type: :TLM, scope:)
|
110
|
+
self.packets(target_name, type: type, scope: scope).map! { |hash| hash.slice("packet_name", "description") }
|
111
|
+
end
|
112
|
+
|
100
113
|
def self.set_packet(target_name, packet_name, packet, type: :TLM, scope:)
|
101
114
|
raise "Unknown type #{type} for #{target_name} #{packet_name}" unless VALID_TYPES.include?(type)
|
102
115
|
|
@@ -113,7 +126,6 @@ module Cosmos
|
|
113
126
|
packet = packet(target_name, packet_name, type: type, scope: scope)
|
114
127
|
item = packet['items'].find { |item| item['name'] == item_name.to_s }
|
115
128
|
raise "Item '#{packet['target_name']} #{packet['packet_name']} #{item_name}' does not exist" unless item
|
116
|
-
|
117
129
|
item
|
118
130
|
end
|
119
131
|
|
@@ -149,7 +161,7 @@ module Cosmos
|
|
149
161
|
when 'TARGET'
|
150
162
|
usage = "#{keyword} <TARGET FOLDER NAME> <TARGET NAME>"
|
151
163
|
parser.verify_num_parameters(2, 2, usage)
|
152
|
-
parser.
|
164
|
+
parser.verify_parameter_naming(2) # Target name is the 2nd parameter
|
153
165
|
return self.new(name: parameters[1].to_s.upcase, folder_name: parameters[0].to_s.upcase, plugin: plugin, scope: scope)
|
154
166
|
else
|
155
167
|
raise ConfigParser::Error.new(parser, "Unknown keyword and parameters for Target: #{keyword} #{parameters.join(" ")}")
|
@@ -171,20 +183,35 @@ module Cosmos
|
|
171
183
|
plugin: nil,
|
172
184
|
cmd_log_cycle_time: 600,
|
173
185
|
cmd_log_cycle_size: 50_000_000,
|
186
|
+
cmd_log_retain_time: nil,
|
174
187
|
cmd_decom_log_cycle_time: 600,
|
175
188
|
cmd_decom_log_cycle_size: 50_000_000,
|
189
|
+
cmd_decom_log_retain_time: nil,
|
176
190
|
tlm_log_cycle_time: 600,
|
177
191
|
tlm_log_cycle_size: 50_000_000,
|
192
|
+
tlm_log_retain_time: nil,
|
178
193
|
tlm_decom_log_cycle_time: 600,
|
179
194
|
tlm_decom_log_cycle_size: 50_000_000,
|
195
|
+
tlm_decom_log_retain_time: nil,
|
196
|
+
reduced_minute_log_retain_time: nil,
|
197
|
+
reduced_hour_log_retain_time: nil,
|
198
|
+
reduced_day_log_retain_time: nil,
|
199
|
+
cleanup_poll_time: 900,
|
180
200
|
needs_dependencies: false,
|
181
201
|
scope:
|
182
202
|
)
|
183
203
|
super("#{scope}__#{PRIMARY_KEY}", name: name, plugin: plugin, updated_at: updated_at,
|
184
204
|
cmd_log_cycle_time: cmd_log_cycle_time, cmd_log_cycle_size: cmd_log_cycle_size,
|
205
|
+
cmd_log_retain_time: cmd_log_retain_time,
|
185
206
|
cmd_decom_log_cycle_time: cmd_decom_log_cycle_time, cmd_decom_log_cycle_size: cmd_decom_log_cycle_size,
|
207
|
+
cmd_decom_log_retain_time: cmd_decom_log_retain_time,
|
186
208
|
tlm_log_cycle_time: tlm_log_cycle_time, tlm_log_cycle_size: tlm_log_cycle_size,
|
209
|
+
tlm_log_retain_time: tlm_log_retain_time,
|
187
210
|
tlm_decom_log_cycle_time: tlm_decom_log_cycle_time, tlm_decom_log_cycle_size: tlm_decom_log_cycle_size,
|
211
|
+
tlm_decom_log_retain_time: tlm_decom_log_retain_time,
|
212
|
+
reduced_minute_log_retain_time: reduced_minute_log_retain_time,
|
213
|
+
reduced_hour_log_retain_time: reduced_hour_log_retain_time, reduced_day_log_retain_time: reduced_day_log_retain_time,
|
214
|
+
cleanup_poll_time: cleanup_poll_time, needs_dependencies: needs_dependencies,
|
188
215
|
scope: scope)
|
189
216
|
@folder_name = folder_name
|
190
217
|
@requires = requires
|
@@ -197,12 +224,20 @@ module Cosmos
|
|
197
224
|
@id = id
|
198
225
|
@cmd_log_cycle_time = cmd_log_cycle_time
|
199
226
|
@cmd_log_cycle_size = cmd_log_cycle_size
|
227
|
+
@cmd_log_retain_time = cmd_log_retain_time
|
200
228
|
@cmd_decom_log_cycle_time = cmd_decom_log_cycle_time
|
201
229
|
@cmd_decom_log_cycle_size = cmd_decom_log_cycle_size
|
230
|
+
@cmd_decom_log_retain_time = cmd_decom_log_retain_time
|
202
231
|
@tlm_log_cycle_time = tlm_log_cycle_time
|
203
232
|
@tlm_log_cycle_size = tlm_log_cycle_size
|
233
|
+
@tlm_log_retain_time = tlm_log_retain_time
|
204
234
|
@tlm_decom_log_cycle_time = tlm_decom_log_cycle_time
|
205
235
|
@tlm_decom_log_cycle_size = tlm_decom_log_cycle_size
|
236
|
+
@tlm_decom_log_retain_time = tlm_decom_log_retain_time
|
237
|
+
@reduced_minute_log_retain_time = reduced_minute_log_retain_time
|
238
|
+
@reduced_hour_log_retain_time = reduced_hour_log_retain_time
|
239
|
+
@reduced_day_log_retain_time = reduced_day_log_retain_time
|
240
|
+
@cleanup_poll_time = cleanup_poll_time
|
206
241
|
@needs_dependencies = needs_dependencies
|
207
242
|
end
|
208
243
|
|
@@ -222,12 +257,20 @@ module Cosmos
|
|
222
257
|
'plugin' => @plugin,
|
223
258
|
'cmd_log_cycle_time' => @cmd_log_cycle_time,
|
224
259
|
'cmd_log_cycle_size' => @cmd_log_cycle_size,
|
260
|
+
'cmd_log_retain_time' => @cmd_log_retain_time,
|
225
261
|
'cmd_decom_log_cycle_time' => @cmd_decom_log_cycle_time,
|
226
262
|
'cmd_decom_log_cycle_size' => @cmd_decom_log_cycle_size,
|
263
|
+
'cmd_decom_log_retain_time' => @cmd_decom_log_retain_time,
|
227
264
|
'tlm_log_cycle_time' => @tlm_log_cycle_time,
|
228
265
|
'tlm_log_cycle_size' => @tlm_log_cycle_size,
|
266
|
+
'tlm_log_retain_time' => @tlm_log_retain_time,
|
229
267
|
'tlm_decom_log_cycle_time' => @tlm_decom_log_cycle_time,
|
230
268
|
'tlm_decom_log_cycle_size' => @tlm_decom_log_cycle_size,
|
269
|
+
'tlm_decom_log_retain_time' => @tlm_decom_log_retain_time,
|
270
|
+
'reduced_minute_log_retain_time' => @reduced_minute_log_retain_time,
|
271
|
+
'reduced_hour_log_retain_time' => @reduced_hour_log_retain_time,
|
272
|
+
'reduced_day_log_retain_time' => @reduced_day_log_retain_time,
|
273
|
+
'cleanup_poll_time' => @cleanup_poll_time,
|
231
274
|
'needs_dependencies' => @needs_dependencies,
|
232
275
|
}
|
233
276
|
end
|
@@ -245,24 +288,72 @@ module Cosmos
|
|
245
288
|
when 'CMD_LOG_CYCLE_SIZE'
|
246
289
|
parser.verify_num_parameters(1, 1, "#{keyword} <Maximum file size in bytes>")
|
247
290
|
@cmd_log_cycle_size = parameters[0].to_i
|
291
|
+
when 'CMD_LOG_RETAIN_TIME'
|
292
|
+
parser.verify_num_parameters(1, 1, "#{keyword} <Retention time for cmd log files in seconds - nil = Forever>")
|
293
|
+
@cmd_log_retain_time = ConfigParser.handle_nil(parameters[0])
|
294
|
+
@cmd_log_retain_time = @cmd_log_retain_time.to_i if @cmd_log_retain_time
|
248
295
|
when 'CMD_DECOM_LOG_CYCLE_TIME'
|
249
296
|
parser.verify_num_parameters(1, 1, "#{keyword} <Maximum time between files in seconds>")
|
250
297
|
@cmd_decom_log_cycle_time = parameters[0].to_i
|
251
298
|
when 'CMD_DECOM_LOG_CYCLE_SIZE'
|
252
299
|
parser.verify_num_parameters(1, 1, "#{keyword} <Maximum file size in bytes>")
|
253
300
|
@cmd_decom_log_cycle_size = parameters[0].to_i
|
301
|
+
when 'CMD_DECOM_LOG_RETAIN_TIME'
|
302
|
+
parser.verify_num_parameters(1, 1, "#{keyword} <Retention time for cmd decom log files in seconds - nil = Forever>")
|
303
|
+
@cmd_decom_log_retain_time = ConfigParser.handle_nil(parameters[0])
|
304
|
+
@cmd_decom_log_retain_time = @cmd_decom_log_retain_time.to_i if @cmd_decom_log_retain_time
|
254
305
|
when 'TLM_LOG_CYCLE_TIME'
|
255
306
|
parser.verify_num_parameters(1, 1, "#{keyword} <Maximum time between files in seconds>")
|
256
307
|
@tlm_log_cycle_time = parameters[0].to_i
|
257
308
|
when 'TLM_LOG_CYCLE_SIZE'
|
258
309
|
parser.verify_num_parameters(1, 1, "#{keyword} <Maximum file size in bytes>")
|
259
310
|
@tlm_log_cycle_size = parameters[0].to_i
|
311
|
+
when 'TLM_LOG_RETAIN_TIME'
|
312
|
+
parser.verify_num_parameters(1, 1, "#{keyword} <Retention time for tlm log files in seconds - nil = Forever>")
|
313
|
+
@tlm_log_retain_time = ConfigParser.handle_nil(parameters[0])
|
314
|
+
@tlm_log_retain_time = @tlm_log_retain_time.to_i if @tlm_log_retain_time
|
260
315
|
when 'TLM_DECOM_LOG_CYCLE_TIME'
|
261
316
|
parser.verify_num_parameters(1, 1, "#{keyword} <Maximum time between files in seconds>")
|
262
317
|
@tlm_decom_log_cycle_time = parameters[0].to_i
|
263
318
|
when 'TLM_DECOM_LOG_CYCLE_SIZE'
|
264
319
|
parser.verify_num_parameters(1, 1, "#{keyword} <Maximum file size in bytes>")
|
265
320
|
@tlm_decom_log_cycle_size = parameters[0].to_i
|
321
|
+
when 'TLM_DECOM_LOG_RETAIN_TIME'
|
322
|
+
parser.verify_num_parameters(1, 1, "#{keyword} <Retention time for tlm decom log files in seconds - nil = Forever>")
|
323
|
+
@tlm_decom_log_retain_time = ConfigParser.handle_nil(parameters[0])
|
324
|
+
@tlm_decom_log_retain_time = @tlm_decom_log_retain_time.to_i if @tlm_decom_log_retain_time
|
325
|
+
when 'REDUCED_MINUTE_LOG_RETAIN_TIME'
|
326
|
+
parser.verify_num_parameters(1, 1, "#{keyword} <Retention time for reduced minute log files in seconds - nil = Forever>")
|
327
|
+
@reduced_minute_log_retain_time = ConfigParser.handle_nil(parameters[0])
|
328
|
+
@reduced_minute_log_retain_time = @reduced_minute_log_retain_time.to_i if @reduced_minute_log_retain_time
|
329
|
+
when 'REDUCED_HOUR_LOG_RETAIN_TIME'
|
330
|
+
parser.verify_num_parameters(1, 1, "#{keyword} <Retention time for reduced hour log files in seconds - nil = Forever>")
|
331
|
+
@reduced_hour_log_retain_time = ConfigParser.handle_nil(parameters[0])
|
332
|
+
@reduced_hour_log_retain_time = @reduced_hour_log_retain_time.to_i if @reduced_hour_log_retain_time
|
333
|
+
when 'REDUCED_DAY_LOG_RETAIN_TIME'
|
334
|
+
parser.verify_num_parameters(1, 1, "#{keyword} <Retention time for reduced day log files in seconds - nil = Forever>")
|
335
|
+
@reduced_day_log_retain_time = ConfigParser.handle_nil(parameters[0])
|
336
|
+
@reduced_day_log_retain_time = @reduced_day_log_retain_time.to_i if @reduced_day_log_retain_time
|
337
|
+
when 'LOG_RETAIN_TIME'
|
338
|
+
parser.verify_num_parameters(1, 1, "#{keyword} <Retention time for all log files in seconds - nil = Forever>")
|
339
|
+
log_retain_time = ConfigParser.handle_nil(parameters[0])
|
340
|
+
if log_retain_time
|
341
|
+
@cmd_log_retain_time = log_retain_time.to_i
|
342
|
+
@cmd_decom_log_retain_time = log_retain_time.to_i
|
343
|
+
@tlm_log_retain_time = log_retain_time.to_i
|
344
|
+
@tlm_decom_log_retain_time = log_retain_time.to_i
|
345
|
+
end
|
346
|
+
when 'REDUCED_LOG_RETAIN_TIME'
|
347
|
+
parser.verify_num_parameters(1, 1, "#{keyword} <Retention time for all reduced log files in seconds - nil = Forever>")
|
348
|
+
reduced_log_retain_time = ConfigParser.handle_nil(parameters[0])
|
349
|
+
if reduced_log_retain_time
|
350
|
+
@reduced_minute_log_retain_time = reduced_log_retain_time.to_i
|
351
|
+
@reduced_hour_log_retain_time = reduced_log_retain_time.to_i
|
352
|
+
@reduced_day_log_retain_time = reduced_log_retain_time.to_i
|
353
|
+
end
|
354
|
+
when 'CLEANUP_POLL_TIME'
|
355
|
+
parser.verify_num_parameters(1, 1, "#{keyword} <Cleanup polling period in seconds>")
|
356
|
+
@cleanup_poll_time = parameters[0].to_i
|
266
357
|
else
|
267
358
|
raise ConfigParser::Error.new(parser, "Unknown keyword and parameters for Target: #{keyword} #{parameters.join(" ")}")
|
268
359
|
end
|
@@ -289,7 +380,7 @@ module Cosmos
|
|
289
380
|
data = File.read(filename, mode: "rb")
|
290
381
|
begin
|
291
382
|
Cosmos.set_working_dir(File.dirname(filename)) do
|
292
|
-
data = ERB.new(data).result(binding.set_variables(variables)) if data.is_printable? and File.basename(filename)[0] != '_'
|
383
|
+
data = ERB.new(data, trim_mode: "-").result(binding.set_variables(variables)) if data.is_printable? and File.basename(filename)[0] != '_'
|
293
384
|
end
|
294
385
|
rescue => error
|
295
386
|
raise "ERB error parsing: #{filename}: #{error.formatted}"
|
@@ -322,12 +413,12 @@ module Cosmos
|
|
322
413
|
Store.hdel("#{@scope}__limits_groups", group)
|
323
414
|
end
|
324
415
|
self.class.packets(@name, type: :CMD, scope: @scope).each do |packet|
|
325
|
-
|
326
|
-
|
416
|
+
Topic.del("#{@scope}__COMMAND__{#{@name}}__#{packet['packet_name']}")
|
417
|
+
Topic.del("#{@scope}__DECOMCMD__{#{@name}}__#{packet['packet_name']}")
|
327
418
|
end
|
328
419
|
self.class.packets(@name, scope: @scope).each do |packet|
|
329
|
-
|
330
|
-
|
420
|
+
Topic.del("#{@scope}__TELEMETRY__{#{@name}}__#{packet['packet_name']}")
|
421
|
+
Topic.del("#{@scope}__DECOM__{#{@name}}__#{packet['packet_name']}")
|
331
422
|
CvtModel.del(target_name: @name, packet_name: packet['packet_name'], scope: @scope)
|
332
423
|
LimitsEventTopic.delete(@name, packet['packet_name'], scope: @scope)
|
333
424
|
end
|
@@ -335,7 +426,7 @@ module Cosmos
|
|
335
426
|
Store.del("#{@scope}__cosmoscmd__#{@name}")
|
336
427
|
|
337
428
|
# Note: these match the names of the services in deploy_microservices
|
338
|
-
%w(DECOM COMMANDLOG DECOMCMDLOG PACKETLOG DECOMLOG REDUCER).each do |type|
|
429
|
+
%w(DECOM COMMANDLOG DECOMCMDLOG PACKETLOG DECOMLOG REDUCER CLEANUP).each do |type|
|
339
430
|
model = MicroserviceModel.get_model(name: "#{@scope}__#{type}__#{@name}", scope: @scope)
|
340
431
|
model.destroy if model
|
341
432
|
end
|
@@ -364,7 +455,7 @@ module Cosmos
|
|
364
455
|
|
365
456
|
begin
|
366
457
|
Cosmos.set_working_dir(File.dirname(path)) do
|
367
|
-
return ERB.new(File.read(path)).result(b)
|
458
|
+
return ERB.new(File.read(path), trim_mode: "-").result(b)
|
368
459
|
end
|
369
460
|
rescue => error
|
370
461
|
raise "ERB error parsing: #{path}: #{error.formatted}"
|
@@ -494,10 +585,10 @@ module Cosmos
|
|
494
585
|
# No telemetry packets for this target
|
495
586
|
end
|
496
587
|
# It's ok to call initialize_streams with an empty array
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
588
|
+
Topic.initialize_streams(command_topic_list)
|
589
|
+
Topic.initialize_streams(decom_command_topic_list)
|
590
|
+
Topic.initialize_streams(packet_topic_list)
|
591
|
+
Topic.initialize_streams(decom_topic_list)
|
501
592
|
|
502
593
|
unless command_topic_list.empty?
|
503
594
|
# CommandLog Microservice
|
@@ -627,6 +718,22 @@ module Cosmos
|
|
627
718
|
microservice.deploy(gem_path, variables)
|
628
719
|
Logger.info "Configured microservice #{microservice_name}"
|
629
720
|
end
|
721
|
+
|
722
|
+
if @cmd_log_retain_time or @cmd_decom_log_retain_time or @tlm_log_retain_time or @tlm_decom_log_retain_time or
|
723
|
+
@reduced_minute_log_retain_time or @reduced_hour_log_retain_time or @reduced_day_log_retain_time
|
724
|
+
# Cleanup Microservice
|
725
|
+
microservice_name = "#{@scope}__CLEANUP__#{@name}"
|
726
|
+
microservice = MicroserviceModel.new(
|
727
|
+
name: microservice_name,
|
728
|
+
cmd: ["ruby", "cleanup_microservice.rb", microservice_name],
|
729
|
+
work_dir: '/cosmos/lib/cosmos/microservices',
|
730
|
+
plugin: plugin,
|
731
|
+
scope: @scope
|
732
|
+
)
|
733
|
+
microservice.create
|
734
|
+
microservice.deploy(gem_path, variables)
|
735
|
+
Logger.info "Configured microservice #{microservice_name}"
|
736
|
+
end
|
630
737
|
end
|
631
738
|
end
|
632
739
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# encoding: ascii-8bit
|
2
|
+
|
3
|
+
# Copyright 2022 Ball Aerospace & Technologies Corp.
|
4
|
+
# All Rights Reserved.
|
5
|
+
#
|
6
|
+
# This program is free software; you can modify and/or redistribute it
|
7
|
+
# under the terms of the GNU Affero General Public License
|
8
|
+
# as published by the Free Software Foundation; version 3 with
|
9
|
+
# attribution addendums as found in the LICENSE.txt
|
10
|
+
#
|
11
|
+
# This program is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU Affero General Public License for more details.
|
15
|
+
#
|
16
|
+
# This program may also be used under the terms of a commercial or
|
17
|
+
# enterprise edition license of COSMOS if purchased from the
|
18
|
+
# copyright holder
|
19
|
+
|
20
|
+
module Cosmos
|
21
|
+
class ToolConfigModel
|
22
|
+
def self.list_configs(tool, scope: $cosmos_scope)
|
23
|
+
Store.hkeys("#{scope}__config__#{tool}")
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.load_config(tool, name, scope: $cosmos_scope)
|
27
|
+
Store.hget("#{scope}__config__#{tool}", name)
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.save_config(tool, name, data, scope: $cosmos_scope)
|
31
|
+
Store.hset("#{scope}__config__#{tool}", name, data)
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.delete_config(tool, name, scope: $cosmos_scope)
|
35
|
+
Store.hdel("#{scope}__config__#{tool}", name)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -231,7 +231,7 @@ module Cosmos
|
|
231
231
|
|
232
232
|
# Load tool files
|
233
233
|
data = File.read(filename, mode: "rb")
|
234
|
-
data = ERB.new(data).result(binding.set_variables(variables)) if data.is_printable?
|
234
|
+
data = ERB.new(data, trim_mode: "-").result(binding.set_variables(variables)) if data.is_printable?
|
235
235
|
rubys3_client.put_object(bucket: 'tools', content_type: content_type, cache_control: cache_control, key: key, body: data)
|
236
236
|
end
|
237
237
|
end
|
@@ -121,7 +121,7 @@ module Cosmos
|
|
121
121
|
# Load widget file
|
122
122
|
data = File.read(filename, mode: "rb")
|
123
123
|
Cosmos.set_working_dir(File.dirname(filename)) do
|
124
|
-
data = ERB.new(data).result(binding.set_variables(variables)) if data.is_printable?
|
124
|
+
data = ERB.new(data, trim_mode: "-").result(binding.set_variables(variables)) if data.is_printable?
|
125
125
|
end
|
126
126
|
# TODO: support widgets that aren't just a single js file (and its associated map file)
|
127
127
|
rubys3_client.put_object(bucket: 'tools', content_type: 'application/javascript', cache_control: cache_control, key: @s3_key, body: data)
|
@@ -39,7 +39,7 @@ module Cosmos
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def convert_microservice_to_process_definition(microservice_name, microservice_config)
|
42
|
-
process_definition = ["ruby", "plugin_microservice.rb"
|
42
|
+
process_definition = ["ruby", "plugin_microservice.rb"]
|
43
43
|
work_dir = "/cosmos/lib/cosmos/microservices"
|
44
44
|
env = microservice_config["env"].dup
|
45
45
|
if microservice_config["needs_dependencies"]
|
@@ -47,6 +47,7 @@ module Cosmos
|
|
47
47
|
else
|
48
48
|
env['GEM_HOME'] = nil
|
49
49
|
end
|
50
|
+
env['COSMOS_MICROSERVICE_NAME'] = microservice_name
|
50
51
|
container = microservice_config["container"]
|
51
52
|
scope = microservice_name.split("__")[0]
|
52
53
|
return process_definition, work_dir, env, scope, container
|
@@ -445,6 +445,11 @@ module Cosmos
|
|
445
445
|
@meta ||= {}
|
446
446
|
end
|
447
447
|
|
448
|
+
# Sets packet specific metadata
|
449
|
+
def meta=(meta)
|
450
|
+
@meta = meta
|
451
|
+
end
|
452
|
+
|
448
453
|
# Indicates if the packet has been identified
|
449
454
|
# @return [TrueClass or FalseClass]
|
450
455
|
def identified?
|
@@ -1009,6 +1014,24 @@ module Cosmos
|
|
1009
1014
|
config
|
1010
1015
|
end
|
1011
1016
|
|
1017
|
+
def self.from_json(hash)
|
1018
|
+
endianness = hash['endianness'] ? hash['endianness'].intern : nil # Convert to symbol
|
1019
|
+
packet = Packet.new(hash['target_name'], hash['packet_name'], endianness, hash['description'])
|
1020
|
+
packet.short_buffer_allowed = hash['short_buffer_allowed']
|
1021
|
+
packet.hazardous = hash['hazardous']
|
1022
|
+
packet.hazardous_description = hash['hazardous_description']
|
1023
|
+
packet.messages_disabled = hash['messages_disabled']
|
1024
|
+
packet.disabled = hash['disabled']
|
1025
|
+
packet.hidden = hash['hidden']
|
1026
|
+
# packet.stale is read only
|
1027
|
+
packet.meta = hash['meta']
|
1028
|
+
# Can't convert processors
|
1029
|
+
hash['items'].each do |item|
|
1030
|
+
packet.define(PacketItem.from_json(item))
|
1031
|
+
end
|
1032
|
+
packet
|
1033
|
+
end
|
1034
|
+
|
1012
1035
|
protected
|
1013
1036
|
|
1014
1037
|
# Performs packet specific processing on the packet.
|
@@ -463,8 +463,8 @@ module Cosmos
|
|
463
463
|
when 'POLY_READ_CONVERSION', 'POLY_WRITE_CONVERSION'
|
464
464
|
usage = "#{keyword} <C0> <C1> <C2> ..."
|
465
465
|
parser.verify_num_parameters(1, nil, usage)
|
466
|
-
@current_item.read_conversion = PolynomialConversion.new(params) if keyword.include? "READ"
|
467
|
-
@current_item.write_conversion = PolynomialConversion.new(params) if keyword.include? "WRITE"
|
466
|
+
@current_item.read_conversion = PolynomialConversion.new(*params) if keyword.include? "READ"
|
467
|
+
@current_item.write_conversion = PolynomialConversion.new(*params) if keyword.include? "WRITE"
|
468
468
|
|
469
469
|
# Apply a segmented polynomial conversion to the current item
|
470
470
|
# after it is read from the telemetry packet
|
@@ -486,6 +486,63 @@ module Cosmos
|
|
486
486
|
config
|
487
487
|
end
|
488
488
|
|
489
|
+
def self.from_json(hash)
|
490
|
+
# Convert strings to symbols
|
491
|
+
endianness = hash['endianness'] ? hash['endianness'].intern : nil
|
492
|
+
data_type = hash['data_type'] ? hash['data_type'].intern : nil
|
493
|
+
overflow = hash['overflow'] ? hash['overflow'].intern : nil
|
494
|
+
item = PacketItem.new(hash['name'], hash['bit_offset'], hash['bit_size'],
|
495
|
+
data_type, endianness, hash['array_size'], overflow)
|
496
|
+
item.description = hash['description']
|
497
|
+
item.id_value = hash['id_value']
|
498
|
+
item.default = hash['default']
|
499
|
+
item.range = (hash['minimum']..hash['maximum']) if hash['minimum'] && hash['maximum']
|
500
|
+
item.required = hash['required']
|
501
|
+
item.format_string = hash['format_string']
|
502
|
+
item.units = hash['units']
|
503
|
+
item.units_full = hash['units_full']
|
504
|
+
if hash['states']
|
505
|
+
item.states = {}
|
506
|
+
item.hazardous = {}
|
507
|
+
item.state_colors = {}
|
508
|
+
hash['states'].each do |state_name, state|
|
509
|
+
item.states[state_name] = state['value']
|
510
|
+
item.hazardous[state_name] = state['hazardous']
|
511
|
+
item.state_colors[state_name] = state['color'].to_sym if state['color']
|
512
|
+
end
|
513
|
+
end
|
514
|
+
# Recreate COSMOS built-in conversions
|
515
|
+
if hash['read_conversion']
|
516
|
+
begin
|
517
|
+
item.read_conversion = Cosmos::const_get(hash['read_conversion']['class']).new(*hash['read_conversion']['params'])
|
518
|
+
rescue => error
|
519
|
+
Logger.instance.error "#{item.name} read_conversion of #{hash['read_conversion']} could not be instantiated due to #{error}"
|
520
|
+
end
|
521
|
+
end
|
522
|
+
if hash['write_conversion']
|
523
|
+
begin
|
524
|
+
item.write_conversion = Cosmos::const_get(hash['write_conversion']['class']).new(*hash['write_conversion']['params'])
|
525
|
+
rescue => error
|
526
|
+
Logger.instance.error "#{item.name} write_conversion of #{hash['write_conversion']} could not be instantiated due to #{error}"
|
527
|
+
end
|
528
|
+
end
|
529
|
+
|
530
|
+
if hash['limits']
|
531
|
+
item.limits = PacketItemLimits.new
|
532
|
+
# Delete these keys so the only ones left are limits sets
|
533
|
+
item.limits.persistence_setting = hash['limits'].delete('persistence_setting')
|
534
|
+
item.limits.enabled = true if hash['limits'].delete('enabled')
|
535
|
+
values = {}
|
536
|
+
hash['limits'].each do |set, items|
|
537
|
+
values[set.to_sym] = [items['red_low'], items['yellow_low'], items['yellow_high'], items['red_high']]
|
538
|
+
values[set.to_sym].concat([items['green_low'], items['green_high']]) if items['green_low'] && items['green_high']
|
539
|
+
end
|
540
|
+
item.limits.values = values
|
541
|
+
end
|
542
|
+
item.meta = hash['meta']
|
543
|
+
item
|
544
|
+
end
|
545
|
+
|
489
546
|
protected
|
490
547
|
|
491
548
|
def parameter_config
|
@@ -132,7 +132,7 @@ module Cosmos
|
|
132
132
|
end
|
133
133
|
alias dup clone
|
134
134
|
|
135
|
-
def
|
135
|
+
def as_json
|
136
136
|
hash = {}
|
137
137
|
hash['values'] = self.values
|
138
138
|
hash['enabled'] = self.enabled
|
@@ -146,5 +146,17 @@ module Cosmos
|
|
146
146
|
hash['persistence_count'] = self.persistence_count
|
147
147
|
hash
|
148
148
|
end
|
149
|
+
|
150
|
+
def self.from_json(hash)
|
151
|
+
limits = PacketItemLimits.new
|
152
|
+
limits.values = hash['values'].transform_keys(&:to_sym) if hash['values']
|
153
|
+
limits.enabled = hash['enabled']
|
154
|
+
limits.state = hash['state'] ? hash['state'].to_sym : nil
|
155
|
+
# Can't recreate a LimitsResponse class
|
156
|
+
# limits.response = hash['response']
|
157
|
+
limits.persistence_setting = hash['persistence_setting'] if hash['persistence_setting']
|
158
|
+
limits.persistence_count = hash['persistence_count'] if hash['persistence_count']
|
159
|
+
limits
|
160
|
+
end
|
149
161
|
end
|
150
|
-
end
|
162
|
+
end
|
@@ -56,7 +56,7 @@ module Cosmos
|
|
56
56
|
max_options = @usage.count("<")
|
57
57
|
# The last two options (description and endianness) are optional
|
58
58
|
@parser.verify_num_parameters(max_options - 2, max_options, @usage)
|
59
|
-
@parser.
|
59
|
+
@parser.verify_parameter_naming(1) # Item name is the 1st parameter
|
60
60
|
end
|
61
61
|
|
62
62
|
def create_packet_item(packet, cmd_or_tlm)
|
@@ -72,7 +72,7 @@ module Cosmos
|
|
72
72
|
def verify_parameters
|
73
73
|
@usage = "#{@parser.keyword} <TARGET NAME> <PACKET NAME> <ENDIANNESS: BIG_ENDIAN/LITTLE_ENDIAN> <DESCRIPTION (Optional)>"
|
74
74
|
@parser.verify_num_parameters(3, 4, @usage)
|
75
|
-
@parser.
|
75
|
+
@parser.verify_parameter_naming(2) # Packet name is the 2nd parameter
|
76
76
|
end
|
77
77
|
|
78
78
|
def create_command(target_name, commands, warnings)
|
@@ -293,7 +293,7 @@ module Cosmos
|
|
293
293
|
xtce_recurse_element(element) do |block_element|
|
294
294
|
if block_element.name == 'Term'
|
295
295
|
exponent = Float(block_element['exponent']).to_i
|
296
|
-
@current_type.conversion ||= PolynomialConversion.new(
|
296
|
+
@current_type.conversion ||= PolynomialConversion.new()
|
297
297
|
@current_type.conversion.coeffs[exponent] = Float(block_element['coefficient'])
|
298
298
|
@current_type.conversion.coeffs.each_with_index do |value, index|
|
299
299
|
@current_type.conversion.coeffs[index] = 0.0 if value.nil?
|
@@ -292,7 +292,16 @@ module Cosmos
|
|
292
292
|
end
|
293
293
|
alias dup clone
|
294
294
|
|
295
|
-
def
|
295
|
+
def self.from_json(hash)
|
296
|
+
# Convert strings to symbols
|
297
|
+
endianness = hash['endianness'] ? hash['endianness'].intern : nil
|
298
|
+
data_type = hash['data_type'] ? hash['data_type'].intern : nil
|
299
|
+
overflow = hash['overflow'] ? hash['overflow'].intern : nil
|
300
|
+
StructureItem.new(hash['name'], hash['bit_offset'], hash['bit_size'], data_type,
|
301
|
+
endianness, hash['array_size'], overflow)
|
302
|
+
end
|
303
|
+
|
304
|
+
def as_json
|
296
305
|
hash = {}
|
297
306
|
hash['name'] = self.name
|
298
307
|
hash['bit_offset'] = self.bit_offset
|