Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Find and install box file for multi-provider boxes automatically #86

Merged
merged 2 commits into from
Sep 3, 2014
Merged

Find and install box file for multi-provider boxes automatically #86

merged 2 commits into from
Sep 3, 2014

Conversation

mkuzmin
Copy link
Contributor

@mkuzmin mkuzmin commented Aug 26, 2014

That's a simple change with a quite long explanation.

I develop multi-provider boxes, and publish them on private Vagrant cloud server.
For that I need to put all vSphere connection settings into "dummy box" file, which is published on the server.
Actual Vagrantfiles inherit these settings, and do not set them explicitly.
The setup works fine, with one exception: on each new machine vagrant up fails with errors like Configuration must specify a vSphere host. This happens because dummy box files are not downloaded yet, and vSphere connections settings are nowhere defined. I have to explicitly use vagrant box add command to download the box file from the server.

This pull request fixes the whole issue. It forces Vagrant to check whether required box file for this particular provider is installed, and if not then downloads and installs it automatically.

@flamingbear
Copy link
Member

Hi there,

For such a small change it did a couple of things.

First, it broke the specs....

savoie@Matts-MacBook-Air-2 ~/Dropbox/projects/vagrant-vsphere (mkuzmin-install-box *)$ bundle exec rake spec
/Users/savoie/.rbenv/versions/2.0.0-p451/bin/ruby -I/Users/savoie/Dropbox/projects/vagrant-vsphere/vendor/bundle/ruby/2.0.0/gems/rspec-core-3.0.4/lib:/Users/savoie/Dropbox/projects/vagrant-vsphere/vendor/bundle/ruby/2.0.0/gems/rspec-support-3.0.4/lib -S /Users/savoie/Dropbox/projects/vagrant-vsphere/vendor/bundle/ruby/2.0.0/gems/rspec-core-3.0.4/exe/rspec ./spec/action_spec.rb ./spec/clone_spec.rb ./spec/connect_vsphere_spec.rb ./spec/destroy_spec.rb ./spec/get_ssh_info_spec.rb ./spec/get_state_spec.rb ./spec/is_created_spec.rb
FFFF................................

Failures:

  1) VagrantPlugins::VSphere::Action up should connect to vSphere
     Failure/Error: Vagrant::Action::Runner.new.run described_class.send("action_#{action}"), @env
       Double "config_vm" received unexpected message :box with (no args)
     # ./spec/action_spec.rb:6:in `run'
     # ./spec/action_spec.rb:15:in `run_up'
     # ./spec/action_spec.rb:21:in `block (3 levels) in <top (required)>'

  2) VagrantPlugins::VSphere::Action up should check if the VM exits
     Failure/Error: Vagrant::Action::Runner.new.run described_class.send("action_#{action}"), @env
       Double "config_vm" received unexpected message :box with (no args)
     # ./spec/action_spec.rb:6:in `run'
     # ./spec/action_spec.rb:15:in `run_up'
     # ./spec/action_spec.rb:27:in `block (3 levels) in <top (required)>'

  3) VagrantPlugins::VSphere::Action up should create the VM when the VM does already not exist
     Failure/Error: Vagrant::Action::Runner.new.run described_class.send("action_#{action}"), @env
       Double "config_vm" received unexpected message :box with (no args)
     # ./spec/action_spec.rb:6:in `run'
     # ./spec/action_spec.rb:15:in `run_up'
     # ./spec/action_spec.rb:35:in `block (3 levels) in <top (required)>'

  4) VagrantPlugins::VSphere::Action up should not create the VM when the VM already exists
     Failure/Error: Vagrant::Action::Runner.new.run described_class.send("action_#{action}"), @env
       Double "config_vm" received unexpected message :box with (no args)
     # ./spec/action_spec.rb:6:in `run'
     # ./spec/action_spec.rb:15:in `run_up'
     # ./spec/action_spec.rb:43:in `block (3 levels) in <top (required)>'

Finished in 0.49564 seconds (files took 0.76185 seconds to load)
36 examples, 4 failures

Failed examples:

rspec ./spec/action_spec.rb:18 # VagrantPlugins::VSphere::Action up should connect to vSphere
rspec ./spec/action_spec.rb:24 # VagrantPlugins::VSphere::Action up should check if the VM exits
rspec ./spec/action_spec.rb:30 # VagrantPlugins::VSphere::Action up should create the VM when the VM does already not exist
rspec ./spec/action_spec.rb:38 # VagrantPlugins::VSphere::Action up should not create the VM when the VM already exists
/Users/savoie/.rbenv/versions/2.0.0-p451/bin/ruby -I/Users/savoie/Dropbox/projects/vagrant-vsphere/vendor/bundle/ruby/2.0.0/gems/rspec-core-3.0.4/lib:/Users/savoie/Dropbox/projects/vagrant-vsphere/vendor/bundle/ruby/2.0.0/gems/rspec-support-3.0.4/lib -S /Users/savoie/Dropbox/projects/vagrant-vsphere/vendor/bundle/ruby/2.0.0/gems/rspec-core-3.0.4/exe/rspec ./spec/action_spec.rb ./spec/clone_spec.rb ./spec/connect_vsphere_spec.rb ./spec/destroy_spec.rb ./spec/get_ssh_info_spec.rb ./spec/get_state_spec.rb ./spec/is_created_spec.rb failed

But it also appears to have shown a mismatch somewhere in the boxen.

(manage-vsphere=)$ vagrant up dev --provider vsphere
Bringing machine 'dev' up with 'vsphere' provider...
==> dev: Running triggers before up...
==> dev: Box 'vsphere' could not be found. Attempting to find and install...
    dev: Box Provider: vsphere
    dev: Box Version: >= 0
==> dev: Adding box 'vsphere' (v0) for provider: vsphere
    dev: Downloading: file:///Users/savoie/Dropbox/projects/vagrant-nsidc/vsphere/vsphere.box
The box you attempted to add doesn't match the provider you specified.

Provider expected: vsphere
Provider of box: vSphere

Not sure what to do with this.

Sorry,
Matt

@mkuzmin
Copy link
Contributor Author

mkuzmin commented Aug 28, 2014

Sorry for the tests, I'm fixing them now.

Your second issue must be caused by upper-case "vSphere" word specified
somewhere within your box settings, probably in metadata.json. Vagrant is
case sensitive, and doesn't accept the value. Could you recheck that?

On Wednesday, August 27, 2014, Matt Savoie [email protected] wrote:

Hi there,

For such a small change it did a couple of things.

First, it broke the specs....

savoie@Matts-MacBook-Air-2 ~/Dropbox/projects/vagrant-vsphere (mkuzmin-install-box *)$ bundle exec rake spec
/Users/savoie/.rbenv/versions/2.0.0-p451/bin/ruby -I/Users/savoie/Dropbox/projects/vagrant-vsphere/vendor/bundle/ruby/2.0.0/gems/rspec-core-3.0.4/lib:/Users/savoie/Dropbox/projects/vagrant-vsphere/vendor/bundle/ruby/2.0.0/gems/rspec-support-3.0.4/lib -S /Users/savoie/Dropbox/projects/vagrant-vsphere/vendor/bundle/ruby/2.0.0/gems/rspec-core-3.0.4/exe/rspec ./spec/action_spec.rb ./spec/clone_spec.rb ./spec/connect_vsphere_spec.rb ./spec/destroy_spec.rb ./spec/get_ssh_info_spec.rb ./spec/get_state_spec.rb ./spec/is_created_spec.rb
FFFF................................

Failures:

  1. VagrantPlugins::VSphere::Action up should connect to vSphere
    Failure/Error: Vagrant::Action::Runner.new.run described_class.send("action_#{action}"), @env
    Double "config_vm" received unexpected message :box with (no args)

    ./spec/action_spec.rb:6:in `run'

    ./spec/action_spec.rb:15:in`run_up'

    ./spec/action_spec.rb:21:in `block (3 levels) in <top (required)>'

  2. VagrantPlugins::VSphere::Action up should check if the VM exits
    Failure/Error: Vagrant::Action::Runner.new.run described_class.send("action_#{action}"), @env
    Double "config_vm" received unexpected message :box with (no args)

    ./spec/action_spec.rb:6:in `run'

    ./spec/action_spec.rb:15:in`run_up'

    ./spec/action_spec.rb:27:in `block (3 levels) in <top (required)>'

  3. VagrantPlugins::VSphere::Action up should create the VM when the VM does already not exist
    Failure/Error: Vagrant::Action::Runner.new.run described_class.send("action_#{action}"), @env
    Double "config_vm" received unexpected message :box with (no args)

    ./spec/action_spec.rb:6:in `run'

    ./spec/action_spec.rb:15:in`run_up'

    ./spec/action_spec.rb:35:in `block (3 levels) in <top (required)>'

  4. VagrantPlugins::VSphere::Action up should not create the VM when the VM already exists
    Failure/Error: Vagrant::Action::Runner.new.run described_class.send("action_#{action}"), @env
    Double "config_vm" received unexpected message :box with (no args)

    ./spec/action_spec.rb:6:in `run'

    ./spec/action_spec.rb:15:in`run_up'

    ./spec/action_spec.rb:43:in `block (3 levels) in <top (required)>'

Finished in 0.49564 seconds (files took 0.76185 seconds to load)
36 examples, 4 failures

Failed examples:

rspec ./spec/action_spec.rb:18 # VagrantPlugins::VSphere::Action up should connect to vSphere
rspec ./spec/action_spec.rb:24 # VagrantPlugins::VSphere::Action up should check if the VM exits
rspec ./spec/action_spec.rb:30 # VagrantPlugins::VSphere::Action up should create the VM when the VM does already not exist
rspec ./spec/action_spec.rb:38 # VagrantPlugins::VSphere::Action up should not create the VM when the VM already exists
/Users/savoie/.rbenv/versions/2.0.0-p451/bin/ruby -I/Users/savoie/Dropbox/projects/vagrant-vsphere/vendor/bundle/ruby/2.0.0/gems/rspec-core-3.0.4/lib:/Users/savoie/Dropbox/projects/vagrant-vsphere/vendor/bundle/ruby/2.0.0/gems/rspec-support-3.0.4/lib -S /Users/savoie/Dropbox/projects/vagrant-vsphere/vendor/bundle/ruby/2.0.0/gems/rspec-core-3.0.4/exe/rspec ./spec/action_spec.rb ./spec/clone_spec.rb ./spec/connect_vsphere_spec.rb ./spec/destroy_spec.rb ./spec/get_ssh_info_spec.rb ./spec/get_state_spec.rb ./spec/is_created_spec.rb failed

But it also appears to have shown a mismatch somewhere in the boxen.

(manage-vsphere=)$ vagrant up dev --provider vsphere
Bringing machine 'dev' up with 'vsphere' provider...
==> dev: Running triggers before up...
==> dev: Box 'vsphere' could not be found. Attempting to find and install...
dev: Box Provider: vsphere
dev: Box Version: >= 0
==> dev: Adding box 'vsphere' (v0) for provider: vsphere
dev: Downloading: file:///Users/savoie/Dropbox/projects/vagrant-nsidc/vsphere/vsphere.box
The box you attempted to add doesn't match the provider you specified.

Provider expected: vsphere
Provider of box: vSphere

Not sure what to do with this.

Sorry,
Matt


Reply to this email directly or view it on GitHub
#86 (comment).

@flamingbear
Copy link
Member

So I don't have access to the vsphere hypervisor, but only the code in this project. There is a vsphere.box file, but it's a binary file of some sort. Can you give me something to take to the Admins? Sorry for my ignorace on that side of the house, it certainly makes this hard for me to maintain.

(also, this may end up waiting until next week as I'll be on vacation til Tuesday)

Thanks
Matt

@mkuzmin
Copy link
Contributor Author

mkuzmin commented Aug 28, 2014

What ignorance are you talking about? I have replies the same day, and a new release after each accepted pull request. Thank you!

vsphere.box file needs to be be re-packed with a change from #87 as explained in https://github.com/nsidc/vagrant-vsphere#usage. This should fix the second issue.

@mkuzmin
Copy link
Contributor Author

mkuzmin commented Aug 28, 2014

Here you are.
The tests were not ready to store data from HandleBox action.
I have fixed it now.

@flamingbear
Copy link
Member

I'm following up with my box provider now. I'll let you know what I hear

@flamingbear flamingbear merged commit 89e85ea into nsidc:master Sep 3, 2014
@mkuzmin mkuzmin deleted the install-box branch September 9, 2014 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants