Method: OodCore::BatchConnect::Template#initialize

Defined in:
lib/ood_core/batch_connect/template.rb

#initialize(context = {}) ⇒ Template

Returns a new instance of Template.

Parameters:

  • context (#to_h) (defaults to: {})

    the context used to render the template

Options Hash (context):

  • :work_dir (#to_s)

    Working directory for batch script

  • :conn_file (#to_s) — default: "connection.yml"

    The file that holds connection information

  • :conn_params (#to_sym, Array<#to_sym>) — default: []

    A list of connection parameters added to the connection file (`:host`, `:port`, and `:password` will always exist)

  • :bash_helpers (#to_s) — default: "..."

    Bash helper methods

  • :min_port (#to_i) — default: 2000

    Minimum port used when looking for available port

  • :max_port (#to_i) — default: 65535

    Maximum port used when looking for available port

  • :password_size (#to_i) — default: 32

    Length of randomly generated password

  • :header (#to_s) — default: ""

    Shell code prepended at the top of the script body

  • :footer (#to_s) — default: ""

    Shell code appended at the bottom of the script body

  • :script_wrapper (#to_s) — default: "%s"

    Bash code that wraps around the body of the template script (use `%s` to interpolate the body)

  • :set_host (#to_s) — default: "host=$(hostname)"

    Bash code used to set the `host` environment variable used for connection information

  • :before_script (#to_s) — default: "..."

    Bash code run before the main script is forked off

  • :before_file (#to_s) — default: "before.sh"

    Path to script that is sourced before main script is forked (assumes you don't modify `:before_script`)

  • :run_script (#to_s) — default: "..."

    Bash code that is forked off and treated as the main script

  • :script_file (#to_s) — default: "./script.sh"

    Path to script that is forked as the main scripta (assumes you don't modify `:run_script`)

  • :timeout (#to_s) — default: ""

    Timeout the main script in seconds, if empty then let script run for full walltime (assumes you don't modify `:run_script`)

  • :clean_script (#to_s) — default: "..."

    Bash code run during clean up after job finishes

  • :clean_file (#to_s) — default: "clean.sh"

    Path to script that is sourced during clean up (assumes you don't modify `:clean_script`)

Raises:

  • (ArgumentError)

56
57
58
59
# File 'lib/ood_core/batch_connect/template.rb', line 56

def initialize(context = {})
  @context = context.to_h.compact.symbolize_keys
  raise ArgumentError, "No work_dir specified. Missing argument: work_dir" unless context.include?(:work_dir)
end