Class: VagrantPlugins::BetterHosts::Action::RemoveHosts

Inherits:
BaseAction
  • Object
show all
Defined in:
lib/vagrant-betterhosts/Action/RemoveHosts.rb

Overview

Remove hosts

Instance Method Summary collapse

Methods inherited from BaseAction

#call, #initialize

Methods included from BetterHosts

#add_betterhost_entries, #add_host_entries, #check_hostnames_to_add, #disable_clean, #generate_hostnames_by_ips, #get_clean_parameter_by_system, #get_cli, #get_hostnames, #get_ips, #get_os_binary, #print_readme, #remove_betterhost_entries, #remove_host_entries

Constructor Details

This class inherits a constructor from VagrantPlugins::BetterHosts::Action::BaseAction

Instance Method Details

#run(env) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/vagrant-betterhosts/Action/RemoveHosts.rb', line 7

def run(env)
  machine_action = env[:machine_action]

  return unless @machine.id
  return unless %i[destroy halt suspend].include? machine_action

  if (%i[halt suspend].include? machine_action) && (false == @machine.config.goodhosts.remove_on_suspend)
    @ui.info '[vagrant-betterhosts] Removing hosts on suspend disabled'
  else
    remove_host_entries
  end
end