vagrant-auto_network 1.0.0.beta2 → 1.0.0.rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f95b22bf6a47ec537f8006cc11b3c3f3997507eb
4
- data.tar.gz: 6c54bb78892dfca504042ccfd29d69fe9a7e7ca2
3
+ metadata.gz: 497131d24f1670f54dd51b9264f9d896c6d5c299
4
+ data.tar.gz: acfdf515d2a0c57f6607b1d43029d290e99ce33c
5
5
  SHA512:
6
- metadata.gz: 6f54e0c340517c61c20969df5fd69cc4d40757ab2f355a053c5de4b1a14bc2794c8585fae6fd50d6975d5d9a2a5cd12bfc75cc83e1d43ed1f4440dd1b1d1378c
7
- data.tar.gz: f3d2054ae710fd14231ae1ff7e3f2c058f717d468a284244f74b059bb0c4ad5b3979e35e07582013740869e8ccc3d88a2ebb76ae08f29a4991e85e515e9e184d
6
+ metadata.gz: ebb3a65b50265b98b07310e1a5ceab508acb57f2146bea4157d57f5562bdc4453176d89954c8b0dea0a20fb6817e52c8afbf2e6bcd1e329df0ec1931fe6a6fa7
7
+ data.tar.gz: b0df283881996781bcf2ad23fe7dfcca4259a3c10f7ac3e7022f5e304c8d4f521af6d9f9062e864b0b2d2a1d5c91421bfdb79072c28151780d1a3ada2565032e
data/.gitignore CHANGED
@@ -2,6 +2,9 @@
2
2
  .yardoc
3
3
  Gemfile.local
4
4
  Gemfile.lock
5
+ license-vagrant-vmware-fusion.lic
6
+ vagrant-spec.config.rb
5
7
  acceptance/artifacts
6
8
  coverage
7
9
  doc
10
+ rgloader
data/.travis.yml ADDED
@@ -0,0 +1,17 @@
1
+ ---
2
+ language: ruby
3
+ before_install:
4
+ - gem install bundler --version 1.5.3
5
+ install: bundle $BUNDLER_VERSION install
6
+ script: bundle $BUNDLER_VERSION exec rspec --color --format documentation
7
+ notifications:
8
+ email: false
9
+ rvm:
10
+ - 2.0.0
11
+ env:
12
+ global:
13
+ - NOKOGIRI_USE_SYSTEM_LIBRARIES=true
14
+ matrix:
15
+ - TEST_VAGRANT_VERSION=v1.5.4 BUNDLER_VERSION=_1.5.3_
16
+ - TEST_VAGRANT_VERSION=v1.6.2
17
+ - TEST_VAGRANT_VERSION=HEAD
data/.yardopts CHANGED
@@ -1 +1,2 @@
1
1
  --markup markdown
2
+ --protected
data/CHANGELOG CHANGED
@@ -26,8 +26,24 @@ Specifically, the following issues have been addressed:
26
26
  storage mechanism that offers more resiliance to race conditions and data
27
27
  loss from aborted actions.
28
28
 
29
+ The following features have been removed:
30
+
29
31
  * (GH-14) Remove depreciated AutoNetwork mixin module.
30
32
 
33
+
34
+ 1.0.0.rc1
35
+ ---------
36
+
37
+ 2014-05-12
38
+
39
+ Changes since 1.0.0.beta2:
40
+
41
+ * Addition of integration tests that check for interoperability between
42
+ AutoNetwork and Vagrant. Test suite automatically run by Travis CI.
43
+
44
+ * Internal refactoring and cleanup.
45
+
46
+
31
47
  1.0.0.beta2
32
48
  -----------
33
49
 
@@ -39,6 +55,7 @@ Bug Fixes:
39
55
 
40
56
  * Ensure directories exist when creating `pool.yaml` for the first time.
41
57
 
58
+
42
59
  1.0.0.beta1
43
60
  -----------
44
61
 
data/Gemfile CHANGED
@@ -1,17 +1,23 @@
1
1
  source 'https://rubygems.org'
2
2
  ruby '2.0.0'
3
3
 
4
+ ENV['TEST_VAGRANT_VERSION'] ||= 'v1.6.2'
5
+
4
6
  # Using the :plugins group causes Vagrant to automagially load auto_network
5
7
  # during acceptance tests.
6
8
  group :plugins do
7
9
  gemspec
8
10
  end
9
11
 
10
- group :development do
11
- gem 'vagrant', :github => 'mitchellh/vagrant', :tag => 'v1.5.4'
12
- # Pinned on 05/05/2014.
12
+ group :test do
13
+ if ENV['TEST_VAGRANT_VERSION'] == 'HEAD'
14
+ gem 'vagrant', :github => 'mitchellh/vagrant', :branch => 'master'
15
+ else
16
+ gem 'vagrant', :github => 'mitchellh/vagrant', :tag => ENV['TEST_VAGRANT_VERSION']
17
+ end
18
+
19
+ # Pinned on 05/05/2014. Compatible with Vagrant 1.5.x and 1.6.x.
13
20
  gem 'vagrant-spec', :github => 'mitchellh/vagrant-spec', :ref => 'aae28ee'
14
- gem 'rake'
15
21
  end
16
22
 
17
23
  if File.exists? "#{__FILE__}.local"
data/README.markdown CHANGED
@@ -3,6 +3,8 @@ Vagrant Auto-network
3
3
 
4
4
  Automatically configure Vagrant private network interfaces.
5
5
 
6
+ [![Build Status](https://travis-ci.org/adrienthebo/vagrant-auto_network.svg?branch=travis-ci)](https://travis-ci.org/adrienthebo/vagrant-auto_network)
7
+
6
8
  Summary
7
9
  -------
8
10
 
@@ -22,12 +22,12 @@ shared_examples 'provider/auto_network' do |provider, options|
22
22
  # invocation is dependant on the state created by the prior command.
23
23
  it 'manages IP address allocation for the lifecycle of a VM' do
24
24
  result = assert_execute('vagrant', 'up', "--provider=#{provider}")
25
- expect(result.stdout).to match(/Assigning "\S+" to 'default'/)
25
+ expect(result.stdout).to match(/AutoNetwork assigning "\S+" to 'default'/)
26
26
 
27
27
  assert_execute('vagrant', 'status')
28
28
  assert_execute('vagrant', 'reload', 'default')
29
29
 
30
30
  result = assert_execute('vagrant', 'destroy', '--force')
31
- expect(result.stdout).to match(/Releasing "\S+" from default/)
31
+ expect(result.stdout).to match(/AutoNetwork releasing "\S+" from 'default'/)
32
32
  end
33
33
  end
@@ -0,0 +1,65 @@
1
+ module AutoNetwork
2
+ # This is an abstract base class for AutoNetwork actions that provides
3
+ # helper methods for interfacing with a {AutoNetwork::PoolManager} object
4
+ # and the {AutoNetwork::Pool} instances it manages.
5
+ #
6
+ # @abstract Subclass and override {#call} to implement a new AutoNetwork
7
+ # action.
8
+ class Action::Base
9
+ # Create a new action instance that is suitable for execution as part of
10
+ # Vagrant middleware.
11
+ #
12
+ # @param app [#call] an instance of an object that responds to `call`.
13
+ # Typically an object representing a chain of Vagrant actions.
14
+ # Executing `call` passes execution to the next action in the chain.
15
+ # @param env [Hash] a hash representing the Vagrant state this action
16
+ # executes under. Unfortunately, there are two or three variations of
17
+ # what data can be passed, so Action logic that inspects this parameter
18
+ # is a bit fragile.
19
+ def initialize(app, env)
20
+ @app, @env = app, env
21
+ end
22
+
23
+ def call(env)
24
+ raise NotImplementedError
25
+ end
26
+
27
+ protected
28
+
29
+ # Determine if the given machine exists and has an auto_network address
30
+ #
31
+ # @param machine [Vagrant::Machine]
32
+ #
33
+ # @return [true, false]
34
+ def machine_has_address?(machine)
35
+ !!(machine and AutoNetwork.active_pool_manager.address_for(machine))
36
+ end
37
+
38
+ # Fetch all private networks that are tagged for auto networking
39
+ #
40
+ # @param machine [Vagrant::Machine]
41
+ #
42
+ # @return [Array(Symbol, Hash)] All auto_networks
43
+ def machine_auto_networks(machine)
44
+ machine.config.vm.networks.select do |(net_type, options)|
45
+ net_type == :private_network and options[:auto_network]
46
+ end
47
+ end
48
+
49
+ # Convert an auto network to a private network with a static IP address.
50
+ #
51
+ # This does an in-place modification of the private_network options hash
52
+ # to strip out the auto_network configuration and make this behave like a
53
+ # normal private network interface with a static IP address.
54
+ #
55
+ # @param iface [Array(Symbol, Hash)]
56
+ # @param addr [String] The static IP address to assign to the private network
57
+ #
58
+ # @return [void]
59
+ def filter_private_network(iface, addr)
60
+ opts = iface[1]
61
+ opts.delete(:auto_network)
62
+ opts[:ip] = addr
63
+ end
64
+ end
65
+ end
@@ -1,16 +1,6 @@
1
- require 'auto_network/action_helpers'
2
- require 'log4r'
3
-
4
- class AutoNetwork::Action::FilterNetworks
5
-
6
- include AutoNetwork::ActionHelpers
7
-
8
- def initialize(app, env)
9
- @app, @env = app, env
10
-
11
- @logger = Log4r::Logger.new('vagrant::auto_network::filter_networks')
12
- end
1
+ require 'auto_network/action/base'
13
2
 
3
+ class AutoNetwork::Action::FilterNetworks < AutoNetwork::Action::Base
14
4
  # Convert auto_network interfaces to static private_network interfaces.
15
5
  #
16
6
  # @param env [Hash]
@@ -48,8 +38,7 @@ class AutoNetwork::Action::FilterNetworks
48
38
 
49
39
  def assign_address(machine)
50
40
  machine_auto_networks(machine).each do |net|
51
- addr = AutoNetwork.pool_manager.address_for(machine)
52
- @logger.info "Reassigning #{addr.inspect} to existing machine #{machine.name}"
41
+ addr = AutoNetwork.active_pool_manager.address_for(machine)
53
42
  filter_private_network(net, addr)
54
43
  end
55
44
  end
@@ -1,11 +1,6 @@
1
- require 'auto_network'
2
-
3
- class AutoNetwork::Action::LoadPool
4
-
5
- def initialize(app, env)
6
- @app, @env = app, env
7
- end
1
+ require 'auto_network/action/base'
8
2
 
3
+ class AutoNetwork::Action::LoadPool < AutoNetwork::Action::Base
9
4
  # Handle the loading and unloading of the auto_network pool
10
5
  #
11
6
  # @param env [Hash]
@@ -39,6 +34,9 @@ class AutoNetwork::Action::LoadPool
39
34
  end
40
35
 
41
36
  def deserialize!
37
+ unless @statefile.exist?
38
+ @env[:env].ui.info "Initializing AutoNetwork pool storage."
39
+ end
42
40
  AutoNetwork.pool_manager = AutoNetwork::PoolManager.new(@statefile)
43
41
  end
44
42
  end
@@ -1,13 +1,6 @@
1
- require 'auto_network/action_helpers'
2
-
3
- class AutoNetwork::Action::Release
4
-
5
- include AutoNetwork::ActionHelpers
6
-
7
- def initialize(app, env)
8
- @app, @env = app, env
9
- end
1
+ require 'auto_network/action/base'
10
2
 
3
+ class AutoNetwork::Action::Release < AutoNetwork::Action::Base
11
4
  # Release auto_network IP address on VM destruction
12
5
  #
13
6
  # @param env [Hash]
@@ -29,8 +22,9 @@ class AutoNetwork::Action::Release
29
22
  private
30
23
 
31
24
  def release_network_addresses
32
- addr = AutoNetwork.pool_manager.address_for(@machine)
33
- @env[:ui].info "Releasing #{addr.inspect} from #{@machine.name}", :prefix => true
34
- AutoNetwork.pool_manager.release(@machine)
25
+ addr = AutoNetwork.active_pool_manager.address_for(@machine)
26
+ @env[:ui].info "AutoNetwork releasing #{addr.inspect} from '#{@machine.name}'",
27
+ :prefix => true
28
+ AutoNetwork.active_pool_manager.release(@machine)
35
29
  end
36
30
  end
@@ -1,13 +1,6 @@
1
- require 'auto_network/action_helpers'
2
-
3
- class AutoNetwork::Action::Request
4
-
5
- include AutoNetwork::ActionHelpers
6
-
7
- def initialize(app, env)
8
- @app, @env = app, env
9
- end
1
+ require 'auto_network/action/base'
10
2
 
3
+ class AutoNetwork::Action::Request < AutoNetwork::Action::Base
11
4
  # Request an auto_network IP address on VM creation
12
5
  #
13
6
  # @param env [Hash]
@@ -30,8 +23,9 @@ class AutoNetwork::Action::Request
30
23
 
31
24
  def request_address
32
25
  machine_auto_networks(@machine).each do |net|
33
- addr = AutoNetwork.pool_manager.request(@machine)
34
- @env[:ui].info "Assigning #{addr.inspect} to '#{@machine.name}'", :prefix => true
26
+ addr = AutoNetwork.active_pool_manager.request(@machine)
27
+ @env[:ui].info "AutoNetwork assigning #{addr.inspect} to '#{@machine.name}'",
28
+ :prefix => true
35
29
  filter_private_network(net, addr)
36
30
  end
37
31
  end
@@ -13,8 +13,7 @@ module AutoNetwork
13
13
  error_key(:pool_exhausted, 'vagrant_auto_network')
14
14
  end
15
15
 
16
- # @!attribute [r] network_range
17
- # @return [String] The address range manged by this Pool instance.
16
+ # @return [String] The address range manged by this Pool instance.
18
17
  attr_reader :network_range
19
18
 
20
19
  # Create a new Pool object that manages a range of IP addresses.
@@ -76,6 +75,14 @@ module AutoNetwork
76
75
  addr
77
76
  end
78
77
 
78
+ # Compute the value that will be used to identify a machine. This value
79
+ # will be associated with IP addresses allocated to the machine.
80
+ #
81
+ # @param machine [Vagrant::Machine]
82
+ #
83
+ # @return [Hash{String=>String}] A hash containing the path to the
84
+ # directory containing the Vagrantfile that defined the machine and the
85
+ # machine name.
79
86
  def id_for(machine)
80
87
  {
81
88
  'path' => machine.env.root_path.to_s,
@@ -1,4 +1,5 @@
1
1
  require 'ipaddr'
2
+ require 'auto_network/pool_manager'
2
3
  require 'vagrant/errors'
3
4
 
4
5
  module AutoNetwork
@@ -13,10 +14,29 @@ module AutoNetwork
13
14
  error_key(:invalid_setting, 'vagrant_auto_network')
14
15
  end
15
16
 
16
- # @!attribute [rw] pool_manager
17
- # @return [AutoNetwork::PoolManager, nil]
17
+ # Access the global {AutoNetwork::PoolManager} instance.
18
+ # @return [AutoNetwork::PoolManager, nil]
18
19
  attr_accessor :pool_manager
19
20
 
21
+ # Assertively retrieve the global {AutoNetwork::PoolManager} instance.
22
+ #
23
+ # Raises an error if {#pool_manager} has been set to `nil` or an invalid
24
+ # value.
25
+ #
26
+ # @return [AutoNetwork::PoolManager]
27
+ # @raise [InvalidSettingErrror] If {#pool_manager} is not set to a usable
28
+ # value.
29
+ def active_pool_manager
30
+ manager = pool_manager
31
+ unless manager.is_a?(AutoNetwork::PoolManager)
32
+ raise InvalidSettingErrror,
33
+ :setting_name => 'pool_manager',
34
+ :value => manager
35
+ end
36
+
37
+ manager
38
+ end
39
+
20
40
  # Unless overriden, this will be the IP range assigned to the very first
21
41
  # {AutoNetwork::Pool} created by {AutoNetwork::PoolManager} instances.
22
42
  DEFAULT_POOL = '10.20.1.0/24'
@@ -1,3 +1,3 @@
1
1
  module AutoNetwork
2
- VERSION = '1.0.0.beta2'
2
+ VERSION = '1.0.0.rc1'
3
3
  end
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+ require_relative 'shared/auto_network_0x_context'
3
+
4
+ describe 'Working with AutoNetwork 0.x data' do
5
+ include_context 'vagrant-unit'
6
+ include_context 'auto_network 0.x'
7
+
8
+ def current_ip(machine)
9
+ settings.pool_manager.with_pool_for(machine) {|p| p.address_for(machine)}
10
+ end
11
+
12
+ before(:each) do
13
+ env = test_env.create_vagrant_env
14
+ @test_machine = env.machine(:test1, :dummy)
15
+
16
+ # Legacy pool data is assigned to the VirtualBox provider. Fake our
17
+ # provider name for this purpose.
18
+ allow(@test_machine).to receive(:provider_name).and_return(:virtualbox)
19
+ end
20
+
21
+ it 'upgrades the poolfile format when saving data' do
22
+ # Running a read/write transaction will cause the poolfile to be
23
+ # regenerated.
24
+ settings.pool_manager.with_pool_for(@test_machine, read_only=false){|p| }
25
+ pool_data = YAML.load_file(pool_file)
26
+
27
+ # Expect that the poolfile has been upgraded to the latest version.
28
+ expect(pool_data).to include({
29
+ 'poolfile_version' => AutoNetwork::PoolStorage::POOLFILE_VERSION
30
+ })
31
+ end
32
+
33
+ # The 0.x context defines one machine with an IP allocated by UUID.
34
+ it 'releases IP addresses allocated by UUID' do
35
+ expect(current_ip(@test_machine)).to eq('10.20.1.2')
36
+
37
+ @test_machine.action(:destroy)
38
+
39
+ expect(current_ip(@test_machine)).to be_nil
40
+ end
41
+ end
@@ -1,28 +1,51 @@
1
1
  require 'spec_helper'
2
+ require_relative 'shared/auto_network_1x_context'
2
3
 
3
4
  describe AutoNetwork::Plugin do
4
5
  include_context 'vagrant-unit'
6
+ include_context 'auto_network 1.x'
5
7
 
6
8
  context 'when a vagrant environment is initialized' do
7
- let(:settings) {
8
- Module.new do
9
- extend AutoNetwork::Settings
10
- end
11
- }
12
- let(:manager_double) { double().as_null_object }
13
-
14
9
  it 'sets the global pool_manager' do
15
- allow(AutoNetwork).to receive(:pool_manager=) do |pool_manager|
16
- settings.pool_manager = pool_manager
17
- end
18
- allow(manager_double).to receive(:new).and_return('a_pool_manager')
19
- stub_const('AutoNetwork::PoolManager', manager_double)
20
-
21
10
  # Create an environment \o/
22
- isolated_environment.create_vagrant_env
11
+ test_env.create_vagrant_env
12
+
13
+ expect(settings.pool_manager).to be_a(AutoNetwork::PoolManager)
14
+ end
15
+
16
+ it 'assigns autonetworked IP addresses to existing machines' do
17
+ env = test_env.create_vagrant_env
18
+
19
+ test_machine = env.machine(:test1, :dummy)
20
+ _, network_opts = test_machine.config.vm.networks.find {|n| n.first == :private_network}
21
+
22
+ expect(network_opts).to include(:ip => '10.20.1.2')
23
+ end
24
+ end
25
+
26
+ context 'when destroying a machine' do
27
+ def current_ip(machine)
28
+ settings.pool_manager.with_pool_for(machine) {|p| p.address_for(machine)}
29
+ end
30
+
31
+ it 'releases the allocated IP address' do
32
+ env = test_env.create_vagrant_env
33
+ test_machine = env.machine(:test1, :dummy)
23
34
 
24
- expect(settings.pool_manager).to eq('a_pool_manager')
35
+ expect(current_ip(test_machine)).to eq('10.20.1.2')
36
+
37
+ test_machine.action(:destroy)
38
+
39
+ expect(current_ip(test_machine)).to be_nil
25
40
  end
41
+ end
26
42
 
43
+ # Testing IP allocation is pretty tricky since it hooks into
44
+ # provider-specific behavior that our dummy provider does not have.
45
+ # Currently, this behavior is exercised by the acceptance tests.
46
+ context 'when creating a machine' do
47
+ it 'allocates an IP address' do
48
+ pending 'This is currently delegated to the acceptance suite.'
49
+ end
27
50
  end
28
51
  end
@@ -0,0 +1,48 @@
1
+ require_relative 'isolated_settings_context'
2
+
3
+ # Creates an environment for each test containing data that would have been
4
+ # created by an installation of AutoNetwork 0.x.
5
+ shared_context 'auto_network 0.x' do
6
+ include_context 'vagrant-unit'
7
+ include_context 'auto_network-settings'
8
+
9
+ # Configure each testing environment to contain an AutoNetwork version 1 pool
10
+ # file and a single existing machine that has been allocated in the pool
11
+ let(:test_env) { isolated_environment }
12
+ let(:pool_file) { test_env.homedir.join('auto_network', 'pool.yaml') }
13
+ before(:each) do
14
+ pool_file.dirname.mkpath
15
+ pool_file.open('w+') do |f|
16
+ f.write <<-EOF
17
+ --- !ruby/object:AutoNetwork::Pool
18
+ network_range: 10.20.1.0/29
19
+ pool:
20
+ 10.20.1.2: some-uuid-string
21
+ 10.20.1.3:
22
+ 10.20.1.4:
23
+ 10.20.1.5:
24
+ 10.20.1.6:
25
+ EOF
26
+ end
27
+
28
+ test_env.vagrantfile <<-EOF
29
+ Vagrant.configure("2") do |config|
30
+ config.vm.define 'test1' do |node|
31
+ node.vm.network :private_network, :auto_network => true
32
+ end
33
+ end
34
+ EOF
35
+
36
+ # Touch an ID file so that Vagrant thinks test1 exists. The 'dummy'
37
+ # component of the path actually tells Vagrant which provider is managing
38
+ # the machine. vagrant-spec defines a dummy provider for us.
39
+ machine_dir = test_env.workdir.join('.vagrant/machines/test1/dummy')
40
+ machine_dir.mkpath
41
+ machine_dir.join('id').open('w+') { |f| f.write('some-uuid-string') }
42
+ end
43
+
44
+ # Dispose of the temporary directory used to run the test.
45
+ after(:each) do
46
+ test_env.close
47
+ end
48
+ end
@@ -0,0 +1,53 @@
1
+ require_relative 'isolated_settings_context'
2
+
3
+ # Creates an environment for each test containing a small pool of AutoNetwork
4
+ # addresses and a single "created" VM.
5
+ shared_context 'auto_network 1.x' do
6
+ include_context 'vagrant-unit'
7
+ include_context 'auto_network-settings'
8
+
9
+ # Configure each testing environment to contain an AutoNetwork version 2 pool
10
+ # file and a single existing machine that has been allocated in the pool
11
+ let(:test_env) { isolated_environment }
12
+ let(:pool_file) { test_env.homedir.join('auto_network', 'pool.yaml') }
13
+ before(:each) do
14
+ pool_file.dirname.mkpath
15
+ pool_file.open('w+') do |f|
16
+ f.write <<-EOF
17
+ ---
18
+ poolfile_version: 2
19
+ pools:
20
+ dummy: !ruby/object:AutoNetwork::Pool
21
+ network_range: 10.20.1.0/29
22
+ pool:
23
+ 10.20.1.2:
24
+ path: #{test_env.workdir}
25
+ name: test1
26
+ 10.20.1.3:
27
+ 10.20.1.4:
28
+ 10.20.1.5:
29
+ 10.20.1.6:
30
+ EOF
31
+ end
32
+
33
+ test_env.vagrantfile <<-EOF
34
+ Vagrant.configure("2") do |config|
35
+ config.vm.define 'test1' do |node|
36
+ node.vm.network :private_network, :auto_network => true
37
+ end
38
+ end
39
+ EOF
40
+
41
+ # Touch an ID file so that Vagrant thinks test1 exists. The 'dummy'
42
+ # component of the path actually tells Vagrant which provider is managing
43
+ # the machine. vagrant-spec defines a dummy provider for us.
44
+ machine_dir = test_env.workdir.join('.vagrant/machines/test1/dummy')
45
+ machine_dir.mkpath
46
+ machine_dir.join('id').open('w+') { |f| f.write('') }
47
+ end
48
+
49
+ # Dispose of the temporary directory used to run the test.
50
+ after(:each) do
51
+ test_env.close
52
+ end
53
+ end
@@ -0,0 +1,17 @@
1
+ shared_context 'auto_network-settings' do
2
+ # Create a Dummy settings module for each test.
3
+ let(:settings) {
4
+ Module.new do
5
+ extend AutoNetwork::Settings
6
+ end
7
+ }
8
+
9
+ # Stub the settings attached to the AutoNetwork module so we don't change
10
+ # global state during tests.
11
+ before(:each) do
12
+ allow(AutoNetwork).to receive(:pool_manager=) do |pool_manager|
13
+ settings.pool_manager = pool_manager
14
+ end
15
+ allow(AutoNetwork).to receive(:pool_manager).and_return { settings.pool_manager }
16
+ end
17
+ end
@@ -19,4 +19,12 @@ describe AutoNetwork::Settings do
19
19
  end
20
20
 
21
21
  end
22
+
23
+ describe 'pool_manager' do
24
+ context 'when unset' do
25
+ it 'raises an error when accessed through active_pool_manager' do
26
+ expect { subject.active_pool_manager }.to raise_error(AutoNetwork::Settings::InvalidSettingErrror)
27
+ end
28
+ end
29
+ end
22
30
  end
@@ -7,8 +7,8 @@ Gem::Specification.new do |gem|
7
7
  gem.name = "vagrant-auto_network"
8
8
  gem.version = AutoNetwork::VERSION
9
9
 
10
- gem.authors = 'Adrien Thebo'
11
- gem.email = 'adrien@somethingsinistral.net'
10
+ gem.authors = ['Adrien Thebo', 'Charlie Sharpsteen']
11
+ gem.email = ['adrien@somethingsinistral.net', 'source@sharpsteen.net']
12
12
  gem.homepage = 'https://github.com/adrienthebo/vagrant-auto_network'
13
13
 
14
14
  gem.summary = "Automatically create an internal network for all vagrant boxes"
@@ -18,5 +18,6 @@ Gem::Specification.new do |gem|
18
18
 
19
19
  gem.license = 'Apache 2.0'
20
20
 
21
+ gem.add_development_dependency 'rake'
21
22
  gem.add_development_dependency 'rspec', '~> 2.14.0'
22
23
  end
@@ -13,4 +13,13 @@ Vagrant::Spec::Acceptance.configure do |c|
13
13
  'VBOX_USER_HOME' => '{{homedir}}',
14
14
  'AUTO_NETWORK_TEST_RANGE' => '10.42.1.0/24',
15
15
  }
16
+
17
+ # VMware Fusion disabled by default. Instructions:
18
+ # https://github.com/adrienthebo/vagrant-auto_network/wiki#vmware-fusion
19
+
20
+ #c.provider 'vmware_fusion',
21
+ # box: (acceptance_dir + 'artifacts' + 'vmware_fusion.box').to_s,
22
+ # env_vars: {
23
+ # 'AUTO_NETWORK_TEST_RANGE' => '10.42.2.0/24',
24
+ # }
16
25
  end
metadata CHANGED
@@ -1,15 +1,30 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-auto_network
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.beta2
4
+ version: 1.0.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrien Thebo
8
+ - Charlie Sharpsteen
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2014-05-09 00:00:00.000000000 Z
12
+ date: 2014-05-12 00:00:00.000000000 Z
12
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - '>='
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - '>='
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
13
28
  - !ruby/object:Gem::Dependency
14
29
  name: rspec
15
30
  requirement: !ruby/object:Gem::Requirement
@@ -25,12 +40,15 @@ dependencies:
25
40
  - !ruby/object:Gem::Version
26
41
  version: 2.14.0
27
42
  description:
28
- email: adrien@somethingsinistral.net
43
+ email:
44
+ - adrien@somethingsinistral.net
45
+ - source@sharpsteen.net
29
46
  executables: []
30
47
  extensions: []
31
48
  extra_rdoc_files: []
32
49
  files:
33
50
  - .gitignore
51
+ - .travis.yml
34
52
  - .yardopts
35
53
  - CHANGELOG
36
54
  - Gemfile
@@ -40,11 +58,11 @@ files:
40
58
  - acceptance/skeletons/auto_network/Vagrantfile
41
59
  - lib/auto_network.rb
42
60
  - lib/auto_network/action.rb
61
+ - lib/auto_network/action/base.rb
43
62
  - lib/auto_network/action/filter_networks.rb
44
63
  - lib/auto_network/action/load_pool.rb
45
64
  - lib/auto_network/action/release.rb
46
65
  - lib/auto_network/action/request.rb
47
- - lib/auto_network/action_helpers.rb
48
66
  - lib/auto_network/plugin.rb
49
67
  - lib/auto_network/pool.rb
50
68
  - lib/auto_network/pool_manager.rb
@@ -52,14 +70,18 @@ files:
52
70
  - lib/auto_network/settings.rb
53
71
  - lib/auto_network/version.rb
54
72
  - lib/vagrant-auto_network.rb
73
+ - spec/integration/legacy_spec.rb
55
74
  - spec/integration/plugin_spec.rb
75
+ - spec/integration/shared/auto_network_0x_context.rb
76
+ - spec/integration/shared/auto_network_1x_context.rb
77
+ - spec/integration/shared/isolated_settings_context.rb
56
78
  - spec/spec_helper.rb
57
79
  - spec/unit/pool_spec.rb
58
80
  - spec/unit/settings_spec.rb
59
81
  - tasks/acceptance.rake
60
82
  - templates/locales/en.yml
61
83
  - vagrant-auto_network.gemspec
62
- - vagrant-spec.config.rb
84
+ - vagrant-spec.config.example.rb
63
85
  homepage: https://github.com/adrienthebo/vagrant-auto_network
64
86
  licenses:
65
87
  - Apache 2.0
@@ -1,40 +0,0 @@
1
- module AutoNetwork
2
- module ActionHelpers
3
-
4
- # Determine if the given machine exists and has an auto_network address
5
- #
6
- # @param [Vagrant::Machine]
7
- #
8
- # @return [true, false]
9
- def machine_has_address?(machine)
10
- !!(machine and AutoNetwork.pool_manager.address_for(machine))
11
- end
12
-
13
- # Fetch all private networks that are tagged for auto networking
14
- #
15
- # @param iface [Array<Symbol, Hash>]
16
- #
17
- # @return [Array<Symbol, Hash>] All auto_networks
18
- def machine_auto_networks(machine)
19
- machine.config.vm.networks.select do |(net_type, options)|
20
- net_type == :private_network and options[:auto_network]
21
- end
22
- end
23
-
24
- # Convert an auto network to a private network with a static IP address.
25
- #
26
- # This does an in-place modification of the private_network options hash
27
- # to strip out the auto_network configuration and make this behave like a
28
- # normal private network interface with a static IP address.
29
- #
30
- # @param iface [Array<Symbol, Hash>]
31
- # @param addr [String] The static IP address to assign to the private network
32
- #
33
- # @return [void]
34
- def filter_private_network(iface, addr)
35
- opts = iface[1]
36
- opts.delete(:auto_network)
37
- opts[:ip] = addr
38
- end
39
- end
40
- end