Class: OodCore::Job::Adapters::LinuxHost::Launcher Private
- Inherits:
-
Object
- Object
- OodCore::Job::Adapters::LinuxHost::Launcher
- Defined in:
- lib/ood_core/job/adapters/linux_host/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
Constant Summary collapse
- UNIT_SEPARATOR =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
","
Instance Attribute Summary collapse
- #contain ⇒ Object readonly private
- #debug ⇒ Object readonly private
- #default_singularity_image ⇒ Object readonly private
- #session_name_label ⇒ Object readonly private
- #singularity_bin ⇒ Object readonly private
- #site_singularity_bindpath ⇒ Object readonly private
- #site_timeout ⇒ Object readonly private
- #ssh_hosts ⇒ Object readonly private
- #strict_host_checking ⇒ Object readonly private
- #tmux_bin ⇒ Object readonly private
- #username ⇒ Object readonly private
Instance Method Summary collapse
-
#initialize(contain: false, debug: false, site_timeout: nil, singularity_bin:, singularity_bindpath: '/etc,/media,/mnt,/opt,/run,/srv,/usr,/var,/users', singularity_image:, ssh_hosts:, strict_host_checking: false, submit_host:, tmux_bin:, **_) ⇒ 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(contain: false, debug: false, site_timeout: nil, singularity_bin:, singularity_bindpath: '/etc,/media,/mnt,/opt,/run,/srv,/usr,/var,/users', singularity_image:, ssh_hosts:, strict_host_checking: false, submit_host:, tmux_bin:, **_) ⇒ 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.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/ood_core/job/adapters/linux_host/launcher.rb', line 30 def initialize( contain: false, debug: false, site_timeout: nil, singularity_bin:, singularity_bindpath: '/etc,/media,/mnt,/opt,/run,/srv,/usr,/var,/users', singularity_image:, ssh_hosts:, strict_host_checking: false, submit_host:, tmux_bin:, **_ ) @contain = !! contain @debug = !! debug @site_timeout = site_timeout.to_i @session_name_label = 'launched-by-ondemand' @singularity_bin = Pathname.new(singularity_bin) @site_singularity_bindpath = singularity_bindpath.to_s @default_singularity_image = Pathname.new(singularity_image) @ssh_hosts = ssh_hosts @strict_host_checking = strict_host_checking @submit_host = submit_host @tmux_bin = tmux_bin @username = Etc.getlogin end |
Instance Attribute Details
#contain ⇒ 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/linux_host/launcher.rb', line 12 def contain @contain end |
#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/linux_host/launcher.rb', line 12 def debug @debug end |
#default_singularity_image ⇒ 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/linux_host/launcher.rb', line 12 def default_singularity_image @default_singularity_image 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/linux_host/launcher.rb', line 12 def session_name_label @session_name_label end |
#singularity_bin ⇒ 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/linux_host/launcher.rb', line 12 def singularity_bin @singularity_bin end |
#site_singularity_bindpath ⇒ 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/linux_host/launcher.rb', line 12 def site_singularity_bindpath @site_singularity_bindpath 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/linux_host/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/linux_host/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/linux_host/launcher.rb', line 12 def strict_host_checking @strict_host_checking end |
#tmux_bin ⇒ 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/linux_host/launcher.rb', line 12 def tmux_bin @tmux_bin 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/linux_host/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.
85 86 87 88 89 90 91 92 93 |
# File 'lib/ood_core/job/adapters/linux_host/launcher.rb', line 85 def list_remote_sessions(host: nil) host_list = (host) ? [host] : ssh_hosts host_list.map { |hostname| list_remote_tmux_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.
59 60 61 62 63 64 65 66 |
# File 'lib/ood_core/job/adapters/linux_host/launcher.rb', line 59 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.
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/ood_core/job/adapters/linux_host/launcher.rb', line 68 def stop_remote_session(session_name, hostname) cmd = ssh_cmd(hostname, ['/usr/bin/env', 'bash']) kill_cmd = <<~SCRIPT # Get the tmux pane PID for the target session pane_pid=$(tmux list-panes -aF '\#{session_name} \#{pane_pid}' | grep '#{session_name}' | cut -f 2 -d ' ') # Find the Singularity sinit PID child of the pane process pane_sinit_pid=$(pstree -p -l "$pane_pid" | egrep -o 'sinit[(][[:digit:]]*|shim-init[(][[:digit:]]|appinit[(][[:digit:]]*' | grep -o '[[:digit:]]*') # Kill sinit which stops both Singularity-based processes and the tmux session kill "$pane_sinit_pid" 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.
95 96 97 98 99 100 101 |
# File 'lib/ood_core/job/adapters/linux_host/launcher.rb', line 95 def submit_host(script = nil) if script && script.native && script.native['submit_host_override'] script.native['submit_host_override'] else @submit_host end end |