Skip to content

Commit

Permalink
Merge (rebased) pull request #128 from tknerr/lxc-provider-support
Browse files Browse the repository at this point in the history
  • Loading branch information
fnichol committed Mar 23, 2015
2 parents e598544 + 1a43f54 commit 3df523d
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 0 deletions.
76 changes: 76 additions & 0 deletions spec/kitchen/driver/vagrant_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -937,6 +937,82 @@
end
end

context "for lxc provider" do

before { config[:provider] = "lxc" }

it "sets container_name to :machine if set" do
config[:customize] = {
:container_name => ":machine"
}
cmd

expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
c.vm.provider :lxc do |p|
p.container_name = :machine
end
RUBY
end

it "sets container_name to another value in quotes if set" do
config[:customize] = {
:container_name => "beans"
}
cmd

expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
c.vm.provider :lxc do |p|
p.container_name = "beans"
end
RUBY
end

it "sets backingstore if set" do
config[:customize] = {
:backingstore => "lvm"
}
cmd

expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
c.vm.provider :lxc do |p|
p.backingstore = "lvm"
end
RUBY
end

it "sets backingstore_option line for each backingstore_options" do
config[:customize] = {
:backingstore_options => {
:vgname => "schroots",
:fstype => "xfs"
}
}
cmd

expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
c.vm.provider :lxc do |p|
p.backingstore_option "--vgname", "schroots"
p.backingstore_option "--fstype", "xfs"
end
RUBY
end

it "sets all other options to customize lines" do
config[:customize] = {
:cookies => "cream",
:salt => "vinegar"
}
cmd

expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
c.vm.provider :lxc do |p|
p.customize "cookies", "cream"
p.customize "salt", "vinegar"
end
RUBY
end
end

context "for vmware_* providers" do

before { config[:provider] = "vmware_desktop" }
Expand Down
12 changes: 12 additions & 0 deletions templates/Vagrantfile.erb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,18 @@ Vagrant.configure("2") do |c|
<% case config[:provider]
when "libvirt" %>
p.<%= key %> = <%= value%>
<% when "lxc" %>
<% if key == :container_name %>
p.container_name = <%= value == ":machine" ? value : "\"#{value}\"" %>
<% elsif key == :backingstore %>
p.backingstore = "<%= value %>"
<% elsif key == :backingstore_options %>
<% config[:customize][:backingstore_options].each do |opt, opt_val| %>
p.backingstore_option "--<%= opt %>", "<%= opt_val %>"
<% end %>
<% else %>
p.customize "<%= key %>", "<%= value %>"
<% end %>
<% when "parallels" %>
p.customize ["set", :id, "--<%= key.to_s.gsub('_', '-') %>", "<%= value %>"]
<% when "rackspace", "softlayer" %>
Expand Down

0 comments on commit 3df523d

Please sign in to comment.