Class: VagrantPlugins::Openstack::Action::DeleteStack

Inherits:
AbstractAction
  • Object
show all
Defined in:
lib/vagrant-openstack-provider/action/delete_stack.rb

Instance Method Summary collapse

Methods inherited from AbstractAction

#call

Constructor Details

#initialize(app, _env) ⇒ DeleteStack

Returns a new instance of DeleteStack.



16
17
18
19
# File 'lib/vagrant-openstack-provider/action/delete_stack.rb', line 16

def initialize(app, _env)
  @app = app
  @logger = Log4r::Logger.new('vagrant_openstack::action::delete_stack')
end

Instance Method Details

#execute(env) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/vagrant-openstack-provider/action/delete_stack.rb', line 21

def execute(env)
  @logger.info 'Start delete stacks action'

  heat = env[:openstack_client].heat

  list_stack_files(env).each do |stack|
    env[:ui].info(I18n.t('vagrant_openstack.delete_stack'))
    env[:ui].info(" -- Stack Name : #{stack[:name]}")
    env[:ui].info(" -- Stack ID   : #{stack[:id]}")

    heat.delete_stack(env, stack[:name], stack[:id])

    waiting_for_stack_to_be_deleted(env, stack[:name], stack[:id])
  end

  # This will remove all files in the .vagrant instance directory
  env[:machine].id = nil

  @app.call(env)
end