Sha256: 8554f1b4f2c863b18e8e79db2fe1dc5f840c6377724ff5840511b5023493506c

Contents?: true

Size: 843 Bytes

Versions: 1

Compression:

Stored size: 843 Bytes

Contents

require 'auto_network/action_helpers'

class AutoNetwork::Action::Release

  include AutoNetwork::ActionHelpers

  def initialize(app, env)
    @app, @env = app, env
  end

  # 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]
    @pool    = @env[:auto_network_pool]

    release_network_addresses if machine_has_address?(@machine)

    @app.call(@env)
  end

  private

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vagrant-auto_network-1.0.0.beta1 lib/auto_network/action/release.rb