Sha256: b1a0249c1acefa8cbdf95472ced1babe8e60bf84dbe0f4333c6d1a7e8cfcbab3

Contents?: true

Size: 994 Bytes

Versions: 4

Compression:

Stored size: 994 Bytes

Contents

module Landrush
  module Action
    class Teardown
      include Common

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

      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

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

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

      def teardown_server
        Server.stop
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
landrush-0.13.1 lib/landrush/action/teardown.rb
landrush-0.13.0 lib/landrush/action/teardown.rb
landrush-0.12.0 lib/landrush/action/teardown.rb
landrush-0.11.0 lib/landrush/action/teardown.rb