vagrant-lxc 0.7.0 → 0.8.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/CHANGELOG.md +23 -2
- data/Gemfile.lock +7 -7
- data/LICENSE.txt +1 -1
- data/README.md +23 -14
- data/lib/vagrant-lxc/action/create.rb +14 -3
- data/lib/vagrant-lxc/config.rb +6 -0
- data/lib/vagrant-lxc/driver.rb +6 -1
- data/lib/vagrant-lxc/driver/cli.rb +8 -1
- data/lib/vagrant-lxc/errors.rb +13 -0
- data/lib/vagrant-lxc/provider.rb +3 -1
- data/lib/vagrant-lxc/sudo_wrapper.rb +2 -1
- data/lib/vagrant-lxc/version.rb +1 -1
- data/locales/en.yml +5 -0
- data/spec/unit/driver/cli_spec.rb +23 -11
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee93b037eb8ad8145d874a64f28a585bba51ab3f
|
4
|
+
data.tar.gz: 41040fa650a3be3ec3bf59c9f8eed18a9a84cdfa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48855758f0ed808c6caa4a5c48852811c128e0ab223204f2b01b5091695475e541d15283a3588d1202b795460e1d02086d1c622a2148d4a9adddfdde252460a0
|
7
|
+
data.tar.gz: 25e57b7957bec28488416a534313cf431147c88cf131549b163b37ec823f427f00beef8ffa716d7f1f01ffaf477035c219e925b8f5b3ca12f9a8e8be6d5eff24
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,21 @@
|
|
1
|
-
## [0.
|
1
|
+
## [0.8.0](https://github.com/fgrehm/vagrant-lxc/compare/v0.7.0...v0.8.0) (Feb 26, 2014)
|
2
|
+
|
3
|
+
FEATURES:
|
4
|
+
|
5
|
+
- Support for naming containers from Vagrantfiles [#132](https://github.com/fgrehm/vagrant-lxc/issues/132)
|
6
|
+
|
7
|
+
IMPROVEMENTS:
|
8
|
+
|
9
|
+
- Use a safer random name for containers [#152](https://github.com/fgrehm/vagrant-lxc/issues/152)
|
10
|
+
- Improve Ubuntu 13.10 compatibility [#190](https://github.com/fgrehm/vagrant-lxc/pull/190) / [#197](https://github.com/fgrehm/vagrant-lxc/pull/197)
|
11
|
+
- Improved mac address detection from lxc configs [#226](https://github.com/fgrehm/vagrant-lxc/pull/226)
|
12
|
+
|
13
|
+
BUG FIXES:
|
14
|
+
|
15
|
+
- Properly detect if lxc is installed on hosts that do not have `lxc-version` on their paths [#186](https://github.com/fgrehm/vagrant-lxc/issues/186)
|
16
|
+
|
17
|
+
|
18
|
+
## [0.7.0](https://github.com/fgrehm/vagrant-lxc/compare/v0.6.4...v0.7.0) (Nov 8, 2013)
|
2
19
|
|
3
20
|
IMPROVEMENTS:
|
4
21
|
|
@@ -8,7 +25,7 @@ IMPROVEMENTS:
|
|
8
25
|
|
9
26
|
BUG FIXES:
|
10
27
|
|
11
|
-
-
|
28
|
+
- Nicely handle blank strings provided to `:host_ip` when specifying forwarded ports [#170](https://github.com/fgrehm/vagrant-lxc/issues/170)
|
12
29
|
- Fix "Permission denied" when starting/destroying containers after lxc
|
13
30
|
security update in Ubuntu [#180](https://github.com/fgrehm/vagrant-lxc/issues/180)
|
14
31
|
- Fix `vagrant package` [#172](https://github.com/fgrehm/vagrant-lxc/issues/172)
|
@@ -16,6 +33,10 @@ BUG FIXES:
|
|
16
33
|
|
17
34
|
## [0.6.4](https://github.com/fgrehm/vagrant-lxc/compare/v0.6.3...v0.6.4) (Oct 27, 2013)
|
18
35
|
|
36
|
+
FEATURES:
|
37
|
+
|
38
|
+
- New script for building OpenMandriva base boxes [#167](https://github.com/fgrehm/vagrant-lxc/issues/167)
|
39
|
+
|
19
40
|
IMPROVEMENTS:
|
20
41
|
|
21
42
|
- Make `lxc-template` compatible with Ubuntu 13.10 [#150](https://github.com/fgrehm/vagrant-lxc/issues/150)
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
GIT
|
2
2
|
remote: git://github.com/fgrehm/vagrant-cachier.git
|
3
|
-
revision:
|
3
|
+
revision: a9f41c5f01297773f209c0525400e22704b40c93
|
4
4
|
specs:
|
5
|
-
vagrant-cachier (0.
|
5
|
+
vagrant-cachier (0.5.0)
|
6
6
|
|
7
7
|
GIT
|
8
8
|
remote: git://github.com/fgrehm/vagrant-pristine.git
|
@@ -25,7 +25,7 @@ GIT
|
|
25
25
|
PATH
|
26
26
|
remote: .
|
27
27
|
specs:
|
28
|
-
vagrant-lxc (0.
|
28
|
+
vagrant-lxc (0.8.0)
|
29
29
|
|
30
30
|
GEM
|
31
31
|
remote: https://rubygems.org/
|
@@ -41,7 +41,7 @@ GEM
|
|
41
41
|
simplecov (>= 0.7)
|
42
42
|
term-ansicolor
|
43
43
|
thor
|
44
|
-
diff-lcs (1.2.
|
44
|
+
diff-lcs (1.2.5)
|
45
45
|
erubis (2.7.0)
|
46
46
|
ffi (1.9.3)
|
47
47
|
formatador (0.2.4)
|
@@ -84,8 +84,8 @@ GEM
|
|
84
84
|
rspec-core (2.13.1)
|
85
85
|
rspec-expectations (2.13.0)
|
86
86
|
diff-lcs (>= 1.1.3, < 2.0)
|
87
|
-
rspec-fire (1.
|
88
|
-
rspec (
|
87
|
+
rspec-fire (1.3.0)
|
88
|
+
rspec (>= 2.11, < 4)
|
89
89
|
rspec-mocks (2.13.1)
|
90
90
|
rspec-spies (2.1.4)
|
91
91
|
rspec (~> 2.0)
|
@@ -98,7 +98,7 @@ GEM
|
|
98
98
|
tins (~> 0.8)
|
99
99
|
thor (0.18.1)
|
100
100
|
timers (1.1.0)
|
101
|
-
tins (0.
|
101
|
+
tins (0.13.0)
|
102
102
|
vagrant-omnibus (1.1.2)
|
103
103
|
|
104
104
|
PLATFORMS
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# vagrant-lxc
|
2
2
|
|
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)
|
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://www.gittip.com/fgrehm/)
|
4
4
|
|
5
5
|
[LXC](http://lxc.sourceforge.net/) provider for [Vagrant](http://www.vagrantup.com/) 1.1+
|
6
6
|
|
@@ -23,7 +23,7 @@ to see it in action.
|
|
23
23
|
* [Vagrant 1.1+](http://downloads.vagrantup.com/)
|
24
24
|
* lxc 0.7.5+
|
25
25
|
* redir (if you are planning to use port forwarding)
|
26
|
-
* A [
|
26
|
+
* A [kernel != 3.5.0-17.28](https://github.com/fgrehm/vagrant-lxc/wiki/Troubleshooting#wiki-im-unable-to-restart-containers)
|
27
27
|
|
28
28
|
The plugin is known to work better and pretty much out of the box on Ubuntu 12.04+
|
29
29
|
hosts and installing the dependencies on it basically means a `apt-get install lxc lxc-templates cgroup-lite redir`
|
@@ -55,7 +55,7 @@ vagrant plugin install vagrant-lxc
|
|
55
55
|
After installing, add a [base box](#base-boxes) using any name you want, for example:
|
56
56
|
|
57
57
|
```
|
58
|
-
vagrant box add quantal64 http://bit.ly/vagrant-lxc-quantal64-2013-
|
58
|
+
vagrant box add quantal64 http://bit.ly/vagrant-lxc-quantal64-2013-10-23
|
59
59
|
```
|
60
60
|
|
61
61
|
Then create a Vagrantfile that looks like the following, changing the box name
|
@@ -95,11 +95,30 @@ prior to starting it.
|
|
95
95
|
|
96
96
|
For other configuration options, please check the [lxc.conf manpages](http://manpages.ubuntu.com/manpages/quantal/man5/lxc.conf.5.html).
|
97
97
|
|
98
|
+
### Container naming
|
99
|
+
|
100
|
+
By default vagrant-lxc will attempt to generate a unique container name
|
101
|
+
for you. However, if the container name is important to you, you may use the
|
102
|
+
`container_name` attribute to set it explicitly from the `provider` block:
|
103
|
+
|
104
|
+
```ruby
|
105
|
+
Vagrant.configure("2") do |config|
|
106
|
+
config.vm.box = "quantal64"
|
107
|
+
|
108
|
+
config.vm.define "db" do |node|
|
109
|
+
node.vm.provider :lxc do |lxc|
|
110
|
+
lxc.container_name = :machine # Sets the container name to 'db'
|
111
|
+
lxc.container_name = 'mysql' # Sets the container name to 'mysql'
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
```
|
116
|
+
|
98
117
|
### Avoiding `sudo` passwords
|
99
118
|
|
100
119
|
This plugin requires **a lot** of `sudo`ing since [user namespaces](https://wiki.ubuntu.com/UserNamespace)
|
101
120
|
are not supported on mainstream kernels. Have a look at the [Wiki](https://github.com/fgrehm/vagrant-lxc/wiki/Avoiding-'sudo'-passwords)
|
102
|
-
to find out how to work around that specially if you are running an OS with sudo
|
121
|
+
to find out how to work around that specially if you are running an OS with `sudo`
|
103
122
|
< 1.8.4 (like Ubuntu 12.04) as you might be affected by a bug.
|
104
123
|
|
105
124
|
### Base boxes
|
@@ -123,14 +142,6 @@ list if you have a problem and feel free to use the [issue tracker](https://gith
|
|
123
142
|
propose new functionality and / or report bugs.
|
124
143
|
|
125
144
|
|
126
|
-
## Support
|
127
|
-
|
128
|
-
Support this project and [others by fgrehm](https://github.com/fgrehm)
|
129
|
-
via [gittip](https://www.gittip.com/fgrehm/).
|
130
|
-
|
131
|
-
[](https://www.gittip.com/fgrehm/)
|
132
|
-
|
133
|
-
|
134
145
|
## Contributing
|
135
146
|
|
136
147
|
1. Fork it
|
@@ -138,5 +149,3 @@ via [gittip](https://www.gittip.com/fgrehm/).
|
|
138
149
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
139
150
|
4. Push to the branch (`git push origin my-new-feature`)
|
140
151
|
5. Create new Pull Request
|
141
|
-
|
142
|
-
[](https://bitdeli.com/free "Bitdeli Badge")
|
@@ -7,9 +7,20 @@ module Vagrant
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def call(env)
|
10
|
-
container_name =
|
11
|
-
|
12
|
-
container_name
|
10
|
+
container_name = env[:machine].provider_config.container_name
|
11
|
+
|
12
|
+
case container_name
|
13
|
+
when :machine
|
14
|
+
container_name = env[:machine].name.to_s
|
15
|
+
when String
|
16
|
+
# Nothing to do here, move along...
|
17
|
+
else
|
18
|
+
container_name = "#{env[:root_path].basename}_#{env[:machine].name}"
|
19
|
+
container_name.gsub!(/[^-a-z0-9_]/i, "")
|
20
|
+
# milliseconds + random number suffix to allow for simultaneous
|
21
|
+
# `vagrant up` of the same box in different dirs
|
22
|
+
container_name << "_#{(Time.now.to_f * 1000.0).to_i}_#{rand(100000)}"
|
23
|
+
end
|
13
24
|
|
14
25
|
env[:machine].provider.driver.create(
|
15
26
|
container_name,
|
data/lib/vagrant-lxc/config.rb
CHANGED
@@ -12,9 +12,14 @@ module Vagrant
|
|
12
12
|
# on /etc/sudoers
|
13
13
|
attr_accessor :sudo_wrapper
|
14
14
|
|
15
|
+
# A string to explicitly set the container name. To use the vagrant
|
16
|
+
# machine name, set this to :machine
|
17
|
+
attr_accessor :container_name
|
18
|
+
|
15
19
|
def initialize
|
16
20
|
@customizations = []
|
17
21
|
@sudo_wrapper = UNSET_VALUE
|
22
|
+
@container_name = UNSET_VALUE
|
18
23
|
end
|
19
24
|
|
20
25
|
# Customize the container by calling `lxc-start` with the given
|
@@ -34,6 +39,7 @@ module Vagrant
|
|
34
39
|
|
35
40
|
def finalize!
|
36
41
|
@sudo_wrapper = nil if @sudo_wrapper == UNSET_VALUE
|
42
|
+
@container_name = nil if @container_name == UNSET_VALUE
|
37
43
|
end
|
38
44
|
|
39
45
|
def validate(machine)
|
data/lib/vagrant-lxc/driver.rb
CHANGED
@@ -40,7 +40,7 @@ module Vagrant
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def mac_address
|
43
|
-
@mac_address ||= config_string.match(/^lxc\.network\.hwaddr\s
|
43
|
+
@mac_address ||= config_string.match(/^lxc\.network\.hwaddr\s*+=\s*+(.+)$/)[1]
|
44
44
|
end
|
45
45
|
|
46
46
|
def config_string
|
@@ -111,6 +111,11 @@ module Vagrant
|
|
111
111
|
target_path = "#{Dir.mktmpdir}/rootfs.tar.gz"
|
112
112
|
|
113
113
|
@logger.info "Compressing '#{rootfs_path}' rootfs to #{target_path}"
|
114
|
+
# "vagrant package" will copy the existing lxc-template in the new box file
|
115
|
+
# To keep this function backwards compatible with existing boxes, the path
|
116
|
+
# included in the tarball needs to have the same amount of path components (2)
|
117
|
+
# that will be stripped before extraction, hence the './.'
|
118
|
+
# TODO: This should be reviewed before 1.0
|
114
119
|
cmds = [
|
115
120
|
"cd #{base_path}",
|
116
121
|
"rm -f rootfs.tar.gz",
|
@@ -38,7 +38,7 @@ module Vagrant
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def state
|
41
|
-
if @name && run(:info, '--name', @name, retryable: true) =~ /^state:[^A-Z]+([A-Z]+)$/
|
41
|
+
if @name && run(:info, '--name', @name, retryable: true) =~ /^state:[^A-Z]+([A-Z]+)$/i
|
42
42
|
$1.downcase.to_sym
|
43
43
|
elsif @name
|
44
44
|
:unknown
|
@@ -58,6 +58,12 @@ module Vagrant
|
|
58
58
|
'--name', @name,
|
59
59
|
*(config_opts),
|
60
60
|
*extra
|
61
|
+
rescue Errors::ExecuteError => e
|
62
|
+
if e.stderr =~ /already exists/i
|
63
|
+
raise Errors::ContainerAlreadyExists, name: @name
|
64
|
+
else
|
65
|
+
raise
|
66
|
+
end
|
61
67
|
end
|
62
68
|
|
63
69
|
def destroy
|
@@ -69,6 +75,7 @@ module Vagrant
|
|
69
75
|
end
|
70
76
|
|
71
77
|
def stop
|
78
|
+
attach '/sbin/halt'
|
72
79
|
run :stop, '--name', @name
|
73
80
|
end
|
74
81
|
|
data/lib/vagrant-lxc/errors.rb
CHANGED
@@ -5,7 +5,16 @@ module Vagrant
|
|
5
5
|
module Errors
|
6
6
|
class ExecuteError < Vagrant::Errors::VagrantError
|
7
7
|
error_key(:lxc_execute_error)
|
8
|
+
attr_reader :stderr, :stdout
|
9
|
+
def initialize(message, *args)
|
10
|
+
super
|
11
|
+
if message.is_a?(Hash)
|
12
|
+
@stderr = message[:stderr]
|
13
|
+
@stdout = message[:stdout]
|
14
|
+
end
|
15
|
+
end
|
8
16
|
end
|
17
|
+
|
9
18
|
class NamespacesNotSupported < Vagrant::Errors::VagrantError
|
10
19
|
end
|
11
20
|
|
@@ -13,6 +22,10 @@ module Vagrant
|
|
13
22
|
error_key(:lxc_not_installed)
|
14
23
|
end
|
15
24
|
|
25
|
+
class ContainerAlreadyExists < Vagrant::Errors::VagrantError
|
26
|
+
error_key(:lxc_container_already_exists)
|
27
|
+
end
|
28
|
+
|
16
29
|
# Box related errors
|
17
30
|
class TemplateFileMissing < Vagrant::Errors::VagrantError
|
18
31
|
error_key(:lxc_template_file_missing)
|
data/lib/vagrant-lxc/provider.rb
CHANGED
@@ -51,7 +51,8 @@ module Vagrant
|
|
51
51
|
if @interrupted
|
52
52
|
@logger.info("Exit code != 0, but interrupted. Ignoring.")
|
53
53
|
else
|
54
|
-
raise LXC::Errors::ExecuteError,
|
54
|
+
raise LXC::Errors::ExecuteError,
|
55
|
+
command: command.inspect, stderr: r.stderr, stdout: r.stdout
|
55
56
|
end
|
56
57
|
end
|
57
58
|
end
|
data/lib/vagrant-lxc/version.rb
CHANGED
data/locales/en.yml
CHANGED
@@ -60,3 +60,8 @@ en:
|
|
60
60
|
|
61
61
|
lxc_redir_not_installed: |-
|
62
62
|
`redir` is not installed or is not accessible on the PATH.
|
63
|
+
|
64
|
+
lxc_container_already_exists: |-
|
65
|
+
There is container on your system with the same name you've specified
|
66
|
+
on your Vagrantfile (%{name}), please choose a different one or
|
67
|
+
run `lxc-destroy --name %{name}` and try again.
|
@@ -49,20 +49,27 @@ describe Vagrant::LXC::Driver::CLI do
|
|
49
49
|
|
50
50
|
before do
|
51
51
|
subject.stub(:run) { |*args| @run_args = args }
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'issues a lxc-create with provided template, container name and hash of arguments' do
|
52
55
|
subject.create(template, config_file, template_args)
|
56
|
+
subject.should have_received(:run).with(
|
57
|
+
:create,
|
58
|
+
'--template', template,
|
59
|
+
'--name', name,
|
60
|
+
'-f', config_file,
|
61
|
+
'--',
|
62
|
+
'--extra-param', 'param',
|
63
|
+
'--other', 'value'
|
64
|
+
)
|
53
65
|
end
|
54
66
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
'--',
|
62
|
-
'--extra-param', 'param',
|
63
|
-
'--other', 'value'
|
64
|
-
)
|
65
|
-
end
|
67
|
+
it 'wraps a low level error into something more meaningful in case the container already exists' do
|
68
|
+
subject.stub(:run) { raise Vagrant::LXC::Errors::ExecuteError, stderr: 'alreAdy Exists' }
|
69
|
+
expect {
|
70
|
+
subject.create(template, config_file, template_args)
|
71
|
+
}.to raise_error(Vagrant::LXC::Errors::ContainerAlreadyExists)
|
72
|
+
end
|
66
73
|
end
|
67
74
|
|
68
75
|
describe 'destroy' do
|
@@ -134,6 +141,11 @@ describe Vagrant::LXC::Driver::CLI do
|
|
134
141
|
it 'maps the output of lxc-info status out to a symbol' do
|
135
142
|
subject.state.should == :stopped
|
136
143
|
end
|
144
|
+
|
145
|
+
it 'is not case sensitive' do
|
146
|
+
subject.stub(:run).and_return("StatE: STarTED\npid: 2")
|
147
|
+
subject.state.should == :started
|
148
|
+
end
|
137
149
|
end
|
138
150
|
|
139
151
|
describe 'attach' do
|
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: 0.
|
4
|
+
version: 0.8.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: 2014-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Linux Containers provider for Vagrant
|
14
14
|
email:
|
@@ -17,10 +17,10 @@ executables: []
|
|
17
17
|
extensions: []
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
|
-
- .gitignore
|
21
|
-
- .rspec
|
22
|
-
- .travis.yml
|
23
|
-
- .vimrc
|
20
|
+
- ".gitignore"
|
21
|
+
- ".rspec"
|
22
|
+
- ".travis.yml"
|
23
|
+
- ".vimrc"
|
24
24
|
- BOXES.md
|
25
25
|
- CHANGELOG.md
|
26
26
|
- CONTRIBUTING.md
|
@@ -114,17 +114,17 @@ require_paths:
|
|
114
114
|
- lib
|
115
115
|
required_ruby_version: !ruby/object:Gem::Requirement
|
116
116
|
requirements:
|
117
|
-
- -
|
117
|
+
- - ">="
|
118
118
|
- !ruby/object:Gem::Version
|
119
119
|
version: '0'
|
120
120
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- -
|
122
|
+
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
requirements: []
|
126
126
|
rubyforge_project:
|
127
|
-
rubygems_version: 2.
|
127
|
+
rubygems_version: 2.2.2
|
128
128
|
signing_key:
|
129
129
|
specification_version: 4
|
130
130
|
summary: Linux Containers provider for Vagrant
|