Sha256: 5d5eaca60310445a1eba92914e83dc8652148eea32d876dd32960206cd9b7812

Contents?: true

Size: 1.22 KB

Versions: 4

Compression:

Stored size: 1.22 KB

Contents

module AutoNetwork
  module ActionHelpers

    # Determine if the given machine exists and has an auto_network address
    #
    # @param [Vagrant::Machine]
    #
    # @return [true, false]
    def machine_has_address?(machine)
      !!(machine and @pool.address_for(machine))
    end

    # Fetch all private networks that are tagged for auto networking
    #
    # @param iface [Array<Symbol, Hash>]
    #
    # @return [Array<Symbol, Hash>] All auto_networks
    def machine_auto_networks(machine)
      machine.config.vm.networks.select do |(net_type, options)|
        net_type == :private_network and options[:auto_network]
      end
    end

    # Convert an auto network to a private network with a static IP address.
    #
    # This does an in-place modification of the private_network options hash
    # to strip out the auto_network configuration and make this behave like a
    # normal private network interface with a static IP address.
    #
    # @param iface [Array<Symbol, Hash>]
    # @param addr [String] The static IP address to assign to the private network
    #
    # @return [void]
    def filter_private_network(iface, addr)
      opts = iface[1]
      opts.delete(:auto_network)
      opts[:ip] = addr
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
vagrant-auto_network-1.0.0.beta1 lib/auto_network/action_helpers.rb
vagrant-auto_network-0.2.2 lib/auto_network/action_helpers.rb
vagrant-auto_network-0.2.1 lib/auto_network/action_helpers.rb
vagrant-auto_network-0.2.0 lib/auto_network/action_helpers.rb