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

#enabled?, #global_config, #handle_action_stack, included, #info, #initialize, #machine, #machine_hostname, #provider, #virtualbox?, #vmware?

Instance Method Details

#call(env) ⇒ Object



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

def call(env)
  handle_action_stack(env) do
    teardown if enabled?
  end
end

#teardownObject



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

def teardown
  teardown_machine_dns
  DependentVMs.remove(machine_hostname)

  if DependentVMs.none?
    teardown_static_dns
    teardown_server
  else
    info "there are #{DependentVMs.count} VMs left, leaving DNS server and static entries"
    info DependentVMs.list.map { |dvm| " - #{dvm}" }.join("\n")
  end
end

#teardown_machine_dnsObject



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

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

#teardown_serverObject



37
38
39
# File 'lib/landrush/action/teardown.rb', line 37

def teardown_server
  Server.stop
end

#teardown_static_dnsObject



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

def teardown_static_dns
  global_config.landrush.hosts.each do |static_hostname, _|
    info "removing static entry: #{static_hostname}"
    Store.hosts.delete static_hostname
  end
end