Class: VagrantPlugins::TerraformProvider::Action::HaltVM
- Inherits:
-
Object
- Object
- VagrantPlugins::TerraformProvider::Action::HaltVM
- Includes:
- Util::TerraformExecute, Util::UpdateVmState
- Defined in:
- lib/vagrant-terraform/action/halt_vm.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ HaltVM
constructor
A new instance of HaltVM.
Methods included from Util::UpdateVmState
Methods included from Util::TerraformExecute
Constructor Details
#initialize(app, env) ⇒ HaltVM
Returns a new instance of HaltVM.
14 15 16 17 |
# File 'lib/vagrant-terraform/action/halt_vm.rb', line 14 def initialize(app, env) @logger = Log4r::Logger.new("vagrant_terraform::action::halt_vm") @app = app end |
Instance Method Details
#call(env) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/vagrant-terraform/action/halt_vm.rb', line 19 def call(env) env[:ui].info(I18n.t("vagrant_terraform.halt_vm")) begin terraform_dir = ".vagrant/terraform/#{env[:machine].id}" terraform_main_file = "#{terraform_dir}/main.tf" update_vm_state(terraform_main_file, "stopped") terraform_execute(env, 'terraform apply -auto-approve') rescue Exception => e # TODO: need to retry in some case? # retry if e.message =~ /something/ raise e end @app.call(env) end |