openc3 5.0.8 → 5.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/openc3cli +128 -95
- data/data/config/widgets.yaml +49 -73
- data/lib/openc3/api/cmd_api.rb +5 -2
- data/lib/openc3/api/interface_api.rb +15 -0
- data/lib/openc3/api/limits_api.rb +3 -3
- data/lib/openc3/core_ext/file.rb +5 -0
- data/lib/openc3/io/json_rpc.rb +3 -3
- data/lib/openc3/microservices/cleanup_microservice.rb +7 -5
- data/lib/openc3/models/interface_model.rb +41 -0
- data/lib/openc3/models/microservice_model.rb +7 -1
- data/lib/openc3/models/plugin_model.rb +1 -1
- data/lib/openc3/models/target_model.rb +85 -68
- data/lib/openc3/packets/parsers/xtce_parser.rb +68 -3
- data/lib/openc3/script/storage.rb +18 -1
- data/lib/openc3/utilities/local_mode.rb +518 -0
- data/lib/openc3/utilities/target_file.rb +146 -0
- data/lib/openc3/version.rb +5 -5
- metadata +9 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce13d20a53c970d01c019afff0088ee574998e393eb0e56be1ea3bc1af2dbc3c
|
4
|
+
data.tar.gz: '079099f252bf45fcbbcec9f05239de9c84858a166cfb2077806554bcdae76258'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf8762aa78976151e1c561e55fd08de0593f82055d759a6c1c2ed5db9fd3b0510141077f70592cade4a7dbf1ff957657ea4252b6a7d4839046b6b69f853a5cda
|
7
|
+
data.tar.gz: 457563612d61588d7f18da69a48df88b0368b0fba3e9840d7a316eabf334d3e88218cfca584327f927f23f119c005aef4dba63e033b011a7d4c8bcdc071df15c
|
data/bin/openc3cli
CHANGED
@@ -21,9 +21,11 @@
|
|
21
21
|
# This file will handle OpenC3 tasks such as instantiating a new project
|
22
22
|
|
23
23
|
require 'openc3'
|
24
|
+
require 'openc3/utilities/local_mode'
|
24
25
|
require 'openc3/utilities/s3'
|
25
26
|
require 'openc3/models/scope_model'
|
26
27
|
require 'openc3/models/plugin_model'
|
28
|
+
require 'openc3/models/gem_model'
|
27
29
|
require 'openc3/packets/packet_config'
|
28
30
|
require 'openc3/bridge/bridge'
|
29
31
|
require 'ostruct'
|
@@ -35,6 +37,7 @@ require 'json'
|
|
35
37
|
require 'redis'
|
36
38
|
require 'psych'
|
37
39
|
require 'erb'
|
40
|
+
require 'pp'
|
38
41
|
|
39
42
|
$redis_url = "redis://#{ENV['OPENC3_REDIS_HOSTNAME']}:#{ENV['OPENC3_REDIS_PORT']}"
|
40
43
|
|
@@ -313,18 +316,30 @@ ensure
|
|
313
316
|
exit(result)
|
314
317
|
end
|
315
318
|
|
316
|
-
def update_plugin(plugin_file_path, plugin_name, variables: nil, plugin_txt_lines: nil, scope:)
|
319
|
+
def update_plugin(plugin_file_path, plugin_name, variables: nil, plugin_txt_lines: nil, scope:, existing_plugin_name:)
|
317
320
|
new_gem = File.basename(plugin_file_path)
|
318
|
-
old_gem =
|
319
|
-
puts "Updating existing plugin: #{
|
320
|
-
plugin_model = OpenC3::PluginModel.get_model(name:
|
321
|
+
old_gem = existing_plugin_name.split("__")[0]
|
322
|
+
puts "Updating existing plugin: #{existing_plugin_name} with #{File.basename(plugin_file_path)}"
|
323
|
+
plugin_model = OpenC3::PluginModel.get_model(name: existing_plugin_name, scope: scope)
|
321
324
|
begin
|
322
325
|
# Only update if something has changed
|
323
|
-
if (new_gem != old_gem) or (variables != plugin_model.variables) or (plugin_txt_lines != plugin_model.plugin_txt_lines)
|
326
|
+
if (new_gem != old_gem) or (variables and variables != plugin_model.variables) or (plugin_txt_lines and plugin_txt_lines != plugin_model.plugin_txt_lines)
|
327
|
+
puts "Gem version change detected - New: #{new_gem}, Old: #{old_gem}" if new_gem != old_gem
|
328
|
+
if variables and variables != plugin_model.variables
|
329
|
+
pp_variables = ""
|
330
|
+
PP.pp(variables, pp_variables)
|
331
|
+
pp_plugin_model_variables = ""
|
332
|
+
PP.pp(plugin_model.variables, pp_plugin_model_variables)
|
333
|
+
puts "Variables change detected\nNew:\n#{pp_variables}\nOld:\n#{pp_plugin_model_variables}"
|
334
|
+
end
|
335
|
+
puts "plugin.txt change detected\nNew:\n#{plugin_txt_lines.join("\n")}\n\nOld:\n#{plugin_model.plugin_txt_lines.join("\n")}\n" if plugin_txt_lines and plugin_txt_lines != plugin_model.plugin_txt_lines
|
324
336
|
variables = plugin_model.variables unless variables
|
325
337
|
plugin_model.destroy
|
338
|
+
|
326
339
|
plugin_hash = OpenC3::PluginModel.install_phase1(plugin_file_path, existing_variables: variables, existing_plugin_txt_lines: plugin_txt_lines, process_existing: true, scope: scope)
|
327
|
-
|
340
|
+
puts "Updating plugin: #{plugin_file_path}\n#{plugin_hash}"
|
341
|
+
plugin_hash = OpenC3::PluginModel.install_phase2(plugin_hash, scope: scope)
|
342
|
+
OpenC3::LocalMode.update_local_plugin(plugin_file_path, plugin_hash, old_plugin_name: plugin_name, scope: scope)
|
328
343
|
else
|
329
344
|
puts "No changes detected - Exiting without change"
|
330
345
|
end
|
@@ -354,6 +369,7 @@ def load_plugin(plugin_file_path, scope:, plugin_hash_file: nil)
|
|
354
369
|
# Only create the scope if it doesn't already exist
|
355
370
|
unless OpenC3::ScopeModel.names.include?(scope)
|
356
371
|
begin
|
372
|
+
puts "Creating scope: #{scope}"
|
357
373
|
scope_model = OpenC3::ScopeModel.new(name: scope, scope: scope)
|
358
374
|
scope_model.create
|
359
375
|
scope_model.deploy(".", {})
|
@@ -381,7 +397,9 @@ def load_plugin(plugin_file_path, scope:, plugin_hash_file: nil)
|
|
381
397
|
found = true
|
382
398
|
# Upgrade if version changed else do nothing
|
383
399
|
if file_full_name != full_name
|
384
|
-
update_plugin(plugin_file_path, plugin_name, scope: scope)
|
400
|
+
update_plugin(plugin_file_path, plugin_name, scope: scope, existing_plugin_name: plugin_name)
|
401
|
+
else
|
402
|
+
puts "No version change detected for: #{plugin_name}"
|
385
403
|
end
|
386
404
|
end
|
387
405
|
end
|
@@ -394,16 +412,24 @@ def load_plugin(plugin_file_path, scope:, plugin_hash_file: nil)
|
|
394
412
|
existing_plugin_hash = OpenC3::PluginModel.get(name: plugin_hash['name'], scope: scope)
|
395
413
|
|
396
414
|
# Existing plugin hash will be present if plugin is being edited or upgraded
|
397
|
-
#
|
398
|
-
#
|
415
|
+
# However, a missing existing could also be that a plugin was updated in local mode directly from across installations
|
416
|
+
# changing the plugin name without really meaning to create a new instance of the plugin
|
417
|
+
# ie.
|
418
|
+
# User on machine 1 checks in a changed plugin_instance.json with a different name - There is still only one plugin desired and committed
|
419
|
+
# User on machine 2 starts up with the new configuration, OpenC3::PluginModel.get will return nil because the exact name is different
|
420
|
+
# In this case, the plugin should be updated without installing a second instance. analyze_local_mode figures this out.
|
421
|
+
unless existing_plugin_hash
|
422
|
+
existing_plugin_hash = OpenC3::LocalMode.analyze_local_mode(plugin_name: plugin_hash['name'], scope: scope)
|
423
|
+
end
|
399
424
|
|
400
425
|
if existing_plugin_hash
|
401
426
|
# Upgrade or Edit
|
402
|
-
update_plugin(plugin_file_path, plugin_hash['name'], variables: plugin_hash['variables'], plugin_txt_lines: plugin_hash['plugin_txt_lines'], scope: scope)
|
427
|
+
update_plugin(plugin_file_path, plugin_hash['name'], variables: plugin_hash['variables'], plugin_txt_lines: plugin_hash['plugin_txt_lines'], scope: scope, existing_plugin_name: existing_plugin_hash['name'])
|
403
428
|
else
|
404
429
|
# New Install
|
405
430
|
puts "Loading new plugin: #{plugin_file_path}\n#{plugin_hash}"
|
406
|
-
OpenC3::PluginModel.install_phase2(plugin_hash, scope: scope)
|
431
|
+
plugin_hash = OpenC3::PluginModel.install_phase2(plugin_hash, scope: scope)
|
432
|
+
OpenC3::LocalMode.update_local_plugin(plugin_file_path, plugin_hash, scope: scope)
|
407
433
|
end
|
408
434
|
rescue => err
|
409
435
|
abort("Error installing plugin: #{scope}: #{plugin_file_path}: #{err.formatted}")
|
@@ -414,6 +440,7 @@ def unload_plugin(plugin_name, scope:)
|
|
414
440
|
scope ||= 'DEFAULT'
|
415
441
|
begin
|
416
442
|
OpenC3::PluginModel.new(name: plugin_name, scope: scope).destroy
|
443
|
+
OpenC3::LocalMode.remove_local_plugin(plugin_name, scope: scope)
|
417
444
|
OpenC3::Logger.info("PluginModel destroyed: #{plugin_name}", scope: scope)
|
418
445
|
rescue => err
|
419
446
|
abort("Error uninstalling plugin: #{scope}: #{plugin_name}: #{err.formatted}")
|
@@ -450,113 +477,119 @@ def get_redis_keys
|
|
450
477
|
puts "Packets Defs: #{keys.select { |item| item[/^tlm__/] }}"
|
451
478
|
end
|
452
479
|
|
453
|
-
if
|
480
|
+
if __FILE__ == $0
|
481
|
+
if not ARGV[0].nil? # argument(s) given
|
454
482
|
|
455
|
-
|
456
|
-
|
483
|
+
# Handle each task
|
484
|
+
case ARGV[0].downcase
|
457
485
|
|
458
|
-
|
459
|
-
|
486
|
+
when 'rake'
|
487
|
+
puts `rake #{ARGV[1..-1].join(' ')}`
|
460
488
|
|
461
|
-
|
462
|
-
|
489
|
+
when 'validate'
|
490
|
+
validate_plugin(ARGV[1], scope: ARGV[2], variables_file: ARGV[3])
|
463
491
|
|
464
|
-
|
465
|
-
|
492
|
+
when 'load'
|
493
|
+
load_plugin(ARGV[1], scope: ARGV[2], plugin_hash_file: ARGV[3])
|
466
494
|
|
467
|
-
|
468
|
-
|
495
|
+
when 'unload'
|
496
|
+
unload_plugin(ARGV[1], scope: ARGV[2])
|
469
497
|
|
470
|
-
|
471
|
-
|
498
|
+
when 'geminstall'
|
499
|
+
gem_install(ARGV[1])
|
472
500
|
|
473
|
-
|
474
|
-
|
501
|
+
when 'generate'
|
502
|
+
generate(ARGV[1..-1])
|
475
503
|
|
476
|
-
|
477
|
-
|
504
|
+
when 'migrate'
|
505
|
+
migrate(ARGV[1..-1])
|
478
506
|
|
479
|
-
|
480
|
-
|
507
|
+
when 'rubysloc'
|
508
|
+
puts `ruby /openc3/bin/rubysloc #{ARGV[1..-1].join(' ')}`
|
481
509
|
|
482
|
-
|
483
|
-
|
510
|
+
when 'cstol_converter'
|
511
|
+
puts `ruby /openc3/bin/cstol_converter #{ARGV[1..-1].join(' ')}`
|
484
512
|
|
485
|
-
|
486
|
-
|
513
|
+
when 'xtce_converter'
|
514
|
+
xtce_converter(ARGV[1..-1])
|
487
515
|
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
516
|
+
when 'bridge'
|
517
|
+
ENV['OPENC3_NO_STORE'] = '1'
|
518
|
+
filename = ARGV[1]
|
519
|
+
filename = 'bridge.txt' unless filename
|
520
|
+
bridge = OpenC3::Bridge.new(filename)
|
521
|
+
begin
|
522
|
+
while true
|
523
|
+
sleep(1)
|
524
|
+
end
|
525
|
+
rescue Interrupt
|
526
|
+
exit(0)
|
496
527
|
end
|
497
|
-
rescue Interrupt
|
498
|
-
exit(0)
|
499
|
-
end
|
500
528
|
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
when 'help'
|
510
|
-
print_usage()
|
529
|
+
when 'bridgesetup'
|
530
|
+
ENV['OPENC3_NO_STORE'] = '1'
|
531
|
+
filename = ARGV[1]
|
532
|
+
filename = 'bridge.txt' unless filename
|
533
|
+
unless File.exist?(filename)
|
534
|
+
OpenC3::BridgeConfig.generate_default(filename)
|
535
|
+
end
|
511
536
|
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
537
|
+
when 'help'
|
538
|
+
print_usage()
|
539
|
+
|
540
|
+
when 'redis'
|
541
|
+
case (ARGV[1])
|
542
|
+
when 'keys'
|
543
|
+
get_redis_keys()
|
544
|
+
when 'hget'
|
545
|
+
redis = Redis.new(url: $redis_url, username: ENV['OPENC3_REDIS_USERNAME'], password: ENV['OPENC3_REDIS_PASSWORD'])
|
546
|
+
puts JSON.parse(redis.hget(ARGV[2], ARGV[3]), :allow_nan => true, :create_additions => true)
|
547
|
+
else
|
548
|
+
puts "Unknown redis task: #{ARGV[1]}\n"
|
549
|
+
puts "Valid redis tasks: keys, hget"
|
550
|
+
end
|
523
551
|
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
552
|
+
when 'removebase'
|
553
|
+
# Used to remove tool base to better support enterprise upgrade
|
554
|
+
scopes = OpenC3::ScopeModel.all
|
555
|
+
scopes.each do |scope_name, scope|
|
556
|
+
plugins = OpenC3::PluginModel.all(scope: scope_name)
|
557
|
+
plugins.each do |plugin_name, plugin|
|
558
|
+
if plugin["name"] =~ /tool-base/ and plugin["name"] !~ /enterprise/
|
559
|
+
unload_plugin(plugin_name, scope: scope_name)
|
560
|
+
end
|
561
|
+
if plugin["name"] =~ /tool-admin/ and plugin["name"] !~ /enterprise/
|
562
|
+
unload_plugin(plugin_name, scope: scope_name)
|
563
|
+
end
|
535
564
|
end
|
536
565
|
end
|
537
|
-
end
|
538
566
|
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
567
|
+
when 'removeenterprise'
|
568
|
+
# Used to remove enterprise plugins to better support downgrade
|
569
|
+
scopes = OpenC3::ScopeModel.all
|
570
|
+
scopes.each do |scope_name, scope|
|
571
|
+
plugins = OpenC3::PluginModel.all(scope: scope_name)
|
572
|
+
plugins.each do |plugin_name, plugin|
|
573
|
+
if plugin["name"] =~ /enterprise/
|
574
|
+
unload_plugin(plugin_name, scope: scope_name)
|
575
|
+
end
|
547
576
|
end
|
548
577
|
end
|
549
|
-
end
|
550
578
|
|
551
|
-
|
552
|
-
|
553
|
-
|
579
|
+
when 'destroyscope'
|
580
|
+
scope = OpenC3::ScopeModel.get_model(name: ARGV[1])
|
581
|
+
scope.destroy
|
582
|
+
|
583
|
+
when 'localinit'
|
584
|
+
OpenC3::LocalMode.local_init()
|
554
585
|
|
555
|
-
|
586
|
+
else # Unknown task
|
587
|
+
print_usage()
|
588
|
+
abort("Unknown task: #{ARGV[0]}")
|
589
|
+
end
|
590
|
+
|
591
|
+
else # No arguments given
|
556
592
|
print_usage()
|
557
|
-
abort("Unknown task: #{ARGV[0]}")
|
558
593
|
end
|
559
594
|
|
560
|
-
|
561
|
-
print_usage()
|
562
|
-
end
|
595
|
+
end
|