Method: Miasma::Models::Orchestration::Terraform::Boule#stack_reload

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

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

Reload the stack data from the API

Parameters:

  • stack (Models::Orchestration::Stack)

Returns:

  • (Models::Orchestration::Stack)


263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
# File 'lib/miasma/contrib/terraform/orchestration.rb', line 263

def stack_reload(stack)
  if(stack.persisted?)
    result = request(
      :method => :get,
      :path => "/terraform/stack/#{stack.name}"
    )
    s = result.get(:body, :stack)
    stack.load_data(
      :id => s[:id],
      :created => s[:creation_time].to_s.empty? ? nil : Time.at(s[:creation_time].to_i / 1000.0),
      :description => s[:description],
      :name => s[:name],
      :state => s[:status].downcase.to_sym,
      :status => s[:status],
      :status_reason => s[:stack_status_reason],
      :updated => s[:updated_time].to_s.empty? ? nil : Time.at(s[:updated_time].to_i / 1000.0),
      :outputs => s[:outputs].map{|k,v| {:key => k, :value => v}}
    ).valid_state
  end
  stack
end