Method: Ec2Script#start_script

Defined in:
lib/scripts/ec2/ec2_script.rb

#start_scriptObject

Executes the script.



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/scripts/ec2/ec2_script.rb', line 46

def start_script()
  # optional parameters and initialization
  check_input_parameters()
  @input_params[:script] = self
  begin
    current_state = load_initial_state()
    @state_change_listeners.each() {|listener|
      current_state.register_state_change_listener(listener)
    }
    end_state = current_state.start_state_machine()
    if end_state.failed?
      @result[:failed] = true
      @result[:failure_reason] = current_state.end_state.failure_reason
      @result[:end_state] = current_state.end_state
    else
      @result[:failed] = false
    end
  rescue Exception => e
    @logger.warn "exception during encryption: #{e}"
    @logger.warn e.backtrace.join("\n")
    err = e.to_s
    err += " (in #{current_state.end_state.to_s})" unless current_state == nil
    @result[:failed] = true
    @result[:failure_reason] = err
    @result[:end_state] = current_state.end_state unless current_state == nil
  ensure
    begin
    @input_params[:remote_command_handler].disconnect
    rescue Exception => e2
    end
  end
  #
  @result[:done] = true
end