Sha256: d3580a7336ac59d4414892cfb3893c05d24464a397025d2c1249615e08b8b64d

Contents?: true

Size: 867 Bytes

Versions: 3

Compression:

Stored size: 867 Bytes

Contents

module CheckDSL
  def run(command, args = {})
    args[:exec] = command
    host = :localhost
    host = args[:on] if args[:on]
    goto(host, args)
  end

  def run_script(command, args = {})
    host = :localhost
    host = args[:on] if args[:on]
    filename = command.split[1]
    upload filename, to: host
    run command, args
  end

  def goto(host = :localhost, args = {})
    result.reset
    @stats[:hosts][host] = @stats[:hosts][host] ? (@stats[:hosts][host] + 1) : 1
    Logger.info "      run         '#{args[:exec]}' on #{host}"
  end

  def upload(filename, args = {})
    host = args[:to]
    args.delete(:to)
    custom = if args == {}
      ""
    else
      values = args.map { "#{_1}=#{_2}" }
      "and #{values.join(",")}"
    end
    @stats[:uploads] << filename
    Logger.info "      upload      '#{filename}' to #{host} #{custom}"
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
teuton-2.9.2 lib/teuton/check/dsl/run.rb
teuton-2.9.1 lib/teuton/check/dsl/run.rb
teuton-2.9.0 lib/teuton/check/dsl/run.rb