Commit Graph

1983 Commits

Author SHA1 Message Date
Mitchell Hashimoto e20326d577 Added the Confirm built-in middleware
This middleware asks the user a question and expects a Y/N answer. This
middleware can be used with the Call middleware.
2012-07-27 19:16:44 -07:00
Mitchell Hashimoto 556a53d48d You can no longer set env vars on Builders via `use` 2012-07-27 19:05:35 -07:00
Mitchell Hashimoto 90517a0f9b The `Call` built-in middleware allows for conditional MW sequences.
Read the documentation for more information.
2012-07-26 23:56:47 -07:00
Mitchell Hashimoto 5eed3b8417 Building up the `destroy` action again using new provider API.
This shows me moving the built-in middleware sequences to the provider
and how I'm organizing all that.
2012-07-26 22:39:27 -07:00
Mitchell Hashimoto 5f8a654393 Goodbye, instance_eval on Vagrant::Action::Builder! 2012-07-26 22:00:25 -07:00
Mitchell Hashimoto 2ef20586da Remove the action registry feature.
This can be removed since in the future all actions will come from the
providers or something. There are still issues with box actions but
we'll get back to that later...
2012-07-26 21:57:11 -07:00
Mitchell Hashimoto 44b4b9dfef Move drivers to the VirtualBox plugin. Use Machine class.
This starts the transition of replacing VM with Machine. Machine still
isn't ready to fully replace VM but by moving it now, I'm able to find
the spots that need to be fixed. At this point `vagrant status` works
with the new provider interface.
2012-07-24 21:32:38 -07:00
Mitchell Hashimoto 912998ef31 Fill in the provider API a bit more to what it is. 2012-07-16 15:24:51 -07:00
Mitchell Hashimoto aef2c5f48e Logging statements to Vagrant::Machine 2012-07-16 14:21:51 -07:00
Mitchell Hashimoto 8f0375d7f3 Machines can call actions on their providers. 2012-07-16 14:12:58 -07:00
Mitchell Hashimoto 8fc5591b8e Machine queries state from the provider 2012-07-16 10:57:17 -07:00
Mitchell Hashimoto 353610021c Vagrant::Machine
This is the class that will represent a machine that is managed by
Vagrant. The class has a number of attributes associated with it and is
meant to be a single API for managing the machines.
2012-07-16 10:28:42 -07:00
Mitchell Hashimoto 3519bf0372 Add the "provider" API to the V1 plugin. 2012-07-15 11:17:58 -07:00
Mitchell Hashimoto 436da57cc4 Add the #action API to the provider plugin 2012-07-14 17:04:06 -07:00
Mitchell Hashimoto 3b82f2efc4 Create the basic provider plugin interface.
Non-functional at this point.
2012-07-14 16:57:54 -07:00
Mark LaPerriere 28e19d5449 Update load_plugins to be more Windows friendly. Uses File::PATH_SEPARATOR instead of hard-coded colon (':'). 2012-07-12 15:25:28 -03:00
Mitchell Hashimoto 690d380b77 Use the new BoxCollection API 2012-07-11 18:41:13 -07:00
Mitchell Hashimoto f20666e230 Automatically upgrade the boxes all over. 2012-07-11 18:36:23 -07:00
Mitchell Hashimoto bcd1304ef4 Remove unused middleware sequences related to repackaging 2012-07-11 18:36:23 -07:00
Mitchell Hashimoto cc076e5ee5 Box#repackage to repackage a box. 2012-07-11 18:36:22 -07:00
Mitchell Hashimoto 798ffc93bd BoxCollection#add throws an UpgradeRequired exception if a V1 box
already exists
2012-07-11 18:36:22 -07:00
Mitchell Hashimoto 1d197d84c3 BoxCollection#add transparently upgrades V1 boxes to V2
This means that V1 boxes can be added to a V2 box collection without
issue.
2012-07-11 18:36:22 -07:00
Mitchell Hashimoto 8026715619 Remove the box_remove builtin middleware sequence. 2012-07-11 18:36:22 -07:00
Mitchell Hashimoto 6bb621026f `vagrant box add` uses the new API.
This assumes VirtualBox boxes for now, which is fine.
2012-07-11 18:36:22 -07:00
Mitchell Hashimoto 623ecb3e3d Environment attempts to upgrade box on config load.
If a V1 box is encountered when Vagrant loads the configuration, then it
will be upgraded on the fly.
2012-07-11 18:36:22 -07:00
Mitchell Hashimoto 7595f0078e BoxCollection#add provider argument is optional
In the case that not provider is given then whatever provider the box
represents will be added to the system. Ideally, a provider will be
given, but if not, Vagrant still does a "best effort" to install the
box.
2012-07-11 18:36:22 -07:00
Mitchell Hashimoto da15105a8f Make Box2 the new Box
This involved defaulting all box searching at the moment to VirtualBox.
Additionally, box upgrading is not yet handled. This needs to be done at
some point.
2012-07-11 18:36:21 -07:00
Mitchell Hashimoto e7bed7c2ff Raise an exception if an invalid tar file is added. 2012-07-11 18:36:21 -07:00
Mitchell Hashimoto a35f6a175d Exception when you attempt to add a box when a V1 box conflicts. 2012-07-11 18:36:21 -07:00
Mitchell Hashimoto 9e33d16ca1 Adding a box that already exists should result in an exception. 2012-07-11 18:36:21 -07:00
Mitchell Hashimoto 9cb0015b6e Test that an added box provider must match expected. 2012-07-11 18:36:21 -07:00
Mitchell Hashimoto c2151681ec Box collection can add a new box. This is the happy path only. 2012-07-11 18:36:21 -07:00
Mitchell Hashimoto e647afc7d2 Add logging statements to the box upgrade process. 2012-07-11 18:36:21 -07:00
Mitchell Hashimoto ffd5ac5af4 BoxCollection can now upgrade V1 boxes to V2 2012-07-11 18:36:21 -07:00
Mitchell Hashimoto 2eaa850853 Box2 reads the metadata.json file. 2012-07-11 18:36:21 -07:00
Mitchell Hashimoto 4386ff9887 BoxCollection#all returns all boxes, including V1 boxes 2012-07-11 18:36:20 -07:00
Mitchell Hashimoto 9d1924811e Box collection can detect V1 boxes and throws an exception
The exception notifies the caller that the box needs to be upgraded. The
upgrade process is not yet done but is coming ina  future commit.
2012-07-11 18:36:20 -07:00
Mitchell Hashimoto a6d7bd48fd Find boxes with new on-disk structure.
The box collection can now find new-style boxes with providers and
return proper Box objects. In the future, we'll also have to implement
upgrading old style ones as well.
2012-07-11 18:36:20 -07:00
Mitchell Hashimoto 42826356ad Basic "Box2" implementation.
This is the beginning of the new box internals. The basic idea is that
the new box has a new field: provider. The provider will describe what
provider that box was built with and what provider it is made to work
with.
2012-07-11 18:36:20 -07:00
Mitchell Hashimoto a34801588c Handle the case where ctrl-D is pressed on input. 2012-07-11 18:30:37 -07:00
Mitchell Hashimoto 61621369d2 Catch Net::SSH::Disconnect when connecting to SSH
This error was experienced by @pearkes. It is thrown when the remote end
unexpectedly closes the remote end. This is usually caused by SSH not
being able to properly setup the connection.
2012-07-04 08:26:09 -10:00
Mitchell Hashimoto ef265ab3ba Disable read timeout for HTTP downloader 2012-06-28 21:28:40 -07:00
Mitchell Hashimoto 5bc0fa1dff Default the IO.select result to empty array to avoid nil errors 2012-06-28 08:22:06 -07:00
Mitchell Hashimoto 0b9173efd9 Handle case that `writers` is nil on IO.select in subprocess
This can happen when IO.select timeout is reached when we're listening
for writers.
2012-06-27 13:54:05 -07:00
Mitchell Hashimoto 0b3e703498 Add the gateway to hostonly network interfaces on Debian [GH-990] 2012-06-27 11:18:23 -07:00
Mitchell Hashimoto 134e56db21 Reference proper constant ALL_ACTIONS 2012-06-27 11:16:04 -07:00
Mitchell Hashimoto 70bdd9f56e Move host base class to a plugin component 2012-06-27 09:26:03 -07:00
Mitchell Hashimoto 214b29888a Remove the old guest base 2012-06-26 16:29:53 -07:00
Mitchell Hashimoto 53d8c28c8e Move guests to Vagrant.plugin("1", :guest) 2012-06-26 16:28:49 -07:00
Mitchell Hashimoto b23dda54b8 Move command base class to a plugin component 2012-06-26 16:18:02 -07:00
Mitchell Hashimoto 7258daf535 Support specifying a component for Vagrant.plugin
The future of subclassing things like configuration bases and so on will
be to use `Vagrant.plugin(version, component)`. For example:
`Vagrant.plugin("1", :provisioner)`.
2012-06-26 15:47:26 -07:00
Mitchell Hashimoto 2e00a007ce Move provisioner superclass into the V1 namespace 2012-06-26 15:06:04 -07:00
Mitchell Hashimoto 798704c6d2 Move the loader into the Config::V1 namespace. 2012-06-26 15:06:03 -07:00
Mitchell Hashimoto 41bc8e7454 Move Config::V1::Base to Vagrant::Plugin::V1::Config 2012-06-24 17:06:11 -07:00
Mitchell Hashimoto ffab8cab68 Renamespace V1 plugin root to Vagrant::Plugin::V1::Plugin
This is mostly a transparent change to end users, but I'm going to put
all base classes for V1 into Vagrant::Plugin::V1.
2012-06-24 14:24:52 -07:00
Mitchell Hashimoto 6231bef3f0 Simple logging text change 2012-06-23 23:40:55 -07:00
Mitchell Hashimoto 7a299ae2de Configuration loader can handle upgrading.
The basic process for this is to:

1. Load the configuration using the proper loader for that version. i.e.
   if you're loading V1 config, then use the V1 loader.
2. If we just loaded a version that isn't current (imagine we're
   currently at V3), then we need to upgrade that config. So we first
   ask the V2 loader to upgrade the V1 config to V2, then we ask the V3
   loader to upgrade the V2 config to V3. We keep track of warnings and
   errors throughout this process.
3. Finally, we have a current config, so we merge it into the in-process
   configuration that is being loaded.
2012-06-23 19:56:31 -07:00
Mitchell Hashimoto 9bc1ea5f04 Use config finalize to move some version-specific logic to the version
This moves out the concept of a "default VM" from the Environment class
and makes it the responsibility of the V1 configuration that at least
one VM is defined on it. This lets the configuration ultimately decide
what a "default" implementation is.
2012-06-23 12:48:53 -07:00
Mitchell Hashimoto 70fb804128 Configuration versions can finalize config after loading
This is useful so that it can take a look at the final loaded
configuration object and possibly make some tweaks to the configuration
object. The use case this was built for was so that config V1 can verify
that there is always at least a single VM defined as a sub-VM, the
"default" VM.
2012-06-23 12:27:32 -07:00
Mitchell Hashimoto 7e19d6849b Config loader no longer assumes latest version for procs.
Previously, all procs were assumed to just be the current version. This
is certainly not going to be true always so now the version number of
the configuration must be explicit if you're assigning a proc to the
configuration loader.
2012-06-23 12:06:54 -07:00
Mitchell Hashimoto b3db82e516 Separate out the versions the config loader knows as init params.
This means that the Config::Loader now only knows how to load
configuration for versions used to initialize the class. This lets
things like the tests be completely isolated from what the actual
configuration is for Vagrant. This will be immensely useful to verify
that the loader functionality works for non-trivial bits (like
upgrading) without depending on Vagrant's upgrading functionality.
2012-06-23 11:33:53 -07:00
Mitchell Hashimoto a677c15e86 Use `next` instead of `return` for 1.8.x compatibility.
Since we're not calling this lambda from inside a method, the `return`
causes a LocalJumpError on 1.8.x. It appears this functionality works
fine on 1.9.x but we'd like to support both. The correct behavior
appears to use `next`.
2012-06-23 10:47:01 -07:00
Mitchell Hashimoto ba64c28304 Convert the path to a string because it may be a Pathname 2012-06-22 21:06:49 -07:00
Mitchell Hashimoto fa99eb7e54 Check for permission denied when using SCP to upload [GH-924] 2012-06-22 21:04:21 -07:00
Mitchell Hashimoto d8c16035c8 Don't use Pathname#each_child for 1.8.7 compat [GH-979]
each_child is a 1.9.x feature. The implementation however is simple
enough that I copied it over and just use the 1.8.7 compatible version.
2012-06-22 20:47:43 -07:00
Mitchell Hashimoto 51be92eeb6 Remove dependence on V1 Kernel from Environment 2012-06-14 18:46:48 -07:00
Paul Morton 922a5aade5 Update drivers to support reading MAC Addresses 2012-06-11 21:29:21 -07:00
Matt Robenolt db76b42ef5 Allow the .vagrant dotfile to be moved into a completely different directory tree
I wanted to define my dotfile as: `config.vagrant.dotfile_name =
"~/.vagrant-projectname"` and noticed that the full path wasn't
expanded as expected.

This patch allows the vagrant file to be placed anywhere on the
filesystem.
2012-06-09 22:56:54 -07:00
mxtthias 447d6810f7 Explicitly tell ssh server we're done sending data 2012-06-08 14:40:49 +02:00
Mitchell Hashimoto b393de052f Subprocess now only yields stdout/stderr if you're listening 2012-06-01 23:17:48 +02:00
Mitchell Hashimoto 2441961a34 Fix bug where SSH didn't work properly
Forgot to set the `shell` variable properly
2012-06-01 23:17:38 +02:00
Mitchell Hashimoto 1a6ae81aa9 Require what to be notified for with block and Subprocess.execute
There was an issue before where the stdin buffer would always have space
so it would always yield that block and Ruby would spin at 100%. Now we
require all callers to say what they want to listen for. This drops
CPU down to almost nothing.

See GH-832
2012-06-01 17:02:12 +02:00
Mitchell Hashimoto 903fd3acdc Easy operations API `local` now echoes stdout/stderr 2012-06-01 16:38:40 +02:00
Mitchell Hashimoto ca6d49bc94 Easy operations `run` and `sudo` now echo stdout/stderr 2012-06-01 16:33:41 +02:00
Mitchell Hashimoto f133f39bcc Add comment to explain unclear code 2012-06-01 16:08:41 +02:00
Mitchell Hashimoto fd9ad904fe Easy commands now take a target VM name
It is assumed to be the first arg, as long as the first arg doesn't
begin as a flag "-foo"
2012-06-01 15:59:05 +02:00
Mitchell Hashimoto 83917a6bb0 Added `arg` and `arg_extra` API to easy commands
Easy commands can now easily get arguments from the command line.

Using `arg`, you can get named arguments on the command line, such as
"--foo" or "-f"

With `arg_extra`, you can get any remaining arguments after a "--"
on the command line, which is a common pattern used to grab longer
parameters.
2012-06-01 15:57:55 +02:00
Mitchell Hashimoto 100e1f7eb0 Primary VMs are respected again.
At some point in the past, primary VMs were no longer respected for
commands. This fixes taht.
2012-06-01 15:10:26 +02:00
Mitchell Hashimoto 9cb53860c2 New easy command APIs: argv, info, error, success
Some new APIs were added to the easy command operations. `info`,
`error`, and `success` are simple ways to output messages to the UI
without resorting to "puts" in Ruby, since the Vagrant UI object is the
idiomatic way to do communication with the world.

Additionally, `argv` was added which gives commands access to the
command-line arguments that are remaining that does not include the
vagrant binary or subcommand.

Also, behavior was changed: Previously, easy commands would run for
every target VM. Now, it is only run once with the primary VM. In the
next commit, I plan on adding a new flag that signifies an easy command
is meant to work with a named VM.
2012-06-01 14:55:08 +02:00
Mitchell Hashimoto 1ef679f683 SSH log level fatal. Thanks @petejkim
This change makes it so that SSH errors are shown, whereas QUIET hid
those as well. The main change to QUIET was to get rid of warnings,
not errors, so this fixes that.
2012-05-31 23:42:28 +02:00
Zsolt Takács cac79cf409 preserve attributes on packaging when using ruby 1.9.2
see http://bugs.ruby-lang.org/issues/4507
2012-05-26 16:51:18 -07:00
Matt Callaway 117a9c146a On Linux where IPv6 is disabled, where /etc/hosts has '::1 localhost', a socket connect to localhost 2222 results in ENETUNREACH which needs to be caught as per this patch. 2012-05-25 15:45:18 -05:00
Mitchell Hashimoto d5a7ca6159 config.ssh.shell now contains full shell command
Before, it only contained the shell executable and "-l" was magically
appended to it. However, every shell doesn't support "-l" and maybe "-l"
isn't even the behavior that users want!

Therefore, the config.ssh.shell command must now contain the full
command to execute.
2012-05-23 15:30:16 -07:00
Mitchell Hashimoto de78a3637a Plugin activation
Vagrant is only guaranteeing that the plugin definition superclass (the
Vagrant.plugin("1") part) is backwards compatible. Anything else, such
as Vagrant::Command::Base and so on, will likely change in future
versions. Beacuse of this, plugins should only immediately expose their
definition.

In order to support loading the other classes, plugins should defer
loading to the "activation" phase of a plugin. This can be done using
the `activated` block:

    class MyPlugin < Vagrant.plugin("1")
      name "my plugin"

      activated do
        require "myplugin/my_command"
      end

      command("foo") { MyCommand }
    end

Plugin activation is done at two specific times:

  * Right when a Vagrant::Environment is created and the global plugins
    (such as from ~.vagrantrc) are loaded.
  * Right before loading configuration, but after the Vagrantfiles have
    been evaluated. This allows plugins to be defined within these files
    as well.
2012-05-21 22:23:50 -07:00
Mitchell Hashimoto 3204b3a580 Vagrant.configure and versioned configuration
Vagrant.configure is now how configuration is done in Vagrantfiles
(previously it was Vagrant::Config.run). This function takes a single
argument which is the version of configuration to use.

Various internals were updated for this new versioned configuration.

Note that multiple versions of configuration aren't yet used so aren't
fully supported by Vagrant, but the foundation is being set here.
2012-05-21 21:47:01 -07:00
Mitchell Hashimoto 95e554314e Foundation for supporting multiple version types
I created VersionBase which is the abstract base class for any
configuration versions. Configuration versions are responsible for
knowing how to load configuration given a proc (from a
Vagrant.configure block), as well as merging configuration procs. In the
future, it will have to upgrade versions as well. This is not done yet.

The VERSIONS constant was added to Vagrant::Config which is a registry
to keep track of all the available configuration versions. The
VERSIONS_ORDER constant is an array of the ordering of these versions.
The ordering is important so that in the future Vagrant can attempt to
gracefully upgrade the configurations. It is also used to determine the
current configuration version (which is assumed to be the last version
in the order).

The loader was modified to use the current version and the VERSIONS
registry instead of hardcoding V1.
2012-05-20 17:47:24 -07:00
Mitchell Hashimoto 0f85cb7b74 Log the guest class chosen 2012-05-19 09:32:43 -07:00
Josh Mahowald 174df1edf0 Setting up hostname before setting up the network to minimize issues as described in http://serverfault.com/questions/38114/why-does-sudo-command-take-long-to-execute 2012-05-19 09:17:44 -07:00
Mitchell Hashimoto 73c8299ecd Merge pull request #868 from justinlynn/add_dhcp_default_route_option
Issue #862: Allow bridged networking without removing the interface's DHCP assigned default route
2012-05-06 14:46:58 -07:00
Mitchell Hashimoto 8c6f3edf2d Single-VM mode still allows target name in vagrant commands 2012-05-06 14:33:47 -07:00
Mitchell Hashimoto bc0643613a Vagrant.require_plugin [GH-916] 2012-05-06 14:01:10 -07:00
Mitchell Hashimoto d230f0a41c Environment.rb doesn't need to load in "rubygems" anymore 2012-05-06 13:49:22 -07:00
Mitchell Hashimoto de92f5217c Use `load` for the Vagrantrc, make sure it is only loaded once 2012-05-06 10:09:33 -07:00
Mitchell Hashimoto 0d6248394c Tests for the Easy command base 2012-05-06 10:01:50 -07:00
Mitchell Hashimoto dc4f6e1939 Allow creating multiple easy commands 2012-05-06 09:54:23 -07:00
Ryan LeCompte 2355a4b9a6 fix support for multiple unique easy commands 2012-05-06 01:47:43 -07:00
Mitchell Hashimoto b7854c1ef6 Easy hooks 2012-05-05 22:31:21 -07:00
Mitchell Hashimoto 31ac7271aa Rename EasyCommand namespace to Easy 2012-05-05 22:16:13 -07:00
Mitchell Hashimoto 3d147f1d96 Raise exception if the insert_before middleware is not found 2012-05-05 22:10:26 -07:00
Mitchell Hashimoto 879f98b5d5 Action builder supports indexing middlewares by name 2012-05-05 22:01:53 -07:00