openc3 7.5.1 → 7.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +0 -0
- data/bin/openc3cli +82 -5
- data/data/config/_params.yaml +3 -0
- data/data/config/command_modifiers.yaml +5 -3
- data/data/config/default_plugins.yaml +1 -0
- data/data/config/interface_modifiers.yaml +17 -1
- data/data/config/item_modifiers.yaml +24 -1
- data/data/config/microservice.yaml +15 -1
- data/data/config/parameter_modifiers.yaml +4 -4
- data/data/config/plugins.yaml +511 -3
- data/data/config/settings.yaml +17 -0
- data/data/config/target.yaml +53 -0
- data/data/config/telemetry.yaml +58 -2
- data/data/config/widgets.yaml +30 -0
- data/lib/openc3/accessors/accessor.rb +14 -2
- data/lib/openc3/accessors/binary_accessor.rb +25 -5
- data/lib/openc3/api/CLAUDE.md +1 -0
- data/lib/openc3/api/api.rb +1 -0
- data/lib/openc3/api/cmd_api.rb +9 -1
- data/lib/openc3/api/interface_api.rb +7 -2
- data/lib/openc3/api/limits_api.rb +93 -41
- data/lib/openc3/api/router_api.rb +7 -2
- data/lib/openc3/api/settings_api.rb +4 -1
- data/lib/openc3/api/shared_resource_api.rb +107 -0
- data/lib/openc3/api/tlm_api.rb +10 -0
- data/lib/openc3/interfaces/http_client_interface.rb +84 -27
- data/lib/openc3/interfaces/protocols/preidentified_protocol.rb +6 -2
- data/lib/openc3/interfaces/tcpip_server_interface.rb +205 -125
- data/lib/openc3/io/json_api.rb +2 -10
- data/lib/openc3/io/json_api_object.rb +2 -10
- data/lib/openc3/logs/packet_log_writer.rb +8 -3
- data/lib/openc3/microservices/decom_common.rb +4 -1
- data/lib/openc3/microservices/decom_microservice.rb +52 -6
- data/lib/openc3/microservices/interface_decom_common.rb +13 -0
- data/lib/openc3/microservices/interface_microservice.rb +50 -11
- data/lib/openc3/microservices/limits_group_microservice.rb +513 -0
- data/lib/openc3/microservices/log_microservice.rb +22 -8
- data/lib/openc3/microservices/microservice.rb +8 -2
- data/lib/openc3/microservices/multi_microservice.rb +76 -22
- data/lib/openc3/microservices/queue_microservice.rb +29 -24
- data/lib/openc3/migrations/20260704000000_default_bridge.rb +1 -2
- data/lib/openc3/migrations/20261103000001_limits_group_backfill.rb +193 -0
- data/lib/openc3/models/bridge_model.rb +3 -3
- data/lib/openc3/models/cvt_model.rb +3 -1
- data/lib/openc3/models/host_interface_microservice_model.rb +4 -4
- data/lib/openc3/models/interface_model.rb +27 -7
- data/lib/openc3/models/microservice_group.rb +167 -0
- data/lib/openc3/models/microservice_model.rb +88 -2
- data/lib/openc3/models/panel_model.rb +109 -0
- data/lib/openc3/models/plugin_model.rb +1006 -26
- data/lib/openc3/models/plugin_store_model.rb +6 -1
- data/lib/openc3/models/protected_storage_model.rb +64 -0
- data/lib/openc3/models/queue_model.rb +19 -10
- data/lib/openc3/models/scope_model.rb +80 -3
- data/lib/openc3/models/setting_model.rb +2 -2
- data/lib/openc3/models/shared_resource_model.rb +381 -0
- data/lib/openc3/models/target_model.rb +324 -68
- data/lib/openc3/operators/microservice_operator.rb +76 -9
- data/lib/openc3/operators/operator.rb +29 -0
- data/lib/openc3/packets/commands.rb +16 -16
- data/lib/openc3/packets/limits.rb +2 -0
- data/lib/openc3/packets/packet.rb +75 -4
- data/lib/openc3/packets/packet_config.rb +152 -13
- data/lib/openc3/packets/packet_item.rb +35 -14
- data/lib/openc3/packets/packet_item_limits.rb +67 -6
- data/lib/openc3/packets/parsers/limits_parser.rb +69 -2
- data/lib/openc3/packets/parsers/packet_item_parser.rb +6 -0
- data/lib/openc3/packets/parsers/packet_parser.rb +45 -0
- data/lib/openc3/packets/parsers/state_parser.rb +1 -1
- data/lib/openc3/script/CLAUDE.md +1 -0
- data/lib/openc3/script/api_shared.rb +17 -9
- data/lib/openc3/script/calendar.rb +18 -6
- data/lib/openc3/script/commands.rb +11 -9
- data/lib/openc3/script/critical_cmd.rb +22 -2
- data/lib/openc3/script/metadata.rb +30 -4
- data/lib/openc3/script/plugins.rb +8 -0
- data/lib/openc3/script/script.rb +8 -24
- data/lib/openc3/script/web_socket_api.rb +23 -17
- data/lib/openc3/system/system.rb +9 -3
- data/lib/openc3/top_level.rb +17 -0
- data/lib/openc3/topics/command_topic.rb +7 -1
- data/lib/openc3/topics/decom_interface_topic.rb +9 -3
- data/lib/openc3/topics/discovery_topic.rb +84 -0
- data/lib/openc3/topics/limits_event_topic.rb +236 -17
- data/lib/openc3/topics/telemetry_decom_topic.rb +12 -3
- data/lib/openc3/topics/topic.rb +2 -1
- data/lib/openc3/utilities/authentication.rb +67 -16
- data/lib/openc3/utilities/cli_generator.rb +117 -25
- data/lib/openc3/utilities/client_ip_header_filter.rb +38 -0
- data/lib/openc3/utilities/config_overlay.rb +24 -1
- data/lib/openc3/utilities/cosmos_rails_formatter.rb +18 -10
- data/lib/openc3/utilities/hardware_discovery.rb +279 -0
- data/lib/openc3/utilities/limits_rollup.rb +81 -0
- data/lib/openc3/utilities/local_mode.rb +48 -5
- data/lib/openc3/utilities/questdb_client.rb +130 -22
- data/lib/openc3/utilities/reingest_job.rb +12 -3
- data/lib/openc3/utilities/running_script.rb +206 -49
- data/lib/openc3/utilities/script.rb +24 -12
- data/lib/openc3/utilities/script_env.rb +164 -0
- data/lib/openc3/utilities/script_message_signing.rb +133 -0
- data/lib/openc3/utilities/store_autoload.rb +32 -1
- data/lib/openc3/utilities/store_queued.rb +5 -1
- data/lib/openc3/version.rb +6 -6
- data/templates/command_validator/command_validator.py +9 -9
- data/templates/{tool_react/pnpm-workspace.yaml → panel/.prettierrc.cjs} +7 -5
- data/templates/panel/Rakefile +24 -0
- data/templates/panel/package.json +17 -0
- data/templates/{tool_angular → panel}/pnpm-workspace.yaml +5 -0
- data/templates/panel/src/Panel.js +52 -0
- data/templates/panel/src/Panel.vue +60 -0
- data/templates/panel/src/panelSdk.js +24 -0
- data/templates/panel/vite-Panel.config.js +43 -0
- data/templates/tool_vue/package.json +3 -3
- data/templates/widget/package.json +2 -2
- metadata +24 -56
- data/templates/tool_angular/.editorconfig +0 -16
- data/templates/tool_angular/.gitignore +0 -44
- data/templates/tool_angular/.vscode/extensions.json +0 -4
- data/templates/tool_angular/.vscode/launch.json +0 -20
- data/templates/tool_angular/.vscode/tasks.json +0 -42
- data/templates/tool_angular/angular.json +0 -111
- data/templates/tool_angular/extra-webpack.config.js +0 -8
- data/templates/tool_angular/package.json +0 -48
- data/templates/tool_angular/src/app/app-routing.module.ts +0 -15
- data/templates/tool_angular/src/app/app.component.html +0 -22
- data/templates/tool_angular/src/app/app.component.scss +0 -18
- data/templates/tool_angular/src/app/app.component.spec.ts +0 -29
- data/templates/tool_angular/src/app/app.component.ts +0 -52
- data/templates/tool_angular/src/app/app.module.ts +0 -30
- data/templates/tool_angular/src/app/custom-overlay-container.ts +0 -17
- data/templates/tool_angular/src/app/empty-route/empty-route.component.ts +0 -7
- data/templates/tool_angular/src/app/openc3-api.d.ts +0 -1
- data/templates/tool_angular/src/assets/.gitkeep +0 -0
- data/templates/tool_angular/src/environments/environment.prod.ts +0 -3
- data/templates/tool_angular/src/environments/environment.ts +0 -16
- data/templates/tool_angular/src/favicon.ico +0 -0
- data/templates/tool_angular/src/index.html +0 -13
- data/templates/tool_angular/src/main.single-spa.ts +0 -40
- data/templates/tool_angular/src/single-spa/asset-url.ts +0 -12
- data/templates/tool_angular/src/single-spa/single-spa-props.ts +0 -8
- data/templates/tool_angular/src/styles.scss +0 -1
- data/templates/tool_angular/tsconfig.app.json +0 -13
- data/templates/tool_angular/tsconfig.json +0 -33
- data/templates/tool_angular/tsconfig.spec.json +0 -14
- data/templates/tool_react/.eslintrc +0 -7
- data/templates/tool_react/.gitignore +0 -71
- data/templates/tool_react/.prettierignore +0 -8
- data/templates/tool_react/babel.config.json +0 -29
- data/templates/tool_react/jest.config.js +0 -12
- data/templates/tool_react/package.json +0 -51
- data/templates/tool_react/src/openc3-tool_name.js +0 -24
- data/templates/tool_react/src/root.component.js +0 -88
- data/templates/tool_react/src/root.component.test.js +0 -9
- data/templates/tool_react/webpack.config.js +0 -27
- data/templates/tool_svelte/.gitignore +0 -71
- data/templates/tool_svelte/.prettierignore +0 -8
- data/templates/tool_svelte/.prettierrc.js +0 -5
- data/templates/tool_svelte/babel.config.js +0 -12
- data/templates/tool_svelte/build/smui.css +0 -1
- data/templates/tool_svelte/jest.config.js +0 -9
- data/templates/tool_svelte/package.json +0 -49
- data/templates/tool_svelte/pnpm-workspace.yaml +0 -20
- data/templates/tool_svelte/rollup.config.js +0 -74
- data/templates/tool_svelte/src/App.svelte +0 -42
- data/templates/tool_svelte/src/App.test.js +0 -9
- data/templates/tool_svelte/src/theme/_smui-theme.scss +0 -25
- data/templates/tool_svelte/src/tool_name.js +0 -17
- data/templates/widget/LICENSE.md +0 -20
|
@@ -18,7 +18,10 @@ module OpenC3
|
|
|
18
18
|
class PluginStoreModel < Model
|
|
19
19
|
PRIMARY_KEY = 'openc3_plugin_store'
|
|
20
20
|
DEFAULT_STORE_URL = 'https://store.openc3.com'
|
|
21
|
-
|
|
21
|
+
# v1.3 adds the hardware discovery data of each plugin (see HardwareDiscovery).
|
|
22
|
+
# Older stores (e.g. self-hosted) don't have it, so fall back to v1.2.
|
|
23
|
+
JSON_ENDPOINT = '/api/v1.3/cosmos_plugins'
|
|
24
|
+
FALLBACK_JSON_ENDPOINT = '/api/v1.2/cosmos_plugins'
|
|
22
25
|
|
|
23
26
|
def self.set(plugin_store_data)
|
|
24
27
|
Store.set(PRIMARY_KEY, plugin_store_data)
|
|
@@ -57,6 +60,8 @@ module OpenC3
|
|
|
57
60
|
end
|
|
58
61
|
|
|
59
62
|
response = conn.get(JSON_ENDPOINT)
|
|
63
|
+
# Stores without v1.3 reject it as an unknown API version
|
|
64
|
+
response = conn.get(FALLBACK_JSON_ENDPOINT) if [400, 404].include?(response.status)
|
|
60
65
|
if response.success?
|
|
61
66
|
self.set(response.body)
|
|
62
67
|
else
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
# Copyright 2026 OpenC3, Inc.
|
|
4
|
+
# All Rights Reserved.
|
|
5
|
+
#
|
|
6
|
+
# This program is distributed in the hope that it will be useful,
|
|
7
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
8
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
9
|
+
# See LICENSE.md for more details.
|
|
10
|
+
#
|
|
11
|
+
# This file may also be used under the terms of a commercial license
|
|
12
|
+
# if purchased from OpenC3, Inc.
|
|
13
|
+
|
|
14
|
+
require 'openc3/utilities/store'
|
|
15
|
+
|
|
16
|
+
module OpenC3
|
|
17
|
+
# Registry of protected storage locations. A location is a bucket or volume
|
|
18
|
+
# (named by its OPENC3_*_BUCKET / OPENC3_*_VOLUME environment variable) plus
|
|
19
|
+
# an optional key prefix. Bucket Explorer hides protected locations from, and
|
|
20
|
+
# refuses access to, everyone but system administrators (superadmin).
|
|
21
|
+
class ProtectedStorageModel
|
|
22
|
+
KEY = 'openc3__protected_storage'
|
|
23
|
+
|
|
24
|
+
# @param root [String] Environment variable name such as OPENC3_CONFIG_BUCKET
|
|
25
|
+
# @param prefix [String] Key prefix to protect. An empty prefix protects the whole root.
|
|
26
|
+
def self.add(root:, prefix: '')
|
|
27
|
+
Store.sadd(KEY, "#{root}:#{normalize_prefix(prefix)}")
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# @param root [String] Environment variable name such as OPENC3_CONFIG_BUCKET
|
|
31
|
+
# @param key [String] Key or path within the root
|
|
32
|
+
# @param contains [Boolean] Also true if a protected location is inside key,
|
|
33
|
+
# i.e. key is a parent that would include protected content (used for directory deletes)
|
|
34
|
+
# @return [Boolean] true if key is a protected prefix or inside one
|
|
35
|
+
def self.protected?(root:, key:, contains: false)
|
|
36
|
+
key = normalize_key(key)
|
|
37
|
+
dir = key.empty? ? '' : "#{key}/"
|
|
38
|
+
prefixes_for(root).any? { |prefix| dir.start_with?(prefix) || (contains && prefix.start_with?(dir)) }
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# @return [Boolean] true if any location is protected for the root
|
|
42
|
+
def self.any?(root:)
|
|
43
|
+
!prefixes_for(root).empty?
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Canonical key: no empty or '.' segments, so no leading, trailing or doubled slashes.
|
|
47
|
+
# Storage backends resolve './' and '//' inside a key to the canonical key so a raw
|
|
48
|
+
# comparison could be sidestepped.
|
|
49
|
+
def self.normalize_key(key)
|
|
50
|
+
key.to_s.split('/').reject { |part| part.empty? || part == '.' }.join('/')
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def self.normalize_prefix(prefix)
|
|
54
|
+
prefix = normalize_key(prefix)
|
|
55
|
+
prefix.empty? ? '' : "#{prefix}/"
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def self.prefixes_for(root)
|
|
59
|
+
marker = "#{root}:"
|
|
60
|
+
Store.smembers(KEY).select { |member| member.start_with?(marker) }.map { |member| member[marker.length..] }
|
|
61
|
+
end
|
|
62
|
+
private_class_method :prefixes_for
|
|
63
|
+
end
|
|
64
|
+
end
|
|
@@ -40,7 +40,7 @@ module OpenC3
|
|
|
40
40
|
end
|
|
41
41
|
# END NOTE
|
|
42
42
|
|
|
43
|
-
def self.queue_command(name, command: nil, target_name: nil, cmd_name: nil, cmd_params: nil, validate: true, timeout: nil, username:, scope:)
|
|
43
|
+
def self.queue_command(name, command: nil, target_name: nil, cmd_name: nil, cmd_params: nil, extra: nil, validate: true, timeout: nil, username:, scope:)
|
|
44
44
|
model = get_model(name: name, scope: scope)
|
|
45
45
|
raise QueueError, "Queue '#{name}' not found in scope '#{scope}'" unless model
|
|
46
46
|
|
|
@@ -53,7 +53,7 @@ module OpenC3
|
|
|
53
53
|
id = result.empty? ? 1.0 : result[0][1].to_f + 1
|
|
54
54
|
|
|
55
55
|
command_data = build_command_data(username: username, command: command, target_name: target_name,
|
|
56
|
-
cmd_name: cmd_name, cmd_params: cmd_params, validate: validate, timeout: timeout)
|
|
56
|
+
cmd_name: cmd_name, cmd_params: cmd_params, extra: extra, validate: validate, timeout: timeout)
|
|
57
57
|
Store.zadd("#{scope}:#{name}", id, command_data.to_json)
|
|
58
58
|
model.notify(kind: 'command')
|
|
59
59
|
end
|
|
@@ -61,7 +61,7 @@ module OpenC3
|
|
|
61
61
|
# Build the hash that gets serialized into Redis. Always uses symbol keys so
|
|
62
62
|
# downstream code in this class can access values consistently. cmd_params is
|
|
63
63
|
# JSON-encoded as a string so binary data survives the round-trip via as_json.
|
|
64
|
-
def self.build_command_data(username:, command: nil, target_name: nil, cmd_name: nil, cmd_params: nil, validate: nil, timeout: nil)
|
|
64
|
+
def self.build_command_data(username:, command: nil, target_name: nil, cmd_name: nil, cmd_params: nil, extra: nil, validate: nil, timeout: nil)
|
|
65
65
|
command_data = { username: username, timestamp: Time.now.to_nsec_from_epoch }
|
|
66
66
|
if target_name && cmd_name
|
|
67
67
|
command_data[:target_name] = target_name
|
|
@@ -74,6 +74,10 @@ module OpenC3
|
|
|
74
74
|
end
|
|
75
75
|
command_data[:validate] = validate unless validate.nil?
|
|
76
76
|
command_data[:timeout] = timeout unless timeout.nil?
|
|
77
|
+
unless extra.nil?
|
|
78
|
+
# extra is already a JSON string when carried forward from an existing queue entry
|
|
79
|
+
command_data[:extra] = extra.is_a?(String) ? extra : JSON.generate(extra.as_json, allow_nan: true)
|
|
80
|
+
end
|
|
77
81
|
command_data
|
|
78
82
|
end
|
|
79
83
|
|
|
@@ -118,7 +122,7 @@ module OpenC3
|
|
|
118
122
|
QueueTopic.write_notification(notification, scope: @scope)
|
|
119
123
|
end
|
|
120
124
|
|
|
121
|
-
def insert_command(id: nil, username:, command: nil, target_name: nil, cmd_name: nil, cmd_params: nil, validate: nil, timeout: nil)
|
|
125
|
+
def insert_command(id: nil, username:, command: nil, target_name: nil, cmd_name: nil, cmd_params: nil, extra: nil, validate: nil, timeout: nil)
|
|
122
126
|
if @state == 'DISABLE'
|
|
123
127
|
command_name = command || "#{target_name} #{cmd_name}"
|
|
124
128
|
raise QueueError, "Queue '#{@name}' is disabled. Command '#{command_name}' not queued."
|
|
@@ -130,12 +134,12 @@ module OpenC3
|
|
|
130
134
|
end
|
|
131
135
|
|
|
132
136
|
command_data = self.class.build_command_data(username: username, command: command, target_name: target_name,
|
|
133
|
-
cmd_name: cmd_name, cmd_params: cmd_params, validate: validate, timeout: timeout)
|
|
137
|
+
cmd_name: cmd_name, cmd_params: cmd_params, extra: extra, validate: validate, timeout: timeout)
|
|
134
138
|
Store.zadd("#{@scope}:#{@name}", id, command_data.to_json)
|
|
135
139
|
notify(kind: 'command')
|
|
136
140
|
end
|
|
137
141
|
|
|
138
|
-
def update_command(id:, username:, command: nil, target_name: nil, cmd_name: nil, cmd_params: nil, validate: nil, timeout: nil)
|
|
142
|
+
def update_command(id:, username:, command: nil, target_name: nil, cmd_name: nil, cmd_params: nil, extra: nil, validate: nil, timeout: nil)
|
|
139
143
|
if @state == 'DISABLE'
|
|
140
144
|
raise QueueError, "Queue '#{@name}' is disabled. Command at id #{id} not updated."
|
|
141
145
|
end
|
|
@@ -145,10 +149,15 @@ module OpenC3
|
|
|
145
149
|
raise QueueError, "No command found at id #{id} in queue '#{@name}'"
|
|
146
150
|
end
|
|
147
151
|
|
|
148
|
-
|
|
152
|
+
# Carry forward the caller metadata attached by cmd(extra: ...) when the update
|
|
153
|
+
# doesn't supply its own. Editing a queued command shouldn't silently drop it.
|
|
154
|
+
extra = JSON.parse(existing[0])['extra'] if extra.nil?
|
|
155
|
+
|
|
156
|
+
# Serialize before removing so bad replacement metadata can't drop the queued command
|
|
149
157
|
command_data = self.class.build_command_data(username: username, command: command, target_name: target_name,
|
|
150
|
-
cmd_name: cmd_name, cmd_params: cmd_params, validate: validate, timeout: timeout)
|
|
151
|
-
Store.
|
|
158
|
+
cmd_name: cmd_name, cmd_params: cmd_params, extra: extra, validate: validate, timeout: timeout).to_json
|
|
159
|
+
Store.zremrangebyscore("#{@scope}:#{@name}", id, id)
|
|
160
|
+
Store.zadd("#{@scope}:#{@name}", id, command_data)
|
|
152
161
|
notify(kind: 'command')
|
|
153
162
|
end
|
|
154
163
|
|
|
@@ -243,4 +252,4 @@ module OpenC3
|
|
|
243
252
|
super()
|
|
244
253
|
end
|
|
245
254
|
end
|
|
246
|
-
end
|
|
255
|
+
end
|
|
@@ -44,6 +44,7 @@ end
|
|
|
44
44
|
module OpenC3
|
|
45
45
|
class ScopeModel < Model
|
|
46
46
|
PRIMARY_KEY = "openc3_scopes"
|
|
47
|
+
MAX_CRITICAL_CMD_APPROVERS = 10
|
|
47
48
|
|
|
48
49
|
# Default thresholds used by the System Health tool and the metrics
|
|
49
50
|
# microservices. Stored in the 'system_health' setting as a JSON string.
|
|
@@ -85,7 +86,11 @@ module OpenC3
|
|
|
85
86
|
attr_accessor :cleanup_poll_time
|
|
86
87
|
attr_accessor :command_authority
|
|
87
88
|
attr_accessor :critical_commanding
|
|
89
|
+
attr_accessor :critical_cmd_approvers
|
|
88
90
|
attr_accessor :shard
|
|
91
|
+
# Whether the microservices in this scope run. A disabled scope keeps its
|
|
92
|
+
# configuration and data but the operators stop all of its microservices.
|
|
93
|
+
attr_accessor :enabled
|
|
89
94
|
|
|
90
95
|
# NOTE: The following three class methods are used by the ModelController
|
|
91
96
|
# and are reimplemented to enable various Model class methods to work
|
|
@@ -119,6 +124,19 @@ module OpenC3
|
|
|
119
124
|
end
|
|
120
125
|
end
|
|
121
126
|
|
|
127
|
+
# @return [Array<String>] Names of the scopes which have been disabled
|
|
128
|
+
def self.disabled_scopes
|
|
129
|
+
all().select { |_name, json| json['enabled'] == false }.keys
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
# @return [Boolean] Whether the named scope's microservices should run.
|
|
133
|
+
# Unknown scopes are reported as enabled.
|
|
134
|
+
def self.enabled?(name)
|
|
135
|
+
json = get(name: name)
|
|
136
|
+
return true unless json
|
|
137
|
+
json['enabled'] != false
|
|
138
|
+
end
|
|
139
|
+
|
|
122
140
|
def initialize(name:,
|
|
123
141
|
text_log_cycle_time: 600,
|
|
124
142
|
text_log_cycle_size: 50_000_000,
|
|
@@ -127,7 +145,9 @@ module OpenC3
|
|
|
127
145
|
cleanup_poll_time: 3600,
|
|
128
146
|
command_authority: false,
|
|
129
147
|
critical_commanding: "OFF",
|
|
148
|
+
critical_cmd_approvers: 1,
|
|
130
149
|
shard: 0,
|
|
150
|
+
enabled: true,
|
|
131
151
|
updated_at: nil)
|
|
132
152
|
super(
|
|
133
153
|
PRIMARY_KEY,
|
|
@@ -148,7 +168,17 @@ module OpenC3
|
|
|
148
168
|
unless ["OFF", "NORMAL", "ALL"].include?(@critical_commanding)
|
|
149
169
|
raise "Invalid value for critical_commanding: #{@critical_commanding}"
|
|
150
170
|
end
|
|
171
|
+
# Number of distinct users (other than the sender) who must approve each critical command
|
|
172
|
+
# Only accept whole numbers so values like 1.9 or "2oops" aren't silently truncated
|
|
173
|
+
approvers = critical_cmd_approvers.nil? ? 1 : critical_cmd_approvers
|
|
174
|
+
approvers = approvers.strip if approvers.is_a?(String)
|
|
175
|
+
@critical_cmd_approvers = approvers.to_i if approvers.is_a?(Integer) or (approvers.is_a?(String) and /\A[0-9]+\z/.match?(approvers))
|
|
176
|
+
if @critical_cmd_approvers.nil? or @critical_cmd_approvers < 1 or @critical_cmd_approvers > MAX_CRITICAL_CMD_APPROVERS
|
|
177
|
+
raise "Invalid value for critical_cmd_approvers: #{critical_cmd_approvers} (must be 1 to #{MAX_CRITICAL_CMD_APPROVERS})"
|
|
178
|
+
end
|
|
151
179
|
@shard = shard.to_i # to_i to handle nil
|
|
180
|
+
# Scopes created before this setting existed are enabled
|
|
181
|
+
@enabled = !(enabled == false or enabled.to_s.downcase == 'false')
|
|
152
182
|
@children = []
|
|
153
183
|
end
|
|
154
184
|
|
|
@@ -159,6 +189,8 @@ module OpenC3
|
|
|
159
189
|
raise "Invalid scope name: #{@name} (double underscore not allowed)" if @name.include?("__")
|
|
160
190
|
@name = @name.upcase
|
|
161
191
|
@scope = @name # Ensure @scope matches @name
|
|
192
|
+
# DEFAULT runs the cluster wide microservices (NOSCOPE logging, periodic, etc)
|
|
193
|
+
raise "DEFAULT scope cannot be disabled" if @name == "DEFAULT" and !@enabled
|
|
162
194
|
# Ensure the various cycle and retain times are integers
|
|
163
195
|
@text_log_cycle_time = @text_log_cycle_time.to_i
|
|
164
196
|
@text_log_cycle_size = @text_log_cycle_size.to_i
|
|
@@ -213,12 +245,14 @@ module OpenC3
|
|
|
213
245
|
"cleanup_poll_time" => @cleanup_poll_time,
|
|
214
246
|
"command_authority" => @command_authority,
|
|
215
247
|
"critical_commanding" => @critical_commanding,
|
|
216
|
-
"
|
|
248
|
+
"critical_cmd_approvers" => @critical_cmd_approvers,
|
|
249
|
+
"shard" => @shard,
|
|
250
|
+
"enabled" => @enabled}
|
|
217
251
|
end
|
|
218
252
|
|
|
219
253
|
# Every scope gets a DEFAULT bridge_microservice: the Iroh hub that lets
|
|
220
|
-
# openc3-app run COSMOS interfaces on the host. It idles (no data streams,
|
|
221
|
-
# no enrolled app) until an interface is bridged / openc3-app enrolls.
|
|
254
|
+
# openc3-cosmos-app run COSMOS interfaces on the host. It idles (no data streams,
|
|
255
|
+
# no enrolled app) until an interface is bridged / openc3-cosmos-app enrolls.
|
|
222
256
|
#
|
|
223
257
|
# It is a top-level microservice (spawned directly by the operator), NOT a
|
|
224
258
|
# child of SCOPEMULTI: that runs its Ruby children in-process, and the bridge
|
|
@@ -338,6 +372,27 @@ module OpenC3
|
|
|
338
372
|
Logger.info "Configured microservice #{microservice_name}"
|
|
339
373
|
end
|
|
340
374
|
|
|
375
|
+
def deploy_limits_group_microservice(gem_path, variables, parent)
|
|
376
|
+
microservice_name = "#{@scope}__LIMITSGROUP__#{@scope}"
|
|
377
|
+
microservice = MicroserviceModel.new(**self.class.limits_group_microservice_options(@scope, @shard, parent))
|
|
378
|
+
microservice.create
|
|
379
|
+
microservice.deploy(gem_path, variables)
|
|
380
|
+
@children << microservice_name if parent
|
|
381
|
+
Logger.info "Configured microservice #{microservice_name}"
|
|
382
|
+
end
|
|
383
|
+
|
|
384
|
+
# Shared with the migration which adds the limits group microservice to existing scopes
|
|
385
|
+
def self.limits_group_microservice_options(scope, shard, parent)
|
|
386
|
+
{
|
|
387
|
+
name: "#{scope}__LIMITSGROUP__#{scope}",
|
|
388
|
+
cmd: ["ruby", "limits_group_microservice.rb", "#{scope}__LIMITSGROUP__#{scope}"],
|
|
389
|
+
work_dir: "/openc3/lib/openc3/microservices",
|
|
390
|
+
parent: parent,
|
|
391
|
+
shard: shard,
|
|
392
|
+
scope: scope
|
|
393
|
+
}
|
|
394
|
+
end
|
|
395
|
+
|
|
341
396
|
def deploy_critical_cmd_microservice(gem_path, variables, parent)
|
|
342
397
|
microservice_name = "#{@scope}__CRITICALCMD__#{@scope}"
|
|
343
398
|
microservice = MicroserviceModel.new(
|
|
@@ -354,6 +409,22 @@ module OpenC3
|
|
|
354
409
|
Logger.info "Configured microservice #{microservice_name}"
|
|
355
410
|
end
|
|
356
411
|
|
|
412
|
+
# Runs the TSDB partition archive, restore and release jobs. Its own process (not a SCOPEMULTI child), since
|
|
413
|
+
# the jobs are long and on Kubernetes it gets the archive volume.
|
|
414
|
+
def deploy_tsdb_partitions_microservice(gem_path, variables)
|
|
415
|
+
microservice_name = "#{@scope}__TSDBPARTITIONS__#{@scope}"
|
|
416
|
+
microservice = MicroserviceModel.new(
|
|
417
|
+
name: microservice_name,
|
|
418
|
+
cmd: ["ruby", "tsdb_partitions_microservice.rb", microservice_name],
|
|
419
|
+
work_dir: "/openc3-enterprise/lib/openc3-enterprise/microservices",
|
|
420
|
+
shard: @shard,
|
|
421
|
+
scope: @scope
|
|
422
|
+
)
|
|
423
|
+
microservice.create
|
|
424
|
+
microservice.deploy(gem_path, variables)
|
|
425
|
+
Logger.info "Configured microservice #{microservice_name}"
|
|
426
|
+
end
|
|
427
|
+
|
|
357
428
|
def deploy_scopemulti_microservice(gem_path, variables)
|
|
358
429
|
microservice_name = "#{@scope}__SCOPEMULTI__#{@scope}"
|
|
359
430
|
microservice = MicroserviceModel.new(
|
|
@@ -401,11 +472,17 @@ module OpenC3
|
|
|
401
472
|
if @scope == "DEFAULT"
|
|
402
473
|
# Periodic Microservice
|
|
403
474
|
deploy_periodic_microservice(gem_path, variables, @parent)
|
|
475
|
+
|
|
476
|
+
# TSDB data is cluster wide, so one TSDB Partitions Microservice serves every scope
|
|
477
|
+
deploy_tsdb_partitions_microservice(gem_path, variables) if ENTERPRISE
|
|
404
478
|
end
|
|
405
479
|
|
|
406
480
|
# Scope Cleanup Microservice
|
|
407
481
|
deploy_scopecleanup_microservice(gem_path, variables, @parent)
|
|
408
482
|
|
|
483
|
+
# Limits Group Microservice publishes each target's LIMITS_GROUP packet
|
|
484
|
+
deploy_limits_group_microservice(gem_path, variables, @parent)
|
|
485
|
+
|
|
409
486
|
if ENTERPRISE
|
|
410
487
|
# Critical Cmd Microservice
|
|
411
488
|
deploy_critical_cmd_microservice(gem_path, variables, @parent)
|
|
@@ -352,7 +352,7 @@ module OpenC3
|
|
|
352
352
|
# and overwriting it is the silent clobber this mechanism exists to
|
|
353
353
|
# prevent. The cost is that a deployment upgrading into this feature needs
|
|
354
354
|
# one run with OVERWRITE_ENV_VAR before env changes take effect again. That
|
|
355
|
-
# cost is documented for operators too - compose.override.yaml under
|
|
355
|
+
# cost is documented for operators too - compose.override.example.yaml under
|
|
356
356
|
# OPENC3_SETTINGS_OVERWRITE and `cli initsettings --help` both say it -
|
|
357
357
|
# so keep those in sync with this behavior.
|
|
358
358
|
def self.seeded_value?(name, current)
|
|
@@ -505,7 +505,7 @@ module OpenC3
|
|
|
505
505
|
|
|
506
506
|
# One "KEY=value" env entry, quoted when YAML would otherwise mangle it.
|
|
507
507
|
# JSON always contains '":', which YAML reads as a mapping, so those always
|
|
508
|
-
# need quoting - the exact trap the compose.override.yaml comments warn about.
|
|
508
|
+
# need quoting - the exact trap the compose.override.example.yaml comments warn about.
|
|
509
509
|
def self.yaml_env_item(name, data)
|
|
510
510
|
value = data.is_a?(String) ? data : JSON.generate(data)
|
|
511
511
|
entry = "#{SETTING_ENV_PREFIX}#{name.upcase}=#{value}"
|