Class: Landrush::Action::Teardown

Inherits:
Object
  • Object
show all
Includes:
Common
Defined in:
lib/landrush/action/teardown.rb

Constant Summary

Constants included from Common

Common::SUPPORTED_PROVIDERS

Instance Method Summary collapse

Methods included from Common

#config, #enabled?, #guest_redirect_dns?, #handle_action_stack, included, #info, #initialize, #libvirt?, #log, #machine, #machine_hostname, #parallels?, #provider, #read_machine_hostname, #virtualbox?, #vmware?

Instance Method Details

#call(env) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/landrush/action/teardown.rb', line 6

def call(env)
  # Make sure we use the right data directory for Landrush
  # Seems Vagrant only makes home_path available in this case, compared to custom commands where there is also data_dir
  Server.working_dir = File.join(env[:home_path], 'data', 'landrush')

  handle_action_stack(env) do
    teardown if enabled?
  end
end

#teardownObject



16
17
18
19
20
21
22
23
24
# File 'lib/landrush/action/teardown.rb', line 16

def teardown
  teardown_machine_dns
  DependentVMs.remove(machine_hostname)

  if DependentVMs.none?
    teardown_static_dns
    teardown_server
  end
end

#teardown_machine_dnsObject



26
27
28
29
30
31
# File 'lib/landrush/action/teardown.rb', line 26

def teardown_machine_dns
  if Store.hosts.has? machine_hostname
    info "removing machine entry: #{machine_hostname}"
    Store.hosts.delete(machine_hostname)
  end
end

#teardown_serverObject



42
43
44
# File 'lib/landrush/action/teardown.rb', line 42

def teardown_server
  Server.stop
end

#teardown_static_dnsObject



33
34
35
36
37
38
39
40
# File 'lib/landrush/action/teardown.rb', line 33

def teardown_static_dns
  config.hosts.each do |static_hostname|
    if Store.hosts.has? static_hostname
      info "removing static entry: #{static_hostname}"
      Store.hosts.delete static_hostname
    end
  end
end