Class: OodCore::Job::Adapters::LinuxSystemd::Launcher Private
- Inherits:
-
Object
- Object
- OodCore::Job::Adapters::LinuxSystemd::Launcher
- Defined in:
- lib/ood_core/job/adapters/systemd/launcher.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Object used for simplified communication SSH hosts
Defined Under Namespace
Classes: Error
Instance Attribute Summary collapse
- #debug ⇒ Object readonly private
- #session_name_label ⇒ Object readonly private
- #site_timeout ⇒ Object readonly private
- #ssh_hosts ⇒ Object readonly private
- #strict_host_checking ⇒ Object readonly private
- #username ⇒ Object readonly private
Instance Method Summary collapse
-
#initialize(debug: false, site_timeout: nil, ssh_hosts:, strict_host_checking: false, submit_host:, **_) ⇒ Launcher
constructor
private
A new instance of Launcher.
- #list_remote_sessions(host: nil) ⇒ Object private
- #start_remote_session(script) ⇒ Object private
- #stop_remote_session(session_name, hostname) ⇒ Object private
- #submit_host(script = nil) ⇒ Object private
Constructor Details
#initialize(debug: false, site_timeout: nil, ssh_hosts:, strict_host_checking: false, submit_host:, **_) ⇒ Launcher
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Launcher.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/ood_core/job/adapters/systemd/launcher.rb', line 23 def initialize( debug: false, site_timeout: nil, ssh_hosts:, strict_host_checking: false, submit_host:, **_ ) @debug = !! debug @site_timeout = site_timeout.to_i @session_name_label = 'ondemand' @ssh_hosts = ssh_hosts @strict_host_checking = strict_host_checking @submit_host = submit_host @username = Etc.getlogin end |
Instance Attribute Details
#debug ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
12 13 14 |
# File 'lib/ood_core/job/adapters/systemd/launcher.rb', line 12 def debug @debug end |
#session_name_label ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
12 13 14 |
# File 'lib/ood_core/job/adapters/systemd/launcher.rb', line 12 def session_name_label @session_name_label end |
#site_timeout ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
12 13 14 |
# File 'lib/ood_core/job/adapters/systemd/launcher.rb', line 12 def site_timeout @site_timeout end |
#ssh_hosts ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
12 13 14 |
# File 'lib/ood_core/job/adapters/systemd/launcher.rb', line 12 def ssh_hosts @ssh_hosts end |
#strict_host_checking ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
12 13 14 |
# File 'lib/ood_core/job/adapters/systemd/launcher.rb', line 12 def strict_host_checking @strict_host_checking end |
#username ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
12 13 14 |
# File 'lib/ood_core/job/adapters/systemd/launcher.rb', line 12 def username @username end |
Instance Method Details
#list_remote_sessions(host: nil) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
65 66 67 68 69 70 71 72 73 |
# File 'lib/ood_core/job/adapters/systemd/launcher.rb', line 65 def list_remote_sessions(host: nil) host_list = (host) ? [host] : ssh_hosts host_list.map { |hostname| list_remote_systemd_session(hostname) }.flatten.sort_by { |hsh| hsh[:session_name] } end |
#start_remote_session(script) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
42 43 44 45 46 47 48 49 50 |
# File 'lib/ood_core/job/adapters/systemd/launcher.rb', line 42 def start_remote_session(script) cmd = ssh_cmd(submit_host(script), ['/usr/bin/env', 'bash']) session_name = unique_session_name output = call(*cmd, stdin: wrapped_script(script, session_name)) hostname = parse_hostname(output) "#{session_name}@#{hostname}" end |
#stop_remote_session(session_name, hostname) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/ood_core/job/adapters/systemd/launcher.rb', line 52 def stop_remote_session(session_name, hostname) cmd = ssh_cmd(hostname, ['/usr/bin/env', 'bash']) kill_cmd = <<~SCRIPT # stop the session by name systemctl --user stop #{session_name}.service SCRIPT call(*cmd, stdin: kill_cmd) rescue Error => e interpret_and_raise(e) end |
#submit_host(script = nil) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
75 76 77 78 79 80 81 |
# File 'lib/ood_core/job/adapters/systemd/launcher.rb', line 75 def submit_host(script = nil) if script && script.native && script.native['submit_host_override'] script.native['submit_host_override'] else @submit_host end end |