Module: Proxy::RemoteExecution::Ssh
- Defined in:
- lib/smart_proxy_remote_execution_ssh/version.rb,
lib/smart_proxy_remote_execution_ssh/dispatcher.rb,
lib/smart_proxy_remote_execution_ssh/log_filter.rb,
lib/smart_proxy_remote_execution_ssh/job_storage.rb,
lib/smart_proxy_remote_execution_ssh/actions/run_script.rb,
lib/smart_proxy_remote_execution_ssh/runners.rb,
lib/smart_proxy_remote_execution_ssh/actions.rb,
lib/smart_proxy_remote_execution_ssh/plugin.rb,
lib/smart_proxy_remote_execution_ssh/api.rb,
lib/smart_proxy_remote_execution_ssh.rb
Defined Under Namespace
Modules: Actions, Runners
Classes: Api, Dispatcher, JobStorage, LogFilter, Plugin
Constant Summary
collapse
- VERSION =
'0.5.3'
Class Method Summary
collapse
Class Method Details
.private_key_file ⇒ Object
28
29
30
|
# File 'lib/smart_proxy_remote_execution_ssh.rb', line 28
def private_key_file
File.expand_path(Plugin.settings.ssh_identity_key_file)
end
|
.public_key_file ⇒ Object
32
33
34
|
# File 'lib/smart_proxy_remote_execution_ssh.rb', line 32
def public_key_file
File.expand_path("#{private_key_file}.pub")
end
|
.validate! ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/smart_proxy_remote_execution_ssh.rb', line 9
def validate!
unless private_key_file
raise "settings for `ssh_identity_key` not set"
end
unless File.exist?(private_key_file)
raise "Ssh public key file #{private_key_file} doesn't exist.\n"\
"You can generate one with `ssh-keygen -t rsa -b 4096 -f #{private_key_file} -N ''`"
end
unless File.exist?(public_key_file)
raise "Ssh public key file #{public_key_file} doesn't exist"
end
validate_mode!
validate_ssh_log_level!
validate_mqtt_settings!
end
|
.validate_mode! ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/smart_proxy_remote_execution_ssh.rb', line 36
def validate_mode!
Plugin.settings.mode = Plugin.settings.mode.to_sym
unless Plugin::MODES.include? Plugin.settings.mode
raise "Mode has to be one of #{Plugin::MODES.join(', ')}, given #{Plugin.settings.mode}"
end
if Plugin.settings.async_ssh
Plugin.logger.warn('Option async_ssh is deprecated, use ssh-async mode instead.')
case Plugin.settings.mode
when :ssh
Plugin.logger.warn('Deprecated option async_ssh used together with ssh mode, switching mode to ssh-async.')
Plugin.settings.mode = :'ssh-async'
when :'ssh-async'
else
Plugin.logger.warn('Deprecated option async_ssh used together with incompatible mode, ignoring.')
end
end
end
|
.validate_mqtt_settings! ⇒ Object
58
59
60
61
62
63
|
# File 'lib/smart_proxy_remote_execution_ssh.rb', line 58
def validate_mqtt_settings!
return unless Plugin.settings.mode == :'pull-mqtt'
raise 'mqtt_broker has to be set when pull-mqtt mode is used' if Plugin.settings.mqtt_broker.nil?
raise 'mqtt_port has to be set when pull-mqtt mode is used' if Plugin.settings.mqtt_port.nil?
end
|
.validate_ssh_log_level! ⇒ Object
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
# File 'lib/smart_proxy_remote_execution_ssh.rb', line 65
def validate_ssh_log_level!
wanted_level = Plugin.settings.ssh_log_level.to_s
levels = Plugin::SSH_LOG_LEVELS
unless levels.include? wanted_level
raise "Wrong value '#{Plugin.settings.ssh_log_level}' for ssh_log_level, must be one of #{levels.join(', ')}"
end
current = ::Proxy::SETTINGS.log_level.to_s.downcase
ssh, regular = [wanted_level, current].map do |wanted|
levels.each_with_index.find { |value, _index| value == wanted }.last
end
if ssh < regular
raise 'ssh_log_level cannot be more verbose than regular log level'
end
Plugin.settings.ssh_log_level = Plugin.settings.ssh_log_level.to_sym
end
|