Commit 2816af4a4127d260987d9ad22f4bca46fec0be60
1 parent
ce310af3
Add provider config for privileged container
Showing
3 changed files
with
31 additions
and
8 deletions
| 1 | module VagrantPlugins | 1 | module VagrantPlugins |
| 2 | module ProviderLxd | 2 | module ProviderLxd |
| 3 | class Config < Vagrant.plugin("2", :config) | 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 | end | 15 | end |
| 5 | end | 16 | end |
| 6 | end | 17 | end |
| 18 | + | ||
| 19 | +# vim: set et ts=2 sw=2: |
| @@ -90,7 +90,7 @@ module VagrantPlugins | @@ -90,7 +90,7 @@ module VagrantPlugins | ||
| 90 | end | 90 | end |
| 91 | 91 | ||
| 92 | def image | 92 | def image |
| 93 | - @machine.box.name.split("/")[1..-1].join("/") if @machine.box | 93 | + @machine.box.name if @machine.box |
| 94 | end | 94 | end |
| 95 | 95 | ||
| 96 | def image? | 96 | def image? |
| @@ -117,9 +117,13 @@ module VagrantPlugins | @@ -117,9 +117,13 @@ module VagrantPlugins | ||
| 117 | end | 117 | end |
| 118 | 118 | ||
| 119 | def ipv4 | 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 | end | 127 | end |
| 124 | 128 | ||
| 125 | def state | 129 | def state |
| @@ -150,10 +154,16 @@ module VagrantPlugins | @@ -150,10 +154,16 @@ module VagrantPlugins | ||
| 150 | execute(*args) | 154 | execute(*args) |
| 151 | end | 155 | end |
| 152 | 156 | ||
| 153 | - def create | 157 | + def create(config) |
| 154 | # network could be also attached right here if it turns out to be | 158 | # network could be also attached right here if it turns out to be |
| 155 | # a good idea. | 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 | end | 167 | end |
| 158 | 168 | ||
| 159 | def start | 169 | def start |
| @@ -220,7 +230,7 @@ module VagrantPlugins | @@ -220,7 +230,7 @@ module VagrantPlugins | ||
| 220 | opts = command.pop if command.last.is_a?(Hash) | 230 | opts = command.pop if command.last.is_a?(Hash) |
| 221 | 231 | ||
| 222 | tries = 0 | 232 | tries = 0 |
| 223 | - tries = 3 if opts[:retryable] | 233 | + tries = 10 if opts[:retryable] |
| 224 | 234 | ||
| 225 | # Variable to store our execution result | 235 | # Variable to store our execution result |
| 226 | r = nil | 236 | r = nil |
Please
register
or
login
to post a comment