openc3 5.0.10 → 5.1.0
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 +16 -5
- 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 +4 -0
- data/lib/openc3/interfaces/interface.rb +4 -1
- 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 +3 -0
- 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 +118 -0
- data/lib/openc3/logs/log_writer.rb +94 -41
- 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 -20
- 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 +5 -2
- 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 -1
- 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 +8 -5
- 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 +34 -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 +9 -4
- 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 +54 -62
- 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 +8 -6
- 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 +89 -63
- 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 -218
- data/lib/openc3/utilities/s3_file_cache.rb +0 -274
@@ -12,36 +12,39 @@
|
|
12
12
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
13
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
14
|
# GNU Affero General Public License for more details.
|
15
|
+
#
|
16
|
+
# This file may also be used under the terms of a commercial license
|
17
|
+
# if purchased from OpenC3, Inc.
|
15
18
|
|
16
19
|
require 'fileutils'
|
17
20
|
require 'json'
|
18
21
|
require 'openc3/core_ext/file'
|
19
22
|
# require 'openc3/models/gem_model' # These are used but also create circular dependency
|
20
23
|
# require 'openc3/models/plugin_model' # These are used but also create circular dependency
|
21
|
-
require 'openc3/utilities/
|
24
|
+
require 'openc3/utilities/bucket'
|
22
25
|
|
23
26
|
module OpenC3
|
24
27
|
module LocalMode
|
25
28
|
OPENC3_LOCAL_MODE_PATH = ENV['OPENC3_LOCAL_MODE_PATH'] || "/plugins"
|
26
29
|
|
27
30
|
DEFAULT_PLUGINS = [
|
28
|
-
'openc3-tool-admin',
|
29
|
-
'openc3-tool-autonomic',
|
30
|
-
'openc3-tool-
|
31
|
-
'openc3-tool-
|
32
|
-
'openc3-tool-
|
33
|
-
'openc3-tool-
|
34
|
-
'openc3-tool-
|
35
|
-
'openc3-tool-
|
36
|
-
'openc3-tool-
|
37
|
-
'openc3-tool-
|
38
|
-
'openc3-tool-
|
39
|
-
'openc3-tool-
|
40
|
-
'openc3-tool-
|
41
|
-
'openc3-tool-
|
42
|
-
'openc3-tool-
|
31
|
+
'openc3-cosmos-tool-admin',
|
32
|
+
'openc3-cosmos-tool-autonomic',
|
33
|
+
'openc3-cosmos-tool-calendar',
|
34
|
+
'openc3-cosmos-tool-cmdsender',
|
35
|
+
'openc3-cosmos-tool-cmdtlmserver',
|
36
|
+
'openc3-cosmos-tool-dataextractor',
|
37
|
+
'openc3-cosmos-tool-dataviewer',
|
38
|
+
'openc3-cosmos-tool-handbooks',
|
39
|
+
'openc3-cosmos-tool-limitsmonitor',
|
40
|
+
'openc3-cosmos-tool-packetviewer',
|
41
|
+
'openc3-cosmos-tool-scriptrunner',
|
42
|
+
'openc3-cosmos-tool-tablemanager',
|
43
|
+
'openc3-cosmos-tool-tlmgrapher',
|
44
|
+
'openc3-cosmos-tool-tlmviewer',
|
45
|
+
'openc3-cosmos-enterprise-tool-admin',
|
43
46
|
'openc3-enterprise-tool-base',
|
44
|
-
'openc3-
|
47
|
+
'openc3-tool-base',
|
45
48
|
]
|
46
49
|
|
47
50
|
# Install plugins from local plugins folder
|
@@ -277,7 +280,7 @@ module OpenC3
|
|
277
280
|
temp_dir = Dir.mktmpdir
|
278
281
|
begin
|
279
282
|
unless File.exists?(plugin_file_path)
|
280
|
-
plugin_file_path = OpenC3::GemModel.get(
|
283
|
+
plugin_file_path = OpenC3::GemModel.get(plugin_file_path)
|
281
284
|
end
|
282
285
|
File.open(File.join(full_folder_path, File.basename(plugin_file_path)), 'wb') do |file|
|
283
286
|
data = File.read(plugin_file_path)
|
@@ -318,18 +321,10 @@ module OpenC3
|
|
318
321
|
|
319
322
|
def self.sync_targets_modified
|
320
323
|
if ENV['OPENC3_LOCAL_MODE'] and Dir.exist?(OPENC3_LOCAL_MODE_PATH)
|
321
|
-
|
322
|
-
|
323
|
-
# Ensure config bucket exists
|
324
|
-
begin
|
325
|
-
rubys3_client.head_bucket(bucket: 'config')
|
326
|
-
rescue Aws::S3::Errors::NotFound
|
327
|
-
rubys3_client.create_bucket(bucket: 'config')
|
328
|
-
end
|
329
|
-
|
324
|
+
bucket = Bucket.getClient()
|
330
325
|
scopes = ScopeModel.names()
|
331
326
|
scopes.each do |scope|
|
332
|
-
|
327
|
+
sync_with_bucket(bucket, scope: scope)
|
333
328
|
end
|
334
329
|
end
|
335
330
|
end
|
@@ -389,15 +384,22 @@ module OpenC3
|
|
389
384
|
|
390
385
|
def self.open_local_file(path, scope:)
|
391
386
|
full_path = "#{OPENC3_LOCAL_MODE_PATH}/#{scope}/targets_modified/#{path}"
|
392
|
-
return File.open(full_path, 'rb')
|
393
|
-
|
387
|
+
return File.open(full_path, 'rb')
|
388
|
+
rescue Errno::ENOENT
|
389
|
+
nil
|
394
390
|
end
|
395
391
|
|
396
|
-
def self.local_target_files(scope:, path_matchers:)
|
392
|
+
def self.local_target_files(scope:, path_matchers:, include_temp: false)
|
397
393
|
files = []
|
398
394
|
local_catalog = build_local_catalog(scope: scope)
|
399
395
|
local_catalog.each do |key, size|
|
400
396
|
split_key = key.split('/')
|
397
|
+
# DEFAULT/targets_modified/__TEMP__/YYYY_MM_DD_HH_MM_SS_mmm_temp.rb
|
398
|
+
# See target_file.rb TEMP_FOLDER
|
399
|
+
if split_key[2] === '__TEMP__'
|
400
|
+
files << split_key[2..-1].join('/') if include_temp
|
401
|
+
next
|
402
|
+
end
|
401
403
|
found = false
|
402
404
|
path_matchers.each do |path|
|
403
405
|
if split_key.include?(path)
|
@@ -413,16 +415,16 @@ module OpenC3
|
|
413
415
|
|
414
416
|
# Helper methods
|
415
417
|
|
416
|
-
def self.sync_remote_to_local(
|
418
|
+
def self.sync_remote_to_local(bucket, key)
|
417
419
|
local_path = "#{OPENC3_LOCAL_MODE_PATH}/#{key}"
|
418
420
|
FileUtils.mkdir_p(File.dirname(local_path))
|
419
|
-
|
421
|
+
bucket.get_object(bucket: ENV['OPENC3_CONFIG_BUCKET'], key: key, path: local_path)
|
420
422
|
end
|
421
423
|
|
422
|
-
def self.sync_local_to_remote(
|
424
|
+
def self.sync_local_to_remote(bucket, key)
|
423
425
|
local_path = "#{OPENC3_LOCAL_MODE_PATH}/#{key}"
|
424
426
|
File.open(local_path, 'rb') do |read_file|
|
425
|
-
|
427
|
+
bucket.put_object(bucket: ENV['OPENC3_CONFIG_BUCKET'], key: key, body: read_file)
|
426
428
|
end
|
427
429
|
end
|
428
430
|
|
@@ -432,8 +434,8 @@ module OpenC3
|
|
432
434
|
nil
|
433
435
|
end
|
434
436
|
|
435
|
-
def self.delete_remote(
|
436
|
-
|
437
|
+
def self.delete_remote(bucket, key)
|
438
|
+
bucket.delete_object(bucket: ENV['OPENC3_CONFIG_BUCKET'], key: key)
|
437
439
|
end
|
438
440
|
|
439
441
|
# Returns equivalent names and sizes to remote catalog
|
@@ -453,32 +455,23 @@ module OpenC3
|
|
453
455
|
|
454
456
|
# Returns keys and sizes from remote catalog
|
455
457
|
# {"scope/targets_modified/target_name/file" => size}
|
456
|
-
def self.build_remote_catalog(
|
458
|
+
def self.build_remote_catalog(bucket, scope:)
|
457
459
|
remote_catalog = {}
|
458
|
-
bucket = 'config'
|
459
460
|
prefix = "#{scope}/targets_modified"
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
continuation_token: token
|
467
|
-
})
|
468
|
-
|
469
|
-
resp.contents.each do |item|
|
470
|
-
remote_catalog[item.key] = item.size
|
471
|
-
end
|
472
|
-
break unless resp.is_truncated
|
473
|
-
token = resp.next_continuation_token
|
461
|
+
resp = bucket.list_objects(
|
462
|
+
bucket: ENV['OPENC3_CONFIG_BUCKET'],
|
463
|
+
prefix: prefix,
|
464
|
+
)
|
465
|
+
resp.each do |item|
|
466
|
+
remote_catalog[item.key] = item.size
|
474
467
|
end
|
475
468
|
return remote_catalog
|
476
469
|
end
|
477
470
|
|
478
|
-
def self.
|
471
|
+
def self.sync_with_bucket(bucket, scope:)
|
479
472
|
# Build catalogs
|
480
473
|
local_catalog = build_local_catalog(scope: scope)
|
481
|
-
remote_catalog = build_remote_catalog(
|
474
|
+
remote_catalog = build_remote_catalog(bucket, scope: scope)
|
482
475
|
|
483
476
|
# Find and Handle Differences
|
484
477
|
local_catalog.each do |key, size|
|
@@ -486,9 +479,9 @@ module OpenC3
|
|
486
479
|
if remote_size
|
487
480
|
# Both files exist
|
488
481
|
if ENV['OPENC3_LOCAL_MODE_SECONDARY']
|
489
|
-
sync_remote_to_local(
|
482
|
+
sync_remote_to_local(bucket, key) if size != remote_size or ENV['OPENC3_LOCAL_MODE_FORCE_SYNC']
|
490
483
|
else
|
491
|
-
sync_local_to_remote(
|
484
|
+
sync_local_to_remote(bucket, key) if size != remote_size or ENV['OPENC3_LOCAL_MODE_FORCE_SYNC']
|
492
485
|
end
|
493
486
|
else
|
494
487
|
# Remote is missing local file
|
@@ -496,7 +489,7 @@ module OpenC3
|
|
496
489
|
delete_local(key)
|
497
490
|
else
|
498
491
|
# Go ahead and copy up to get in sync
|
499
|
-
sync_local_to_remote(
|
492
|
+
sync_local_to_remote(bucket, key)
|
500
493
|
end
|
501
494
|
end
|
502
495
|
end
|
@@ -508,14 +501,13 @@ module OpenC3
|
|
508
501
|
else
|
509
502
|
# Local is missing remote file
|
510
503
|
if not ENV['OPENC3_LOCAL_MODE_SECONDARY'] and ENV['OPENC3_LOCAL_MODE_SYNC_REMOVE']
|
511
|
-
delete_remote(
|
504
|
+
delete_remote(bucket, key)
|
512
505
|
else
|
513
506
|
# Go ahead and copy down to get in sync
|
514
|
-
sync_remote_to_local(
|
507
|
+
sync_remote_to_local(bucket, key)
|
515
508
|
end
|
516
509
|
end
|
517
510
|
end
|
518
511
|
end
|
519
|
-
|
520
512
|
end
|
521
|
-
end
|
513
|
+
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/core_ext/class'
|
21
24
|
require 'openc3/core_ext/time'
|
@@ -171,7 +174,10 @@ module OpenC3
|
|
171
174
|
end
|
172
175
|
data[:container_name] = @container_name
|
173
176
|
data[:log] = message
|
174
|
-
|
177
|
+
if @stdout
|
178
|
+
puts data.as_json(:allow_nan => true).to_json(:allow_nan => true)
|
179
|
+
$stdout.flush
|
180
|
+
end
|
175
181
|
unless @no_store
|
176
182
|
if scope
|
177
183
|
Topic.write_topic("#{scope}__openc3_log_messages", data)
|
@@ -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/config/config_parser'
|
21
24
|
require 'openc3/system/system'
|
22
25
|
require 'fileutils'
|
23
|
-
require 'openc3/utilities/
|
26
|
+
require 'openc3/utilities/bucket_utilities'
|
24
27
|
|
25
28
|
module OpenC3
|
26
29
|
# Handles writing message logs to a file
|
@@ -59,14 +62,14 @@ module OpenC3
|
|
59
62
|
end
|
60
63
|
|
61
64
|
# Closes the message log and marks it read only
|
62
|
-
def stop(take_mutex = true,
|
65
|
+
def stop(take_mutex = true, metadata: {})
|
63
66
|
@mutex.lock if take_mutex
|
64
67
|
if @file and not @file.closed?
|
65
68
|
@file.close
|
66
69
|
File.chmod(0444, @filename)
|
67
|
-
|
70
|
+
bucket_key = File.join(@remote_log_directory, @start_day, File.basename(@filename))
|
68
71
|
begin
|
69
|
-
thread =
|
72
|
+
thread = BucketUtilities.move_log_file_to_bucket(@filename, bucket_key, metadata: metadata)
|
70
73
|
thread.join
|
71
74
|
rescue StandardError => e
|
72
75
|
Logger.error e.formatted
|
@@ -16,13 +16,16 @@
|
|
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/metric_model'
|
21
24
|
require 'thread'
|
22
25
|
|
23
26
|
module OpenC3
|
24
27
|
class Metric
|
25
|
-
# This class is designed to output metrics to the openc3-cmd-tlm-api
|
28
|
+
# This class is designed to output metrics to the openc3-cosmos-cmd-tlm-api
|
26
29
|
# InternalMetricsController. Output format can be read about here
|
27
30
|
# https://prometheus.io/docs/concepts/data_model/
|
28
31
|
#
|
@@ -0,0 +1,96 @@
|
|
1
|
+
# encoding: ascii-8bit
|
2
|
+
|
3
|
+
# Copyright 2022 OpenC3, Inc.
|
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 file may also be used under the terms of a commercial license
|
17
|
+
# if purchased from OpenC3, Inc.
|
18
|
+
|
19
|
+
require 'openc3/utilities/bucket'
|
20
|
+
|
21
|
+
module OpenC3
|
22
|
+
@otel_enabled = false
|
23
|
+
|
24
|
+
def self.otel_enabled
|
25
|
+
@otel_enabled
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.inject_context(hash)
|
29
|
+
if @otel_enabled
|
30
|
+
OpenTelemetry.propagation.inject(hash)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.with_context(hash)
|
35
|
+
if @otel_enabled
|
36
|
+
extracted_context = OpenTelemetry.propagation.extract(hash)
|
37
|
+
OpenTelemetry::Context.with_current(extracted_context) do
|
38
|
+
yield
|
39
|
+
end
|
40
|
+
else
|
41
|
+
yield
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.in_span(span_name, tracer_name = 'openc3-tracer')
|
46
|
+
if @otel_enabled
|
47
|
+
tracer = OpenTelemetry.tracer_provider.tracer(tracer_name)
|
48
|
+
tracer.in_span(span_name) do |span|
|
49
|
+
yield span
|
50
|
+
end
|
51
|
+
else
|
52
|
+
yield nil
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.setup_open_telemetry(service_name, support_rails = false)
|
57
|
+
if ENV['OTEL_EXPORTER_OTLP_ENDPOINT']
|
58
|
+
split_services = ENV['OPENC3_OTEL'].to_s.split(',')
|
59
|
+
@otel_enabled = true if split_services.include?(service_name) or split_services.include?('ALL')
|
60
|
+
|
61
|
+
if @otel_enabled
|
62
|
+
require 'redis'
|
63
|
+
require 'httpclient'
|
64
|
+
require 'openc3/utilities/bucket'
|
65
|
+
# Load the bucket client code so the instrumentation works later
|
66
|
+
Bucket.getClient()
|
67
|
+
require 'opentelemetry/sdk'
|
68
|
+
require 'opentelemetry/exporter/otlp'
|
69
|
+
require 'opentelemetry/instrumentation/redis'
|
70
|
+
require 'opentelemetry/instrumentation/http_client'
|
71
|
+
require 'opentelemetry/instrumentation/aws_sdk'
|
72
|
+
if support_rails
|
73
|
+
require 'opentelemetry/instrumentation/rack'
|
74
|
+
require 'opentelemetry/instrumentation/action_pack'
|
75
|
+
end
|
76
|
+
OpenTelemetry::SDK.configure do |c|
|
77
|
+
c.service_name = service_name
|
78
|
+
if support_rails
|
79
|
+
c.use('OpenTelemetry::Instrumentation::Rack')
|
80
|
+
c.use('OpenTelemetry::Instrumentation::ActionPack', { enable_recognize_route: true })
|
81
|
+
end
|
82
|
+
c.use 'OpenTelemetry::Instrumentation::Redis', {
|
83
|
+
# The obfuscation of arguments in the db.statement attribute is enabled by default.
|
84
|
+
# To include the full query, set db_statement to :include.
|
85
|
+
# To obfuscate, set db_statement to :obfuscate.
|
86
|
+
# To omit the attribute, set db_statement to :omit.
|
87
|
+
db_statement: :include,
|
88
|
+
}
|
89
|
+
c.use 'OpenTelemetry::Instrumentation::HttpClient'
|
90
|
+
c.use 'OpenTelemetry::Instrumentation::AwsSdk'
|
91
|
+
# TODO: Add in additional cloud SDKs
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
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/operators/operator'
|
21
24
|
require 'openc3/models/process_status_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 'irb/ruby-lex'
|
21
24
|
require 'stringio'
|
@@ -1,9 +1,11 @@
|
|
1
1
|
require 'aws-sdk-s3'
|
2
2
|
|
3
3
|
Aws.config.update(
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
4
|
+
s3: {
|
5
|
+
endpoint: ENV['OPENC3_BUCKET_URL'] || (ENV['OPENC3_DEVEL'] ? 'http://127.0.0.1:9000' : 'http://openc3-minio:9000'),
|
6
|
+
access_key_id: ENV['OPENC3_BUCKET_USERNAME'],
|
7
|
+
secret_access_key: ENV['OPENC3_BUCKET_PASSWORD'],
|
8
|
+
force_path_style: true,
|
9
|
+
region: 'us-east-1'
|
10
|
+
}
|
11
|
+
)
|
@@ -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/packets/packet'
|
21
24
|
require 'openc3/packets/structure'
|
@@ -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
|
# Allows for a breakable sleep implementation using the self-pipe trick
|
@@ -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
|
autoload(:Store, "openc3/utilities/store_autoload.rb")
|
@@ -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 'redis'
|
21
24
|
require 'json'
|
@@ -23,9 +26,9 @@ require 'connection_pool'
|
|
23
26
|
|
24
27
|
if ENV['OPENC3_REDIS_CLUSTER']
|
25
28
|
require 'openc3-enterprise/utilities/store'
|
26
|
-
$
|
29
|
+
$openc3_redis_cluster = true
|
27
30
|
else
|
28
|
-
$
|
31
|
+
$openc3_redis_cluster = false
|
29
32
|
end
|
30
33
|
|
31
34
|
module OpenC3
|
@@ -73,7 +76,6 @@ module OpenC3
|
|
73
76
|
end
|
74
77
|
|
75
78
|
def initialize(pool_size = 10)
|
76
|
-
Redis.exists_returns_integer = true
|
77
79
|
@redis_username = ENV['OPENC3_REDIS_USERNAME']
|
78
80
|
@redis_key = ENV['OPENC3_REDIS_PASSWORD']
|
79
81
|
@redis_url = "redis://#{ENV['OPENC3_REDIS_HOSTNAME']}:#{ENV['OPENC3_REDIS_PORT']}"
|
@@ -81,7 +83,7 @@ module OpenC3
|
|
81
83
|
@topic_offsets = {}
|
82
84
|
end
|
83
85
|
|
84
|
-
unless $
|
86
|
+
unless $openc3_redis_cluster
|
85
87
|
def build_redis
|
86
88
|
return Redis.new(url: @redis_url, username: @redis_username, password: @redis_key)
|
87
89
|
end
|
@@ -154,22 +156,26 @@ module OpenC3
|
|
154
156
|
return offsets
|
155
157
|
end
|
156
158
|
|
157
|
-
unless $
|
159
|
+
unless $openc3_redis_cluster
|
158
160
|
def read_topics(topics, offsets = nil, timeout_ms = 1000, count = nil)
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
result.
|
165
|
-
|
166
|
-
|
167
|
-
|
161
|
+
begin
|
162
|
+
# Logger.debug "read_topics: #{topics}, #{offsets} pool:#{@redis_pool}"
|
163
|
+
@redis_pool.with do |redis|
|
164
|
+
offsets = update_topic_offsets(topics) unless offsets
|
165
|
+
result = redis.xread(topics, offsets, block: timeout_ms, count: count)
|
166
|
+
if result and result.length > 0
|
167
|
+
result.each do |topic, messages|
|
168
|
+
messages.each do |msg_id, msg_hash|
|
169
|
+
@topic_offsets[topic] = msg_id
|
170
|
+
yield topic, msg_id, msg_hash, redis if block_given?
|
171
|
+
end
|
168
172
|
end
|
169
173
|
end
|
174
|
+
# Logger.debug "result:#{result}" if result and result.length > 0
|
175
|
+
return result
|
170
176
|
end
|
171
|
-
|
172
|
-
return
|
177
|
+
rescue Redis::TimeoutError
|
178
|
+
return {} # Should return an empty hash not array - xread returns a hash
|
173
179
|
end
|
174
180
|
end
|
175
181
|
end
|
@@ -180,7 +186,7 @@ module OpenC3
|
|
180
186
|
# @example Without options
|
181
187
|
# store.write_topic('MANGO__TOPIC', {'message' => 'something'})
|
182
188
|
# @example With options
|
183
|
-
# store.write_topic('MANGO__TOPIC', {'message' => 'something'}, id: '0-0', maxlen: 1000, approximate: true)
|
189
|
+
# store.write_topic('MANGO__TOPIC', {'message' => 'something'}, id: '0-0', maxlen: 1000, approximate: 'true')
|
184
190
|
#
|
185
191
|
# @param topic [String] the stream / topic
|
186
192
|
# @param msg_hash [Hash] one or multiple field-value pairs
|
@@ -188,10 +194,10 @@ module OpenC3
|
|
188
194
|
# @option opts [String] :id the entry id, default value is `*`, it means auto generation,
|
189
195
|
# if `nil` id is passed it will be changed to `*`
|
190
196
|
# @option opts [Integer] :maxlen max length of entries, default value is `nil`, it means will grow forever
|
191
|
-
# @option opts [
|
197
|
+
# @option opts [String] :approximate whether to add `~` modifier of maxlen or not, default value is 'true'
|
192
198
|
#
|
193
199
|
# @return [String] the entry id
|
194
|
-
def write_topic(topic, msg_hash, id = '*', maxlen = nil, approximate = true)
|
200
|
+
def write_topic(topic, msg_hash, id = '*', maxlen = nil, approximate = 'true')
|
195
201
|
id = '*' if id.nil?
|
196
202
|
# Logger.debug "write_topic topic:#{topic} id:#{id} hash:#{msg_hash}"
|
197
203
|
@redis_pool.with do |redis|
|
@@ -205,14 +211,15 @@ module OpenC3
|
|
205
211
|
# @example Without options
|
206
212
|
# store.trim_topic('MANGO__TOPIC', 1000)
|
207
213
|
# @example With options
|
208
|
-
# store.trim_topic('MANGO__TOPIC', 1000, approximate: true, limit: 0)
|
214
|
+
# store.trim_topic('MANGO__TOPIC', 1000, approximate: 'true', limit: 0)
|
209
215
|
#
|
210
216
|
# @param topic [String] the stream key
|
211
217
|
# @param minid [Integer] mid id length of entries to trim
|
218
|
+
# @param approximate [Boolean] whether to add `~` modifier of maxlen or not
|
212
219
|
# @param limit [Boolean] whether to add `~` modifier of maxlen or not
|
213
220
|
#
|
214
221
|
# @return [Integer] the number of entries actually deleted
|
215
|
-
def trim_topic(topic, minid, approximate = true, limit: 0)
|
222
|
+
def trim_topic(topic, minid, approximate = 'true', limit: 0)
|
216
223
|
@redis_pool.with do |redis|
|
217
224
|
return redis.xtrim_minid(topic, minid, approximate: approximate, limit: limit)
|
218
225
|
end
|
@@ -229,9 +236,9 @@ module OpenC3
|
|
229
236
|
end
|
230
237
|
|
231
238
|
class Redis
|
232
|
-
def xtrim_minid(key, minid, approximate: true, limit: nil)
|
239
|
+
def xtrim_minid(key, minid, approximate: 'true', limit: nil)
|
233
240
|
args = [:xtrim, key, :MINID, (approximate ? '~' : nil), minid].compact
|
234
241
|
args.concat([:LIMIT, limit]) if limit
|
235
|
-
|
242
|
+
send_command(args)
|
236
243
|
end
|
237
244
|
end
|