procon_bypass_man 0.3.5 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -3
- data/Gemfile.lock +1 -1
- data/Steepfile +0 -1
- data/bin/generate_output_report +18 -0
- data/lib/procon_bypass_man/background/jobs/post_completed_remote_action_job.rb +20 -0
- data/lib/procon_bypass_man/background/jobs/report_info_log_job.rb +11 -0
- data/lib/procon_bypass_man/background.rb +1 -0
- data/lib/procon_bypass_man/bypass/procon_to_switch.rb +3 -0
- data/lib/procon_bypass_man/commands/send_info_log_command.rb +11 -0
- data/lib/procon_bypass_man/commands.rb +1 -0
- data/lib/procon_bypass_man/configuration.rb +1 -1
- data/lib/procon_bypass_man/procon.rb +22 -11
- data/lib/procon_bypass_man/procon_display/status.rb +1 -0
- data/lib/procon_bypass_man/procon_display.rb +0 -1
- data/lib/procon_bypass_man/{remote_macro → remote_action}/queue_over_process.rb +2 -2
- data/lib/procon_bypass_man/{remote_macro/remote_macro_object.rb → remote_action/remote_action_object.rb} +1 -1
- data/lib/procon_bypass_man/{remote_macro/remote_macro_receiver.rb → remote_action/remote_action_receiver.rb} +8 -7
- data/lib/procon_bypass_man/remote_action/remote_action_sender.rb +9 -0
- data/lib/procon_bypass_man/remote_action/remote_pbm_job/base_action.rb +55 -0
- data/lib/procon_bypass_man/remote_action/remote_pbm_job/change_pbm_version_action.rb +31 -0
- data/lib/procon_bypass_man/remote_action/remote_pbm_job/commands/run_remote_pbm_job_dispatch_command.rb +29 -0
- data/lib/procon_bypass_man/{remote_pbm_action/commands/update_remote_pbm_action_status_command.rb → remote_action/remote_pbm_job/commands/update_remote_pbm_job_status_command.rb} +2 -2
- data/lib/procon_bypass_man/remote_action/remote_pbm_job/reboot_os_action.rb +24 -0
- data/lib/procon_bypass_man/remote_action/remote_pbm_job/report_procon_status.rb +25 -0
- data/lib/procon_bypass_man/remote_action/remote_pbm_job/restore_pbm_setting.rb +42 -0
- data/lib/procon_bypass_man/remote_action/remote_pbm_job/stop_pbm_action.rb +23 -0
- data/lib/procon_bypass_man/{remote_pbm_action/value_objects/remote_pbm_action_object.rb → remote_action/remote_pbm_job/value_objects/remote_pbm_job_object.rb} +2 -2
- data/lib/procon_bypass_man/remote_action/remote_pbm_job.rb +45 -0
- data/lib/procon_bypass_man/remote_action/task.rb +14 -0
- data/lib/procon_bypass_man/{remote_macro → remote_action}/task_queue.rb +1 -1
- data/lib/procon_bypass_man/remote_action.rb +19 -0
- data/lib/procon_bypass_man/support/callbacks.rb +1 -0
- data/lib/procon_bypass_man/support/{update_remote_pbm_action_status_http_client.rb → update_remote_pbm_job_status_http_client.rb} +1 -1
- data/lib/procon_bypass_man/version.rb +1 -1
- data/lib/procon_bypass_man/websocket/client.rb +42 -26
- data/lib/procon_bypass_man.rb +5 -7
- data/project_template/app.rb +1 -1
- data/project_template/app.rb.erb +1 -1
- data/sig/main.rbs +0 -6
- metadata +24 -20
- data/lib/procon_bypass_man/procon_display/bypass_hook.rb +0 -12
- data/lib/procon_bypass_man/remote_macro/remote_macro_sender.rb +0 -8
- data/lib/procon_bypass_man/remote_macro/task.rb +0 -2
- data/lib/procon_bypass_man/remote_macro.rb +0 -16
- data/lib/procon_bypass_man/remote_pbm_action/base_action.rb +0 -53
- data/lib/procon_bypass_man/remote_pbm_action/change_pbm_version_action.rb +0 -29
- data/lib/procon_bypass_man/remote_pbm_action/commands/run_remote_pbm_action_dispatch_command.rb +0 -21
- data/lib/procon_bypass_man/remote_pbm_action/reboot_os_action.rb +0 -22
- data/lib/procon_bypass_man/remote_pbm_action/restore_pbm_setting.rb +0 -41
- data/lib/procon_bypass_man/remote_pbm_action/stop_pbm_action.rb +0 -21
- data/lib/procon_bypass_man/remote_pbm_action.rb +0 -36
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f19608c134a980243f4e45da1a1685367dd4bffc114482682b5d8d6bef03a90
|
4
|
+
data.tar.gz: c0ce801d735e63e5d6a385854ad83abb08fe044342bda63b5d70d2d50b3589f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11e84f9b7fa368adc1cbbb8593aca61d2a1a362453a13c5b226912d490c82933d476072f11ecb36226657107aa68b08be734ac19ec8901b56a00deb980d218b9
|
7
|
+
data.tar.gz: 642a6813619dccbb9d28f634bb7bb866ec92a2ed34fac254336562ed462512b1e9eb6ec2672dae17727e9c6790651f4e481e24a9a919dbd87381e4a457c62796
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,10 @@
|
|
1
|
-
## [0.3.
|
2
|
-
|
1
|
+
## [0.3.6] 2023-03-12
|
2
|
+
- プロコンの入力状態をpbm-cloudサーバに送信できるようになりました
|
3
|
+
|
4
|
+
## [0.3.5] - 2023-2-9
|
5
|
+
* 設定ファイルに起動に必要なPBMのバージョンを表記できるようになりました
|
3
6
|
* https://github.com/splaplapla/procon_bypass_man/pull/238
|
4
|
-
* レイヤー変更ボタン(prefix_keys_for_changing_layer)
|
7
|
+
* レイヤー変更ボタン(prefix_keys_for_changing_layer)が空欄の時に設定ファイルをエラーが起きないようにしました
|
5
8
|
* PBM-CloudからPBMをアップグレードするときに、古いバージョンを削除するようにしました
|
6
9
|
|
7
10
|
## [0.3.4] - 2022-12-26
|
data/Gemfile.lock
CHANGED
data/Steepfile
CHANGED
@@ -40,7 +40,6 @@ target :lib do
|
|
40
40
|
check 'lib/procon_bypass_man/support/on_memory_cache'
|
41
41
|
check 'lib/procon_bypass_man/support/uptime.rb'
|
42
42
|
check 'lib/procon_bypass_man/support/safe_timeout'
|
43
|
-
check 'lib/procon_bypass_man/support/update_remote_pbm_action_status_http_client'
|
44
43
|
check 'lib/procon_bypass_man/support/compress_array'
|
45
44
|
|
46
45
|
signature 'sig'
|
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "procon_bypass_man"
|
5
|
+
require "pry"
|
6
|
+
|
7
|
+
# \x30のみ生成する
|
8
|
+
# Usage:
|
9
|
+
# $ `generate_output_report x zl y` のように、引数にボタン名を渡す
|
10
|
+
|
11
|
+
no_action_binary = ["30f28100800078c77448287509550274ff131029001b0022005a0271ff191028001e00210064027cff1410280020002100000000000000000000000000000000"].pack("H*")
|
12
|
+
user_operation = ProconBypassMan::Procon::UserOperation.new(no_action_binary)
|
13
|
+
|
14
|
+
ARGV.map { |x| x.to_sym }.each do |button|
|
15
|
+
user_operation.press_button(button)
|
16
|
+
end
|
17
|
+
|
18
|
+
puts user_operation.binary.unpack.first
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class ProconBypassMan::PostCompletedRemoteActionJob < ProconBypassMan::BaseJob
|
2
|
+
extend ProconBypassMan::HasExternalApiSetting
|
3
|
+
|
4
|
+
# @param [Symbol] status
|
5
|
+
def self.perform(job_id)
|
6
|
+
ProconBypassMan::RemoteMacroHttpClient.new(
|
7
|
+
path: path,
|
8
|
+
server: api_server,
|
9
|
+
).post(job_id: job_id)
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.path
|
13
|
+
device_id = ProconBypassMan.device_id
|
14
|
+
"/api/devices/#{ProconBypassMan.device_id}/completed_pbm_remote_macro_jobs"
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.re_enqueue_if_failed
|
18
|
+
true
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class ProconBypassMan::ReportInfoLogJob < ProconBypassMan::ReportEventBaseJob
|
2
|
+
extend ProconBypassMan::HasExternalApiSetting
|
3
|
+
|
4
|
+
# @param [String] body
|
5
|
+
def self.perform(body)
|
6
|
+
ProconBypassMan::ReportHttpClient.new(
|
7
|
+
path: path,
|
8
|
+
server: api_server,
|
9
|
+
).post(body: body, event_type: :info)
|
10
|
+
end
|
11
|
+
end
|
@@ -10,6 +10,7 @@ require "procon_bypass_man/background/jobs/report_error_reload_config_job"
|
|
10
10
|
require "procon_bypass_man/background/jobs/report_load_config_job"
|
11
11
|
require "procon_bypass_man/background/jobs/report_error_job"
|
12
12
|
require "procon_bypass_man/background/jobs/report_warning_job"
|
13
|
+
require "procon_bypass_man/background/jobs/report_info_log_job"
|
13
14
|
require "procon_bypass_man/background/jobs/report_completed_upgrade_pbm_job"
|
14
15
|
require "procon_bypass_man/background/jobs/report_procon_performance_measurements_job"
|
15
16
|
require "procon_bypass_man/background/jobs/sync_device_stats_job"
|
@@ -47,6 +47,9 @@ class ProconBypassMan::Bypass::ProconToSwitch
|
|
47
47
|
self.bypass_value.binary = ProconBypassMan::Domains::InboundProconBinary.new(binary: raw_output)
|
48
48
|
end
|
49
49
|
|
50
|
+
# 後続処理で入力値を取得できるように詰めておく
|
51
|
+
ProconBypassMan::ProconDisplay::Status.instance.current = bypass_value.binary.to_procon_reader.to_hash
|
52
|
+
|
50
53
|
result = measurement.record_write_time do
|
51
54
|
begin
|
52
55
|
ProconBypassMan::Retryable.retryable(tries: 5, on_no_retry: [Errno::EIO, Errno::ENODEV, Errno::EPROTO, IOError, Errno::ESHUTDOWN, Errno::ETIMEDOUT]) do
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class ProconBypassMan::SendInfoLogCommand
|
2
|
+
# @param [String] message
|
3
|
+
# @return [void]
|
4
|
+
def self.execute(message: , stdout: true)
|
5
|
+
body = message
|
6
|
+
ProconBypassMan.logger.info(body)
|
7
|
+
puts body if stdout
|
8
|
+
|
9
|
+
ProconBypassMan::ReportInfoLogJob.perform(body)
|
10
|
+
end
|
11
|
+
end
|
@@ -5,3 +5,4 @@ require "procon_bypass_man/commands/write_device_id_command"
|
|
5
5
|
require "procon_bypass_man/commands/send_reload_config_event_command"
|
6
6
|
require "procon_bypass_man/commands/send_error_command"
|
7
7
|
require "procon_bypass_man/commands/send_warning_command"
|
8
|
+
require "procon_bypass_man/commands/send_info_log_command"
|
@@ -127,17 +127,28 @@ class ProconBypassMan::Procon
|
|
127
127
|
end
|
128
128
|
end
|
129
129
|
|
130
|
-
# remote macro
|
131
|
-
if task = ProconBypassMan::
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
130
|
+
# remote macro or pbm action
|
131
|
+
if task = ProconBypassMan::RemoteAction::TaskQueueInProcess.non_blocking_shift
|
132
|
+
case task.type
|
133
|
+
when ProconBypassMan::RemoteAction::Task::TYPE_MACRO
|
134
|
+
no_op_step = :wait_for_0_3 # マクロの最後に固まって最後の入力をし続けるので、無の状態を最後に注入する
|
135
|
+
BlueGreenProcess::SharedVariable.extend_run_on_this_process = true
|
136
|
+
ProconBypassMan::Procon::MacroRegistry.cleanup_remote_macros!
|
137
|
+
macro_name = task.name || "RemoteMacro-#{task.steps.join}".to_sym
|
138
|
+
task.steps << no_op_step
|
139
|
+
ProconBypassMan::Procon::MacroRegistry.install_plugin(macro_name, steps: task.steps, macro_type: :remote)
|
140
|
+
@@status[:ongoing_macro] = MacroRegistry.load(macro_name, macro_type: :remote) do
|
141
|
+
GC.start # NOTE: extend_run_on_this_process = true するとGCされなくなるので手動で呼び出す
|
142
|
+
ProconBypassMan::PostCompletedRemoteMacroJob.perform_async(task.uuid)
|
143
|
+
end
|
144
|
+
when ProconBypassMan::RemoteAction::Task::TYPE_ACTION
|
145
|
+
ProconBypassMan::RemoteAction::RemotePbmJob::RunRemotePbmJobDispatchCommand.execute(
|
146
|
+
action: task.action,
|
147
|
+
uuid: task.uuid,
|
148
|
+
job_args: task.job_args,
|
149
|
+
)
|
150
|
+
else
|
151
|
+
ProconBypassMan::SendErrorCommand.execute(error: 'unknown type of remote pbm action')
|
141
152
|
end
|
142
153
|
end
|
143
154
|
|
@@ -8,4 +8,3 @@ require "procon_bypass_man/procon_display/server_app"
|
|
8
8
|
require "procon_bypass_man/procon_display/status"
|
9
9
|
require "procon_bypass_man/procon_display/http_response"
|
10
10
|
require "procon_bypass_man/procon_display/http_request"
|
11
|
-
require "procon_bypass_man/procon_display/bypass_hook"
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class ProconBypassMan::
|
1
|
+
class ProconBypassMan::RemoteAction::QueueOverProcess
|
2
2
|
extend ProconBypassMan::CanOverProcess
|
3
3
|
|
4
4
|
include Singleton
|
@@ -7,7 +7,7 @@ class ProconBypassMan::RemoteMacro::QueueOverProcess
|
|
7
7
|
|
8
8
|
# @override
|
9
9
|
def self.enable?
|
10
|
-
ProconBypassMan.config.
|
10
|
+
ProconBypassMan.config.enable_remote_action?
|
11
11
|
end
|
12
12
|
|
13
13
|
# @override
|
@@ -1,13 +1,14 @@
|
|
1
|
-
|
1
|
+
# FIXME: BypassProcessSenderみたいにする
|
2
|
+
class ProconBypassMan::RemoteActionReceiver
|
2
3
|
# forkしたプロセスで動かすクラス。sock経由で命令を受け取ってmacoのキューに積んでいく
|
3
4
|
def self.start_with_foreground!
|
4
|
-
return unless ProconBypassMan.config.
|
5
|
+
return unless ProconBypassMan.config.enable_remote_action?
|
5
6
|
|
6
7
|
run
|
7
8
|
end
|
8
9
|
|
9
10
|
def self.start!
|
10
|
-
return unless ProconBypassMan.config.
|
11
|
+
return unless ProconBypassMan.config.enable_remote_action?
|
11
12
|
|
12
13
|
Thread.start do
|
13
14
|
start_with_foreground!
|
@@ -15,7 +16,7 @@ class ProconBypassMan::RemoteMacroReceiver
|
|
15
16
|
end
|
16
17
|
|
17
18
|
def self.run
|
18
|
-
while(task = ProconBypassMan::
|
19
|
+
while(task = ProconBypassMan::RemoteAction::QueueOverProcess.pop)
|
19
20
|
receive(task)
|
20
21
|
end
|
21
22
|
shutdown
|
@@ -24,10 +25,10 @@ class ProconBypassMan::RemoteMacroReceiver
|
|
24
25
|
end
|
25
26
|
|
26
27
|
|
27
|
-
# @param [ProconBypassMan::
|
28
|
+
# @param [ProconBypassMan::RemoteAction::Task] task
|
28
29
|
def self.receive(task)
|
29
|
-
ProconBypassMan.logger.info "[remote macro][receiver] name: #{task.name}, uuid: #{task.uuid}, steps: #{task.steps}"
|
30
|
-
ProconBypassMan::
|
30
|
+
ProconBypassMan.logger.info "[remote macro][receiver] name: #{task.name}, uuid: #{task.uuid}, steps: #{task.steps}, type: #{task.type}"
|
31
|
+
ProconBypassMan::RemoteAction::TaskQueueInProcess.push(task)
|
31
32
|
true
|
32
33
|
end
|
33
34
|
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# FIXME: RemoteMacroSenderという名前をやめる。BypassProcessSenderみたいにする
|
2
|
+
class ProconBypassMan::RemoteActionSender
|
3
|
+
def self.execute(name: , uuid: , steps: , type: )
|
4
|
+
ProconBypassMan.logger.info "[remote macro][sender] name: #{name}, uuid: #{uuid}, steps: #{steps}, type: #{type}"
|
5
|
+
ProconBypassMan::RemoteAction::QueueOverProcess.push(
|
6
|
+
ProconBypassMan::RemoteAction::Task.new(name, uuid, steps, type)
|
7
|
+
)
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module ProconBypassMan
|
2
|
+
module RemoteAction
|
3
|
+
module RemotePbmJob
|
4
|
+
class ActionUnexpectedError < StandardError; end
|
5
|
+
class NeedPbmVersionError < ActionUnexpectedError; end
|
6
|
+
|
7
|
+
class BaseAction
|
8
|
+
attr_accessor :pbm_job_uuid
|
9
|
+
|
10
|
+
# @param [String] pbm_job_uuid
|
11
|
+
def initialize(pbm_job_uuid: )
|
12
|
+
self.pbm_job_uuid = pbm_job_uuid
|
13
|
+
end
|
14
|
+
|
15
|
+
# @return [void]
|
16
|
+
def action_content(_args)
|
17
|
+
raise NotImplementedError, nil
|
18
|
+
end
|
19
|
+
|
20
|
+
# @param [Hash] args
|
21
|
+
# @return [void]
|
22
|
+
def run!(job_args: )
|
23
|
+
before_action_callback
|
24
|
+
action_content(args: job_args)
|
25
|
+
after_action_callback
|
26
|
+
rescue => e
|
27
|
+
be_failed
|
28
|
+
ProconBypassMan::SendErrorCommand.execute(error: e)
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
# @return [void]
|
34
|
+
def before_action_callback; end
|
35
|
+
# @return [void]
|
36
|
+
def after_action_callback; end
|
37
|
+
|
38
|
+
# @return [void]
|
39
|
+
def be_failed
|
40
|
+
ProconBypassMan::UpdateRemotePbmJobStatusCommand.new(pbm_job_uuid: pbm_job_uuid).execute(to_status: :failed)
|
41
|
+
end
|
42
|
+
|
43
|
+
# @return [void]
|
44
|
+
def be_in_progress
|
45
|
+
ProconBypassMan::UpdateRemotePbmJobStatusCommand.new(pbm_job_uuid: pbm_job_uuid).execute(to_status: :in_progress)
|
46
|
+
end
|
47
|
+
|
48
|
+
# @return [void]
|
49
|
+
def be_processed
|
50
|
+
ProconBypassMan::UpdateRemotePbmJobStatusCommand.new(pbm_job_uuid: pbm_job_uuid).execute(to_status: :processed)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module ProconBypassMan
|
2
|
+
module RemoteAction
|
3
|
+
module RemotePbmJob
|
4
|
+
class ChangePbmVersionAction < BaseAction
|
5
|
+
|
6
|
+
def action_content(args: )
|
7
|
+
require "pbmenv"
|
8
|
+
ProconBypassMan.logger.info "execute ChangePbmVersionAction!"
|
9
|
+
pbm_version = args["pbm_version"] or raise(ProconBypassMan::RemotePbmJob::NeedPbmVersionError, "pbm_versionが必要です, #{args.inspect}")
|
10
|
+
Pbmenv.uninstall(pbm_version) # 途中でシャットダウンしてしまった、とか状態が途中の状態かもしれないので一旦消す
|
11
|
+
Pbmenv.install(pbm_version, enable_pbm_cloud: true)
|
12
|
+
Pbmenv.use(pbm_version)
|
13
|
+
Pbmenv.clean(10)
|
14
|
+
ProconBypassMan.logger.info "#{pbm_version}へアップグレードしました"
|
15
|
+
ProconBypassMan::ReportCompletedUpgradePbmJob.perform
|
16
|
+
`reboot` # symlinkの参照先が変わるのでrebootする必要がある
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def before_action_callback
|
22
|
+
be_processed
|
23
|
+
end
|
24
|
+
|
25
|
+
def after_action_callback
|
26
|
+
# no-op
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module ProconBypassMan
|
2
|
+
module RemoteAction
|
3
|
+
module RemotePbmJob
|
4
|
+
class RunRemotePbmJobDispatchCommand
|
5
|
+
# @param [String] action
|
6
|
+
# @param [String] uuid
|
7
|
+
# @return [void]
|
8
|
+
def self.execute(action: , uuid: , job_args: )
|
9
|
+
case action
|
10
|
+
when ProconBypassMan::RemoteAction::RemotePbmJob::ACTION_CHANGE_PBM_VERSION
|
11
|
+
ProconBypassMan::RemoteAction::RemotePbmJob::ChangePbmVersionAction.new(pbm_job_uuid: uuid).run!(job_args: job_args)
|
12
|
+
when ProconBypassMan::RemoteAction::RemotePbmJob::ACTION_STOP_PBM
|
13
|
+
ProconBypassMan::RemoteAction::RemotePbmJob::StopPbmJob.new(pbm_job_uuid: uuid).run!(job_args: {})
|
14
|
+
when ProconBypassMan::RemoteAction::RemotePbmJob::ACTION_REBOOT_OS
|
15
|
+
ProconBypassMan::RemoteAction::RemotePbmJob::RebootOsAction.new(pbm_job_uuid: uuid).run!(job_args: {})
|
16
|
+
when ProconBypassMan::RemoteAction::RemotePbmJob::ACTION_RESTORE_SETTING
|
17
|
+
ProconBypassMan::RemoteAction::RemotePbmJob::RestorePbmSettingAction.new(pbm_job_uuid: uuid).run!(job_args: job_args)
|
18
|
+
when ProconBypassMan::RemoteAction::RemotePbmJob::ACTION_REPORT_PORCON_STATUS
|
19
|
+
ProconBypassMan::RemoteAction::RemotePbmJob::ReportProconStatusAction.new(pbm_job_uuid: uuid).run!(job_args: {})
|
20
|
+
else
|
21
|
+
raise "#{action}は対応していないアクションです"
|
22
|
+
end
|
23
|
+
rescue ProconBypassMan::RemoteAction::RemotePbmJob::ActionUnexpectedError => e
|
24
|
+
ProconBypassMan::SendErrorCommand.execute(error: e)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module ProconBypassMan
|
2
|
-
class
|
2
|
+
class UpdateRemotePbmJobStatusCommand
|
3
3
|
# @param [String] pbm_job_uuid
|
4
4
|
def initialize(pbm_job_uuid: )
|
5
5
|
@pbm_job_uuid = pbm_job_uuid
|
@@ -8,7 +8,7 @@ module ProconBypassMan
|
|
8
8
|
# @param [String] to_status
|
9
9
|
# @return [void]
|
10
10
|
def execute(to_status: )
|
11
|
-
ProconBypassMan::
|
11
|
+
ProconBypassMan::UpdateRemotePbmJobStatusHttpClient.new(
|
12
12
|
path: path,
|
13
13
|
server: ProconBypassMan.config.api_server,
|
14
14
|
).put(to_status: to_status)
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module ProconBypassMan
|
2
|
+
module RemoteAction
|
3
|
+
module RemotePbmJob
|
4
|
+
class RebootOsAction < BaseAction
|
5
|
+
|
6
|
+
def action_content(_args)
|
7
|
+
ProconBypassMan.logger.info "execute RebootOsAction!"
|
8
|
+
`reboot`
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def before_action_callback
|
14
|
+
ProconBypassMan::ReportStartRebootJob.perform
|
15
|
+
be_processed
|
16
|
+
end
|
17
|
+
|
18
|
+
def after_action_callback
|
19
|
+
# no-op
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module ProconBypassMan
|
2
|
+
module RemoteAction
|
3
|
+
module RemotePbmJob
|
4
|
+
class ReportProconStatusAction < BaseAction
|
5
|
+
|
6
|
+
def action_content(_args)
|
7
|
+
ProconBypassMan.logger.info "execute ReportProconStatusAction!"
|
8
|
+
ProconBypassMan::SendInfoLogCommand.execute(
|
9
|
+
message: ProconBypassMan::ProconDisplay::Status.instance.current.to_s
|
10
|
+
)
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def before_action_callback
|
16
|
+
be_in_progress
|
17
|
+
end
|
18
|
+
|
19
|
+
def after_action_callback
|
20
|
+
be_processed
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module ProconBypassMan
|
2
|
+
module RemoteAction
|
3
|
+
module RemotePbmJob
|
4
|
+
class RestorePbmSettingAction < BaseAction
|
5
|
+
|
6
|
+
def action_content(args: )
|
7
|
+
require "pbmenv"
|
8
|
+
ProconBypassMan.logger.info "execute RestorePbmSettingAction!"
|
9
|
+
setting = args.dig("setting") or raise(ProconBypassMan::RemotePbmJob::NeedPbmVersionError, "settingが必要です, #{args.inspect}")
|
10
|
+
|
11
|
+
# 復元に失敗したら戻せるように退避する
|
12
|
+
FileUtils.copy(
|
13
|
+
ProconBypassMan::ButtonsSettingConfiguration.instance.setting_path,
|
14
|
+
ProconBypassMan.fallback_setting_path,
|
15
|
+
)
|
16
|
+
|
17
|
+
ProconBypassMan::YamlWriter.write(
|
18
|
+
path: ProconBypassMan::ButtonsSettingConfiguration.instance.setting_path,
|
19
|
+
content: setting,
|
20
|
+
)
|
21
|
+
|
22
|
+
hot_reload!
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def before_action_callback
|
28
|
+
be_in_progress
|
29
|
+
end
|
30
|
+
|
31
|
+
def after_action_callback
|
32
|
+
be_processed
|
33
|
+
end
|
34
|
+
|
35
|
+
# @return [void]
|
36
|
+
def hot_reload!
|
37
|
+
Process.kill(:USR2, ProconBypassMan.pid)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module ProconBypassMan
|
2
|
+
module RemoteAction
|
3
|
+
module RemotePbmJob
|
4
|
+
class StopPbmJob < BaseAction
|
5
|
+
|
6
|
+
def action_content(_args)
|
7
|
+
ProconBypassMan.logger.info "execute StopPbmJob!"
|
8
|
+
Process.kill("TERM", ProconBypassMan.pid)
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def before_action_callback
|
14
|
+
be_processed
|
15
|
+
end
|
16
|
+
|
17
|
+
def after_action_callback
|
18
|
+
# no-op
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module ProconBypassMan
|
2
|
-
class
|
2
|
+
class RemotePbmJobObject
|
3
3
|
# valueobjectがvalidatorの責務も持っている. 今度分離する
|
4
4
|
class ValidationError < StandardError; end
|
5
5
|
class MustBeNotNilError < ValidationError; end
|
@@ -30,7 +30,7 @@ module ProconBypassMan
|
|
30
30
|
self.status or raise MustBeNotNilError, "statusは値が必須です"
|
31
31
|
self.uuid or raise MustBeNotNilError, "uuidは値が必須です"
|
32
32
|
|
33
|
-
unless ProconBypassMan::
|
33
|
+
unless ProconBypassMan::RemoteAction::RemotePbmJob::ACTIONS.include?(action)
|
34
34
|
raise NonSupportAction, "知らないアクションです"
|
35
35
|
end
|
36
36
|
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ProconBypassMan
|
4
|
+
module RemoteAction
|
5
|
+
module RemotePbmJob
|
6
|
+
require "procon_bypass_man/remote_action/remote_pbm_job/value_objects/remote_pbm_job_object"
|
7
|
+
|
8
|
+
require "procon_bypass_man/remote_action/remote_pbm_job/base_action"
|
9
|
+
require "procon_bypass_man/remote_action/remote_pbm_job/change_pbm_version_action"
|
10
|
+
require "procon_bypass_man/remote_action/remote_pbm_job/reboot_os_action"
|
11
|
+
require "procon_bypass_man/remote_action/remote_pbm_job/stop_pbm_action"
|
12
|
+
require "procon_bypass_man/remote_action/remote_pbm_job/restore_pbm_setting"
|
13
|
+
require "procon_bypass_man/remote_action/remote_pbm_job/report_procon_status"
|
14
|
+
require "procon_bypass_man/remote_action/remote_pbm_job/commands/update_remote_pbm_job_status_command"
|
15
|
+
require "procon_bypass_man/remote_action/remote_pbm_job/commands/run_remote_pbm_job_dispatch_command"
|
16
|
+
|
17
|
+
ACTION_CHANGE_PBM_VERSION = "change_pbm_version"
|
18
|
+
ACTION_REBOOT_OS = "reboot_os"
|
19
|
+
ACTION_STOP_PBM = "stop_pbm"
|
20
|
+
ACTION_RESTORE_SETTING = "restore_pbm_setting"
|
21
|
+
ACTION_REPORT_PORCON_STATUS = 'report_porcon_status'
|
22
|
+
|
23
|
+
ACTIONS_IN_MASTER_PROCESS = [
|
24
|
+
ACTION_CHANGE_PBM_VERSION,
|
25
|
+
ACTION_REBOOT_OS,
|
26
|
+
ACTION_STOP_PBM,
|
27
|
+
ACTION_RESTORE_SETTING,
|
28
|
+
]
|
29
|
+
ACTIONS_IN_BYPASS_PROCESS = [
|
30
|
+
ACTION_REPORT_PORCON_STATUS,
|
31
|
+
]
|
32
|
+
ACTIONS = ACTIONS_IN_MASTER_PROCESS + ACTIONS_IN_BYPASS_PROCESS
|
33
|
+
|
34
|
+
STATUS_FAILED = :failed
|
35
|
+
STATUS_IN_PROGRESS = :in_progress
|
36
|
+
STATUS_PROCESSED = :processed
|
37
|
+
|
38
|
+
ACTION_STATUSES = [
|
39
|
+
STATUS_FAILED,
|
40
|
+
STATUS_IN_PROGRESS,
|
41
|
+
STATUS_PROCESSED,
|
42
|
+
]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# NOTE: remote macroとpbm remote actionの両方で使う
|
2
|
+
class ProconBypassMan::RemoteAction::Task < ::Struct.new(:name, :uuid, :steps, :type)
|
3
|
+
TYPE_MACRO = 'macro'
|
4
|
+
TYPE_ACTION = 'action'
|
5
|
+
|
6
|
+
# remote actionのためのalias
|
7
|
+
def action
|
8
|
+
name
|
9
|
+
end
|
10
|
+
|
11
|
+
def job_args
|
12
|
+
steps
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ProconBypassMan
|
4
|
+
module RemoteAction
|
5
|
+
# NOTE: RemoteActionは「具体的な処理を行うジョブ」と「マクロ」を内包する
|
6
|
+
require "procon_bypass_man/remote_action/remote_pbm_job"
|
7
|
+
|
8
|
+
require "procon_bypass_man/remote_action/remote_action_object"
|
9
|
+
require "procon_bypass_man/remote_action/remote_action_receiver"
|
10
|
+
require "procon_bypass_man/remote_action/remote_action_sender"
|
11
|
+
require "procon_bypass_man/remote_action/queue_over_process"
|
12
|
+
require "procon_bypass_man/remote_action/task"
|
13
|
+
require "procon_bypass_man/remote_action/task_queue"
|
14
|
+
|
15
|
+
ACTION_MACRO = "remote_macro"
|
16
|
+
|
17
|
+
TaskQueueInProcess = ProconBypassMan::RemoteAction::TaskQueue.new
|
18
|
+
end
|
19
|
+
end
|