openc3 6.9.0 → 6.9.1
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/lib/openc3/microservices/queue_microservice.rb +4 -21
- data/lib/openc3/models/microservice_model.rb +1 -1
- data/lib/openc3/models/queue_model.rb +24 -24
- data/lib/openc3/script/queue.rb +11 -3
- data/lib/openc3/utilities/running_script.rb +2 -3
- data/lib/openc3/version.rb +5 -5
- data/templates/tool_angular/package.json +2 -2
- data/templates/tool_react/package.json +1 -1
- data/templates/tool_svelte/package.json +1 -1
- data/templates/tool_vue/package.json +3 -3
- data/templates/widget/package.json +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83838350c2ec54b5fcd1b6108f42fe9d7f45fd24f6de04fb7c5c98855251b9b9
|
4
|
+
data.tar.gz: c1b89314a5af6f7740857228d01c0ab9e2b2e03e59c209b0e646fefb4f281425
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35be666ae0ea4d134fa6c7d54d79ee323e5d878918c25706d17514b1db8b28b6ca05c6c0f175426f285227e6fd16d6b90ccbf21316c71057aaaf958660a7c8a7
|
7
|
+
data.tar.gz: 3c0f703c797d6fbd1be90d526a91ac94a06ec6d9ad042e3ea1212da4c73557be6e4634be73ca49f17c8277f7b7052154e0283b0a994f84f91cf96422811155ac
|
@@ -19,7 +19,7 @@
|
|
19
19
|
require 'openc3/microservices/microservice'
|
20
20
|
require 'openc3/topics/queue_topic'
|
21
21
|
require 'openc3/utilities/authentication'
|
22
|
-
require 'openc3/
|
22
|
+
require 'openc3/api/api'
|
23
23
|
|
24
24
|
module OpenC3
|
25
25
|
module Script
|
@@ -32,6 +32,8 @@ module OpenC3
|
|
32
32
|
|
33
33
|
# The queue processor runs in a single thread and processes commands via cmd_api.
|
34
34
|
class QueueProcessor
|
35
|
+
include Api # Provides access to api methods
|
36
|
+
|
35
37
|
attr_accessor :state
|
36
38
|
attr_reader :name, :scope
|
37
39
|
|
@@ -43,23 +45,6 @@ module OpenC3
|
|
43
45
|
@cancel_thread = false
|
44
46
|
end
|
45
47
|
|
46
|
-
def get_token(username)
|
47
|
-
if ENV['OPENC3_API_CLIENT'].nil?
|
48
|
-
ENV['OPENC3_API_PASSWORD'] ||= ENV['OPENC3_SERVICE_PASSWORD']
|
49
|
-
return OpenC3Authentication.new().token
|
50
|
-
else
|
51
|
-
# Check for offline access token
|
52
|
-
model = nil
|
53
|
-
model = OpenC3::OfflineAccessModel.get_model(name: username, scope: @scope) if username and username != ''
|
54
|
-
if model and model.offline_access_token
|
55
|
-
auth = OpenC3KeycloakAuthentication.new(ENV['OPENC3_KEYCLOAK_URL'])
|
56
|
-
return auth.get_token_from_refresh_token(model.offline_access_token)
|
57
|
-
else
|
58
|
-
return nil
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
48
|
def run
|
64
49
|
while true
|
65
50
|
if @state == 'RELEASE'
|
@@ -77,13 +62,11 @@ module OpenC3
|
|
77
62
|
_queue_name, command_data, _timestamp = Store.bzpopmin("#{@scope}:#{@name}", timeout: 0.2)
|
78
63
|
if command_data
|
79
64
|
command = JSON.parse(command_data)
|
80
|
-
username = command['username']
|
81
|
-
token = get_token(username)
|
82
65
|
# It's important to set queue: false here to avoid infinite recursion when
|
83
66
|
# OPENC3_DEFAULT_QUEUE is set because commands would be re-queued to the default queue
|
84
67
|
# NOTE: cmd() via script rescues hazardous errors and calls prompt_for_hazardous()
|
85
68
|
# but we've overridden it to always return true and go straight to cmd_no_hazardous_check()
|
86
|
-
cmd(command['value'], queue: false, scope: @scope
|
69
|
+
cmd(command['value'], queue: false, scope: @scope)
|
87
70
|
end
|
88
71
|
rescue StandardError => e
|
89
72
|
@logger.error "QueueProcessor failed to process command from queue #{@name}\n#{e.message}"
|
@@ -157,7 +157,7 @@ module OpenC3
|
|
157
157
|
'updated_at' => @updated_at,
|
158
158
|
'plugin' => @plugin,
|
159
159
|
'needs_dependencies' => @needs_dependencies,
|
160
|
-
'secrets' => @secrets
|
160
|
+
'secrets' => @secrets,
|
161
161
|
'prefix' => @prefix,
|
162
162
|
'disable_erb' => @disable_erb,
|
163
163
|
'ignore_changes' => @ignore_changes,
|
@@ -51,11 +51,11 @@ module OpenC3
|
|
51
51
|
if model.state != 'DISABLE'
|
52
52
|
result = Store.zrevrange("#{scope}:#{name}", 0, 0, with_scores: true)
|
53
53
|
if result.empty?
|
54
|
-
|
54
|
+
id = 1.0
|
55
55
|
else
|
56
|
-
|
56
|
+
id = result[0][1].to_f + 1
|
57
57
|
end
|
58
|
-
Store.zadd("#{scope}:#{name}",
|
58
|
+
Store.zadd("#{scope}:#{name}", id, { username: username, value: command, timestamp: Time.now.to_nsec_from_epoch }.to_json)
|
59
59
|
model.notify(kind: 'command')
|
60
60
|
else
|
61
61
|
raise QueueError, "Queue '#{name}' is disabled. Command '#{command}' not queued."
|
@@ -103,55 +103,55 @@ module OpenC3
|
|
103
103
|
QueueTopic.write_notification(notification, scope: @scope)
|
104
104
|
end
|
105
105
|
|
106
|
-
def insert_command(
|
106
|
+
def insert_command(id, command_data)
|
107
107
|
if @state == 'DISABLE'
|
108
108
|
raise QueueError, "Queue '#{@name}' is disabled. Command '#{command_data['value']}' not queued."
|
109
109
|
end
|
110
110
|
|
111
|
-
unless
|
111
|
+
unless id
|
112
112
|
result = Store.zrevrange("#{@scope}:#{@name}", 0, 0, with_scores: true)
|
113
113
|
if result.empty?
|
114
|
-
|
114
|
+
id = 1.0
|
115
115
|
else
|
116
|
-
|
116
|
+
id = result[0][1].to_f + 1
|
117
117
|
end
|
118
118
|
end
|
119
|
-
Store.zadd("#{@scope}:#{@name}",
|
119
|
+
Store.zadd("#{@scope}:#{@name}", id, command_data.to_json)
|
120
120
|
notify(kind: 'command')
|
121
121
|
end
|
122
122
|
|
123
|
-
def update_command(
|
123
|
+
def update_command(id:, command:, username:)
|
124
124
|
if @state == 'DISABLE'
|
125
|
-
raise QueueError, "Queue '#{@name}' is disabled. Command at
|
125
|
+
raise QueueError, "Queue '#{@name}' is disabled. Command at id #{id} not updated."
|
126
126
|
end
|
127
127
|
|
128
|
-
# Check if command exists at the given
|
129
|
-
existing = Store.zrangebyscore("#{@scope}:#{@name}",
|
128
|
+
# Check if command exists at the given id
|
129
|
+
existing = Store.zrangebyscore("#{@scope}:#{@name}", id, id)
|
130
130
|
if existing.empty?
|
131
|
-
raise QueueError, "No command found at
|
131
|
+
raise QueueError, "No command found at id #{id} in queue '#{@name}'"
|
132
132
|
end
|
133
133
|
|
134
|
-
# Remove the existing command and add the new one at the same
|
135
|
-
Store.zremrangebyscore("#{@scope}:#{@name}",
|
134
|
+
# Remove the existing command and add the new one at the same id
|
135
|
+
Store.zremrangebyscore("#{@scope}:#{@name}", id, id)
|
136
136
|
command_data = { username: username, value: command, timestamp: Time.now.to_nsec_from_epoch }
|
137
|
-
Store.zadd("#{@scope}:#{@name}",
|
137
|
+
Store.zadd("#{@scope}:#{@name}", id, command_data.to_json)
|
138
138
|
notify(kind: 'command')
|
139
139
|
end
|
140
140
|
|
141
|
-
def remove_command(
|
141
|
+
def remove_command(id = nil)
|
142
142
|
if @state == 'DISABLE'
|
143
143
|
raise QueueError, "Queue '#{@name}' is disabled. Command not removed."
|
144
144
|
end
|
145
145
|
|
146
|
-
if
|
147
|
-
# Remove specific
|
148
|
-
result = Store.zrangebyscore("#{@scope}:#{@name}",
|
146
|
+
if id
|
147
|
+
# Remove specific id
|
148
|
+
result = Store.zrangebyscore("#{@scope}:#{@name}", id, id)
|
149
149
|
if result.empty?
|
150
150
|
return nil
|
151
151
|
else
|
152
|
-
Store.zremrangebyscore("#{@scope}:#{@name}",
|
152
|
+
Store.zremrangebyscore("#{@scope}:#{@name}", id, id)
|
153
153
|
command_data = JSON.parse(result[0])
|
154
|
-
command_data['
|
154
|
+
command_data['id'] = id.to_f
|
155
155
|
notify(kind: 'command')
|
156
156
|
return command_data
|
157
157
|
end
|
@@ -164,7 +164,7 @@ module OpenC3
|
|
164
164
|
score = result[0][1]
|
165
165
|
Store.zremrangebyscore("#{@scope}:#{@name}", score, score)
|
166
166
|
command_data = JSON.parse(result[0][0])
|
167
|
-
command_data['
|
167
|
+
command_data['id'] = score.to_f
|
168
168
|
notify(kind: 'command')
|
169
169
|
return command_data
|
170
170
|
end
|
@@ -174,7 +174,7 @@ module OpenC3
|
|
174
174
|
def list
|
175
175
|
return Store.zrange("#{@scope}:#{@name}", 0, -1, with_scores: true).map do |item|
|
176
176
|
result = JSON.parse(item[0])
|
177
|
-
result['
|
177
|
+
result['id'] = item[1].to_f
|
178
178
|
result
|
179
179
|
end
|
180
180
|
end
|
data/lib/openc3/script/queue.rb
CHANGED
@@ -31,7 +31,7 @@ module OpenC3
|
|
31
31
|
raise "Failed to #{action}. No response from server."
|
32
32
|
elsif response.status != 200 and response.status != 201
|
33
33
|
result = JSON.parse(response.body, allow_nan: true, create_additions: true)
|
34
|
-
raise "
|
34
|
+
raise "#{action} failed with status #{response.status}. #{result['message']}."
|
35
35
|
end
|
36
36
|
return JSON.parse(response.body, allow_nan: true, create_additions: true)
|
37
37
|
end
|
@@ -66,12 +66,20 @@ module OpenC3
|
|
66
66
|
return _make_request(action: 'disable queue', verb: 'post', uri: "/openc3-api/queues/#{name}/disable", scope: scope)
|
67
67
|
end
|
68
68
|
|
69
|
-
def queue_exec(name,
|
69
|
+
def queue_exec(name, id=nil, scope: $openc3_scope)
|
70
70
|
data = {}
|
71
|
-
data['
|
71
|
+
data['id'] = id if id
|
72
72
|
return _make_request(action: 'exec command', verb: 'post', uri: "/openc3-api/queues/#{name}/exec_command", data: data, scope: scope)
|
73
73
|
end
|
74
74
|
|
75
|
+
# No queue_insert because we do that through the cmd APIs with the queue kwarg
|
76
|
+
|
77
|
+
def queue_remove(name, id=nil, scope: $openc3_scope)
|
78
|
+
data = {}
|
79
|
+
data['id'] = id if id
|
80
|
+
return _make_request(action: 'remove command', verb: 'post', uri: "/openc3-api/queues/#{name}/remove_command", data: data, scope: scope)
|
81
|
+
end
|
82
|
+
|
75
83
|
def queue_delete(name, scope: $openc3_scope)
|
76
84
|
return _make_request(action: 'delete queue', verb: 'delete', uri: "/openc3-api/queues/#{name}", scope: scope)
|
77
85
|
end
|
@@ -458,8 +458,8 @@ class RunningScript
|
|
458
458
|
start_time: start_time, # Time the script started ISO format
|
459
459
|
end_time: nil, # Time the script ended ISO format
|
460
460
|
disconnect: disconnect, # Disconnect is set to true if the script is running in a disconnected mode
|
461
|
-
environment: status_environment
|
462
|
-
suite_runner: suite_runner ? suite_runner
|
461
|
+
environment: status_environment, # hash of environment variables set for the script
|
462
|
+
suite_runner: suite_runner ? suite_runner : nil, # current suite information if any
|
463
463
|
errors: nil, # array of errors that occurred during the script run
|
464
464
|
pid: nil, # pid of the script process - set by the script itself when it starts
|
465
465
|
script_engine: script_engine, # script engine filename
|
@@ -770,7 +770,6 @@ class RunningScript
|
|
770
770
|
|
771
771
|
def run
|
772
772
|
if @script_status.suite_runner
|
773
|
-
@script_status.suite_runner = JSON.parse(@script_status.suite_runner, allow_nan: true, create_additions: true) # Convert to hash
|
774
773
|
if @script_status.suite_runner['options']
|
775
774
|
parse_options(@script_status.suite_runner['options'])
|
776
775
|
else
|
data/lib/openc3/version.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# encoding: ascii-8bit
|
2
2
|
|
3
|
-
OPENC3_VERSION = '6.9.
|
3
|
+
OPENC3_VERSION = '6.9.1'
|
4
4
|
module OpenC3
|
5
5
|
module Version
|
6
6
|
MAJOR = '6'
|
7
7
|
MINOR = '9'
|
8
|
-
PATCH = '
|
8
|
+
PATCH = '1'
|
9
9
|
OTHER = ''
|
10
|
-
BUILD = '
|
10
|
+
BUILD = 'e1529f7b88799a9f85f31378db40a48b6c106899'
|
11
11
|
end
|
12
|
-
VERSION = '6.9.
|
13
|
-
GEM_VERSION = '6.9.
|
12
|
+
VERSION = '6.9.1'
|
13
|
+
GEM_VERSION = '6.9.1'
|
14
14
|
end
|
@@ -1,2 +1,2 @@
|
|
1
|
-
"version": "6.9.
|
2
|
-
"@openc3/js-common": "6.9.
|
1
|
+
"version": "6.9.1",
|
2
|
+
"@openc3/js-common": "6.9.1",
|
@@ -1 +1 @@
|
|
1
|
-
"@openc3/js-common": "6.9.
|
1
|
+
"@openc3/js-common": "6.9.1",
|
@@ -1 +1 @@
|
|
1
|
-
"@openc3/js-common": "6.9.
|
1
|
+
"@openc3/js-common": "6.9.1",
|
@@ -1,3 +1,3 @@
|
|
1
|
-
"version": "6.9.
|
2
|
-
"@openc3/js-common": "6.9.
|
3
|
-
"@openc3/vue-common": "6.9.
|
1
|
+
"version": "6.9.1",
|
2
|
+
"@openc3/js-common": "6.9.1",
|
3
|
+
"@openc3/vue-common": "6.9.1",
|
@@ -1,2 +1,2 @@
|
|
1
|
-
"version": "6.9.
|
2
|
-
"@openc3/vue-common": "6.9.
|
1
|
+
"version": "6.9.1",
|
2
|
+
"@openc3/vue-common": "6.9.1",
|