Commit 2816af4a4127d260987d9ad22f4bca46fec0be60

Authored by Georg Hopp
1 parent ce310af3

Add provider config for privileged container

1 1 module VagrantPlugins
2 2 module ProviderLxd
3 3 class Config < Vagrant.plugin("2", :config)
  4 + def initialize
  5 + @privileged = false
  6 + end
  7 +
  8 + def privileged
  9 + @privileged = true
  10 + end
  11 +
  12 + def privileged?
  13 + @privileged
  14 + end
4 15 end
5 16 end
6 17 end
  18 +
  19 +# vim: set et ts=2 sw=2:
... ...
... ... @@ -90,7 +90,7 @@ module VagrantPlugins
90 90 end
91 91
92 92 def image
93   - @machine.box.name.split("/")[1..-1].join("/") if @machine.box
  93 + @machine.box.name if @machine.box
94 94 end
95 95
96 96 def image?
... ... @@ -117,9 +117,13 @@ module VagrantPlugins
117 117 end
118 118
119 119 def ipv4
120   - network["eth0"]["addresses"].select do |d|
121   - d["family"] == "inet"
122   - end[0]["address"]
  120 + interface = []
  121 + while interface.empty?
  122 + interface = network["eth0"]["addresses"].select do |d|
  123 + d["family"] == "inet"
  124 + end
  125 + end
  126 + interface[0]["address"]
123 127 end
124 128
125 129 def state
... ... @@ -150,10 +154,16 @@ module VagrantPlugins
150 154 execute(*args)
151 155 end
152 156
153   - def create
  157 + def create(config)
154 158 # network could be also attached right here if it turns out to be
155 159 # a good idea.
156   - execute("init", image, @name, "-n", @bridge["name"])
  160 + args = ["-n", @bridge["name"]]
  161 +
  162 + if config.privileged?
  163 + args += ["-c", "security.privileged=true"]
  164 + end
  165 +
  166 + execute("init", image, @name, "-n", @bridge["name"], *args)
157 167 end
158 168
159 169 def start
... ... @@ -220,7 +230,7 @@ module VagrantPlugins
220 230 opts = command.pop if command.last.is_a?(Hash)
221 231
222 232 tries = 0
223   - tries = 3 if opts[:retryable]
  233 + tries = 10 if opts[:retryable]
224 234
225 235 # Variable to store our execution result
226 236 r = nil
... ...
... ... @@ -17,7 +17,7 @@ module VagrantPlugins
17 17 end
18 18
19 19 config(:lxd, :provider) do
20   - require_relative "config"
  20 + require File.expand_path("../config", __FILE__)
21 21 Config
22 22 end
23 23
... ...
Please register or login to post a comment