diff --git a/lib/vagrant-lxd/config.rb b/lib/vagrant-lxd/config.rb index d81e97a..8bef245 100644 --- a/lib/vagrant-lxd/config.rb +++ b/lib/vagrant-lxd/config.rb @@ -1,6 +1,19 @@ module VagrantPlugins module ProviderLxd class Config < Vagrant.plugin("2", :config) + def initialize + @privileged = false + end + + def privileged + @privileged = true + end + + def privileged? + @privileged + end end end end + +# vim: set et ts=2 sw=2: diff --git a/lib/vagrant-lxd/driver.rb b/lib/vagrant-lxd/driver.rb index 973c3bc..6cfb9af 100644 --- a/lib/vagrant-lxd/driver.rb +++ b/lib/vagrant-lxd/driver.rb @@ -90,7 +90,7 @@ module VagrantPlugins end def image - @machine.box.name.split("/")[1..-1].join("/") if @machine.box + @machine.box.name if @machine.box end def image? @@ -117,9 +117,13 @@ module VagrantPlugins end def ipv4 - network["eth0"]["addresses"].select do |d| - d["family"] == "inet" - end[0]["address"] + interface = [] + while interface.empty? + interface = network["eth0"]["addresses"].select do |d| + d["family"] == "inet" + end + end + interface[0]["address"] end def state @@ -150,10 +154,16 @@ module VagrantPlugins execute(*args) end - def create + def create(config) # network could be also attached right here if it turns out to be # a good idea. - execute("init", image, @name, "-n", @bridge["name"]) + args = ["-n", @bridge["name"]] + + if config.privileged? + args += ["-c", "security.privileged=true"] + end + + execute("init", image, @name, "-n", @bridge["name"], *args) end def start @@ -220,7 +230,7 @@ module VagrantPlugins opts = command.pop if command.last.is_a?(Hash) tries = 0 - tries = 3 if opts[:retryable] + tries = 10 if opts[:retryable] # Variable to store our execution result r = nil diff --git a/lib/vagrant-lxd/plugin.rb b/lib/vagrant-lxd/plugin.rb index dbb52de..4bbacdb 100644 --- a/lib/vagrant-lxd/plugin.rb +++ b/lib/vagrant-lxd/plugin.rb @@ -17,7 +17,7 @@ module VagrantPlugins end config(:lxd, :provider) do - require_relative "config" + require File.expand_path("../config", __FILE__) Config end