Sha256: 504397b41e1cc7d0d3af62f5dac029ea6c122d81cb9824a43ca8fef4096baabd

Contents?: true

Size: 801 Bytes

Versions: 5

Compression:

Stored size: 801 Bytes

Contents

require 'auto_network/action/base'

class AutoNetwork::Action::Release < AutoNetwork::Action::Base
  # Release auto_network IP address on VM destruction
  #
  # @param env [Hash]
  #
  # @option env [AutoNetwork::Pool] auto_network_pool The global auto network pool
  # @option env [Vagrant::Machine] machine The Vagrant machine being destroyed
  #
  # @return [void]
  def call(env)
    @env = env

    @machine = @env[:machine]

    release_network_addresses if machine_has_address?(@machine)

    @app.call(@env)
  end

  private

  def release_network_addresses
    addr = AutoNetwork.active_pool_manager.address_for(@machine)
    @env[:ui].info "AutoNetwork releasing #{addr.inspect} from '#{@machine.name}'",
      :prefix => true
    AutoNetwork.active_pool_manager.release(@machine)
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
vagrant-auto_network-1.0.3 lib/auto_network/action/release.rb
vagrant-auto_network-1.0.2 lib/auto_network/action/release.rb
vagrant-auto_network-1.0.1 lib/auto_network/action/release.rb
vagrant-auto_network-1.0.0 lib/auto_network/action/release.rb
vagrant-auto_network-1.0.0.rc1 lib/auto_network/action/release.rb