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?, 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
# 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')

  teardown if enabled?
  app.call(env)
end

#teardownObject



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

def teardown
  teardown_machine_dns
  DependentVMs.remove(machine_hostname)

  return unless DependentVMs.none?
  teardown_static_dns
  teardown_server
end

#teardown_machine_dnsObject



24
25
26
27
28
# File 'lib/landrush/action/teardown.rb', line 24

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

#teardown_serverObject



39
40
41
# File 'lib/landrush/action/teardown.rb', line 39

def teardown_server
  Server.stop
end

#teardown_static_dnsObject



30
31
32
33
34
35
36
37
# File 'lib/landrush/action/teardown.rb', line 30

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