vagrant-lxc 1.2.4 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +6 -5
- data/CHANGELOG.md +17 -0
- data/Gemfile +6 -5
- data/README.md +7 -12
- data/lib/vagrant-lxc/action/boot.rb +0 -3
- data/lib/vagrant-lxc/action/create.rb +3 -1
- data/lib/vagrant-lxc/action/{fetch_ip_with_lxc_attach.rb → fetch_ip_with_lxc_info.rb} +5 -7
- data/lib/vagrant-lxc/action/remove_temporary_files.rb +23 -0
- data/lib/vagrant-lxc/action.rb +4 -4
- data/lib/vagrant-lxc/command/sudoers.rb +3 -2
- data/lib/vagrant-lxc/config.rb +0 -2
- data/lib/vagrant-lxc/driver/cli.rb +11 -29
- data/lib/vagrant-lxc/driver.rb +22 -9
- data/lib/vagrant-lxc/errors.rb +0 -3
- data/lib/vagrant-lxc/provider.rb +3 -6
- data/lib/vagrant-lxc/sudo_wrapper.rb +6 -2
- data/lib/vagrant-lxc/version.rb +1 -1
- data/lib/vagrant-lxc.rb +0 -12
- data/scripts/lxc-template +4 -4
- data/spec/Vagrantfile +0 -4
- data/spec/unit/driver/cli_spec.rb +2 -31
- data/spec/unit/driver_spec.rb +3 -12
- data/templates/sudoers.rb.erb +2 -0
- metadata +4 -5
- data/Gemfile.lock +0 -182
- data/lib/vagrant-lxc/action/fetch_ip_from_dnsmasq_leases.rb +0 -49
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 736cfddbd6bdf4b0fb8d6bbb5291e3dd30722835
|
4
|
+
data.tar.gz: 25d7fba64da0b3f42ae5b537b13db95b55db69ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 085fa926c3d0a3737487d7589b85ab833547bdf19134f544209915742640e5709bcbacef7aaccc76203cdf30068008dabbe509823625072afeb0bfe6d1a04937
|
7
|
+
data.tar.gz: 26cfe6cb8982ed036ed70d4b1aac50ff9c5720d87e3aef3cc87696a1c1cfa3697c31018de546c817aa482ac73f61a1f15f8ac678a0b8d0cabdde520691a4c618
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,20 @@
|
|
1
|
+
## [1.3.0](https://github.com/fgrehm/vagrant-lxc/compare/v1.2.4...v1.3.0) (Jan 20, 2018)
|
2
|
+
|
3
|
+
FEATURES:
|
4
|
+
- lxc-template: make runnable by unprivileged users [[GH-447]]
|
5
|
+
- Use `lxc-info` instead of `lxc-attach` to retrieve container IP
|
6
|
+
- Add support for LXC v2.1+ [[GH-445]]
|
7
|
+
- Remove 2Gb limitation on `/tmp`. [[GH-406]]
|
8
|
+
|
9
|
+
OTHERS:
|
10
|
+
- Bump Vagrant requirements to v1.8+
|
11
|
+
- Bump LXC requirements to v1.0+
|
12
|
+
|
13
|
+
|
14
|
+
[GH-447]: https://github.com/fgrehm/vagrant-lxc/pull/447
|
15
|
+
[GH-445]: https://github.com/fgrehm/vagrant-lxc/pull/445
|
16
|
+
[GH-406]: https://github.com/fgrehm/vagrant-lxc/pull/406
|
17
|
+
|
1
18
|
## [1.2.4](https://github.com/fgrehm/vagrant-lxc/compare/v1.2.3...v1.2.4) (Dec 20, 2017)
|
2
19
|
|
3
20
|
BUGFIX:
|
data/Gemfile
CHANGED
@@ -1,17 +1,18 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
3
|
group :development do
|
4
|
-
gem 'vagrant', git: 'https://github.com/mitchellh/vagrant.git', tag: 'v1.7
|
4
|
+
gem 'vagrant', git: 'https://github.com/mitchellh/vagrant.git', tag: 'v1.8.7'
|
5
5
|
gem 'guard'
|
6
6
|
gem 'guard-rspec'
|
7
7
|
gem 'rb-inotify'
|
8
8
|
end
|
9
9
|
|
10
10
|
group :development, :test do
|
11
|
-
gem 'rake'
|
12
|
-
gem 'rspec',
|
13
|
-
gem 'coveralls',
|
14
|
-
|
11
|
+
gem 'rake', '~> 10.4.2'
|
12
|
+
gem 'rspec', '~> 2.99.0'
|
13
|
+
gem 'coveralls', '~> 0.7.2', require: (ENV['COVERAGE'] == 'true')
|
14
|
+
# The is the ref *just* before we switch to childprocess 0.6, which conflicts with vagrant 1.8 deps.
|
15
|
+
gem 'vagrant-spec', git: 'https://github.com/mitchellh/vagrant-spec.git', ref: '5006bc73cd8796465ca09307d4774f8ec8375aa0'
|
15
16
|
end
|
16
17
|
|
17
18
|
group :plugins do
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
[](https://travis-ci.org/fgrehm/vagrant-lxc) [](http://badge.fury.io/rb/vagrant-lxc) [](https://codeclimate.com/github/fgrehm/vagrant-lxc) [](https://coveralls.io/r/fgrehm/vagrant-lxc) [](https://gitter.im/fgrehm/vagrant-lxc)
|
4
4
|
|
5
|
-
[LXC](http://lxc.sourceforge.net/) provider for [Vagrant](http://www.vagrantup.com/) 1.
|
5
|
+
[LXC](http://lxc.sourceforge.net/) provider for [Vagrant](http://www.vagrantup.com/) 1.8+
|
6
6
|
|
7
7
|
This is a Vagrant plugin that allows it to control and provision Linux Containers
|
8
8
|
as an alternative to the built in VirtualBox provider for Linux hosts. Check out
|
@@ -17,17 +17,14 @@ to see it in action.
|
|
17
17
|
|
18
18
|
## Requirements
|
19
19
|
|
20
|
-
* [Vagrant 1.
|
21
|
-
* lxc >=
|
22
|
-
* tar 1.27 (the lxc-template script uses the --xattrs option)
|
20
|
+
* [Vagrant 1.8+](http://www.vagrantup.com/downloads.html)
|
21
|
+
* lxc >=1.0
|
23
22
|
* `redir` (if you are planning to use port forwarding)
|
24
23
|
* `brctl` (if you are planning to use private networks, on Ubuntu this means `apt-get install bridge-utils`)
|
25
|
-
* A [kernel != 3.5.0-17.28](https://github.com/fgrehm/vagrant-lxc/wiki/Troubleshooting#wiki-im-unable-to-restart-containers)
|
26
24
|
|
27
25
|
The plugin is known to work better and pretty much out of the box on Ubuntu 14.04+
|
28
|
-
hosts and installing the dependencies on it basically means a
|
29
|
-
|
30
|
-
[additional configurations to work](#backingstore-options)). For setting up other
|
26
|
+
hosts and installing the dependencies on it basically means a
|
27
|
+
`apt-get install lxc lxc-templates cgroup-lite redir`. For setting up other
|
31
28
|
types of hosts please have a look at the [Wiki](https://github.com/fgrehm/vagrant-lxc/wiki).
|
32
29
|
|
33
30
|
If you are on a Mac or Windows machine, you might want to have a look at [this](http://the.taoofmac.com/space/HOWTO/Vagrant)
|
@@ -155,16 +152,14 @@ end
|
|
155
152
|
|
156
153
|
## Avoiding `sudo` passwords
|
157
154
|
|
158
|
-
This plugin requires **a lot** of `sudo`ing since [
|
159
|
-
|
155
|
+
This plugin requires **a lot** of `sudo`ing since [unprivileged containers](https://github.com/fgrehm/vagrant-lxc/issues/312)
|
156
|
+
are not supported yet. To work around that, you can use the `vagrant lxc sudoers`
|
160
157
|
command which will create a file under `/etc/sudoers.d/vagrant-lxc` whitelisting
|
161
158
|
all commands required by `vagrant-lxc` to run.
|
162
159
|
|
163
160
|
If you are interested on what will be generated by that command, please check
|
164
161
|
[this code](lib/vagrant-lxc/command/sudoers.rb).
|
165
162
|
|
166
|
-
_vagrant-lxc < 1.0.0 users, please check this [Wiki page](https://github.com/fgrehm/vagrant-lxc/wiki/Avoiding-%27sudo%27-passwords)_
|
167
|
-
|
168
163
|
|
169
164
|
## More information
|
170
165
|
|
@@ -26,9 +26,6 @@ module Vagrant
|
|
26
26
|
config.customize 'mount.entry', '/sys/fs/selinux sys/fs/selinux none bind,ro 0 0'
|
27
27
|
end
|
28
28
|
|
29
|
-
# Make /tmp a tmpfs to prevent init scripts from nuking synced folders mounted in here
|
30
|
-
config.customize 'mount.entry', 'tmpfs tmp tmpfs nodev,nosuid,size=2G 0 0'
|
31
|
-
|
32
29
|
env[:ui].info I18n.t("vagrant_lxc.messages.starting")
|
33
30
|
env[:machine].provider.driver.start(config.customizations)
|
34
31
|
|
@@ -19,7 +19,8 @@ module Vagrant
|
|
19
19
|
container_name = generate_container_name(env)
|
20
20
|
end
|
21
21
|
|
22
|
-
env[:machine].provider.driver
|
22
|
+
driver = env[:machine].provider.driver
|
23
|
+
driver.create(
|
23
24
|
container_name,
|
24
25
|
config.backingstore,
|
25
26
|
config.backingstore_options,
|
@@ -27,6 +28,7 @@ module Vagrant
|
|
27
28
|
env[:lxc_template_config],
|
28
29
|
env[:lxc_template_opts]
|
29
30
|
)
|
31
|
+
driver.update_config_keys
|
30
32
|
|
31
33
|
env[:machine].id = container_name
|
32
34
|
|
@@ -1,19 +1,17 @@
|
|
1
1
|
module Vagrant
|
2
2
|
module LXC
|
3
3
|
module Action
|
4
|
-
class
|
4
|
+
class FetchIpWithLxcInfo
|
5
5
|
# Include this so we can use `Subprocess` more easily.
|
6
6
|
include Vagrant::Util::Retryable
|
7
7
|
|
8
8
|
def initialize(app, env)
|
9
9
|
@app = app
|
10
|
-
@logger = Log4r::Logger.new("vagrant::lxc::action::
|
10
|
+
@logger = Log4r::Logger.new("vagrant::lxc::action::fetch_ip_with_lxc_info")
|
11
11
|
end
|
12
12
|
|
13
13
|
def call(env)
|
14
14
|
env[:machine_ip] ||= assigned_ip(env)
|
15
|
-
rescue LXC::Errors::NamespacesNotSupported
|
16
|
-
@logger.info 'The `lxc-attach` command available does not support the --namespaces parameter, falling back to dnsmasq leases to fetch container ip'
|
17
15
|
ensure
|
18
16
|
@app.call(env)
|
19
17
|
end
|
@@ -26,7 +24,7 @@ module Vagrant
|
|
26
24
|
retryable(:on => LXC::Errors::ExecuteError, :tries => fetch_ip_tries, :sleep => 3) do
|
27
25
|
unless ip = get_container_ip_from_ip_addr(driver)
|
28
26
|
# retry
|
29
|
-
raise LXC::Errors::ExecuteError, :command => "lxc-
|
27
|
+
raise LXC::Errors::ExecuteError, :command => "lxc-info"
|
30
28
|
end
|
31
29
|
end
|
32
30
|
ip
|
@@ -34,8 +32,8 @@ module Vagrant
|
|
34
32
|
|
35
33
|
# From: https://github.com/lxc/lxc/blob/staging/src/python-lxc/lxc/__init__.py#L371-L385
|
36
34
|
def get_container_ip_from_ip_addr(driver)
|
37
|
-
output = driver.
|
38
|
-
if output =~
|
35
|
+
output = driver.info '-iH'
|
36
|
+
if output =~ /^([0-9.]+)/
|
39
37
|
return $1.to_s
|
40
38
|
end
|
41
39
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Vagrant
|
2
|
+
module LXC
|
3
|
+
module Action
|
4
|
+
class RemoveTemporaryFiles
|
5
|
+
def initialize(app, env)
|
6
|
+
@app = app
|
7
|
+
@logger = Log4r::Logger.new("vagrant::lxc::action::remove_tmp_files")
|
8
|
+
end
|
9
|
+
|
10
|
+
def call(env)
|
11
|
+
@logger.debug 'Removing temporary files'
|
12
|
+
driver = env[:machine].provider.driver
|
13
|
+
# To prevent host-side data loss, it's important that all mounts under /tmp are unmounted
|
14
|
+
# before we proceed with the `rm -rf` operation. See #68 and #360.
|
15
|
+
driver.attach("findmnt -R /tmp -o TARGET --list --noheadings | xargs -L 1 --no-run-if-empty umount")
|
16
|
+
driver.attach("rm -rf /tmp/*")
|
17
|
+
|
18
|
+
@app.call env
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/vagrant-lxc/action.rb
CHANGED
@@ -4,8 +4,7 @@ require 'vagrant-lxc/action/create'
|
|
4
4
|
require 'vagrant-lxc/action/destroy'
|
5
5
|
require 'vagrant-lxc/action/destroy_confirm'
|
6
6
|
require 'vagrant-lxc/action/compress_rootfs'
|
7
|
-
require 'vagrant-lxc/action/
|
8
|
-
require 'vagrant-lxc/action/fetch_ip_from_dnsmasq_leases'
|
7
|
+
require 'vagrant-lxc/action/fetch_ip_with_lxc_info'
|
9
8
|
require 'vagrant-lxc/action/forced_halt'
|
10
9
|
require 'vagrant-lxc/action/forward_ports'
|
11
10
|
require 'vagrant-lxc/action/gc_private_network_bridges'
|
@@ -13,6 +12,7 @@ require 'vagrant-lxc/action/handle_box_metadata'
|
|
13
12
|
require 'vagrant-lxc/action/prepare_nfs_settings'
|
14
13
|
require 'vagrant-lxc/action/prepare_nfs_valid_ids'
|
15
14
|
require 'vagrant-lxc/action/private_networks'
|
15
|
+
require 'vagrant-lxc/action/remove_temporary_files'
|
16
16
|
require 'vagrant-lxc/action/setup_package_files'
|
17
17
|
require 'vagrant-lxc/action/warn_networks'
|
18
18
|
|
@@ -125,6 +125,7 @@ module Vagrant
|
|
125
125
|
end
|
126
126
|
|
127
127
|
b2.use ClearForwardedPorts
|
128
|
+
b2.use RemoveTemporaryFiles
|
128
129
|
b2.use GcPrivateNetworkBridges
|
129
130
|
b2.use Builtin::Call, Builtin::GracefulHalt, :stopped, :running do |env2, b3|
|
130
131
|
if !env2[:result]
|
@@ -182,8 +183,7 @@ module Vagrant
|
|
182
183
|
def self.action_ssh_ip
|
183
184
|
Builder.new.tap do |b|
|
184
185
|
b.use Builtin::Call, Builtin::ConfigValidate do |env, b2|
|
185
|
-
b2.use
|
186
|
-
b2.use FetchIpFromDnsmasqLeases
|
186
|
+
b2.use FetchIpWithLxcInfo
|
187
187
|
end
|
188
188
|
end
|
189
189
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'tempfile'
|
2
2
|
|
3
3
|
require "vagrant-lxc/driver"
|
4
|
+
require "vagrant-lxc/sudo_wrapper"
|
4
5
|
|
5
6
|
module Vagrant
|
6
7
|
module LXC
|
@@ -27,7 +28,7 @@ module Vagrant
|
|
27
28
|
argv = parse_options(opts)
|
28
29
|
return unless argv
|
29
30
|
|
30
|
-
wrapper_path =
|
31
|
+
wrapper_path = SudoWrapper.dest_path
|
31
32
|
wrapper = create_wrapper!
|
32
33
|
sudoers = create_sudoers!(options[:user], wrapper_path)
|
33
34
|
|
@@ -45,7 +46,7 @@ module Vagrant
|
|
45
46
|
|
46
47
|
# This requires vagrant 1.5.2+ https://github.com/mitchellh/vagrant/commit/3371c3716278071680af9b526ba19235c79c64cb
|
47
48
|
def create_wrapper!
|
48
|
-
lxc_base_path = Driver.new(
|
49
|
+
lxc_base_path = Driver.new("").containers_path
|
49
50
|
wrapper = Tempfile.new('lxc-wrapper').tap do |file|
|
50
51
|
template = Vagrant::Util::TemplateRenderer.new(
|
51
52
|
'sudoers.rb',
|
data/lib/vagrant-lxc/config.rb
CHANGED
@@ -24,7 +24,6 @@ module Vagrant
|
|
24
24
|
@customizations = []
|
25
25
|
@backingstore = UNSET_VALUE
|
26
26
|
@backingstore_options = []
|
27
|
-
@sudo_wrapper = UNSET_VALUE
|
28
27
|
@container_name = UNSET_VALUE
|
29
28
|
@fetch_ip_tries = UNSET_VALUE
|
30
29
|
end
|
@@ -50,7 +49,6 @@ module Vagrant
|
|
50
49
|
end
|
51
50
|
|
52
51
|
def finalize!
|
53
|
-
@sudo_wrapper = nil if @sudo_wrapper == UNSET_VALUE
|
54
52
|
@container_name = nil if @container_name == UNSET_VALUE
|
55
53
|
@backingstore = "best" if @backingstore == UNSET_VALUE
|
56
54
|
@existing_container_name = nil if @existing_container_name == UNSET_VALUE
|
@@ -29,7 +29,7 @@ module Vagrant
|
|
29
29
|
|
30
30
|
def version
|
31
31
|
return @version if @version
|
32
|
-
@version =
|
32
|
+
@version = run(:create, '--version')
|
33
33
|
if @version =~ /(lxc version:\s+|)(.+)\s*$/
|
34
34
|
@version = $2.downcase
|
35
35
|
else
|
@@ -39,11 +39,11 @@ module Vagrant
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def config(param)
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
42
|
+
run(:config, param).gsub("\n", '')
|
43
|
+
end
|
44
|
+
|
45
|
+
def update_config(path)
|
46
|
+
run('update-config', '-c', path)
|
47
47
|
end
|
48
48
|
|
49
49
|
def state
|
@@ -114,17 +114,17 @@ module Vagrant
|
|
114
114
|
end
|
115
115
|
|
116
116
|
if namespaces
|
117
|
-
|
118
|
-
extra = ['--namespaces', namespaces]
|
119
|
-
else
|
120
|
-
raise LXC::Errors::NamespacesNotSupported
|
121
|
-
end
|
117
|
+
extra = ['--namespaces', namespaces]
|
122
118
|
end
|
123
119
|
end
|
124
120
|
|
125
121
|
run :attach, '--name', @name, *((extra || []) + cmd)
|
126
122
|
end
|
127
123
|
|
124
|
+
def info(*cmd)
|
125
|
+
run(:info, '--name', @name, *cmd)
|
126
|
+
end
|
127
|
+
|
128
128
|
def transition_to(target_state, tries = 30, timeout = 1, &block)
|
129
129
|
raise TransitionBlockNotProvided unless block_given?
|
130
130
|
|
@@ -155,29 +155,11 @@ module Vagrant
|
|
155
155
|
return @supports_attach
|
156
156
|
end
|
157
157
|
|
158
|
-
def support_config_command?
|
159
|
-
version[0].to_i >= 1
|
160
|
-
end
|
161
|
-
|
162
|
-
def support_version_command?
|
163
|
-
@sudo_wrapper.run('which', 'lxc-version').strip.chomp != ''
|
164
|
-
rescue Vagrant::LXC::Errors::ExecuteError
|
165
|
-
return false
|
166
|
-
end
|
167
|
-
|
168
158
|
private
|
169
159
|
|
170
160
|
def run(command, *args)
|
171
161
|
@sudo_wrapper.run("lxc-#{command}", *args)
|
172
162
|
end
|
173
|
-
|
174
|
-
def supports_attach_with_namespaces?
|
175
|
-
unless defined?(@supports_attach_with_namespaces)
|
176
|
-
@supports_attach_with_namespaces = run(:attach, '-h', :show_stderr => true).values.join.include?('--namespaces')
|
177
|
-
end
|
178
|
-
|
179
|
-
return @supports_attach_with_namespaces
|
180
|
-
end
|
181
163
|
end
|
182
164
|
end
|
183
165
|
end
|
data/lib/vagrant-lxc/driver.rb
CHANGED
@@ -3,6 +3,7 @@ require "vagrant/util/subprocess"
|
|
3
3
|
|
4
4
|
require "vagrant-lxc/errors"
|
5
5
|
require "vagrant-lxc/driver/cli"
|
6
|
+
require "vagrant-lxc/sudo_wrapper"
|
6
7
|
|
7
8
|
require "etc"
|
8
9
|
|
@@ -16,15 +17,13 @@ module Vagrant
|
|
16
17
|
class ContainerNotFound < StandardError; end
|
17
18
|
|
18
19
|
# Default root folder where container configs are stored
|
19
|
-
DEFAULT_CONTAINERS_PATH = '/var/lib/lxc'
|
20
|
-
|
21
20
|
attr_reader :container_name,
|
22
21
|
:customizations
|
23
22
|
|
24
|
-
def initialize(container_name, sudo_wrapper, cli = nil)
|
23
|
+
def initialize(container_name, sudo_wrapper = nil, cli = nil)
|
25
24
|
@container_name = container_name
|
26
|
-
@sudo_wrapper = sudo_wrapper
|
27
|
-
@cli = cli || CLI.new(sudo_wrapper, container_name)
|
25
|
+
@sudo_wrapper = sudo_wrapper || SudoWrapper.new()
|
26
|
+
@cli = cli || CLI.new(@sudo_wrapper, container_name)
|
28
27
|
@logger = Log4r::Logger.new("vagrant::provider::lxc::driver")
|
29
28
|
@customizations = []
|
30
29
|
end
|
@@ -35,7 +34,7 @@ module Vagrant
|
|
35
34
|
|
36
35
|
# Root folder where container configs are stored
|
37
36
|
def containers_path
|
38
|
-
@containers_path ||= @cli.
|
37
|
+
@containers_path ||= @cli.config('lxc.lxcpath')
|
39
38
|
end
|
40
39
|
|
41
40
|
def all_containers
|
@@ -46,6 +45,10 @@ module Vagrant
|
|
46
45
|
Pathname.new("#{containers_path}/#{@container_name}")
|
47
46
|
end
|
48
47
|
|
48
|
+
def config_path
|
49
|
+
base_path.join('config').to_s
|
50
|
+
end
|
51
|
+
|
49
52
|
def rootfs_path
|
50
53
|
config_entry = config_string.match(/^lxc\.rootfs\s+=\s+(.+)$/)[1]
|
51
54
|
case config_entry
|
@@ -73,7 +76,7 @@ module Vagrant
|
|
73
76
|
end
|
74
77
|
|
75
78
|
def config_string
|
76
|
-
@sudo_wrapper.run('cat',
|
79
|
+
@sudo_wrapper.run('cat', config_path)
|
77
80
|
end
|
78
81
|
|
79
82
|
def create(name, backingstore, backingstore_options, template_path, config_file, template_options = {})
|
@@ -126,6 +129,10 @@ module Vagrant
|
|
126
129
|
@cli.attach(*command)
|
127
130
|
end
|
128
131
|
|
132
|
+
def info(*command)
|
133
|
+
@cli.info(*command)
|
134
|
+
end
|
135
|
+
|
129
136
|
def configure_private_network(bridge_name, bridge_ip, container_name, address_type, ip)
|
130
137
|
@logger.info "Configuring network interface for #{container_name} using #{ip} and bridge #{bridge_name}"
|
131
138
|
if ip
|
@@ -237,6 +244,12 @@ module Vagrant
|
|
237
244
|
write_config(contents)
|
238
245
|
end
|
239
246
|
|
247
|
+
def update_config_keys
|
248
|
+
@cli.update_config(config_path)
|
249
|
+
rescue Errors::ExecuteError
|
250
|
+
# not on LXC 2.1+. Doesn't matter, ignore.
|
251
|
+
end
|
252
|
+
|
240
253
|
protected
|
241
254
|
|
242
255
|
def write_customizations(customizations)
|
@@ -257,8 +270,8 @@ module Vagrant
|
|
257
270
|
file.chmod 0644
|
258
271
|
file.write contents
|
259
272
|
file.close
|
260
|
-
@sudo_wrapper.run 'cp', '-f', file.path,
|
261
|
-
@sudo_wrapper.run 'chown', 'root:root',
|
273
|
+
@sudo_wrapper.run 'cp', '-f', file.path, config_path
|
274
|
+
@sudo_wrapper.run 'chown', 'root:root', config_path
|
262
275
|
end
|
263
276
|
end
|
264
277
|
end
|
data/lib/vagrant-lxc/errors.rb
CHANGED
data/lib/vagrant-lxc/provider.rb
CHANGED
@@ -2,6 +2,7 @@ require "log4r"
|
|
2
2
|
|
3
3
|
require "vagrant-lxc/action"
|
4
4
|
require "vagrant-lxc/driver"
|
5
|
+
require "vagrant-lxc/sudo_wrapper"
|
5
6
|
|
6
7
|
module Vagrant
|
7
8
|
module LXC
|
@@ -24,13 +25,9 @@ module Vagrant
|
|
24
25
|
machine_id_changed
|
25
26
|
end
|
26
27
|
|
27
|
-
def sudo_wrapper
|
28
|
-
@shell ||= LXC.sudo_wrapper
|
29
|
-
end
|
30
|
-
|
31
28
|
def ensure_lxc_installed!
|
32
29
|
begin
|
33
|
-
|
30
|
+
SudoWrapper.new().run("which", "lxc-create")
|
34
31
|
rescue Vagrant::LXC::Errors::ExecuteError
|
35
32
|
raise Errors::LxcNotInstalled
|
36
33
|
end
|
@@ -43,7 +40,7 @@ module Vagrant
|
|
43
40
|
|
44
41
|
begin
|
45
42
|
@logger.debug("Instantiating the container for: #{id.inspect}")
|
46
|
-
@driver = Driver.new(id
|
43
|
+
@driver = Driver.new(id)
|
47
44
|
@driver.validate!
|
48
45
|
rescue Driver::ContainerNotFound
|
49
46
|
# The container doesn't exist, so we probably have a stale
|
@@ -6,8 +6,12 @@ module Vagrant
|
|
6
6
|
|
7
7
|
attr_reader :wrapper_path
|
8
8
|
|
9
|
-
def
|
10
|
-
|
9
|
+
def self.dest_path
|
10
|
+
"/usr/local/bin/vagrant-lxc-wrapper"
|
11
|
+
end
|
12
|
+
|
13
|
+
def initialize()
|
14
|
+
@wrapper_path = Pathname.new(SudoWrapper.dest_path).exist? && SudoWrapper.dest_path || nil
|
11
15
|
@logger = Log4r::Logger.new("vagrant::lxc::sudo_wrapper")
|
12
16
|
end
|
13
17
|
|
data/lib/vagrant-lxc/version.rb
CHANGED
data/lib/vagrant-lxc.rb
CHANGED
@@ -1,22 +1,10 @@
|
|
1
1
|
require "vagrant-lxc/version"
|
2
2
|
require "vagrant-lxc/plugin"
|
3
|
-
require "vagrant-lxc/sudo_wrapper"
|
4
3
|
|
5
4
|
module Vagrant
|
6
5
|
module LXC
|
7
6
|
def self.source_root
|
8
7
|
@source_root ||= Pathname.new(File.dirname(__FILE__)).join('..').expand_path
|
9
8
|
end
|
10
|
-
|
11
|
-
def self.sudo_wrapper_path
|
12
|
-
"/usr/local/bin/vagrant-lxc-wrapper"
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.sudo_wrapper
|
16
|
-
wrapper = Pathname.new(sudo_wrapper_path).exist? &&
|
17
|
-
sudo_wrapper_path || nil
|
18
|
-
SudoWrapper.new(wrapper)
|
19
|
-
end
|
20
|
-
|
21
9
|
end
|
22
10
|
end
|
data/scripts/lxc-template
CHANGED
@@ -110,7 +110,6 @@ fi
|
|
110
110
|
# Unpack the rootfs
|
111
111
|
echo "Unpacking the rootfs"
|
112
112
|
|
113
|
-
mkdir -p /var/lock/subsys
|
114
113
|
(
|
115
114
|
flock -x 200
|
116
115
|
if [ $? -ne 0 ]; then
|
@@ -119,13 +118,14 @@ mkdir -p /var/lock/subsys
|
|
119
118
|
fi
|
120
119
|
|
121
120
|
mkdir -p ${LXC_ROOTFS}
|
122
|
-
(cd ${LXC_ROOTFS} && tar xfz ${LXC_TARBALL} --strip-components=${LXC_STRIP_COMPONENTS} --xattrs --xattrs-include=*)
|
123
|
-
if [
|
121
|
+
(cd ${LXC_ROOTFS} && tar xfz ${LXC_TARBALL} --strip-components=${LXC_STRIP_COMPONENTS} --xattrs --xattrs-include=* || true)
|
122
|
+
if [ ! -f ${LXC_ROOTFS}/bin/true ]; then
|
124
123
|
echo "Failed to extract rootfs"
|
125
124
|
exit 1
|
126
125
|
fi
|
127
126
|
|
128
|
-
) 200
|
127
|
+
) 200>${LXC_PATH}/vagrant_lock
|
128
|
+
rm ${LXC_PATH}/vagrant_lock
|
129
129
|
|
130
130
|
mkdir -p ${LXC_ROOTFS}/dev/pts/
|
131
131
|
|
data/spec/Vagrantfile
CHANGED
@@ -15,10 +15,6 @@ Vagrant.configure("2") do |config|
|
|
15
15
|
|
16
16
|
config.cache.auto_detect = true
|
17
17
|
|
18
|
-
config.vm.provider :lxc do |lxc|
|
19
|
-
# lxc.sudo_wrapper = '/usr/bin/lxc-vagrant-wrapper'
|
20
|
-
end
|
21
|
-
|
22
18
|
config.vm.provision :shell,
|
23
19
|
inline: 'mkdir -p /vagrant/tmp && echo -n "Provisioned" > /vagrant/tmp/provisioning'
|
24
20
|
|
@@ -30,16 +30,7 @@ describe Vagrant::LXC::Driver::CLI do
|
|
30
30
|
|
31
31
|
describe 'version' do
|
32
32
|
before do
|
33
|
-
allow(subject).to receive(:
|
34
|
-
allow(subject).to receive(:run).with(:version).and_return(lxc_version_out)
|
35
|
-
end
|
36
|
-
|
37
|
-
describe 'lxc version before 1.x.x' do
|
38
|
-
let(:lxc_version_out) { "lxc version: 0.x.y-rc1\n" }
|
39
|
-
|
40
|
-
it 'parses the version from the output' do
|
41
|
-
expect(subject.version).to eq('0.x.y-rc1')
|
42
|
-
end
|
33
|
+
allow(subject).to receive(:run).with(:create, '--version').and_return(lxc_version_out)
|
43
34
|
end
|
44
35
|
|
45
36
|
describe 'lxc version after 1.x.x' do
|
@@ -53,24 +44,11 @@ describe Vagrant::LXC::Driver::CLI do
|
|
53
44
|
|
54
45
|
describe 'config' do
|
55
46
|
before do
|
56
|
-
allow(subject).to receive(:support_version_command?).and_return(support_version_command?)
|
57
47
|
allow(subject).to receive(:run).with(:config, 'lxc.lxcpath').and_return(lxc_config_out)
|
58
|
-
allow(subject).to receive(:run).with(:version).and_return(lxc_version_out)
|
59
48
|
allow(subject).to receive(:run).with(:create, '--version').and_return(lxc_version_out)
|
60
49
|
end
|
61
50
|
|
62
|
-
describe 'lxc version
|
63
|
-
let(:support_version_command?) { true }
|
64
|
-
let(:lxc_config_out) { "/var/lib/lxc\n" }
|
65
|
-
let(:lxc_version_out) { "lxc version: 0.x.y-rc1\n" }
|
66
|
-
|
67
|
-
it 'not supported' do
|
68
|
-
expect{subject.config('lxc.lxcpath')}.to raise_error(Vagrant::LXC::Errors::CommandNotSupported)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
describe 'lxc version before after 1.x.x'do
|
73
|
-
let(:support_version_command?) { false }
|
51
|
+
describe 'lxc version after 1.x.x'do
|
74
52
|
let(:lxc_config_out) { "/var/lib/lxc\n" }
|
75
53
|
let(:lxc_version_out) { "1.0.0\n" }
|
76
54
|
|
@@ -232,13 +210,6 @@ describe Vagrant::LXC::Driver::CLI do
|
|
232
210
|
subject.attach *(command + [{namespaces: ['network', 'mount']}])
|
233
211
|
expect(subject).to have_received(:run).with(:attach, '--name', name, '--namespaces', 'NETWORK|MOUNT', '--', *command)
|
234
212
|
end
|
235
|
-
|
236
|
-
it 'raises a NamespacesNotSupported error if not supported' do
|
237
|
-
allow(subject).to receive(:run).with(:attach, '-h', :show_stderr => true).and_return({:stdout => '', :stderr => 'not supported'})
|
238
|
-
expect {
|
239
|
-
subject.attach *(command + [{namespaces: ['network', 'mount']}])
|
240
|
-
}.to raise_error(Vagrant::LXC::Errors::NamespacesNotSupported)
|
241
|
-
end
|
242
213
|
end
|
243
214
|
|
244
215
|
describe 'transition block' do
|
data/spec/unit/driver_spec.rb
CHANGED
@@ -89,7 +89,7 @@ describe Vagrant::LXC::Driver do
|
|
89
89
|
describe 'start' do
|
90
90
|
let(:customizations) { [['a', '1'], ['b', '2']] }
|
91
91
|
let(:internal_customization) { ['internal', 'customization'] }
|
92
|
-
let(:cli) { double(Vagrant::LXC::Driver::CLI, start: true
|
92
|
+
let(:cli) { double(Vagrant::LXC::Driver::CLI, start: true) }
|
93
93
|
let(:sudo) { double(Vagrant::LXC::SudoWrapper) }
|
94
94
|
|
95
95
|
subject { described_class.new('name', sudo, cli) }
|
@@ -99,6 +99,7 @@ describe Vagrant::LXC::Driver do
|
|
99
99
|
and_return('# CONFIGURATION')
|
100
100
|
sudo.should_receive(:run).twice.with('cp', '-f', %r{/(run|tmp)/.*}, '/var/lib/lxc/name/config')
|
101
101
|
sudo.should_receive(:run).twice.with('chown', 'root:root', '/var/lib/lxc/name/config')
|
102
|
+
expect(cli).to receive(:config).with("lxc.lxcpath").and_return("/var/lib/lxc")
|
102
103
|
|
103
104
|
subject.customizations << internal_customization
|
104
105
|
subject.start(customizations)
|
@@ -152,21 +153,11 @@ describe Vagrant::LXC::Driver do
|
|
152
153
|
end
|
153
154
|
|
154
155
|
describe 'containers_path' do
|
155
|
-
let(:cli) { double(Vagrant::LXC::Driver::CLI, config: cli_config_value
|
156
|
+
let(:cli) { double(Vagrant::LXC::Driver::CLI, config: cli_config_value) }
|
156
157
|
|
157
158
|
subject { described_class.new('name', nil, cli) }
|
158
159
|
|
159
|
-
describe 'lxc version before 1.x.x' do
|
160
|
-
let(:cli_support_config_command_value) { false }
|
161
|
-
let(:cli_config_value) { '/var/lib/lxc' }
|
162
|
-
|
163
|
-
it 'delegates to cli' do
|
164
|
-
expect(subject.containers_path).to eq(cli_config_value)
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
160
|
describe 'lxc version after 1.x.x' do
|
169
|
-
let(:cli_support_config_command_value) { true }
|
170
161
|
let(:cli_config_value) { '/etc/lxc' }
|
171
162
|
|
172
163
|
it 'delegates to cli' do
|
data/templates/sudoers.rb.erb
CHANGED
@@ -109,6 +109,7 @@ Whitelist.add_regex %r{<%= pipework_regex %>}, '**'
|
|
109
109
|
Whitelist.add '<%= cmd_paths['lxc_bin'] %>/lxc-version'
|
110
110
|
Whitelist.add '<%= cmd_paths['lxc_bin'] %>/lxc-ls'
|
111
111
|
Whitelist.add '<%= cmd_paths['lxc_bin'] %>/lxc-info', '--name', /.*/
|
112
|
+
Whitelist.add '<%= cmd_paths['lxc_bin'] %>/lxc-info', '--name', /.*/, '-iH'
|
112
113
|
Whitelist.add '<%= cmd_paths['lxc_bin'] %>/lxc-create', '-B', /.*/, '--template', /.*/, '--name', /.*/, '**'
|
113
114
|
Whitelist.add '<%= cmd_paths['lxc_bin'] %>/lxc-create', '--version'
|
114
115
|
Whitelist.add '<%= cmd_paths['lxc_bin'] %>/lxc-destroy', '--name', /.*/
|
@@ -118,6 +119,7 @@ Whitelist.add '<%= cmd_paths['lxc_bin'] %>/lxc-shutdown', '--name', /.*/
|
|
118
119
|
Whitelist.add '<%= cmd_paths['lxc_bin'] %>/lxc-attach', '--name', /.*/, '**'
|
119
120
|
Whitelist.add '<%= cmd_paths['lxc_bin'] %>/lxc-attach', '-h'
|
120
121
|
Whitelist.add '<%= cmd_paths['lxc_bin'] %>/lxc-config', 'lxc.lxcpath'
|
122
|
+
Whitelist.add '<%= cmd_paths['lxc_bin'] %>/lxc-update-config', '-c', /.*/
|
121
123
|
|
122
124
|
##
|
123
125
|
# Commands from driver/action/remove_temporary_files.rb
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-lxc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fabio Rehm
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Linux Containers provider for Vagrant
|
14
14
|
email:
|
@@ -25,7 +25,6 @@ files:
|
|
25
25
|
- CHANGELOG.md
|
26
26
|
- CONTRIBUTING.md
|
27
27
|
- Gemfile
|
28
|
-
- Gemfile.lock
|
29
28
|
- Guardfile
|
30
29
|
- LICENSE.txt
|
31
30
|
- README.md
|
@@ -38,8 +37,7 @@ files:
|
|
38
37
|
- lib/vagrant-lxc/action/create.rb
|
39
38
|
- lib/vagrant-lxc/action/destroy.rb
|
40
39
|
- lib/vagrant-lxc/action/destroy_confirm.rb
|
41
|
-
- lib/vagrant-lxc/action/
|
42
|
-
- lib/vagrant-lxc/action/fetch_ip_with_lxc_attach.rb
|
40
|
+
- lib/vagrant-lxc/action/fetch_ip_with_lxc_info.rb
|
43
41
|
- lib/vagrant-lxc/action/forced_halt.rb
|
44
42
|
- lib/vagrant-lxc/action/forward_ports.rb
|
45
43
|
- lib/vagrant-lxc/action/gc_private_network_bridges.rb
|
@@ -47,6 +45,7 @@ files:
|
|
47
45
|
- lib/vagrant-lxc/action/prepare_nfs_settings.rb
|
48
46
|
- lib/vagrant-lxc/action/prepare_nfs_valid_ids.rb
|
49
47
|
- lib/vagrant-lxc/action/private_networks.rb
|
48
|
+
- lib/vagrant-lxc/action/remove_temporary_files.rb
|
50
49
|
- lib/vagrant-lxc/action/setup_package_files.rb
|
51
50
|
- lib/vagrant-lxc/action/warn_networks.rb
|
52
51
|
- lib/vagrant-lxc/command/root.rb
|
data/Gemfile.lock
DELETED
@@ -1,182 +0,0 @@
|
|
1
|
-
GIT
|
2
|
-
remote: https://github.com/fgrehm/vagrant-cachier.git
|
3
|
-
revision: 40dddfb368526948e769492a00a7937c5a044a4d
|
4
|
-
specs:
|
5
|
-
vagrant-cachier (1.2.1)
|
6
|
-
|
7
|
-
GIT
|
8
|
-
remote: https://github.com/fgrehm/vagrant-pristine.git
|
9
|
-
revision: 6d044265db17451c606f000bf43437e95a742bb4
|
10
|
-
specs:
|
11
|
-
vagrant-pristine (0.3.0)
|
12
|
-
|
13
|
-
GIT
|
14
|
-
remote: https://github.com/mitchellh/vagrant-spec.git
|
15
|
-
revision: 1df5a3af81cb7cce568b2eac52b8f6822bcb1d8e
|
16
|
-
specs:
|
17
|
-
vagrant-spec (0.0.1)
|
18
|
-
childprocess (~> 0.5.0)
|
19
|
-
log4r (~> 1.1.9)
|
20
|
-
rspec (~> 2.14)
|
21
|
-
thor (~> 0.18.1)
|
22
|
-
|
23
|
-
GIT
|
24
|
-
remote: https://github.com/mitchellh/vagrant.git
|
25
|
-
revision: 78ea5e4a78ce644717ab16d8001ab77430168f0f
|
26
|
-
tag: v1.7.4
|
27
|
-
specs:
|
28
|
-
vagrant (1.7.4)
|
29
|
-
bundler (>= 1.5.2, <= 1.10.5)
|
30
|
-
childprocess (~> 0.5.0)
|
31
|
-
erubis (~> 2.7.0)
|
32
|
-
hashicorp-checkpoint (~> 0.1.1)
|
33
|
-
i18n (>= 0.6.0, <= 0.8.0)
|
34
|
-
listen (~> 3.0.2)
|
35
|
-
log4r (~> 1.1.9, < 1.1.11)
|
36
|
-
net-scp (~> 1.1.0)
|
37
|
-
net-sftp (~> 2.1)
|
38
|
-
net-ssh (>= 2.6.6, < 2.10.0)
|
39
|
-
nokogiri (= 1.6.3.1)
|
40
|
-
rb-kqueue (~> 0.2.0)
|
41
|
-
rest-client (>= 1.6.0, < 2.0)
|
42
|
-
wdm (~> 0.1.0)
|
43
|
-
winrm (~> 1.3)
|
44
|
-
winrm-fs (~> 0.2.0)
|
45
|
-
|
46
|
-
PATH
|
47
|
-
remote: .
|
48
|
-
specs:
|
49
|
-
vagrant-lxc (1.2.4)
|
50
|
-
|
51
|
-
GEM
|
52
|
-
remote: https://rubygems.org/
|
53
|
-
specs:
|
54
|
-
builder (3.2.2)
|
55
|
-
childprocess (0.5.6)
|
56
|
-
ffi (~> 1.0, >= 1.0.11)
|
57
|
-
coderay (1.1.0)
|
58
|
-
coveralls (0.7.2)
|
59
|
-
multi_json (~> 1.3)
|
60
|
-
rest-client (= 1.6.7)
|
61
|
-
simplecov (>= 0.7)
|
62
|
-
term-ansicolor (= 1.2.2)
|
63
|
-
thor (= 0.18.1)
|
64
|
-
diff-lcs (1.2.5)
|
65
|
-
docile (1.1.5)
|
66
|
-
erubis (2.7.0)
|
67
|
-
ffi (1.9.10)
|
68
|
-
formatador (0.2.5)
|
69
|
-
gssapi (1.2.0)
|
70
|
-
ffi (>= 1.0.1)
|
71
|
-
guard (2.12.8)
|
72
|
-
formatador (>= 0.2.4)
|
73
|
-
listen (>= 2.7, <= 4.0)
|
74
|
-
lumberjack (~> 1.0)
|
75
|
-
nenv (~> 0.1)
|
76
|
-
notiffany (~> 0.0)
|
77
|
-
pry (>= 0.9.12)
|
78
|
-
shellany (~> 0.0)
|
79
|
-
thor (>= 0.18.1)
|
80
|
-
guard-compat (1.2.1)
|
81
|
-
guard-rspec (4.6.2)
|
82
|
-
guard (~> 2.1)
|
83
|
-
guard-compat (~> 1.1)
|
84
|
-
rspec (>= 2.99.0, < 4.0)
|
85
|
-
gyoku (1.3.1)
|
86
|
-
builder (>= 2.1.2)
|
87
|
-
hashicorp-checkpoint (0.1.4)
|
88
|
-
httpclient (2.6.0.1)
|
89
|
-
i18n (0.7.0)
|
90
|
-
json (1.8.3)
|
91
|
-
listen (3.0.2)
|
92
|
-
rb-fsevent (>= 0.9.3)
|
93
|
-
rb-inotify (>= 0.9)
|
94
|
-
little-plugger (1.1.3)
|
95
|
-
log4r (1.1.10)
|
96
|
-
logging (1.8.2)
|
97
|
-
little-plugger (>= 1.1.3)
|
98
|
-
multi_json (>= 1.8.4)
|
99
|
-
lumberjack (1.0.9)
|
100
|
-
method_source (0.8.2)
|
101
|
-
mime-types (2.6.1)
|
102
|
-
mini_portile (0.6.0)
|
103
|
-
multi_json (1.11.2)
|
104
|
-
nenv (0.2.0)
|
105
|
-
net-scp (1.1.2)
|
106
|
-
net-ssh (>= 2.6.5)
|
107
|
-
net-sftp (2.1.2)
|
108
|
-
net-ssh (>= 2.6.5)
|
109
|
-
net-ssh (2.9.2)
|
110
|
-
nokogiri (1.6.3.1)
|
111
|
-
mini_portile (= 0.6.0)
|
112
|
-
nori (2.6.0)
|
113
|
-
notiffany (0.0.6)
|
114
|
-
nenv (~> 0.1)
|
115
|
-
shellany (~> 0.0)
|
116
|
-
pry (0.10.1)
|
117
|
-
coderay (~> 1.1.0)
|
118
|
-
method_source (~> 0.8.1)
|
119
|
-
slop (~> 3.4)
|
120
|
-
rake (10.4.2)
|
121
|
-
rb-fsevent (0.9.5)
|
122
|
-
rb-inotify (0.9.5)
|
123
|
-
ffi (>= 0.5.0)
|
124
|
-
rb-kqueue (0.2.4)
|
125
|
-
ffi (>= 0.5.0)
|
126
|
-
rest-client (1.6.7)
|
127
|
-
mime-types (>= 1.16)
|
128
|
-
rspec (2.99.0)
|
129
|
-
rspec-core (~> 2.99.0)
|
130
|
-
rspec-expectations (~> 2.99.0)
|
131
|
-
rspec-mocks (~> 2.99.0)
|
132
|
-
rspec-core (2.99.2)
|
133
|
-
rspec-expectations (2.99.2)
|
134
|
-
diff-lcs (>= 1.1.3, < 2.0)
|
135
|
-
rspec-mocks (2.99.4)
|
136
|
-
rubyntlm (0.4.0)
|
137
|
-
rubyzip (1.1.7)
|
138
|
-
shellany (0.0.1)
|
139
|
-
simplecov (0.10.0)
|
140
|
-
docile (~> 1.1.0)
|
141
|
-
json (~> 1.8)
|
142
|
-
simplecov-html (~> 0.10.0)
|
143
|
-
simplecov-html (0.10.0)
|
144
|
-
slop (3.6.0)
|
145
|
-
term-ansicolor (1.2.2)
|
146
|
-
tins (~> 0.8)
|
147
|
-
thor (0.18.1)
|
148
|
-
tins (0.13.2)
|
149
|
-
uuidtools (2.1.5)
|
150
|
-
vagrant-omnibus (1.4.1)
|
151
|
-
wdm (0.1.1)
|
152
|
-
winrm (1.3.3)
|
153
|
-
builder (>= 2.1.2)
|
154
|
-
gssapi (~> 1.2)
|
155
|
-
gyoku (~> 1.0)
|
156
|
-
httpclient (~> 2.2, >= 2.2.0.2)
|
157
|
-
logging (~> 1.6, >= 1.6.1)
|
158
|
-
nori (~> 2.0)
|
159
|
-
rubyntlm (~> 0.4.0)
|
160
|
-
uuidtools (~> 2.1.2)
|
161
|
-
winrm-fs (0.2.0)
|
162
|
-
erubis (~> 2.7)
|
163
|
-
logging (~> 1.6, >= 1.6.1)
|
164
|
-
rubyzip (~> 1.1)
|
165
|
-
winrm (~> 1.3.0)
|
166
|
-
|
167
|
-
PLATFORMS
|
168
|
-
ruby
|
169
|
-
|
170
|
-
DEPENDENCIES
|
171
|
-
coveralls
|
172
|
-
guard
|
173
|
-
guard-rspec
|
174
|
-
rake
|
175
|
-
rb-inotify
|
176
|
-
rspec (= 2.99.0)
|
177
|
-
vagrant!
|
178
|
-
vagrant-cachier!
|
179
|
-
vagrant-lxc!
|
180
|
-
vagrant-omnibus
|
181
|
-
vagrant-pristine!
|
182
|
-
vagrant-spec!
|
@@ -1,49 +0,0 @@
|
|
1
|
-
module Vagrant
|
2
|
-
module LXC
|
3
|
-
module Action
|
4
|
-
class FetchIpFromDnsmasqLeases
|
5
|
-
def initialize(app, env)
|
6
|
-
@app = app
|
7
|
-
@logger = Log4r::Logger.new("vagrant::lxc::action::fetch_ip_from_dnsmasq_leases")
|
8
|
-
end
|
9
|
-
|
10
|
-
def call(env)
|
11
|
-
env[:machine_ip] ||= assigned_ip(env)
|
12
|
-
@app.call(env)
|
13
|
-
end
|
14
|
-
|
15
|
-
def assigned_ip(env)
|
16
|
-
mac_address = env[:machine].provider.driver.mac_address
|
17
|
-
ip = nil
|
18
|
-
10.times do
|
19
|
-
dnsmasq_leases = read_dnsmasq_leases
|
20
|
-
@logger.debug "Attempting to load ip from dnsmasq leases (mac: #{mac_address})"
|
21
|
-
@logger.debug dnsmasq_leases
|
22
|
-
if dnsmasq_leases =~ /#{Regexp.escape mac_address.to_s}\s+([0-9.]+)\s+/i
|
23
|
-
ip = $1.to_s
|
24
|
-
break
|
25
|
-
else
|
26
|
-
@logger.debug 'Ip could not be parsed from dnsmasq leases file'
|
27
|
-
sleep 2
|
28
|
-
end
|
29
|
-
end
|
30
|
-
ip
|
31
|
-
end
|
32
|
-
|
33
|
-
LEASES_PATHS = %w(
|
34
|
-
/var/lib/misc/dnsmasq.*.leases
|
35
|
-
/var/lib/misc/dnsmasq.leases
|
36
|
-
/var/lib/dnsmasq/dnsmasq.leases
|
37
|
-
/var/db/dnsmasq.leases
|
38
|
-
/var/lib/libvirt/dnsmasq/*.leases
|
39
|
-
)
|
40
|
-
|
41
|
-
def read_dnsmasq_leases
|
42
|
-
Dir["{#{LEASES_PATHS.join(',')}}"].map do |file|
|
43
|
-
File.read(file)
|
44
|
-
end.join("\n")
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|