Class: Rundock::Operation::Task

Inherits:
Base show all
Defined in:
lib/rundock/operation/task.rb

Constant Summary

Constants inherited from Base

Base::OperationNotImplementedError

Instance Attribute Summary

Attributes inherited from Base

#attributes, #instruction

Instance Method Summary collapse

Methods inherited from Base

#assign_args, #initialize, #logging

Constructor Details

This class inherits a constructor from Rundock::Operation::Base

Instance Method Details

#run(backend, attributes = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/rundock/operation/task.rb', line 4

def run(backend, attributes = {})
  @instruction.each do |i|
    task_set = i.split(' ')
    task_name = task_set.first

    if task_set.length > 1
      attributes[:task_args] = task_set.slice(1..-1).map do |arg|
        assign_args(arg, attributes[:parrent_task_args])
      end
    end

    unless attributes[:task_info].key?(task_name.to_sym)
      Logger.warn("task not found and ignored: #{task_name}")
      next
    end

    next if !attributes[:filtered_tasks].nil? && !attributes[:filtered_tasks].include?(task_name)

    scenario = Rundock::Builder::ScenarioBuilder.new(nil, nil).build_task(
      attributes[:task_info][task_name.to_sym], backend, Rundock::Attribute::NodeAttribute.new(attributes)
    )

    logging(i, 'info')
    Logger.formatter.rec_lock

    scenario.run
    Logger.formatter.rec_unlock
  end
end