Browse Source

Add provider config for privileged container

master
Georg Hopp 9 years ago
parent
commit
2816af4a41
  1. 13
      lib/vagrant-lxd/config.rb
  2. 24
      lib/vagrant-lxd/driver.rb
  3. 2
      lib/vagrant-lxd/plugin.rb

13
lib/vagrant-lxd/config.rb

@ -1,6 +1,19 @@
module VagrantPlugins module VagrantPlugins
module ProviderLxd module ProviderLxd
class Config < Vagrant.plugin("2", :config) class Config < Vagrant.plugin("2", :config)
def initialize
@privileged = false
end
def privileged
@privileged = true
end
def privileged?
@privileged
end
end end
end end
end end
# vim: set et ts=2 sw=2:

24
lib/vagrant-lxd/driver.rb

@ -90,7 +90,7 @@ module VagrantPlugins
end end
def image def image
@machine.box.name.split("/")[1..-1].join("/") if @machine.box
@machine.box.name if @machine.box
end end
def image? def image?
@ -117,9 +117,13 @@ module VagrantPlugins
end end
def ipv4 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 end
def state def state
@ -150,10 +154,16 @@ module VagrantPlugins
execute(*args) execute(*args)
end end
def create
def create(config)
# network could be also attached right here if it turns out to be # network could be also attached right here if it turns out to be
# a good idea. # 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 end
def start def start
@ -220,7 +230,7 @@ module VagrantPlugins
opts = command.pop if command.last.is_a?(Hash) opts = command.pop if command.last.is_a?(Hash)
tries = 0 tries = 0
tries = 3 if opts[:retryable]
tries = 10 if opts[:retryable]
# Variable to store our execution result # Variable to store our execution result
r = nil r = nil

2
lib/vagrant-lxd/plugin.rb

@ -17,7 +17,7 @@ module VagrantPlugins
end end
config(:lxd, :provider) do config(:lxd, :provider) do
require_relative "config"
require File.expand_path("../config", __FILE__)
Config Config
end end

Loading…
Cancel
Save