-
Notifications
You must be signed in to change notification settings - Fork 326
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #271 from hunner/add_fusion
(QENG-1146) Add vagrant_fusion, vagrant_workstation and vagrant_virtualbox providers
- Loading branch information
Showing
10 changed files
with
239 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |