-
Notifications
You must be signed in to change notification settings - Fork 328
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
(QENG-1146) Add vagrant_fusion, vagrant_workstation and vagrant_virtualbox providers #271
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
require 'beaker/hypervisor/vagrant' | ||
|
||
class Beaker::VagrantFusion < Beaker::Vagrant | ||
def provision(provider = 'vmware_fusion') | ||
# By default vmware_fusion creates a .vagrant directory relative to the | ||
# Vagrantfile path. That means beaker tries to scp the VM to itself unless | ||
# we move the VM files elsewhere. | ||
ENV['VAGRANT_VMWARE_CLONE_DIRECTORY'] = '~/.vagrant/vmware_fusion' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is that path in a variable anyway? Not a big fan of hard coding it here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is not. This is the published method of modifying the behavior of the vmware_fusion vagrant plugin as per http://docs.vagrantup.com/v2/vmware/configuration.html There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The virtualbox vagrant provider already puts its VMs in |
||
super | ||
end | ||
|
||
def self.provider_vfile_section(host, options) | ||
" v.vm.provider :vmware_fusion do |v|\n" + | ||
" v.vmx['memsize'] = '#{options['vagrant_memsize'] ||= '1024'}'\n" + | ||
" end\n" | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
require 'beaker/hypervisor/vagrant' | ||
|
||
class Beaker::VagrantVirtualbox < Beaker::Vagrant | ||
def provision(provider = 'virtualbox') | ||
super | ||
end | ||
|
||
def self.provider_vfile_section(host, options) | ||
provider_section = "" | ||
provider_section << " v.vm.provider :virtualbox do |vb|\n" | ||
provider_section << " vb.customize ['modifyvm', :id, '--memory', '#{options['vagrant_memsize'] ||= '1024'}']\n" | ||
if host['disk_path'] | ||
unless File.exist?(host['disk_path']) | ||
host['disk_path'] = File.join(host['disk_path'], "#{host.name}.vmdk") | ||
provider_section << " vb.customize ['createhd', '--filename', '#{host['disk_path']}', '--size', #{host['disk_size'] ||= 5 * 1024}, '--format', 'vmdk']\n" | ||
end | ||
provider_section << " vb.customize ['storageattach', :id, '--storagectl', 'SATA Controller', '--port', 1, '--device', 0, '--type', 'hdd', '--medium','#{host['disk_path']}']\n" | ||
provider_section << " vb.customize [\"modifyvm\", :id, \"--natdnshostresolver1\", \"#{host['natdns']}\"]\n" unless host['natdns'].nil? | ||
provider_section << " vb.customize [\"modifyvm\", :id, \"--natdnsproxy1\", \"#{host['natdns']}\"]\n" unless host['natdns'].nil? | ||
provider_section << " end\n" | ||
end | ||
provider_section << " end\n" | ||
|
||
provider_section | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
require 'beaker/hypervisor/vagrant' | ||
|
||
class Beaker::VagrantWorkstation < Beaker::Vagrant | ||
def provision(provider = 'vmware_workstation') | ||
super | ||
end | ||
|
||
def self.provider_vfile_section(host, options) | ||
" v.vm.provider :vmware_workstation do |v|\n" + | ||
" v.vmx['memsize'] = '#{options['vagrant_memsize'] ||= '1024'}'\n" + | ||
" end\n" | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
require 'spec_helper' | ||
|
||
describe Beaker::VagrantFusion do | ||
let( :options ) { make_opts.merge({ :hosts_file => 'sample.cfg', 'logger' => double().as_null_object }) } | ||
let( :vagrant ) { Beaker::VagrantFusion.new( @hosts, options ) } | ||
|
||
before :each do | ||
@hosts = make_hosts() | ||
end | ||
|
||
it "uses the vmware_fusion provider for provisioning" do | ||
@hosts.each do |host| | ||
host_prev_name = host['user'] | ||
vagrant.should_receive( :set_ssh_config ).with( host, 'vagrant' ).once | ||
vagrant.should_receive( :copy_ssh_to_root ).with( host, options ).once | ||
vagrant.should_receive( :set_ssh_config ).with( host, host_prev_name ).once | ||
end | ||
vagrant.should_receive( :hack_etc_hosts ).with( @hosts, options ).once | ||
FakeFS.activate! | ||
vagrant.should_receive( :vagrant_cmd ).with( "up --provider vmware_fusion" ).once | ||
vagrant.provision | ||
end | ||
|
||
it "can make a Vagranfile for a set of hosts" do | ||
FakeFS.activate! | ||
path = vagrant.instance_variable_get( :@vagrant_path ) | ||
vagrant.stub( :randmac ).and_return( "0123456789" ) | ||
|
||
vagrant.make_vfile( @hosts ) | ||
|
||
vagrantfile = File.read( File.expand_path( File.join( path, "Vagrantfile"))) | ||
expect( vagrantfile ).to include( %Q{ v.vm.provider :vmware_fusion do |v|\n v.vmx['memsize'] = '1024'\n end}) | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
require 'spec_helper' | ||
|
||
describe Beaker::VagrantVirtualbox do | ||
let( :options ) { make_opts.merge({ :hosts_file => 'sample.cfg', 'logger' => double().as_null_object }) } | ||
let( :vagrant ) { Beaker::VagrantVirtualbox.new( @hosts, options ) } | ||
|
||
before :each do | ||
@hosts = make_hosts() | ||
end | ||
|
||
it "uses the virtualbox provider for provisioning" do | ||
@hosts.each do |host| | ||
host_prev_name = host['user'] | ||
vagrant.should_receive( :set_ssh_config ).with( host, 'vagrant' ).once | ||
vagrant.should_receive( :copy_ssh_to_root ).with( host, options ).once | ||
vagrant.should_receive( :set_ssh_config ).with( host, host_prev_name ).once | ||
end | ||
vagrant.should_receive( :hack_etc_hosts ).with( @hosts, options ).once | ||
FakeFS.activate! | ||
vagrant.should_receive( :vagrant_cmd ).with( "up --provider virtualbox" ).once | ||
vagrant.provision | ||
end | ||
|
||
it "can make a Vagranfile for a set of hosts" do | ||
FakeFS.activate! | ||
path = vagrant.instance_variable_get( :@vagrant_path ) | ||
vagrant.stub( :randmac ).and_return( "0123456789" ) | ||
|
||
vagrant.make_vfile( @hosts ) | ||
|
||
vagrantfile = File.read( File.expand_path( File.join( path, 'Vagrantfile' ))) | ||
expect( vagrantfile ).to include( %Q{ v.vm.provider :virtualbox do |vb|\n vb.customize ['modifyvm', :id, '--memory', '1024']\n end}) | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
require 'spec_helper' | ||
|
||
describe Beaker::VagrantWorkstation do | ||
let( :options ) { make_opts.merge({ :hosts_file => 'sample.cfg', 'logger' => double().as_null_object }) } | ||
let( :vagrant ) { Beaker::VagrantWorkstation.new( @hosts, options ) } | ||
|
||
before :each do | ||
@hosts = make_hosts() | ||
end | ||
|
||
it "uses the vmware_workstation provider for provisioning" do | ||
@hosts.each do |host| | ||
host_prev_name = host['user'] | ||
vagrant.should_receive( :set_ssh_config ).with( host, 'vagrant' ).once | ||
vagrant.should_receive( :copy_ssh_to_root ).with( host, options ).once | ||
vagrant.should_receive( :set_ssh_config ).with( host, host_prev_name ).once | ||
end | ||
vagrant.should_receive( :hack_etc_hosts ).with( @hosts, options ).once | ||
FakeFS.activate! | ||
vagrant.should_receive( :vagrant_cmd ).with( "up --provider vmware_workstation" ).once | ||
vagrant.provision | ||
end | ||
|
||
it "can make a Vagranfile for a set of hosts" do | ||
FakeFS.activate! | ||
path = vagrant.instance_variable_get( :@vagrant_path ) | ||
vagrant.stub( :randmac ).and_return( "0123456789" ) | ||
|
||
vagrant.make_vfile( @hosts ) | ||
|
||
vagrantfile = File.read( File.expand_path( File.join( path, "Vagrantfile"))) | ||
expect( vagrantfile ).to include( %Q{ v.vm.provider :vmware_workstation do |v|\n v.vmx['memsize'] = '1024'\n end}) | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The downside here is that this will break all the current vagrant config files - maybe we should throw in a default fall through that runs virtual box if no subtype is specified?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current hosts files with
hypervisor: vagrant
will continue to work as usual, actually. Becauseprovision(provider = nil)
will be exactly the same.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just added
Beaker::VagrantVirtualbox
because we can get it for free, essentially.