openc3 5.0.11 → 5.1.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of openc3 might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Guardfile +3 -0
- data/LICENSE.txt +7 -5
- data/README.md +11 -9
- data/Rakefile +3 -0
- data/bin/cstol_converter +3 -0
- data/bin/openc3cli +29 -18
- data/bin/rubysloc +3 -0
- data/data/config/screen.yaml +10 -2
- data/data/config/target.yaml +1 -1
- data/data/config/widgets.yaml +6 -6
- data/ext/mkrf_conf.rb +3 -0
- data/ext/openc3/ext/array/array.c +3 -0
- data/ext/openc3/ext/buffered_file/buffered_file.c +3 -0
- data/ext/openc3/ext/config_parser/config_parser.c +3 -0
- data/ext/openc3/ext/crc/crc.c +3 -0
- data/ext/openc3/ext/openc3_io/openc3_io.c +3 -0
- data/ext/openc3/ext/packet/packet.c +3 -0
- data/ext/openc3/ext/platform/platform.c +3 -0
- data/ext/openc3/ext/polynomial_conversion/polynomial_conversion.c +3 -0
- data/ext/openc3/ext/string/string.c +3 -0
- data/ext/openc3/ext/structure/structure.c +3 -0
- data/ext/openc3/ext/tabbed_plots_config/tabbed_plots_config.c +3 -0
- data/ext/openc3/ext/telemetry/telemetry.c +3 -0
- data/lib/cosmos.rb +3 -0
- data/lib/cosmosc2.rb +3 -0
- data/lib/openc3/accessors/accessor.rb +3 -0
- data/lib/openc3/accessors/binary_accessor.rb +3 -0
- data/lib/openc3/accessors/cbor_accessor.rb +3 -0
- data/lib/openc3/accessors/html_accessor.rb +3 -0
- data/lib/openc3/accessors/json_accessor.rb +4 -1
- data/lib/openc3/accessors/xml_accessor.rb +3 -0
- data/lib/openc3/accessors.rb +3 -0
- data/lib/openc3/api/api.rb +3 -0
- data/lib/openc3/api/authorized_api.rb +3 -0
- data/lib/openc3/api/cmd_api.rb +6 -3
- data/lib/openc3/api/config_api.rb +3 -0
- data/lib/openc3/api/interface_api.rb +6 -2
- data/lib/openc3/api/limits_api.rb +54 -61
- data/lib/openc3/api/router_api.rb +6 -3
- data/lib/openc3/api/settings_api.rb +3 -0
- data/lib/openc3/api/target_api.rb +3 -0
- data/lib/openc3/api/tlm_api.rb +27 -32
- data/lib/openc3/bridge/bridge.rb +3 -0
- data/lib/openc3/bridge/bridge_config.rb +3 -0
- data/lib/openc3/bridge/bridge_interface_thread.rb +3 -0
- data/lib/openc3/bridge/bridge_router_thread.rb +3 -0
- data/lib/openc3/ccsds/ccsds_packet.rb +3 -0
- data/lib/openc3/ccsds/ccsds_parser.rb +3 -0
- data/lib/openc3/config/config_parser.rb +3 -0
- data/lib/openc3/config/meta_config_parser.rb +3 -0
- data/lib/openc3/conversions/conversion.rb +3 -0
- data/lib/openc3/conversions/generic_conversion.rb +3 -0
- data/lib/openc3/conversions/packet_time_formatted_conversion.rb +3 -0
- data/lib/openc3/conversions/packet_time_seconds_conversion.rb +3 -0
- data/lib/openc3/conversions/polynomial_conversion.rb +3 -0
- data/lib/openc3/conversions/processor_conversion.rb +3 -0
- data/lib/openc3/conversions/received_count_conversion.rb +3 -0
- data/lib/openc3/conversions/received_time_formatted_conversion.rb +3 -0
- data/lib/openc3/conversions/received_time_seconds_conversion.rb +3 -0
- data/lib/openc3/conversions/segmented_polynomial_conversion.rb +3 -0
- data/lib/openc3/conversions/unix_time_conversion.rb +3 -0
- data/lib/openc3/conversions/unix_time_formatted_conversion.rb +3 -0
- data/lib/openc3/conversions/unix_time_seconds_conversion.rb +3 -0
- data/lib/openc3/conversions.rb +3 -0
- data/lib/openc3/core_ext/array.rb +3 -0
- data/lib/openc3/core_ext/binding.rb +3 -0
- data/lib/openc3/core_ext/class.rb +3 -0
- data/lib/openc3/core_ext/exception.rb +3 -0
- data/lib/openc3/core_ext/file.rb +3 -0
- data/lib/openc3/core_ext/hash.rb +3 -0
- data/lib/openc3/core_ext/io.rb +3 -0
- data/lib/openc3/core_ext/kernel.rb +3 -0
- data/lib/openc3/core_ext/math.rb +3 -0
- data/lib/openc3/core_ext/matrix.rb +3 -0
- data/lib/openc3/core_ext/objectspace.rb +3 -0
- data/lib/openc3/core_ext/openc3_io.rb +3 -0
- data/lib/openc3/core_ext/range.rb +3 -0
- data/lib/openc3/core_ext/socket.rb +3 -0
- data/lib/openc3/core_ext/string.rb +3 -0
- data/lib/openc3/core_ext/stringio.rb +3 -0
- data/lib/openc3/core_ext/tempfile.rb +3 -0
- data/lib/openc3/core_ext/time.rb +3 -0
- data/lib/openc3/core_ext.rb +3 -0
- data/lib/openc3/interfaces/interface.rb +3 -0
- data/lib/openc3/interfaces/linc_interface.rb +3 -0
- data/lib/openc3/interfaces/protocols/burst_protocol.rb +3 -0
- data/lib/openc3/interfaces/protocols/crc_protocol.rb +3 -0
- data/lib/openc3/interfaces/protocols/fixed_protocol.rb +3 -0
- data/lib/openc3/interfaces/protocols/ignore_packet_protocol.rb +3 -0
- data/lib/openc3/interfaces/protocols/length_protocol.rb +3 -0
- data/lib/openc3/interfaces/protocols/override_protocol.rb +3 -0
- data/lib/openc3/interfaces/protocols/preidentified_protocol.rb +3 -0
- data/lib/openc3/interfaces/protocols/protocol.rb +3 -0
- data/lib/openc3/interfaces/protocols/template_protocol.rb +3 -0
- data/lib/openc3/interfaces/protocols/terminated_protocol.rb +3 -0
- data/lib/openc3/interfaces/serial_interface.rb +3 -0
- data/lib/openc3/interfaces/simulated_target_interface.rb +3 -0
- data/lib/openc3/interfaces/stream_interface.rb +3 -0
- data/lib/openc3/interfaces/tcpip_client_interface.rb +3 -0
- data/lib/openc3/interfaces/tcpip_server_interface.rb +3 -0
- data/lib/openc3/interfaces/udp_interface.rb +3 -0
- data/lib/openc3/interfaces.rb +3 -0
- data/lib/openc3/io/buffered_file.rb +3 -0
- data/lib/openc3/io/io_multiplexer.rb +8 -0
- data/lib/openc3/io/json_api_object.rb +5 -2
- data/lib/openc3/io/json_drb.rb +3 -0
- data/lib/openc3/io/json_drb_object.rb +5 -2
- data/lib/openc3/io/json_drb_rack.rb +3 -0
- data/lib/openc3/io/json_rpc.rb +8 -3
- data/lib/openc3/io/openc3_snmp.rb +3 -0
- data/lib/openc3/io/posix_serial_driver.rb +3 -0
- data/lib/openc3/io/raw_logger.rb +3 -0
- data/lib/openc3/io/raw_logger_pair.rb +3 -0
- data/lib/openc3/io/serial_driver.rb +3 -0
- data/lib/openc3/io/stderr.rb +3 -0
- data/lib/openc3/io/stdout.rb +3 -0
- data/lib/openc3/io/udp_sockets.rb +3 -0
- data/lib/openc3/io/win32_serial_driver.rb +3 -0
- data/lib/openc3/logs/buffered_packet_log_reader.rb +65 -0
- data/lib/openc3/logs/buffered_packet_log_writer.rb +120 -0
- data/lib/openc3/logs/log_writer.rb +95 -40
- data/lib/openc3/logs/packet_log_constants.rb +9 -0
- data/lib/openc3/logs/packet_log_reader.rb +34 -3
- data/lib/openc3/logs/packet_log_writer.rb +85 -18
- data/lib/openc3/logs/text_log_writer.rb +9 -5
- data/lib/openc3/logs.rb +8 -2
- data/lib/openc3/microservices/cleanup_microservice.rb +18 -18
- data/lib/openc3/microservices/decom_microservice.rb +30 -24
- data/lib/openc3/microservices/interface_microservice.rb +136 -91
- data/lib/openc3/microservices/log_microservice.rb +35 -13
- data/lib/openc3/microservices/microservice.rb +16 -14
- data/lib/openc3/microservices/plugin_microservice.rb +3 -1
- data/lib/openc3/microservices/reaction_microservice.rb +4 -1
- data/lib/openc3/microservices/reducer_microservice.rb +332 -149
- data/lib/openc3/microservices/router_microservice.rb +3 -0
- data/lib/openc3/microservices/text_log_microservice.rb +22 -7
- data/lib/openc3/microservices/timeline_microservice.rb +4 -1
- data/lib/openc3/microservices/trigger_group_microservice.rb +3 -0
- data/lib/openc3/models/activity_model.rb +3 -0
- data/lib/openc3/models/auth_model.rb +3 -0
- data/lib/openc3/models/cvt_model.rb +14 -5
- data/lib/openc3/models/environment_model.rb +3 -0
- data/lib/openc3/models/gem_model.rb +30 -51
- data/lib/openc3/models/info_model.rb +3 -0
- data/lib/openc3/models/interface_model.rb +3 -0
- data/lib/openc3/models/interface_status_model.rb +4 -1
- data/lib/openc3/models/metadata_model.rb +3 -0
- data/lib/openc3/models/metric_model.rb +3 -0
- data/lib/openc3/models/microservice_model.rb +9 -6
- data/lib/openc3/models/microservice_status_model.rb +4 -1
- data/lib/openc3/models/model.rb +3 -0
- data/lib/openc3/models/note_model.rb +3 -0
- data/lib/openc3/models/notification_model.rb +3 -0
- data/lib/openc3/models/ping_model.rb +3 -0
- data/lib/openc3/models/plugin_model.rb +20 -14
- data/lib/openc3/models/process_status_model.rb +4 -1
- data/lib/openc3/models/reaction_model.rb +3 -0
- data/lib/openc3/models/reducer_model.rb +31 -24
- data/lib/openc3/models/router_model.rb +3 -0
- data/lib/openc3/models/router_status_model.rb +3 -0
- data/lib/openc3/models/scope_model.rb +3 -4
- data/lib/openc3/models/settings_model.rb +3 -0
- data/lib/openc3/models/sorted_model.rb +3 -0
- data/lib/openc3/models/target_model.rb +61 -94
- data/lib/openc3/models/timeline_model.rb +4 -1
- data/lib/openc3/models/tool_config_model.rb +3 -0
- data/lib/openc3/models/tool_model.rb +11 -9
- data/lib/openc3/models/trigger_group_model.rb +3 -0
- data/lib/openc3/models/trigger_model.rb +3 -0
- data/lib/openc3/models/widget_model.rb +18 -11
- data/lib/openc3/operators/microservice_operator.rb +3 -0
- data/lib/openc3/operators/operator.rb +105 -34
- data/lib/openc3/packets/commands.rb +3 -0
- data/lib/openc3/packets/json_packet.rb +87 -14
- data/lib/openc3/packets/limits.rb +4 -1
- data/lib/openc3/packets/limits_response.rb +3 -0
- data/lib/openc3/packets/packet.rb +5 -1
- data/lib/openc3/packets/packet_config.rb +3 -0
- data/lib/openc3/packets/packet_item.rb +9 -3
- data/lib/openc3/packets/packet_item_limits.rb +3 -0
- data/lib/openc3/packets/parsers/format_string_parser.rb +3 -0
- data/lib/openc3/packets/parsers/limits_parser.rb +3 -0
- data/lib/openc3/packets/parsers/limits_response_parser.rb +3 -0
- data/lib/openc3/packets/parsers/packet_item_parser.rb +3 -0
- data/lib/openc3/packets/parsers/packet_parser.rb +3 -0
- data/lib/openc3/packets/parsers/processor_parser.rb +3 -0
- data/lib/openc3/packets/parsers/state_parser.rb +3 -0
- data/lib/openc3/packets/parsers/xtce_converter.rb +3 -0
- data/lib/openc3/packets/parsers/xtce_parser.rb +3 -0
- data/lib/openc3/packets/structure.rb +3 -0
- data/lib/openc3/packets/structure_item.rb +3 -0
- data/lib/openc3/packets/telemetry.rb +3 -0
- data/lib/openc3/processors/processor.rb +3 -0
- data/lib/openc3/processors/statistics_processor.rb +3 -0
- data/lib/openc3/processors/watermark_processor.rb +3 -0
- data/lib/openc3/processors.rb +3 -0
- data/lib/openc3/script/api_shared.rb +35 -6
- data/lib/openc3/script/calendar.rb +3 -0
- data/lib/openc3/script/commands.rb +3 -0
- data/lib/openc3/script/exceptions.rb +3 -0
- data/lib/openc3/script/extract.rb +3 -0
- data/lib/openc3/script/limits.rb +3 -24
- data/lib/openc3/script/script.rb +11 -7
- data/lib/openc3/script/script_runner.rb +3 -0
- data/lib/openc3/script/storage.rb +33 -16
- data/lib/openc3/script/suite.rb +3 -0
- data/lib/openc3/script/suite_results.rb +3 -0
- data/lib/openc3/script/suite_runner.rb +3 -0
- data/lib/openc3/script/telemetry.rb +43 -0
- data/lib/openc3/script.rb +3 -0
- data/lib/openc3/streams/serial_stream.rb +3 -0
- data/lib/openc3/streams/stream.rb +3 -0
- data/lib/openc3/streams/tcpip_client_stream.rb +3 -0
- data/lib/openc3/streams/tcpip_socket_stream.rb +3 -0
- data/lib/openc3/system/system.rb +23 -10
- data/lib/openc3/system/system_config.rb +3 -0
- data/lib/openc3/system/target.rb +3 -0
- data/lib/openc3/system.rb +3 -0
- data/lib/openc3/tools/cmd_tlm_server/api.rb +3 -0
- data/lib/openc3/tools/cmd_tlm_server/cmd_tlm_server_config.rb +3 -0
- data/lib/openc3/tools/cmd_tlm_server/interface_thread.rb +3 -0
- data/lib/openc3/tools/table_manager/table.rb +3 -0
- data/lib/openc3/tools/table_manager/table_config.rb +3 -0
- data/lib/openc3/tools/table_manager/table_item.rb +3 -0
- data/lib/openc3/tools/table_manager/table_item_parser.rb +3 -0
- data/lib/openc3/tools/table_manager/table_manager_core.rb +3 -0
- data/lib/openc3/tools/table_manager/table_parser.rb +3 -0
- data/lib/openc3/tools/test_runner/test.rb +3 -0
- data/lib/openc3/top_level.rb +3 -0
- data/lib/openc3/topics/autonomic_topic.rb +3 -0
- data/lib/openc3/topics/calendar_topic.rb +3 -0
- data/lib/openc3/topics/command_decom_topic.rb +4 -1
- data/lib/openc3/topics/command_topic.rb +6 -1
- data/lib/openc3/topics/config_topic.rb +3 -0
- data/lib/openc3/topics/interface_topic.rb +9 -2
- data/lib/openc3/topics/limits_event_topic.rb +144 -10
- data/lib/openc3/topics/notifications_topic.rb +3 -0
- data/lib/openc3/topics/router_topic.rb +10 -3
- data/lib/openc3/topics/telemetry_decom_topic.rb +26 -20
- data/lib/openc3/topics/telemetry_reduced_topics.rb +92 -0
- data/lib/openc3/topics/telemetry_topic.rb +5 -2
- data/lib/openc3/topics/timeline_topic.rb +3 -0
- data/lib/openc3/topics/topic.rb +3 -0
- data/lib/openc3/utilities/authentication.rb +3 -0
- data/lib/openc3/utilities/authorization.rb +3 -0
- data/lib/openc3/utilities/aws_bucket.rb +199 -0
- data/lib/openc3/utilities/bucket.rb +82 -0
- data/lib/openc3/utilities/bucket_file_cache.rb +264 -0
- data/lib/openc3/utilities/bucket_utilities.rb +109 -0
- data/lib/openc3/utilities/crc.rb +3 -0
- data/lib/openc3/utilities/csv.rb +3 -0
- data/lib/openc3/utilities/local_bucket.rb +28 -0
- data/lib/openc3/utilities/local_mode.rb +47 -61
- data/lib/openc3/utilities/logger.rb +7 -1
- data/lib/openc3/utilities/message_log.rb +7 -4
- data/lib/openc3/utilities/metric.rb +4 -1
- data/lib/openc3/utilities/open_telemetry.rb +96 -0
- data/lib/openc3/utilities/process_manager.rb +3 -0
- data/lib/openc3/utilities/quaternion.rb +3 -0
- data/lib/openc3/utilities/ruby_lex_utils.rb +3 -0
- data/lib/openc3/utilities/s3_autoload.rb +3 -3
- data/lib/openc3/utilities/simulated_target.rb +3 -0
- data/lib/openc3/utilities/sleeper.rb +3 -0
- data/lib/openc3/utilities/store.rb +3 -0
- data/lib/openc3/utilities/store_autoload.rb +30 -23
- data/lib/openc3/utilities/target_file.rb +70 -83
- data/lib/openc3/utilities/zip.rb +3 -0
- data/lib/openc3/utilities.rb +3 -0
- data/lib/openc3/version.rb +6 -6
- data/lib/openc3/win32/excel.rb +3 -0
- data/lib/openc3/win32/win32.rb +3 -0
- data/lib/openc3/win32/win32_main.rb +3 -0
- data/lib/openc3.rb +3 -0
- data/tasks/gemfile_stats.rake +3 -0
- data/tasks/spec.rake +3 -0
- data/templates/plugin-template/plugin.gemspec +1 -1
- metadata +112 -6
- data/lib/openc3/utilities/s3.rb +0 -220
- data/lib/openc3/utilities/s3_file_cache.rb +0 -274
@@ -16,6 +16,9 @@
|
|
16
16
|
# Modified by OpenC3, Inc.
|
17
17
|
# All changes Copyright 2022, OpenC3, Inc.
|
18
18
|
# All Rights Reserved
|
19
|
+
#
|
20
|
+
# This file may also be used under the terms of a commercial license
|
21
|
+
# if purchased from OpenC3, Inc.
|
19
22
|
|
20
23
|
require 'openc3/utilities/authentication'
|
21
24
|
require 'openc3/microservices/microservice'
|
@@ -97,7 +100,7 @@ module OpenC3
|
|
97
100
|
'timeline' => @timeline_name,
|
98
101
|
'id' => activity.start
|
99
102
|
})
|
100
|
-
hostname = ENV['OPENC3_SCRIPT_HOSTNAME'] || 'openc3-script-runner-api'
|
103
|
+
hostname = ENV['OPENC3_SCRIPT_HOSTNAME'] || 'openc3-cosmos-script-runner-api'
|
101
104
|
response = Net::HTTP.new(hostname, 2902).request(request)
|
102
105
|
raise "failed to call #{hostname}, for script: #{activity.data['script']}, response code: #{response.code}" if response.code != '200'
|
103
106
|
|
@@ -16,6 +16,9 @@
|
|
16
16
|
# Modified by OpenC3, Inc.
|
17
17
|
# All changes Copyright 2022, OpenC3, Inc.
|
18
18
|
# All Rights Reserved
|
19
|
+
#
|
20
|
+
# This file may also be used under the terms of a commercial license
|
21
|
+
# if purchased from OpenC3, Inc.
|
19
22
|
|
20
23
|
require 'openc3/microservices/microservice'
|
21
24
|
require 'openc3/models/notification_model'
|
@@ -16,6 +16,9 @@
|
|
16
16
|
# Modified by OpenC3, Inc.
|
17
17
|
# All changes Copyright 2022, OpenC3, Inc.
|
18
18
|
# All Rights Reserved
|
19
|
+
#
|
20
|
+
# This file may also be used under the terms of a commercial license
|
21
|
+
# if purchased from OpenC3, Inc.
|
19
22
|
|
20
23
|
# https://www.rubydoc.info/gems/redis/Redis/Commands/SortedSets
|
21
24
|
|
@@ -16,6 +16,9 @@
|
|
16
16
|
# Modified by OpenC3, Inc.
|
17
17
|
# All changes Copyright 2022, OpenC3, Inc.
|
18
18
|
# All Rights Reserved
|
19
|
+
#
|
20
|
+
# This file may also be used under the terms of a commercial license
|
21
|
+
# if purchased from OpenC3, Inc.
|
19
22
|
|
20
23
|
require 'digest'
|
21
24
|
require 'openc3/utilities/store'
|
@@ -16,6 +16,9 @@
|
|
16
16
|
# Modified by OpenC3, Inc.
|
17
17
|
# All changes Copyright 2022, OpenC3, Inc.
|
18
18
|
# All Rights Reserved
|
19
|
+
#
|
20
|
+
# This file may also be used under the terms of a commercial license
|
21
|
+
# if purchased from OpenC3, Inc.
|
19
22
|
|
20
23
|
require 'openc3/utilities/store'
|
21
24
|
|
@@ -87,8 +90,10 @@ module OpenC3
|
|
87
90
|
# Return all item values and limit state from the CVT
|
88
91
|
#
|
89
92
|
# @param items [Array<String>] Items to return. Must be formatted as TGT__PKT__ITEM__TYPE
|
93
|
+
# @param stale_time [Integer] Time in seconds from Time.now that value will be marked stale
|
90
94
|
# @return [Array] Array of values
|
91
|
-
def self.get_tlm_values(items, scope: $openc3_scope)
|
95
|
+
def self.get_tlm_values(items, stale_time: 30, scope: $openc3_scope)
|
96
|
+
now = Time.now.to_f
|
92
97
|
results = []
|
93
98
|
lookups = []
|
94
99
|
packet_lookup = {}
|
@@ -109,10 +114,14 @@ module OpenC3
|
|
109
114
|
end
|
110
115
|
# If we were able to find a value, try to get the limits state
|
111
116
|
if item_result[0]
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
117
|
+
if now - hash['RECEIVED_TIMESECONDS'] > stale_time
|
118
|
+
item_result[1] = :STALE
|
119
|
+
else
|
120
|
+
# The last key is simply the name (RAW) so we can append __L
|
121
|
+
# If there is no limits then it returns nil which is acceptable
|
122
|
+
item_result[1] = hash["#{packet_values[-1]}__L"]
|
123
|
+
item_result[1] = item_result[1].intern if item_result[1] # Convert to symbol
|
124
|
+
end
|
116
125
|
else
|
117
126
|
raise "Item '#{target_name} #{packet_name} #{packet_values[-1]}' does not exist" unless hash.key?(packet_values[-1])
|
118
127
|
item_result[1] = nil
|
@@ -16,16 +16,19 @@
|
|
16
16
|
# Modified by OpenC3, Inc.
|
17
17
|
# All changes Copyright 2022, OpenC3, Inc.
|
18
18
|
# All Rights Reserved
|
19
|
+
#
|
20
|
+
# This file may also be used under the terms of a commercial license
|
21
|
+
# if purchased from OpenC3, Inc.
|
19
22
|
|
23
|
+
require 'fileutils'
|
20
24
|
require 'open-uri'
|
21
25
|
require 'nokogiri'
|
22
26
|
require 'httpclient'
|
23
27
|
require 'rubygems'
|
24
28
|
require 'rubygems/uninstaller'
|
25
29
|
require 'tempfile'
|
26
|
-
require 'openc3/utilities/s3'
|
27
30
|
require 'openc3/utilities/process_manager'
|
28
|
-
require
|
31
|
+
require "pathname"
|
29
32
|
|
30
33
|
module OpenC3
|
31
34
|
# This class acts like a Model but doesn't inherit from Model because it doesn't
|
@@ -33,36 +36,25 @@ module OpenC3
|
|
33
36
|
# and destroy to allow interaction with gem files from the PluginModel and
|
34
37
|
# the GemsController.
|
35
38
|
class GemModel
|
36
|
-
extend Api
|
37
|
-
|
38
|
-
@@bucket_initialized = false
|
39
|
-
|
40
39
|
def self.names
|
41
|
-
|
42
|
-
|
43
|
-
rubys3_client.list_objects(bucket: 'gems').contents.each do |object|
|
44
|
-
gems << object.key
|
45
|
-
end
|
46
|
-
gems
|
40
|
+
result = Pathname.new("#{ENV['GEM_HOME']}/gems").children.select { |c| c.directory? }.collect { |p| File.basename(p) + '.gem' }
|
41
|
+
return result.sort
|
47
42
|
end
|
48
43
|
|
49
|
-
def self.get(
|
50
|
-
|
51
|
-
path
|
52
|
-
|
53
|
-
return path
|
44
|
+
def self.get(name)
|
45
|
+
path = "#{ENV['GEM_HOME']}/cache/#{name}"
|
46
|
+
return path if File.exist?(path)
|
47
|
+
raise "Gem #{name} not found"
|
54
48
|
end
|
55
49
|
|
56
50
|
def self.put(gem_file_path, gem_install: true, scope:)
|
57
|
-
rubys3_client = initialize_bucket()
|
58
51
|
if File.file?(gem_file_path)
|
59
52
|
gem_filename = File.basename(gem_file_path)
|
60
|
-
|
61
|
-
|
62
|
-
rubys3_client.put_object(bucket: 'gems', key: gem_filename, body: file)
|
63
|
-
end
|
53
|
+
FileUtils.mkdir_p("#{ENV['GEM_HOME']}/cache") unless Dir.exist?("#{ENV['GEM_HOME']}/cache")
|
54
|
+
FileUtils.cp(gem_file_path, "#{ENV['GEM_HOME']}/cache/#{File.basename(gem_file_path)}")
|
64
55
|
if gem_install
|
65
|
-
|
56
|
+
Logger.info "Installing gem: #{gem_filename}"
|
57
|
+
result = OpenC3::ProcessManager.instance.spawn(["ruby", "/openc3/bin/openc3cli", "geminstall", gem_filename, scope], "gem_install", gem_filename, Time.now + 3600.0, scope: scope)
|
66
58
|
return result
|
67
59
|
end
|
68
60
|
else
|
@@ -74,12 +66,11 @@ module OpenC3
|
|
74
66
|
end
|
75
67
|
|
76
68
|
def self.install(name_or_path, scope:)
|
77
|
-
temp_dir = Dir.mktmpdir
|
78
69
|
begin
|
79
70
|
if File.exist?(name_or_path)
|
80
71
|
gem_file_path = name_or_path
|
81
72
|
else
|
82
|
-
gem_file_path = get(
|
73
|
+
gem_file_path = get(name_or_path)
|
83
74
|
end
|
84
75
|
begin
|
85
76
|
rubygems_url = get_setting('rubygems_url', scope: scope)
|
@@ -92,46 +83,34 @@ module OpenC3
|
|
92
83
|
Gem.done_installing_hooks.clear
|
93
84
|
Gem.install(gem_file_path, "> 0.pre", :build_args => ['--no-document'], :prerelease => true)
|
94
85
|
rescue => err
|
95
|
-
message = "Gem file #{gem_file_path} error installing to
|
86
|
+
message = "Gem file #{gem_file_path} error installing to #{ENV['GEM_HOME']}\n#{err.formatted}"
|
96
87
|
Logger.error message
|
97
|
-
|
98
|
-
FileUtils.remove_entry(temp_dir) if temp_dir and File.exist?(temp_dir)
|
88
|
+
raise err
|
99
89
|
end
|
100
90
|
end
|
101
91
|
|
102
92
|
def self.destroy(name)
|
103
|
-
rubys3_client = initialize_bucket()
|
104
|
-
Logger.info "Removing gem: #{name}"
|
105
|
-
rubys3_client.delete_object(bucket: 'gems', key: name)
|
106
93
|
gem_name, version = self.extract_name_and_version(name)
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
message = "Gem file #{name} error uninstalling\n#{err.formatted}"
|
94
|
+
plugin_gem_names = PluginModel.gem_names
|
95
|
+
if plugin_gem_names.include?(name)
|
96
|
+
message = "Gem file #{name} can't be uninstalled because needed by installed plugin"
|
111
97
|
Logger.error message
|
98
|
+
raise message
|
99
|
+
else
|
100
|
+
begin
|
101
|
+
Gem::Uninstaller.new(gem_name, {:version => version, :force => true}).uninstall
|
102
|
+
rescue => err
|
103
|
+
Logger.error "Gem file #{name} error uninstalling\n#{err.formatted}"
|
104
|
+
raise err
|
105
|
+
end
|
112
106
|
end
|
113
107
|
end
|
114
108
|
|
115
109
|
def self.extract_name_and_version(name)
|
116
110
|
split_name = name.split('-')
|
117
111
|
gem_name = split_name[0..-2].join('-')
|
118
|
-
version = split_name[-1]
|
112
|
+
version = File.basename(split_name[-1], '.gem')
|
119
113
|
return gem_name, version
|
120
114
|
end
|
121
|
-
|
122
|
-
# private
|
123
|
-
|
124
|
-
def self.initialize_bucket
|
125
|
-
rubys3_client = Aws::S3::Client.new
|
126
|
-
unless @@bucket_initialized
|
127
|
-
begin
|
128
|
-
rubys3_client.head_bucket(bucket: 'gems')
|
129
|
-
rescue Aws::S3::Errors::NotFound
|
130
|
-
rubys3_client.create_bucket(bucket: 'gems')
|
131
|
-
end
|
132
|
-
@@bucket_initialized = true
|
133
|
-
end
|
134
|
-
return rubys3_client
|
135
|
-
end
|
136
115
|
end
|
137
116
|
end
|
@@ -16,6 +16,9 @@
|
|
16
16
|
# Modified by OpenC3, Inc.
|
17
17
|
# All changes Copyright 2022, OpenC3, Inc.
|
18
18
|
# All Rights Reserved
|
19
|
+
#
|
20
|
+
# This file may also be used under the terms of a commercial license
|
21
|
+
# if purchased from OpenC3, Inc.
|
19
22
|
|
20
23
|
require 'openc3/models/model'
|
21
24
|
require 'openc3/models/microservice_model'
|
@@ -16,6 +16,9 @@
|
|
16
16
|
# Modified by OpenC3, Inc.
|
17
17
|
# All changes Copyright 2022, OpenC3, Inc.
|
18
18
|
# All Rights Reserved
|
19
|
+
#
|
20
|
+
# This file may also be used under the terms of a commercial license
|
21
|
+
# if purchased from OpenC3, Inc.
|
19
22
|
|
20
23
|
require 'openc3/models/model'
|
21
24
|
|
@@ -23,7 +26,7 @@ module OpenC3
|
|
23
26
|
# Stores the status about an interface. This class also implements logic
|
24
27
|
# to handle status for a router since the functionality is identical
|
25
28
|
# (only difference is the Redis key used).
|
26
|
-
class InterfaceStatusModel <
|
29
|
+
class InterfaceStatusModel < Model
|
27
30
|
INTERFACES_PRIMARY_KEY = 'openc3_interface_status'
|
28
31
|
ROUTERS_PRIMARY_KEY = 'openc3_router_status'
|
29
32
|
|
@@ -16,6 +16,9 @@
|
|
16
16
|
# Modified by OpenC3, Inc.
|
17
17
|
# All changes Copyright 2022, OpenC3, Inc.
|
18
18
|
# All Rights Reserved
|
19
|
+
#
|
20
|
+
# This file may also be used under the terms of a commercial license
|
21
|
+
# if purchased from OpenC3, Inc.
|
19
22
|
|
20
23
|
# https://www.rubydoc.info/gems/redis/Redis/Commands/SortedSets
|
21
24
|
|
@@ -16,10 +16,13 @@
|
|
16
16
|
# Modified by OpenC3, Inc.
|
17
17
|
# All changes Copyright 2022, OpenC3, Inc.
|
18
18
|
# All Rights Reserved
|
19
|
+
#
|
20
|
+
# This file may also be used under the terms of a commercial license
|
21
|
+
# if purchased from OpenC3, Inc.
|
19
22
|
|
20
23
|
require 'openc3/top_level'
|
21
24
|
require 'openc3/models/model'
|
22
|
-
require 'openc3/utilities/
|
25
|
+
require 'openc3/utilities/bucket'
|
23
26
|
|
24
27
|
module OpenC3
|
25
28
|
class MicroserviceModel < Model
|
@@ -76,7 +79,7 @@ module OpenC3
|
|
76
79
|
end
|
77
80
|
end
|
78
81
|
|
79
|
-
# Create a microservice model to be deployed to
|
82
|
+
# Create a microservice model to be deployed to bucket storage
|
80
83
|
def initialize(
|
81
84
|
name:,
|
82
85
|
folder_name: nil,
|
@@ -112,6 +115,7 @@ module OpenC3
|
|
112
115
|
@options = options
|
113
116
|
@container = container
|
114
117
|
@needs_dependencies = needs_dependencies
|
118
|
+
@bucket = Bucket.getClient()
|
115
119
|
end
|
116
120
|
|
117
121
|
def as_json(*a)
|
@@ -220,17 +224,16 @@ module OpenC3
|
|
220
224
|
data = ERB.new(data, trim_mode: "-").result(binding.set_variables(variables)) if data.is_printable?
|
221
225
|
end
|
222
226
|
unless validate_only
|
223
|
-
|
227
|
+
@bucket.put_object(bucket: ENV['OPENC3_CONFIG_BUCKET'], key: key, body: data)
|
224
228
|
ConfigTopic.write({ kind: 'created', type: 'microservice', name: @name, plugin: @plugin }, scope: @scope)
|
225
229
|
end
|
226
230
|
end
|
227
231
|
end
|
228
232
|
|
229
233
|
def undeploy
|
230
|
-
rubys3_client = Aws::S3::Client.new
|
231
234
|
prefix = "#{@scope}/microservices/#{@name}/"
|
232
|
-
|
233
|
-
|
235
|
+
@bucket.list_objects(bucket: ENV['OPENC3_CONFIG_BUCKET'], prefix: prefix).each do |object|
|
236
|
+
@bucket.delete_object(bucket: ENV['OPENC3_CONFIG_BUCKET'], key: object.key)
|
234
237
|
end
|
235
238
|
ConfigTopic.write({ kind: 'deleted', type: 'microservice', name: @name, plugin: @plugin }, scope: @scope)
|
236
239
|
end
|
@@ -16,11 +16,14 @@
|
|
16
16
|
# Modified by OpenC3, Inc.
|
17
17
|
# All changes Copyright 2022, OpenC3, Inc.
|
18
18
|
# All Rights Reserved
|
19
|
+
#
|
20
|
+
# This file may also be used under the terms of a commercial license
|
21
|
+
# if purchased from OpenC3, Inc.
|
19
22
|
|
20
23
|
require 'openc3/models/model'
|
21
24
|
|
22
25
|
module OpenC3
|
23
|
-
class MicroserviceStatusModel <
|
26
|
+
class MicroserviceStatusModel < Model
|
24
27
|
PRIMARY_KEY = 'openc3_microservice_status'
|
25
28
|
|
26
29
|
attr_accessor :state
|
data/lib/openc3/models/model.rb
CHANGED
@@ -16,6 +16,9 @@
|
|
16
16
|
# Modified by OpenC3, Inc.
|
17
17
|
# All changes Copyright 2022, OpenC3, Inc.
|
18
18
|
# All Rights Reserved
|
19
|
+
#
|
20
|
+
# This file may also be used under the terms of a commercial license
|
21
|
+
# if purchased from OpenC3, Inc.
|
19
22
|
|
20
23
|
require 'openc3/utilities/store'
|
21
24
|
require 'openc3/config/config_parser'
|
@@ -16,6 +16,9 @@
|
|
16
16
|
# Modified by OpenC3, Inc.
|
17
17
|
# All changes Copyright 2022, OpenC3, Inc.
|
18
18
|
# All Rights Reserved
|
19
|
+
#
|
20
|
+
# This file may also be used under the terms of a commercial license
|
21
|
+
# if purchased from OpenC3, Inc.
|
19
22
|
|
20
23
|
# https://www.rubydoc.info/gems/redis/Redis/Commands/SortedSets
|
21
24
|
|
@@ -16,6 +16,9 @@
|
|
16
16
|
# Modified by OpenC3, Inc.
|
17
17
|
# All changes Copyright 2022, OpenC3, Inc.
|
18
18
|
# All Rights Reserved
|
19
|
+
#
|
20
|
+
# This file may also be used under the terms of a commercial license
|
21
|
+
# if purchased from OpenC3, Inc.
|
19
22
|
|
20
23
|
module OpenC3
|
21
24
|
class NotificationModel
|
@@ -16,11 +16,14 @@
|
|
16
16
|
# Modified by OpenC3, Inc.
|
17
17
|
# All changes Copyright 2022, OpenC3, Inc.
|
18
18
|
# All Rights Reserved
|
19
|
+
#
|
20
|
+
# This file may also be used under the terms of a commercial license
|
21
|
+
# if purchased from OpenC3, Inc.
|
19
22
|
|
20
23
|
require 'rubygems'
|
21
24
|
require 'rubygems/package'
|
22
25
|
require 'openc3'
|
23
|
-
require 'openc3/utilities/
|
26
|
+
require 'openc3/utilities/bucket'
|
24
27
|
require 'openc3/utilities/store'
|
25
28
|
require 'openc3/config/config_parser'
|
26
29
|
require 'openc3/models/model'
|
@@ -45,7 +48,6 @@ module OpenC3
|
|
45
48
|
attr_accessor :plugin_txt_lines
|
46
49
|
attr_accessor :needs_dependencies
|
47
50
|
|
48
|
-
|
49
51
|
# NOTE: The following three class methods are used by the ModelController
|
50
52
|
# and are reimplemented to enable various Model class methods to work
|
51
53
|
def self.get(name:, scope: nil)
|
@@ -72,7 +74,7 @@ module OpenC3
|
|
72
74
|
# Load gem to internal gem server
|
73
75
|
OpenC3::GemModel.put(gem_file_path, gem_install: false, scope: scope) unless validate_only
|
74
76
|
else
|
75
|
-
gem_file_path = OpenC3::GemModel.get(
|
77
|
+
gem_file_path = OpenC3::GemModel.get(gem_name)
|
76
78
|
end
|
77
79
|
|
78
80
|
# Extract gem and process plugin.txt to determine what VARIABLEs need to be filled in
|
@@ -133,16 +135,6 @@ module OpenC3
|
|
133
135
|
# Because this uses ERB it must be run in a seperate process from the API to
|
134
136
|
# prevent corruption and single require problems in the current proces
|
135
137
|
def self.install_phase2(plugin_hash, scope:, gem_file_path: nil, validate_only: false)
|
136
|
-
# Ensure config bucket exists
|
137
|
-
unless validate_only
|
138
|
-
rubys3_client = Aws::S3::Client.new
|
139
|
-
begin
|
140
|
-
rubys3_client.head_bucket(bucket: 'config')
|
141
|
-
rescue Aws::S3::Errors::NotFound
|
142
|
-
rubys3_client.create_bucket(bucket: 'config')
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
138
|
# Register plugin to aid in uninstall if install fails
|
147
139
|
plugin_hash.delete("existing_plugin_txt_lines")
|
148
140
|
plugin_model = PluginModel.new(**(plugin_hash.transform_keys(&:to_sym)), scope: scope)
|
@@ -155,7 +147,7 @@ module OpenC3
|
|
155
147
|
# Get the gem from local gem server if it hasn't been passed
|
156
148
|
unless gem_file_path
|
157
149
|
gem_name = plugin_hash['name'].split("__")[0]
|
158
|
-
gem_file_path = OpenC3::GemModel.get(
|
150
|
+
gem_file_path = OpenC3::GemModel.get(gem_name)
|
159
151
|
end
|
160
152
|
|
161
153
|
# Actually install the gem now (slow)
|
@@ -290,5 +282,19 @@ module OpenC3
|
|
290
282
|
OpenC3::PluginModel.install_phase2(plugin_hash, scope: @scope)
|
291
283
|
@destroyed = false
|
292
284
|
end
|
285
|
+
|
286
|
+
# Get list of plugin gem names across all scopes to prevent uninstall of gems from GemModel
|
287
|
+
def self.gem_names
|
288
|
+
result = []
|
289
|
+
scopes = ScopeModel.names
|
290
|
+
scopes.each do |scope|
|
291
|
+
plugin_names = self.names(scope: scope)
|
292
|
+
plugin_names.each do |plugin_name|
|
293
|
+
gem_name = plugin_name.split("__")[0]
|
294
|
+
result << gem_name unless result.include?(gem_name)
|
295
|
+
end
|
296
|
+
end
|
297
|
+
return result.sort
|
298
|
+
end
|
293
299
|
end
|
294
300
|
end
|
@@ -16,12 +16,15 @@
|
|
16
16
|
# Modified by OpenC3, Inc.
|
17
17
|
# All changes Copyright 2022, OpenC3, Inc.
|
18
18
|
# All Rights Reserved
|
19
|
+
#
|
20
|
+
# This file may also be used under the terms of a commercial license
|
21
|
+
# if purchased from OpenC3, Inc.
|
19
22
|
|
20
23
|
require 'openc3/models/model'
|
21
24
|
|
22
25
|
module OpenC3
|
23
26
|
# Stores the status about an process.
|
24
|
-
class ProcessStatusModel <
|
27
|
+
class ProcessStatusModel < Model
|
25
28
|
PRIMARY_KEY = 'openc3_process_status'
|
26
29
|
|
27
30
|
attr_accessor :state
|
@@ -16,6 +16,9 @@
|
|
16
16
|
# Modified by OpenC3, Inc.
|
17
17
|
# All changes Copyright 2022, OpenC3, Inc.
|
18
18
|
# All Rights Reserved
|
19
|
+
#
|
20
|
+
# This file may also be used under the terms of a commercial license
|
21
|
+
# if purchased from OpenC3, Inc.
|
19
22
|
|
20
23
|
require 'openc3/models/model'
|
21
24
|
require 'openc3/models/trigger_model'
|
@@ -16,45 +16,52 @@
|
|
16
16
|
# Modified by OpenC3, Inc.
|
17
17
|
# All changes Copyright 2022, OpenC3, Inc.
|
18
18
|
# All Rights Reserved
|
19
|
+
#
|
20
|
+
# This file may also be used under the terms of a commercial license
|
21
|
+
# if purchased from OpenC3, Inc.
|
19
22
|
|
20
23
|
require 'openc3/utilities/store'
|
21
24
|
|
22
25
|
module OpenC3
|
23
|
-
# Tracks the files which are being stored in
|
26
|
+
# Tracks the files which are being stored in buckets for data reduction purposes.
|
24
27
|
# Files are stored in a Redis set by spliting their filenames and storing in
|
25
28
|
# a set named SCOPE__TARGET__reducer__TYPE, e.g. DEFAULT__INST__reducer__decom
|
26
29
|
# Where TYPE can be 'decom', 'minute', or 'hour'. 'day' is not necessary because
|
27
30
|
# day is the final reduction state. As files are reduced they are removed from
|
28
31
|
# the set. Thus the sets contain the active set of files to be reduced.
|
29
32
|
class ReducerModel
|
30
|
-
def self.add_file(
|
31
|
-
#
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
33
|
+
def self.add_file(bucket_key)
|
34
|
+
# Only reduce tlm files
|
35
|
+
bucket_key_split = bucket_key.split('/')
|
36
|
+
if bucket_key_split[2] == 'tlm'
|
37
|
+
# bucket_key is formatted like STARTTIME__ENDTIME__SCOPE__TARGET__PACKET__TYPE.bin
|
38
|
+
# e.g. 20211229191610578229500__20211229192610563836500__DEFAULT__INST__HEALTH_STATUS__rt__decom.bin
|
39
|
+
_, _, scope, target, _ = File.basename(bucket_key).split('__')
|
40
|
+
case bucket_key
|
41
|
+
when /__decom\.bin.gz$/
|
42
|
+
Store.sadd("#{scope}__#{target}__reducer__decom", bucket_key)
|
43
|
+
when /__reduced_minute\.bin.gz$/
|
44
|
+
Store.sadd("#{scope}__#{target}__reducer__minute", bucket_key)
|
45
|
+
when /__reduced_hour\.bin.gz$/
|
46
|
+
Store.sadd("#{scope}__#{target}__reducer__hour", bucket_key)
|
47
|
+
end
|
48
|
+
# No else clause because add_file is called with raw files which are ignored
|
41
49
|
end
|
42
|
-
# No else clause because add_file is called with raw files which are ignored
|
43
50
|
end
|
44
51
|
|
45
|
-
def self.rm_file(
|
46
|
-
_, _, scope, target, _ =
|
47
|
-
case
|
48
|
-
when /__decom\.bin$/
|
49
|
-
Store.srem("#{scope}__#{target}__reducer__decom",
|
50
|
-
when /
|
51
|
-
Store.srem("#{scope}__#{target}__reducer__minute",
|
52
|
-
when /
|
53
|
-
Store.srem("#{scope}__#{target}__reducer__hour",
|
52
|
+
def self.rm_file(bucket_key)
|
53
|
+
_, _, scope, target, _ = bucket_key.split('__')
|
54
|
+
case bucket_key
|
55
|
+
when /__decom\.bin.gz$/
|
56
|
+
Store.srem("#{scope}__#{target}__reducer__decom", bucket_key)
|
57
|
+
when /__reduced_minute\.bin.gz$/
|
58
|
+
Store.srem("#{scope}__#{target}__reducer__minute", bucket_key)
|
59
|
+
when /__reduced_hour\.bin.gz$/
|
60
|
+
Store.srem("#{scope}__#{target}__reducer__hour", bucket_key)
|
54
61
|
else
|
55
62
|
# We should only remove files that were previously in the set
|
56
|
-
# Thus if we don't match the
|
57
|
-
raise "Unknown file #{
|
63
|
+
# Thus if we don't match the bucket_key it is an error
|
64
|
+
raise "Unknown file #{bucket_key}"
|
58
65
|
end
|
59
66
|
end
|
60
67
|
|
@@ -16,6 +16,9 @@
|
|
16
16
|
# Modified by OpenC3, Inc.
|
17
17
|
# All changes Copyright 2022, OpenC3, Inc.
|
18
18
|
# All Rights Reserved
|
19
|
+
#
|
20
|
+
# This file may also be used under the terms of a commercial license
|
21
|
+
# if purchased from OpenC3, Inc.
|
19
22
|
|
20
23
|
require 'openc3/models/interface_model'
|
21
24
|
|
@@ -16,6 +16,9 @@
|
|
16
16
|
# Modified by OpenC3, Inc.
|
17
17
|
# All changes Copyright 2022, OpenC3, Inc.
|
18
18
|
# All Rights Reserved
|
19
|
+
#
|
20
|
+
# This file may also be used under the terms of a commercial license
|
21
|
+
# if purchased from OpenC3, Inc.
|
19
22
|
|
20
23
|
require 'openc3/models/interface_status_model'
|
21
24
|
|
@@ -16,6 +16,9 @@
|
|
16
16
|
# Modified by OpenC3, Inc.
|
17
17
|
# All changes Copyright 2022, OpenC3, Inc.
|
18
18
|
# All Rights Reserved
|
19
|
+
#
|
20
|
+
# This file may also be used under the terms of a commercial license
|
21
|
+
# if purchased from OpenC3, Inc.
|
19
22
|
|
20
23
|
require 'openc3/version'
|
21
24
|
require 'openc3/models/model'
|
@@ -185,9 +188,5 @@ module OpenC3
|
|
185
188
|
setting = SettingsModel.get(name: 'source_url')
|
186
189
|
SettingsModel.set({ name: 'source_url', data: 'https://github.com/OpenC3/openc3' }, scope: @scope) unless setting
|
187
190
|
end
|
188
|
-
|
189
|
-
def self.limits_set(scope:)
|
190
|
-
Store.hget("#{scope}__openc3_system", 'limits_set').intern
|
191
|
-
end
|
192
191
|
end
|
193
192
|
end
|