Method: Miasma::Models::Orchestration::OpenStack#stack_reload

Defined in:
lib/miasma/contrib/open_stack/orchestration.rb

#stack_reload(stack) ⇒ Models::Orchestration::Stack

Reload the stack data from the API

Parameters:

  • stack (Models::Orchestration::Stack)

Returns:

  • (Models::Orchestration::Stack)


62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/miasma/contrib/open_stack/orchestration.rb', line 62

def stack_reload(stack)
  if(stack.persisted?)
    result = request(
      :method => :get,
      :path => "/stacks/#{stack.name}/#{stack.id}",
      :expects => 200
    )
    stk = result.get(:body, :stack)
    stack.load_data(
      :id => stk[:id],
      :capabilities => stk[:capabilities],
      :created => Time.parse(stk[:creation_time]),
      :description => stk[:description],
      :disable_rollback => stk[:disable_rollback].to_s.downcase == 'true',
      :notification_topics => stk[:notification_topics],
      :name => stk[:stack_name],
      :state => stk[:stack_status].downcase.to_sym,
      :status => stk[:stack_status],
      :status_reason => stk[:stack_status_reason],
      :template_description => stk[:template_description],
      :timeout_in_minutes => stk[:timeout_mins].to_s.empty? ? nil : stk[:timeout_mins].to_i,
      :updated => stk[:updated_time].to_s.empty? ? nil : Time.parse(stk[:updated_time]),
      :parameters => stk.fetch(:parameters, Smash.new),
      :outputs => stk.fetch(:outputs, []).map{ |output|
        Smash.new(
          :key => output[:output_key],
          :value => output[:output_value],
          :description => output[:description]
        )
      }
    ).valid_state
  end
  stack
end