Class: Blender::Driver::Blend

Inherits:
Base
  • Object
show all
Defined in:
lib/blender/drivers/blend.rb

Instance Attribute Summary

Attributes inherited from Base

#config, #events, #stderr, #stdout

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Blender::Driver::Base

Instance Method Details

#execute(tasks, hosts) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/blender/drivers/blend.rb', line 23

def execute(tasks, hosts)
  tasks.each do |task|
    cmd = run_command(task.command, hosts)
    if cmd.exitstatus != 0 and !task.[:ignore_failure]
      raise ExecutionFailed, cmd.stderr
    end
  end
end

#run_command(command, hosts) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/blender/drivers/blend.rb', line 32

def run_command(command, hosts)
  exit_status = 0
  err = ''
  begin
    Blender.blend(command.file, command.options) do |sched|
      sched.strategy(command.strategy)
      sched.members(hosts)
      sched.concurrency(command.concurrency)
      command.config_store.keys.each do |key|
        sched.config(key, command.config_store[key])
      end
      sched.instance_eval(File.read(command.file))
    end
  rescue StandardError => e
    err = e.message + "\nBacktrace:" + e.backtrace.join("\n")
    exit_status = -1
  end
  ExecOutput.new(exit_status, '', err)
end