Commit Graph

2842 Commits

Author SHA1 Message Date
Mitchell Hashimoto f1f4f276a0 Set the virtualbox config scope 2013-01-13 12:38:51 -08:00
Mitchell Hashimoto e66c5066e4 Plugin configuration can have scopes now, ex. provider 2013-01-13 12:38:17 -08:00
Mitchell Hashimoto 965427c540 Properly upgrade V1 hostonly/bridged networks to V2 config 2013-01-13 01:07:55 -08:00
Mitchell Hashimoto 212e634c3b Make Provision a built-in action.
This allows other providers to just use it.
2013-01-12 16:22:37 -08:00
Mitchell Hashimoto 22571bf05b Rescue the EHOSTDOWN error for SSH 2013-01-12 12:47:49 -08:00
Mitchell Hashimoto 0fd5152db4 Don't explicitly set the host to 127.0.0.1
Other providers may not have this requirement
2013-01-12 12:25:20 -08:00
Mitchell Hashimoto 124a2ee5d3 Add the --provider optional flag to `box add` 2013-01-11 21:24:57 -08:00
Mitchell Hashimoto 2d8a048946 Merge branch 'abstract-networks'
This introduces the new network configuration syntax for Vagrant 1.1
and forward.

== The Problem

With multiple providers, the concept of networking as it stands in Vagrant
1.0.x becomes really muddy. We have `config.vm.forward_port` and
`config.vm.network :hostonly` and `config.vm.network :bridged`. But what
if someone writes an AWS provider? What is a bridged network in AWS? It
just doesn't make sense.

Networking working out of the box with Vagrant is a core part of what
makes Vagrant "magic" to new users. It is a core part of what makes Vagrant
simple to use. One option to punt networking to provider-specific
configuration was considered, but I found the whole idea of networking
too core to Vagrant to simply punt.

Because of this, a whole new method of networking is introduced.

== The Solution

The solution is to have a high-level notion of networking for Vagrant
configuration. This should cover the most _common_ cases of networking, and
every provider should do their best to implement these high-level
abstractions, to ensure the "just works" nature of Vagrant.

In addition to this high-level networking, low-level networking options
should be exposed on the provider configuration. This allows users to do
advanced provider-specific networking configuration if they want, but aren't
required to.

== High-Level Abstractions

=== Available Types

The high-level abstractions built into Vagrant will be the following:

* Forwarded ports - A mapping of host port to guest port that one can hit
  using `localhost`.
* Private network - A private network, the machine should ideally be
  protected from public access.
* Public network - A public network, one that is easily accessible by
  others.

I'm not sure if these are the proper abstractions. They can change up
until 2.0, but these are what we have so far.

Theoretically, here is how mappings would work. Note that this is just
an example, and the mappings in practice of such providers may or
may not map to this as follows.

**VirtualBox**
* Forwarded ports - NAT network, forwared ports.
* Private network - Hostonly network, static IP assigned.
* Public network - Bridged network, IP assigned via DHCP from router.

**VMWare**
* Forwarded ports - NAT network, forwarded ports.
* Private network - Hostonly network, static IP assigned.
* Public network - Bridged network, IP assigned via DHCP from router.

**AWS**
* Forwarded ports - Unimplemented.
* Private network - Public DNS in EC2, private IP in VPC.
* Public network - Elastic IP in EC2 and VPC.

=== Syntax

Networks are configured at the top-level of a Vagrantfile:

```ruby
Vagrant.configure("2") do |config|
  # ...

  config.vm.network :forwarded_port, 80, 8080
  config.vm.network :private_network, "192.168.1.12"
  config.vm.network :public_network
end
```

Providers should do their best to honor these configurations.

=== Advanced Options

While providers should do their best to satisfy the requirements for the
high-level abstractions, it is expected that provider-specific configuration
may be possible per network, even for the high-level configurations. For
this, provider-prefixed configuration options should be done:

```ruby
config.vm.network :forwarded_port, 80, 8000,
  :vmware__device => "vmnet8"

config.vm.network :public_network,
  :aws__elastic_ip => "1.2.3.4",
  :vmware__device => "en0"
```

If at all possible, providers should **not** require advanced options for
these to function.

== Low-level Configuration

While the high-level configuration should satisfy the common case and make
Vagrant work out of the box for most providers, one of the large benefits of
many providers is the ability to do certain networking tricks. For example,
KVM, Hyper-V, vSphere, etc. can create and be a part of true VLANs, which
may be required for certain upstream networking rules/ACLs. For things like
this, the network configuration should go directly into the provider
configuration in some way.

Examples:

```ruby
config.vm.provider :virtualbox do |vb|
  vb.network_adapter 2, :hostonly
  vb.network_adapter 3, :nat
end

config.vm.provider :aws do |aws|
  aws.routing_table = "route-123456"
end
```

It is up to the provider implementation to define the configuration
syntax as well as the implementation details of such an option. Other
providers are unable to see provider configurations other than their own
so it is truly private to the provider.
2013-01-11 16:18:09 -08:00
Mitchell Hashimoto 48eaa93745 Raise proper error if there aren't any NIC slots available 2013-01-11 15:57:08 -08:00
Mitchell Hashimoto 7cd663391e Forwarded ports allow for scoped hash overrides 2013-01-11 15:52:45 -08:00
Mitchell Hashimoto 102e8f23d6 Use scoped hash overrides for high-level config 2013-01-11 15:50:09 -08:00
Mitchell Hashimoto 0c612f695f Util::ScopedHashOverride 2013-01-11 15:44:35 -08:00
Mitchell Hashimoto ccc4da0d32 Remove the old networking code 2013-01-11 15:23:20 -08:00
Mitchell Hashimoto 48995f6036 Support mac address and nic_type for host only networks 2013-01-11 15:22:55 -08:00
Mitchell Hashimoto d09dc91d1b Add support for bridged networks again 2013-01-11 15:21:09 -08:00
Mitchell Hashimoto 37e158c9b2 Configure networks on the VM 2013-01-11 15:06:38 -08:00
Mitchell Hashimoto da7f227fff Forwarded ports use the new high-level configuration 2013-01-11 14:51:49 -08:00
Mitchell Hashimoto 7e5f175d2c Check port collisions now uses the new high-level networking 2013-01-11 14:44:27 -08:00
Mitchell Hashimoto 2d8f9baf7f New Network VirtualBox middleware to handle the changes.
Note this is a WIP (hence committed on a branch)
2013-01-11 14:16:00 -08:00
Mitchell Hashimoto 8299ac38bd Rework v1 forward_port call to append forward port networks 2013-01-10 12:06:08 -08:00
Mitchell Hashimoto 09126b20d3 Merge pull request #1283 from eladroz/master
Fixing guest code for RH & SUSE
2013-01-06 17:38:09 -08:00
Mitchell Hashimoto f236ed1f61 Merge pull request #1297 from llonchj/master
fedora 17 & 18 support
2013-01-06 17:37:23 -08:00
Jordi Llonch 793ad58e96 fedora 17 & 18 support 2013-01-07 05:23:07 +11:00
Mitchell Hashimoto 7a9363e8a1 Fix ordering of forwarded_port call 2013-01-04 16:35:13 -10:00
Mitchell Hashimoto 559cf25b5f Temporarily disable Network action while it is broken 2013-01-04 16:25:20 -10:00
Mitchell Hashimoto 2d3c0b7148 VirtualBox forwarding port uses new `network` calls 2013-01-04 16:22:38 -10:00
Mitchell Hashimoto a2cf0270a3 Remove network validation on config. We'll re-add this later. 2013-01-04 16:13:02 -10:00
Mitchell Hashimoto 640b296f5a Explicitly set error handling for port collision on resume 2013-01-04 16:11:40 -10:00
Mitchell Hashimoto be36c702d6 Booting new VirtualBox VM should check for port collisions 2013-01-04 16:08:37 -10:00
Mitchell Hashimoto 5c950d8200 Remove old `forward_port` method for configuration. Use `network` 2013-01-04 15:48:54 -10:00
Mitchell Hashimoto a4896293ff Merge pull request #1260 from hdorio/master
Attempt to fix #1108, #1109, tcp and udp port on the same port number
2013-01-03 17:13:07 -08:00
Mitchell Hashimoto f44be14f67 Merge pull request #1293 from yarikoptic/master
DOC: keys/README.md -- fix urls to docs.
2013-01-03 17:04:05 -08:00
Yaroslav Halchenko 3a6ce6e196 DOC: keys/README.md -- fix urls to docs. 2013-01-03 11:32:39 -05:00
Elad Rosenheim 0915186b26 Fix guest plugin for RH & SUSE 2012-12-31 10:38:36 +02:00
Mitchell Hashimoto cf2c5a10c1 One more final fix for 1.8.7 2012-12-30 18:16:51 -10:00
Mitchell Hashimoto 037dbf24db Fix some failing tests for 1.8.7. 2012-12-30 18:13:27 -10:00
Mitchell Hashimoto f428b288f3 Convert provider to symbol only if non-nil 2012-12-30 18:08:07 -10:00
Mitchell Hashimoto 20253c4c4f Convert provider to symbol 2012-12-30 18:04:31 -10:00
Mitchell Hashimoto a30a92bb4f active_machines should return name as a symbol 2012-12-30 11:51:22 -10:00
Mitchell Hashimoto 4c46091746 Environment#primary_machine_name and use it for with_target_vms
This makes the single-provider and default provider semantics work with
primary VMs.
2012-12-30 11:12:56 -10:00
Mitchell Hashimoto 24c3c9a7ae Better test coverage on with_target_vms. Added pending tests to work on. 2012-12-30 10:59:59 -10:00
Mitchell Hashimoto 07157b47ae Only allow one provider active machine at a time.
Temporary limitation of Vagrant to only allow one active machine with a
provider at a time. That means you cant `up` a machine with both vmware
and virtualbox at the same time. In the future you will be able to but
to avoid various edge cases for now we're disallowing it.
2012-12-30 10:52:01 -10:00
Mitchell Hashimoto 526603dbbf Lots more logging in with_target_vms 2012-12-29 18:34:11 -10:00
Mitchell Hashimoto 9257fe3d98 Environment#active_machines
This returns a list of active machines for the environment. An active
machine is a machine that at one point was created by Vagrant.
2012-12-27 19:28:05 -10:00
Mitchell Hashimoto 4e649cc987 Upgrade V1-style dotfile to V2
See the code and comments for details on how this is done. As usual, we
are very careful about this so as not to inadvertently destruct real
user data.
2012-12-26 22:41:42 -08:00
Mitchell Hashimoto 495479f480 Merge branch 'new-data-tiers'
This branch changes how local data is stored for Vagrant environments
from a single "dotfile" approach to having a directory of data, more
similar in style to git.

When a V1-style dotfile is encountered, it is automatically upgraded
to the new style directory format.
2012-12-26 22:03:16 -08:00
Mitchell Hashimoto cd969e1e05 Remove the dotfile_name configuration option.
The dotfile is gone now so the configuration option is obselete
2012-12-26 21:45:24 -08:00
Mitchell Hashimoto c0c3e7bf43 Remove Vagrant::DataStore
We just don't use it yet and the old implementation was sketchy. I was
not happy with it.
2012-12-26 21:45:24 -08:00
Mitchell Hashimoto b15a6dee0e Log more information about the machine 2012-12-26 21:45:24 -08:00
Mitchell Hashimoto 3baa31460f Store machine ID in "id" file in data directory.
Instead of storing an "active" hash in the local_data of an Environment,
we now place the ID of a machine in the "id" file of the machine data
directory. This file is read upon re-instantiation in order to load the
proper state.
2012-12-26 21:45:23 -08:00