Sha256: 1c21fa297bfac899c0daaa1276d14d369715c6d4637b2570313b289a333c0159

Contents?: true

Size: 1.18 KB

Versions: 8

Compression:

Stored size: 1.18 KB

Contents

module Landrush
  module Action
    class Teardown
      include Common

      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

      def teardown
        teardown_machine_dns
        DependentVMs.remove(machine_hostname)

        if DependentVMs.none?
          teardown_static_dns
          teardown_server
        end
      end

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

      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

      def teardown_server
        Server.stop
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
landrush-1.1.2 lib/landrush/action/teardown.rb
landrush-1.1.1 lib/landrush/action/teardown.rb
landrush-1.1.0 lib/landrush/action/teardown.rb
landrush-1.1.0.beta.4 lib/landrush/action/teardown.rb
landrush-1.1.0.beta.3 lib/landrush/action/teardown.rb
landrush-1.1.0.beta.2 lib/landrush/action/teardown.rb
landrush-1.1.0.beta.1 lib/landrush/action/teardown.rb
landrush-1.0.0 lib/landrush/action/teardown.rb