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.

Files changed (280) hide show
  1. checksums.yaml +4 -4
  2. data/Guardfile +3 -0
  3. data/LICENSE.txt +7 -5
  4. data/README.md +11 -9
  5. data/Rakefile +3 -0
  6. data/bin/cstol_converter +3 -0
  7. data/bin/openc3cli +29 -18
  8. data/bin/rubysloc +3 -0
  9. data/data/config/screen.yaml +10 -2
  10. data/data/config/target.yaml +1 -1
  11. data/data/config/widgets.yaml +6 -6
  12. data/ext/mkrf_conf.rb +3 -0
  13. data/ext/openc3/ext/array/array.c +3 -0
  14. data/ext/openc3/ext/buffered_file/buffered_file.c +3 -0
  15. data/ext/openc3/ext/config_parser/config_parser.c +3 -0
  16. data/ext/openc3/ext/crc/crc.c +3 -0
  17. data/ext/openc3/ext/openc3_io/openc3_io.c +3 -0
  18. data/ext/openc3/ext/packet/packet.c +3 -0
  19. data/ext/openc3/ext/platform/platform.c +3 -0
  20. data/ext/openc3/ext/polynomial_conversion/polynomial_conversion.c +3 -0
  21. data/ext/openc3/ext/string/string.c +3 -0
  22. data/ext/openc3/ext/structure/structure.c +3 -0
  23. data/ext/openc3/ext/tabbed_plots_config/tabbed_plots_config.c +3 -0
  24. data/ext/openc3/ext/telemetry/telemetry.c +3 -0
  25. data/lib/cosmos.rb +3 -0
  26. data/lib/cosmosc2.rb +3 -0
  27. data/lib/openc3/accessors/accessor.rb +3 -0
  28. data/lib/openc3/accessors/binary_accessor.rb +3 -0
  29. data/lib/openc3/accessors/cbor_accessor.rb +3 -0
  30. data/lib/openc3/accessors/html_accessor.rb +3 -0
  31. data/lib/openc3/accessors/json_accessor.rb +4 -1
  32. data/lib/openc3/accessors/xml_accessor.rb +3 -0
  33. data/lib/openc3/accessors.rb +3 -0
  34. data/lib/openc3/api/api.rb +3 -0
  35. data/lib/openc3/api/authorized_api.rb +3 -0
  36. data/lib/openc3/api/cmd_api.rb +6 -3
  37. data/lib/openc3/api/config_api.rb +3 -0
  38. data/lib/openc3/api/interface_api.rb +16 -5
  39. data/lib/openc3/api/limits_api.rb +54 -61
  40. data/lib/openc3/api/router_api.rb +6 -3
  41. data/lib/openc3/api/settings_api.rb +3 -0
  42. data/lib/openc3/api/target_api.rb +3 -0
  43. data/lib/openc3/api/tlm_api.rb +27 -32
  44. data/lib/openc3/bridge/bridge.rb +3 -0
  45. data/lib/openc3/bridge/bridge_config.rb +3 -0
  46. data/lib/openc3/bridge/bridge_interface_thread.rb +3 -0
  47. data/lib/openc3/bridge/bridge_router_thread.rb +3 -0
  48. data/lib/openc3/ccsds/ccsds_packet.rb +3 -0
  49. data/lib/openc3/ccsds/ccsds_parser.rb +3 -0
  50. data/lib/openc3/config/config_parser.rb +3 -0
  51. data/lib/openc3/config/meta_config_parser.rb +3 -0
  52. data/lib/openc3/conversions/conversion.rb +3 -0
  53. data/lib/openc3/conversions/generic_conversion.rb +3 -0
  54. data/lib/openc3/conversions/packet_time_formatted_conversion.rb +3 -0
  55. data/lib/openc3/conversions/packet_time_seconds_conversion.rb +3 -0
  56. data/lib/openc3/conversions/polynomial_conversion.rb +3 -0
  57. data/lib/openc3/conversions/processor_conversion.rb +3 -0
  58. data/lib/openc3/conversions/received_count_conversion.rb +3 -0
  59. data/lib/openc3/conversions/received_time_formatted_conversion.rb +3 -0
  60. data/lib/openc3/conversions/received_time_seconds_conversion.rb +3 -0
  61. data/lib/openc3/conversions/segmented_polynomial_conversion.rb +3 -0
  62. data/lib/openc3/conversions/unix_time_conversion.rb +3 -0
  63. data/lib/openc3/conversions/unix_time_formatted_conversion.rb +3 -0
  64. data/lib/openc3/conversions/unix_time_seconds_conversion.rb +3 -0
  65. data/lib/openc3/conversions.rb +3 -0
  66. data/lib/openc3/core_ext/array.rb +3 -0
  67. data/lib/openc3/core_ext/binding.rb +3 -0
  68. data/lib/openc3/core_ext/class.rb +3 -0
  69. data/lib/openc3/core_ext/exception.rb +3 -0
  70. data/lib/openc3/core_ext/file.rb +3 -0
  71. data/lib/openc3/core_ext/hash.rb +3 -0
  72. data/lib/openc3/core_ext/io.rb +3 -0
  73. data/lib/openc3/core_ext/kernel.rb +3 -0
  74. data/lib/openc3/core_ext/math.rb +3 -0
  75. data/lib/openc3/core_ext/matrix.rb +3 -0
  76. data/lib/openc3/core_ext/objectspace.rb +3 -0
  77. data/lib/openc3/core_ext/openc3_io.rb +3 -0
  78. data/lib/openc3/core_ext/range.rb +3 -0
  79. data/lib/openc3/core_ext/socket.rb +3 -0
  80. data/lib/openc3/core_ext/string.rb +3 -0
  81. data/lib/openc3/core_ext/stringio.rb +3 -0
  82. data/lib/openc3/core_ext/tempfile.rb +3 -0
  83. data/lib/openc3/core_ext/time.rb +3 -0
  84. data/lib/openc3/core_ext.rb +4 -0
  85. data/lib/openc3/interfaces/interface.rb +4 -1
  86. data/lib/openc3/interfaces/linc_interface.rb +3 -0
  87. data/lib/openc3/interfaces/protocols/burst_protocol.rb +3 -0
  88. data/lib/openc3/interfaces/protocols/crc_protocol.rb +3 -0
  89. data/lib/openc3/interfaces/protocols/fixed_protocol.rb +3 -0
  90. data/lib/openc3/interfaces/protocols/ignore_packet_protocol.rb +3 -0
  91. data/lib/openc3/interfaces/protocols/length_protocol.rb +3 -0
  92. data/lib/openc3/interfaces/protocols/override_protocol.rb +3 -0
  93. data/lib/openc3/interfaces/protocols/preidentified_protocol.rb +3 -0
  94. data/lib/openc3/interfaces/protocols/protocol.rb +3 -0
  95. data/lib/openc3/interfaces/protocols/template_protocol.rb +3 -0
  96. data/lib/openc3/interfaces/protocols/terminated_protocol.rb +3 -0
  97. data/lib/openc3/interfaces/serial_interface.rb +3 -0
  98. data/lib/openc3/interfaces/simulated_target_interface.rb +3 -0
  99. data/lib/openc3/interfaces/stream_interface.rb +3 -0
  100. data/lib/openc3/interfaces/tcpip_client_interface.rb +3 -0
  101. data/lib/openc3/interfaces/tcpip_server_interface.rb +3 -0
  102. data/lib/openc3/interfaces/udp_interface.rb +3 -0
  103. data/lib/openc3/interfaces.rb +3 -0
  104. data/lib/openc3/io/buffered_file.rb +3 -0
  105. data/lib/openc3/io/io_multiplexer.rb +8 -0
  106. data/lib/openc3/io/json_api_object.rb +5 -2
  107. data/lib/openc3/io/json_drb.rb +3 -0
  108. data/lib/openc3/io/json_drb_object.rb +5 -2
  109. data/lib/openc3/io/json_drb_rack.rb +3 -0
  110. data/lib/openc3/io/json_rpc.rb +3 -0
  111. data/lib/openc3/io/openc3_snmp.rb +3 -0
  112. data/lib/openc3/io/posix_serial_driver.rb +3 -0
  113. data/lib/openc3/io/raw_logger.rb +3 -0
  114. data/lib/openc3/io/raw_logger_pair.rb +3 -0
  115. data/lib/openc3/io/serial_driver.rb +3 -0
  116. data/lib/openc3/io/stderr.rb +3 -0
  117. data/lib/openc3/io/stdout.rb +3 -0
  118. data/lib/openc3/io/udp_sockets.rb +3 -0
  119. data/lib/openc3/io/win32_serial_driver.rb +3 -0
  120. data/lib/openc3/logs/buffered_packet_log_reader.rb +65 -0
  121. data/lib/openc3/logs/buffered_packet_log_writer.rb +118 -0
  122. data/lib/openc3/logs/log_writer.rb +94 -41
  123. data/lib/openc3/logs/packet_log_constants.rb +9 -0
  124. data/lib/openc3/logs/packet_log_reader.rb +34 -3
  125. data/lib/openc3/logs/packet_log_writer.rb +85 -20
  126. data/lib/openc3/logs/text_log_writer.rb +9 -5
  127. data/lib/openc3/logs.rb +8 -2
  128. data/lib/openc3/microservices/cleanup_microservice.rb +18 -18
  129. data/lib/openc3/microservices/decom_microservice.rb +30 -24
  130. data/lib/openc3/microservices/interface_microservice.rb +136 -91
  131. data/lib/openc3/microservices/log_microservice.rb +35 -13
  132. data/lib/openc3/microservices/microservice.rb +16 -14
  133. data/lib/openc3/microservices/plugin_microservice.rb +3 -1
  134. data/lib/openc3/microservices/reaction_microservice.rb +4 -1
  135. data/lib/openc3/microservices/reducer_microservice.rb +332 -149
  136. data/lib/openc3/microservices/router_microservice.rb +3 -0
  137. data/lib/openc3/microservices/text_log_microservice.rb +5 -2
  138. data/lib/openc3/microservices/timeline_microservice.rb +4 -1
  139. data/lib/openc3/microservices/trigger_group_microservice.rb +3 -0
  140. data/lib/openc3/models/activity_model.rb +3 -0
  141. data/lib/openc3/models/auth_model.rb +3 -1
  142. data/lib/openc3/models/cvt_model.rb +14 -5
  143. data/lib/openc3/models/environment_model.rb +3 -0
  144. data/lib/openc3/models/gem_model.rb +30 -51
  145. data/lib/openc3/models/info_model.rb +3 -0
  146. data/lib/openc3/models/interface_model.rb +3 -0
  147. data/lib/openc3/models/interface_status_model.rb +4 -1
  148. data/lib/openc3/models/metadata_model.rb +3 -0
  149. data/lib/openc3/models/metric_model.rb +3 -0
  150. data/lib/openc3/models/microservice_model.rb +9 -6
  151. data/lib/openc3/models/microservice_status_model.rb +4 -1
  152. data/lib/openc3/models/model.rb +3 -0
  153. data/lib/openc3/models/note_model.rb +8 -5
  154. data/lib/openc3/models/notification_model.rb +3 -0
  155. data/lib/openc3/models/ping_model.rb +3 -0
  156. data/lib/openc3/models/plugin_model.rb +20 -14
  157. data/lib/openc3/models/process_status_model.rb +4 -1
  158. data/lib/openc3/models/reaction_model.rb +3 -0
  159. data/lib/openc3/models/reducer_model.rb +31 -24
  160. data/lib/openc3/models/router_model.rb +3 -0
  161. data/lib/openc3/models/router_status_model.rb +3 -0
  162. data/lib/openc3/models/scope_model.rb +3 -4
  163. data/lib/openc3/models/settings_model.rb +3 -0
  164. data/lib/openc3/models/sorted_model.rb +3 -0
  165. data/lib/openc3/models/target_model.rb +61 -94
  166. data/lib/openc3/models/timeline_model.rb +4 -1
  167. data/lib/openc3/models/tool_config_model.rb +3 -0
  168. data/lib/openc3/models/tool_model.rb +11 -9
  169. data/lib/openc3/models/trigger_group_model.rb +3 -0
  170. data/lib/openc3/models/trigger_model.rb +3 -0
  171. data/lib/openc3/models/widget_model.rb +18 -11
  172. data/lib/openc3/operators/microservice_operator.rb +3 -0
  173. data/lib/openc3/operators/operator.rb +105 -34
  174. data/lib/openc3/packets/commands.rb +3 -0
  175. data/lib/openc3/packets/json_packet.rb +87 -14
  176. data/lib/openc3/packets/limits.rb +4 -1
  177. data/lib/openc3/packets/limits_response.rb +3 -0
  178. data/lib/openc3/packets/packet.rb +5 -1
  179. data/lib/openc3/packets/packet_config.rb +3 -0
  180. data/lib/openc3/packets/packet_item.rb +9 -3
  181. data/lib/openc3/packets/packet_item_limits.rb +3 -0
  182. data/lib/openc3/packets/parsers/format_string_parser.rb +3 -0
  183. data/lib/openc3/packets/parsers/limits_parser.rb +3 -0
  184. data/lib/openc3/packets/parsers/limits_response_parser.rb +3 -0
  185. data/lib/openc3/packets/parsers/packet_item_parser.rb +3 -0
  186. data/lib/openc3/packets/parsers/packet_parser.rb +3 -0
  187. data/lib/openc3/packets/parsers/processor_parser.rb +3 -0
  188. data/lib/openc3/packets/parsers/state_parser.rb +3 -0
  189. data/lib/openc3/packets/parsers/xtce_converter.rb +3 -0
  190. data/lib/openc3/packets/parsers/xtce_parser.rb +3 -0
  191. data/lib/openc3/packets/structure.rb +3 -0
  192. data/lib/openc3/packets/structure_item.rb +3 -0
  193. data/lib/openc3/packets/telemetry.rb +3 -0
  194. data/lib/openc3/processors/processor.rb +3 -0
  195. data/lib/openc3/processors/statistics_processor.rb +3 -0
  196. data/lib/openc3/processors/watermark_processor.rb +3 -0
  197. data/lib/openc3/processors.rb +3 -0
  198. data/lib/openc3/script/api_shared.rb +35 -6
  199. data/lib/openc3/script/calendar.rb +3 -0
  200. data/lib/openc3/script/commands.rb +3 -0
  201. data/lib/openc3/script/exceptions.rb +3 -0
  202. data/lib/openc3/script/extract.rb +3 -0
  203. data/lib/openc3/script/limits.rb +3 -24
  204. data/lib/openc3/script/script.rb +11 -7
  205. data/lib/openc3/script/script_runner.rb +3 -0
  206. data/lib/openc3/script/storage.rb +34 -16
  207. data/lib/openc3/script/suite.rb +3 -0
  208. data/lib/openc3/script/suite_results.rb +3 -0
  209. data/lib/openc3/script/suite_runner.rb +3 -0
  210. data/lib/openc3/script/telemetry.rb +43 -0
  211. data/lib/openc3/script.rb +3 -0
  212. data/lib/openc3/streams/serial_stream.rb +3 -0
  213. data/lib/openc3/streams/stream.rb +3 -0
  214. data/lib/openc3/streams/tcpip_client_stream.rb +3 -0
  215. data/lib/openc3/streams/tcpip_socket_stream.rb +3 -0
  216. data/lib/openc3/system/system.rb +23 -10
  217. data/lib/openc3/system/system_config.rb +3 -0
  218. data/lib/openc3/system/target.rb +3 -0
  219. data/lib/openc3/system.rb +3 -0
  220. data/lib/openc3/tools/cmd_tlm_server/api.rb +3 -0
  221. data/lib/openc3/tools/cmd_tlm_server/cmd_tlm_server_config.rb +3 -0
  222. data/lib/openc3/tools/cmd_tlm_server/interface_thread.rb +3 -0
  223. data/lib/openc3/tools/table_manager/table.rb +3 -0
  224. data/lib/openc3/tools/table_manager/table_config.rb +3 -0
  225. data/lib/openc3/tools/table_manager/table_item.rb +3 -0
  226. data/lib/openc3/tools/table_manager/table_item_parser.rb +3 -0
  227. data/lib/openc3/tools/table_manager/table_manager_core.rb +3 -0
  228. data/lib/openc3/tools/table_manager/table_parser.rb +3 -0
  229. data/lib/openc3/tools/test_runner/test.rb +3 -0
  230. data/lib/openc3/top_level.rb +3 -0
  231. data/lib/openc3/topics/autonomic_topic.rb +3 -0
  232. data/lib/openc3/topics/calendar_topic.rb +3 -0
  233. data/lib/openc3/topics/command_decom_topic.rb +4 -1
  234. data/lib/openc3/topics/command_topic.rb +6 -1
  235. data/lib/openc3/topics/config_topic.rb +3 -0
  236. data/lib/openc3/topics/interface_topic.rb +9 -2
  237. data/lib/openc3/topics/limits_event_topic.rb +144 -10
  238. data/lib/openc3/topics/notifications_topic.rb +3 -0
  239. data/lib/openc3/topics/router_topic.rb +10 -3
  240. data/lib/openc3/topics/telemetry_decom_topic.rb +26 -20
  241. data/lib/openc3/topics/telemetry_reduced_topics.rb +92 -0
  242. data/lib/openc3/topics/telemetry_topic.rb +5 -2
  243. data/lib/openc3/topics/timeline_topic.rb +3 -0
  244. data/lib/openc3/topics/topic.rb +3 -0
  245. data/lib/openc3/utilities/authentication.rb +9 -4
  246. data/lib/openc3/utilities/authorization.rb +3 -0
  247. data/lib/openc3/utilities/aws_bucket.rb +199 -0
  248. data/lib/openc3/utilities/bucket.rb +82 -0
  249. data/lib/openc3/utilities/bucket_file_cache.rb +264 -0
  250. data/lib/openc3/utilities/bucket_utilities.rb +109 -0
  251. data/lib/openc3/utilities/crc.rb +3 -0
  252. data/lib/openc3/utilities/csv.rb +3 -0
  253. data/lib/openc3/utilities/local_bucket.rb +28 -0
  254. data/lib/openc3/utilities/local_mode.rb +54 -62
  255. data/lib/openc3/utilities/logger.rb +7 -1
  256. data/lib/openc3/utilities/message_log.rb +7 -4
  257. data/lib/openc3/utilities/metric.rb +4 -1
  258. data/lib/openc3/utilities/open_telemetry.rb +96 -0
  259. data/lib/openc3/utilities/process_manager.rb +3 -0
  260. data/lib/openc3/utilities/quaternion.rb +3 -0
  261. data/lib/openc3/utilities/ruby_lex_utils.rb +3 -0
  262. data/lib/openc3/utilities/s3_autoload.rb +8 -6
  263. data/lib/openc3/utilities/simulated_target.rb +3 -0
  264. data/lib/openc3/utilities/sleeper.rb +3 -0
  265. data/lib/openc3/utilities/store.rb +3 -0
  266. data/lib/openc3/utilities/store_autoload.rb +30 -23
  267. data/lib/openc3/utilities/target_file.rb +89 -63
  268. data/lib/openc3/utilities/zip.rb +3 -0
  269. data/lib/openc3/utilities.rb +3 -0
  270. data/lib/openc3/version.rb +6 -6
  271. data/lib/openc3/win32/excel.rb +3 -0
  272. data/lib/openc3/win32/win32.rb +3 -0
  273. data/lib/openc3/win32/win32_main.rb +3 -0
  274. data/lib/openc3.rb +3 -0
  275. data/tasks/gemfile_stats.rake +3 -0
  276. data/tasks/spec.rake +3 -0
  277. data/templates/plugin-template/plugin.gemspec +1 -1
  278. metadata +112 -6
  279. data/lib/openc3/utilities/s3.rb +0 -218
  280. 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/s3'
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-base',
31
- 'openc3-tool-calendar',
32
- 'openc3-tool-cmdsender',
33
- 'openc3-tool-cmdtlmserver',
34
- 'openc3-tool-dataextractor',
35
- 'openc3-tool-dataviewer',
36
- 'openc3-tool-handbooks',
37
- 'openc3-tool-limitsmonitor',
38
- 'openc3-tool-packetviewer',
39
- 'openc3-tool-scriptrunner',
40
- 'openc3-tool-tablemanager',
41
- 'openc3-tool-tlmgrapher',
42
- 'openc3-tool-tlmviewer',
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-enterprise-tool-admin',
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(temp_dir, plugin_file_path)
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
- rubys3_client = Aws::S3::Client.new
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
- sync_with_minio(rubys3_client, scope: scope)
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') if File.exist?(full_path)
393
- return nil
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(rubys3_client, key)
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
- rubys3_client.get_object(bucket: 'config', key: key, response_target: local_path)
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(rubys3_client, key)
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
- rubys3_client.put_object(bucket: 'config', key: key, body: read_file)
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(rubys3_client, key)
436
- rubys3_client.delete_object(bucket: 'config', key: key)
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(rubys3_client, scope:)
458
+ def self.build_remote_catalog(bucket, scope:)
457
459
  remote_catalog = {}
458
- bucket = 'config'
459
460
  prefix = "#{scope}/targets_modified"
460
- token = nil
461
- while true
462
- resp = rubys3_client.list_objects_v2({
463
- bucket: bucket,
464
- max_keys: 1000,
465
- prefix: prefix,
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.sync_with_minio(rubys3_client, scope:)
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(rubys3_client, scope: scope)
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(rubys3_client, key) if size != remote_size or ENV['OPENC3_LOCAL_MODE_FORCE_SYNC']
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(rubys3_client, key) if size != remote_size or ENV['OPENC3_LOCAL_MODE_FORCE_SYNC']
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(rubys3_client, key)
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(rubys3_client, key)
504
+ delete_remote(bucket, key)
512
505
  else
513
506
  # Go ahead and copy down to get in sync
514
- sync_remote_to_local(rubys3_client, key)
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
- puts data.as_json(:allow_nan => true).to_json(:allow_nan => true) if @stdout
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/s3'
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, s3_object_metadata: {})
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
- s3_key = File.join(@remote_log_directory, @start_day, File.basename(@filename))
70
+ bucket_key = File.join(@remote_log_directory, @start_day, File.basename(@filename))
68
71
  begin
69
- thread = S3Utilities.move_log_file_to_s3(@filename, s3_key, metadata: s3_object_metadata)
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 'openc3/core_ext/matrix'
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 '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
- endpoint: ENV['OPENC3_S3_URL'] || (ENV['OPENC3_DEVEL'] ? 'http://127.0.0.1:9000' : 'http://openc3-minio:9000'),
5
- access_key_id: ENV['OPENC3_MINIO_USERNAME'],
6
- secret_access_key: ENV['OPENC3_MINIO_PASSWORD'],
7
- force_path_style: true,
8
- region: 'us-east-1'
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
- $openc3_enterprise = true
29
+ $openc3_redis_cluster = true
27
30
  else
28
- $openc3_enterprise = false
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 $openc3_enterprise
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 $openc3_enterprise
159
+ unless $openc3_redis_cluster
158
160
  def read_topics(topics, offsets = nil, timeout_ms = 1000, count = nil)
159
- # Logger.debug "read_topics: #{topics}, #{offsets} pool:#{@redis_pool}"
160
- @redis_pool.with do |redis|
161
- offsets = update_topic_offsets(topics) unless offsets
162
- result = redis.xread(topics, offsets, block: timeout_ms, count: count)
163
- if result and result.length > 0
164
- result.each do |topic, messages|
165
- messages.each do |msg_id, msg_hash|
166
- @topic_offsets[topic] = msg_id
167
- yield topic, msg_id, msg_hash, redis if block_given?
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
- # Logger.debug "result:#{result}" if result and result.length > 0
172
- return result
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 [Boolean] :approximate whether to add `~` modifier of maxlen or not, default value is `true`
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
- synchronize { |client| client.call(args) }
242
+ send_command(args)
236
243
  end
237
244
  end