vagrant-lxc 0.8.0 → 1.0.0.alpha.1
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/.travis.yml +2 -2
- data/BOXES.md +13 -21
- data/CHANGELOG.md +49 -0
- data/CONTRIBUTING.md +5 -2
- data/Gemfile +12 -13
- data/Gemfile.lock +66 -51
- data/README.md +39 -25
- data/development/Vagrantfile +0 -2
- data/lib/vagrant-backports/README.md +12 -0
- data/lib/vagrant-backports/action/handle_box.rb +1 -0
- data/lib/vagrant-backports/action/is_state.rb +34 -0
- data/lib/vagrant-backports/action/message.rb +20 -0
- data/lib/{vagrant-lxc → vagrant-backports}/action/wait_for_communicator.rb +6 -5
- data/lib/vagrant-backports/ui.rb +12 -0
- data/lib/vagrant-backports/utils.rb +27 -0
- data/lib/vagrant-lxc.rb +8 -0
- data/lib/vagrant-lxc/action.rb +81 -48
- data/lib/vagrant-lxc/action/boot.rb +2 -1
- data/lib/vagrant-lxc/action/fetch_ip_from_dnsmasq_leases.rb +1 -0
- data/lib/vagrant-lxc/action/handle_box_metadata.rb +36 -14
- data/lib/vagrant-lxc/action/message.rb +0 -23
- data/lib/vagrant-lxc/action/prepare_nfs_settings.rb +64 -0
- data/lib/vagrant-lxc/action/prepare_nfs_valid_ids.rb +19 -0
- data/lib/vagrant-lxc/action/setup_package_files.rb +6 -2
- data/lib/vagrant-lxc/{action → backports/action}/share_folders.rb +0 -0
- data/lib/vagrant-lxc/command/root.rb +58 -0
- data/lib/vagrant-lxc/command/sudoers.rb +87 -0
- data/lib/vagrant-lxc/driver.rb +21 -11
- data/lib/vagrant-lxc/plugin.rb +23 -5
- data/lib/vagrant-lxc/provider/cap/public_address.rb +17 -0
- data/lib/vagrant-lxc/synced_folder.rb +42 -0
- data/lib/vagrant-lxc/version.rb +1 -1
- data/locales/en.yml +6 -5
- data/scripts/lxc-template +165 -0
- data/spec/spec_helper.rb +9 -13
- data/spec/unit/action/clear_forwarded_ports_spec.rb +3 -3
- data/spec/unit/action/compress_rootfs_spec.rb +7 -5
- data/spec/unit/action/forward_ports_spec.rb +8 -8
- data/spec/unit/action/handle_box_metadata_spec.rb +71 -15
- data/spec/unit/action/setup_package_files_spec.rb +32 -8
- data/spec/unit/driver/cli_spec.rb +31 -30
- data/spec/unit/driver_spec.rb +35 -27
- data/spec/unit/support/unit_example_group.rb +6 -6
- data/spec/unit_helper.rb +4 -2
- data/tasks/spec.rake +18 -11
- data/vagrant-lxc.gemspec +7 -0
- data/vagrant-spec.config.rb +24 -0
- metadata +24 -36
- data/boxes/build-all.sh +0 -22
- data/boxes/build-debian-box.sh +0 -167
- data/boxes/build-openmandriva-box.sh +0 -159
- data/boxes/build-ubuntu-box.sh +0 -151
- data/boxes/common/cleanup +0 -7
- data/boxes/common/install-babushka +0 -16
- data/boxes/common/install-chef +0 -15
- data/boxes/common/install-puppet +0 -13
- data/boxes/common/install-salt +0 -12
- data/boxes/common/install-salt-debian +0 -28
- data/boxes/common/lxc-template +0 -226
- data/boxes/common/lxc-template-openmandriva +0 -225
- data/boxes/common/lxc.conf +0 -49
- data/boxes/common/metadata.json +0 -5
- data/lib/vagrant-lxc/action/check_created.rb +0 -21
- data/lib/vagrant-lxc/action/check_running.rb +0 -21
- data/lib/vagrant-lxc/action/created.rb +0 -20
- data/lib/vagrant-lxc/action/disconnect.rb +0 -18
- data/lib/vagrant-lxc/action/is_running.rb +0 -19
- data/spec/acceptance/sanity_check_spec.rb +0 -111
- data/spec/acceptance/support/acceptance_example_group.rb +0 -76
- data/spec/acceptance/support/machine_ext.rb +0 -12
- data/spec/acceptance/support/test_ui.rb +0 -22
- data/spec/acceptance_helper.rb +0 -21
data/lib/vagrant-lxc/version.rb
CHANGED
data/locales/en.yml
CHANGED
@@ -12,15 +12,16 @@ en:
|
|
12
12
|
Starting container...
|
13
13
|
force_shutdown: |-
|
14
14
|
Forcing shutdown of container...
|
15
|
-
# TODO: Remove the following keys after we drop support for vagrant < 1.3
|
16
|
-
waiting_for_start: |-
|
17
|
-
Waiting for container to start. This should not take long.
|
18
|
-
container_ready: |-
|
19
|
-
Container started and ready for use!
|
20
15
|
warn_networks: |-
|
21
16
|
Warning! The LXC provider doesn't support any of the Vagrant public / private
|
22
17
|
network configurations (ex: `config.vm.network :private_network, ip: "some-ip"`).
|
23
18
|
They will be silently ignored.
|
19
|
+
warn_group: |-
|
20
|
+
Warning! The LXC provider doesn't support the :group parameter for synced
|
21
|
+
folders. It will be silently ignored.
|
22
|
+
warn_owner: |-
|
23
|
+
Warning! The LXC provider doesn't support the :owner parameter for synced
|
24
|
+
folders. It will be silently ignored.
|
24
25
|
|
25
26
|
vagrant:
|
26
27
|
commands:
|
@@ -0,0 +1,165 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
# This is a modified version of /usr/share/lxc/templates/lxc-download
|
4
|
+
# that comes with ubuntu-lxc 1.0.0 stable from ppa changed to suit vagrant-lxc needs
|
5
|
+
#
|
6
|
+
# Copyright © 2014 Stéphane Graber <stgraber@ubuntu.com>
|
7
|
+
# Copyright © 2014 Fábio Rehm <fgrehm@gmail.com>
|
8
|
+
#
|
9
|
+
# This library is free software; you can redistribute it and/or
|
10
|
+
# modify it under the terms of the GNU Lesser General Public
|
11
|
+
# License as published by the Free Software Foundation; either
|
12
|
+
# version 2.1 of the License, or (at your option) any later version.
|
13
|
+
|
14
|
+
# This library is distributed in the hope that it will be useful,
|
15
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
17
|
+
# Lesser General Public License for more details.
|
18
|
+
|
19
|
+
# You should have received a copy of the GNU Lesser General Public
|
20
|
+
# License along with this library; if not, write to the Free Software
|
21
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
22
|
+
# USA
|
23
|
+
|
24
|
+
set -eu
|
25
|
+
|
26
|
+
LXC_HOOK_DIR="/usr/share/lxc/hooks"
|
27
|
+
LXC_TEMPLATE_CONFIG="/usr/share/lxc/config"
|
28
|
+
|
29
|
+
LXC_MAPPED_GID=
|
30
|
+
LXC_MAPPED_UID=
|
31
|
+
LXC_NAME=
|
32
|
+
LXC_PATH=
|
33
|
+
LXC_ROOTFS=
|
34
|
+
LXC_TARBALL=
|
35
|
+
LXC_CONFIG=
|
36
|
+
|
37
|
+
usage() {
|
38
|
+
cat <<EOF
|
39
|
+
vagrant-lxc default template
|
40
|
+
|
41
|
+
Required arguments:
|
42
|
+
[ --tarball <path> ]: The full path of the rootfs tarball
|
43
|
+
|
44
|
+
Optional arguments:
|
45
|
+
[ --config ]: Configuration file to be used when building the container
|
46
|
+
[ -h | --help ]: This help message
|
47
|
+
|
48
|
+
LXC internal arguments (do not pass manually!):
|
49
|
+
[ --name <name> ]: The container name
|
50
|
+
[ --path <path> ]: The path to the container
|
51
|
+
[ --rootfs <rootfs> ]: The path to the container's rootfs
|
52
|
+
[ --mapped-uid <map> ]: A uid map (user namespaces)
|
53
|
+
[ --mapped-gid <map> ]: A gid map (user namespaces)
|
54
|
+
EOF
|
55
|
+
return 0
|
56
|
+
}
|
57
|
+
|
58
|
+
options=$(getopt -o h -l tarball:,config:,help:,name:,path:,rootfs:,mapped-uid:,mapped-gid: -- "$@")SS
|
59
|
+
|
60
|
+
if [ $? -ne 0 ]; then
|
61
|
+
usage $(basename $0)
|
62
|
+
exit 1
|
63
|
+
fi
|
64
|
+
eval set -- "$options"
|
65
|
+
|
66
|
+
while true
|
67
|
+
do
|
68
|
+
case "$1" in
|
69
|
+
-h|--help) usage $0 && exit 0;;
|
70
|
+
--config) LXC_CONFIG=$2; shift 2;;
|
71
|
+
--tarball) LXC_TARBALL=$2; shift 2;;
|
72
|
+
--name) LXC_NAME=$2; shift 2;;
|
73
|
+
--path) LXC_PATH=$2; shift 2;;
|
74
|
+
--rootfs) LXC_ROOTFS=$2; shift 2;;
|
75
|
+
--mapped-uid) LXC_MAPPED_UID=$2; shift 2;;
|
76
|
+
--mapped-gid) LXC_MAPPED_GID=$2; shift 2;;
|
77
|
+
*) break;;
|
78
|
+
esac
|
79
|
+
done
|
80
|
+
|
81
|
+
if [ -z "${LXC_NAME}" ]; then
|
82
|
+
echo "'name' parameter is required"
|
83
|
+
exit 1
|
84
|
+
fi
|
85
|
+
|
86
|
+
if [ -z "${LXC_TARBALL}" ]; then
|
87
|
+
echo "'tarball' parameter is required"
|
88
|
+
exit 1
|
89
|
+
fi
|
90
|
+
|
91
|
+
if [ -z "${LXC_ROOTFS}" ]; then
|
92
|
+
echo "'rootfs' parameter is required"
|
93
|
+
exit 1
|
94
|
+
fi
|
95
|
+
|
96
|
+
if [ -z "${LXC_CONFIG}" ]; then
|
97
|
+
echo "'config' parameter is required"
|
98
|
+
exit 1
|
99
|
+
fi
|
100
|
+
|
101
|
+
if [ -z "${LXC_PATH}" ]; then
|
102
|
+
echo "'path' parameter is required"
|
103
|
+
exit 1
|
104
|
+
fi
|
105
|
+
|
106
|
+
# Unpack the rootfs
|
107
|
+
echo "Unpacking the rootfs"
|
108
|
+
|
109
|
+
mkdir -p /var/lock/subsys
|
110
|
+
(
|
111
|
+
flock -x 200
|
112
|
+
if [ $? -ne 0 ]; then
|
113
|
+
echo "Cache repository is busy."
|
114
|
+
exit 1
|
115
|
+
fi
|
116
|
+
|
117
|
+
mkdir -p ${LXC_ROOTFS}
|
118
|
+
(cd ${LXC_ROOTFS} && tar xfz ${LXC_TARBALL} --strip-components=2)
|
119
|
+
if [ $? -ne 0 ]; then
|
120
|
+
echo "Failed to extract rootfs"
|
121
|
+
exit 1
|
122
|
+
fi
|
123
|
+
|
124
|
+
) 200>/var/lock/subsys/lxc
|
125
|
+
|
126
|
+
mkdir -p ${LXC_ROOTFS}/dev/pts/
|
127
|
+
|
128
|
+
## Extract all the network config entries
|
129
|
+
sed -i -e "/lxc.network/{w ${LXC_PATH}/config-network" -e "d}" \
|
130
|
+
${LXC_PATH}/config
|
131
|
+
|
132
|
+
## Extract any other config entry
|
133
|
+
sed -i -e "/lxc./{w ${LXC_PATH}/config-auto" -e "d}" ${LXC_PATH}/config
|
134
|
+
|
135
|
+
## Add the container-specific config
|
136
|
+
echo "" >> ${LXC_PATH}/config
|
137
|
+
echo "##############################################" >> ${LXC_PATH}/config
|
138
|
+
echo "# Container specific configuration (automatically set)" >> ${LXC_PATH}/config
|
139
|
+
if [ -e "${LXC_PATH}/config-auto" ]; then
|
140
|
+
cat ${LXC_PATH}/config-auto >> ${LXC_PATH}/config
|
141
|
+
rm ${LXC_PATH}/config-auto
|
142
|
+
fi
|
143
|
+
echo "lxc.utsname = ${LXC_NAME}" >> ${LXC_PATH}/config
|
144
|
+
|
145
|
+
## Re-add the previously removed network config
|
146
|
+
if [ -e "${LXC_PATH}/config-network" ]; then
|
147
|
+
echo "" >> ${LXC_PATH}/config
|
148
|
+
echo "##############################################" >> ${LXC_PATH}/config
|
149
|
+
echo "# Network configuration (automatically set)" >> ${LXC_PATH}/config
|
150
|
+
cat ${LXC_PATH}/config-network >> ${LXC_PATH}/config
|
151
|
+
rm ${LXC_PATH}/config-network
|
152
|
+
fi
|
153
|
+
|
154
|
+
## Append the defaults
|
155
|
+
echo "" >> ${LXC_PATH}/config
|
156
|
+
echo "##############################################" >> ${LXC_PATH}/config
|
157
|
+
echo "# vagrant-lxc base box specific configuration" >> ${LXC_PATH}/config
|
158
|
+
cat ${LXC_CONFIG} >> ${LXC_PATH}/config
|
159
|
+
|
160
|
+
# Empty section for lxc.customize calls from vagrantfile
|
161
|
+
echo "" >> ${LXC_PATH}/config
|
162
|
+
echo "##############################################" >> ${LXC_PATH}/config
|
163
|
+
echo "# vagrant-lxc container specific configuration" >> ${LXC_PATH}/config
|
164
|
+
|
165
|
+
exit 0
|
data/spec/spec_helper.rb
CHANGED
@@ -10,22 +10,10 @@ require 'bundler/setup'
|
|
10
10
|
|
11
11
|
require 'i18n'
|
12
12
|
|
13
|
-
require '
|
13
|
+
require 'vagrant-lxc'
|
14
14
|
|
15
15
|
Dir[File.dirname(__FILE__) + "/support/**/*.rb"].each { |f| require f }
|
16
16
|
|
17
|
-
# If we should verify constant names, eager loads
|
18
|
-
if ENV['VERIFY_CONSTANT_NAMES']
|
19
|
-
require 'vagrant-lxc/plugin'
|
20
|
-
require 'vagrant-lxc/provider'
|
21
|
-
require 'vagrant-lxc/config'
|
22
|
-
end
|
23
|
-
|
24
|
-
require 'rspec/fire'
|
25
|
-
RSpec::Fire.configure do |config|
|
26
|
-
config.verify_constant_names = ENV['VERIFY_CONSTANT_NAMES'] == '1'
|
27
|
-
end
|
28
|
-
|
29
17
|
RSpec.configure do |config|
|
30
18
|
config.treat_symbols_as_metadata_keys_with_true_values = true
|
31
19
|
config.run_all_when_everything_filtered = true
|
@@ -36,4 +24,12 @@ RSpec.configure do |config|
|
|
36
24
|
# the seed, which is printed after each run.
|
37
25
|
# --seed 1234
|
38
26
|
config.order = 'random'
|
27
|
+
|
28
|
+
config.mock_with :rspec do |c|
|
29
|
+
c.yield_receiver_to_any_instance_implementation_blocks = true
|
30
|
+
end
|
31
|
+
config.expect_with :rspec do |c|
|
32
|
+
c.syntax = :expect
|
33
|
+
end
|
34
|
+
config.raise_errors_for_deprecations!
|
39
35
|
end
|
@@ -24,12 +24,12 @@ describe Vagrant::LXC::Action::ClearForwardedPorts do
|
|
24
24
|
after { FileUtils.rm_rf data_dir.to_s }
|
25
25
|
|
26
26
|
it 'removes all files under pid directory' do
|
27
|
-
Dir[pids_dir.to_s + "/redir_*.pid"].
|
27
|
+
expect(Dir[pids_dir.to_s + "/redir_*.pid"]).to be_empty
|
28
28
|
end
|
29
29
|
|
30
30
|
context 'with a valid redir pid' do
|
31
31
|
it 'kills known processes' do
|
32
|
-
subject.
|
32
|
+
expect(subject).to have_received(:system).with("pkill -TERM -P #{pid}")
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
@@ -37,7 +37,7 @@ describe Vagrant::LXC::Action::ClearForwardedPorts do
|
|
37
37
|
let(:pid_cmd) { 'sudo ls' }
|
38
38
|
|
39
39
|
it 'does not kill the process' do
|
40
|
-
subject.
|
40
|
+
expect(subject).not_to have_received(:system).with("pkill -TERM -P #{pid}")
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
@@ -1,13 +1,15 @@
|
|
1
1
|
require 'unit_helper'
|
2
2
|
|
3
|
+
require 'vagrant-lxc/plugin'
|
4
|
+
require 'vagrant-lxc/provider'
|
3
5
|
require 'vagrant-lxc/action/compress_rootfs'
|
4
6
|
|
5
7
|
describe Vagrant::LXC::Action::CompressRootFS do
|
6
8
|
let(:app) { double(:app, call: true) }
|
7
9
|
let(:env) { {machine: machine, ui: double(info: true)} }
|
8
|
-
let(:machine) {
|
9
|
-
let(:provider) {
|
10
|
-
let(:driver) {
|
10
|
+
let(:machine) { double(Vagrant::Machine, provider: provider) }
|
11
|
+
let(:provider) { double(Vagrant::LXC::Provider, driver: driver) }
|
12
|
+
let(:driver) { double(Vagrant::LXC::Driver, compress_rootfs: compressed_rootfs_path) }
|
11
13
|
let(:compressed_rootfs_path) { '/path/to/rootfs.tar.gz' }
|
12
14
|
|
13
15
|
subject { described_class.new(app, env) }
|
@@ -18,10 +20,10 @@ describe Vagrant::LXC::Action::CompressRootFS do
|
|
18
20
|
end
|
19
21
|
|
20
22
|
it "asks the driver to compress container's rootfs" do
|
21
|
-
driver.
|
23
|
+
expect(driver).to have_received(:compress_rootfs)
|
22
24
|
end
|
23
25
|
|
24
26
|
it 'sets export.temp_dir on action env' do
|
25
|
-
env['package.rootfs'].
|
27
|
+
expect(env['package.rootfs']).to eq(compressed_rootfs_path)
|
26
28
|
end
|
27
29
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'unit_helper'
|
2
2
|
|
3
3
|
require 'tmpdir'
|
4
|
-
require 'vagrant-lxc/
|
4
|
+
require 'vagrant-lxc/provider'
|
5
5
|
require 'vagrant-lxc/action/forward_ports'
|
6
6
|
|
7
7
|
describe Vagrant::LXC::Action::ForwardPorts do
|
@@ -9,7 +9,7 @@ describe Vagrant::LXC::Action::ForwardPorts do
|
|
9
9
|
let(:env) { {machine: machine, ui: double(info: true)} }
|
10
10
|
let(:machine) { double(:machine) }
|
11
11
|
let!(:data_dir) { Pathname.new(Dir.mktmpdir) }
|
12
|
-
let(:provider) {
|
12
|
+
let(:provider) { double(Vagrant::LXC::Provider, ssh_info: {host: container_ip}) }
|
13
13
|
let(:host_ip) { '127.0.0.1' }
|
14
14
|
let(:host_port) { 8080 }
|
15
15
|
let(:guest_port) { 80 }
|
@@ -33,7 +33,7 @@ describe Vagrant::LXC::Action::ForwardPorts do
|
|
33
33
|
it 'forwards ports using redir' do
|
34
34
|
subject.stub(system: true)
|
35
35
|
subject.call(env)
|
36
|
-
subject.
|
36
|
+
expect(subject).to have_received(:spawn).with(
|
37
37
|
"redir --laddr=#{host_ip} --lport=#{host_port} --caddr=#{container_ip} --cport=#{guest_port} 2>/dev/null"
|
38
38
|
)
|
39
39
|
end
|
@@ -42,7 +42,7 @@ describe Vagrant::LXC::Action::ForwardPorts do
|
|
42
42
|
forward_conf.delete(:host_ip)
|
43
43
|
subject.stub(system: true)
|
44
44
|
subject.call(env)
|
45
|
-
subject.
|
45
|
+
expect(subject).to have_received(:spawn).with(
|
46
46
|
"redir --lport=#{host_port} --caddr=#{container_ip} --cport=#{guest_port} 2>/dev/null"
|
47
47
|
)
|
48
48
|
end
|
@@ -51,7 +51,7 @@ describe Vagrant::LXC::Action::ForwardPorts do
|
|
51
51
|
forward_conf[:host_ip] = ' '
|
52
52
|
subject.stub(system: true)
|
53
53
|
subject.call(env)
|
54
|
-
subject.
|
54
|
+
expect(subject).to have_received(:spawn).with(
|
55
55
|
"redir --lport=#{host_port} --caddr=#{container_ip} --cport=#{guest_port} 2>/dev/null"
|
56
56
|
)
|
57
57
|
end
|
@@ -60,18 +60,18 @@ describe Vagrant::LXC::Action::ForwardPorts do
|
|
60
60
|
subject.stub(system: true)
|
61
61
|
subject.call(env)
|
62
62
|
pid_file = data_dir.join('pids', "redir_#{host_port}.pid").read
|
63
|
-
pid_file.
|
63
|
+
expect(pid_file).to eq(pid)
|
64
64
|
end
|
65
65
|
|
66
66
|
it 'allows disabling a previously forwarded port' do
|
67
67
|
forward_conf[:disabled] = true
|
68
68
|
subject.stub(system: true)
|
69
69
|
subject.call(env)
|
70
|
-
subject.
|
70
|
+
expect(subject).not_to have_received(:spawn)
|
71
71
|
end
|
72
72
|
|
73
73
|
it 'raises RedirNotInstalled error if `redir` is not installed' do
|
74
74
|
subject.stub(system: false)
|
75
|
-
|
75
|
+
expect { subject.call(env) }.to raise_error(Vagrant::LXC::Errors::RedirNotInstalled)
|
76
76
|
end
|
77
77
|
end
|
@@ -6,7 +6,7 @@ require 'vagrant-lxc/action/handle_box_metadata'
|
|
6
6
|
|
7
7
|
describe Vagrant::LXC::Action::HandleBoxMetadata do
|
8
8
|
let(:app) { double(:app, call: true) }
|
9
|
-
let(:env) { {machine: machine, ui: double(info: true)} }
|
9
|
+
let(:env) { {machine: machine, ui: double(info: true, warn: true)} }
|
10
10
|
let(:machine) { double(:machine, box: box) }
|
11
11
|
let(:box) { double(:box, name: 'box-name', metadata: metadata, directory: box_directory) }
|
12
12
|
let(:box_directory) { Pathname.new('/path/to/box') }
|
@@ -16,55 +16,111 @@ describe Vagrant::LXC::Action::HandleBoxMetadata do
|
|
16
16
|
|
17
17
|
subject { described_class.new(app, env) }
|
18
18
|
|
19
|
-
context 'with
|
19
|
+
context 'with 1.0.0 box' do
|
20
|
+
let(:version) { '1.0.0' }
|
21
|
+
|
20
22
|
before do
|
21
23
|
File.stub(exists?: true)
|
24
|
+
# REFACTOR: This is pretty bad
|
25
|
+
subject.stub_chain(:template_config_file, :exist?).and_return(true)
|
26
|
+
subject.stub_chain(:template_config_file, :to_s).and_return(box_directory.join('lxc-config').to_s)
|
22
27
|
subject.call(env)
|
23
28
|
end
|
24
29
|
|
25
30
|
it 'sets the tarball argument for the template' do
|
26
|
-
env[:lxc_template_opts].
|
31
|
+
expect(env[:lxc_template_opts]).to include(
|
32
|
+
'--tarball' => box_directory.join('rootfs.tar.gz').to_s
|
33
|
+
)
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'sets the template --config parameter' do
|
37
|
+
expect(env[:lxc_template_opts]).to include(
|
38
|
+
'--config' => box_directory.join('lxc-config').to_s
|
39
|
+
)
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'does not set the auth key argument for the template' do
|
43
|
+
expect(env[:lxc_template_opts]).not_to include(
|
44
|
+
'--auth-key' => vagrant_key
|
45
|
+
)
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'sets the template options from metadata on env hash' do
|
49
|
+
expect(env[:lxc_template_opts]).to include(metadata['template-opts'])
|
50
|
+
end
|
51
|
+
|
52
|
+
xit 'sets the template source path on env hash' do
|
53
|
+
expect(env[:lxc_template_src]).to eq(box_directory.join('lxc-template').to_s)
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'does not warn about deprecation' do
|
57
|
+
expect(env[:ui]).not_to have_received(:warn)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
context 'with valid pre 1.0.0 box' do
|
62
|
+
before do
|
63
|
+
File.stub(exists?: true)
|
64
|
+
# REFACTOR: This is pretty bad
|
65
|
+
subject.stub_chain(:old_template_config_file, :exist?).and_return(true)
|
66
|
+
subject.stub_chain(:old_template_config_file, :to_s).and_return(box_directory.join('lxc.conf').to_s)
|
67
|
+
subject.call(env)
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'sets the tarball argument for the template' do
|
71
|
+
expect(env[:lxc_template_opts]).to include(
|
27
72
|
'--tarball' => box_directory.join('rootfs.tar.gz').to_s
|
28
73
|
)
|
29
74
|
end
|
30
75
|
|
31
76
|
it 'sets the auth key argument for the template' do
|
32
|
-
env[:lxc_template_opts].
|
77
|
+
expect(env[:lxc_template_opts]).to include(
|
33
78
|
'--auth-key' => vagrant_key
|
34
79
|
)
|
35
80
|
end
|
36
81
|
|
82
|
+
it 'sets the lxc config file parameter' do
|
83
|
+
expect(env[:lxc_template_config]).to eq(box_directory.join('lxc.conf').to_s)
|
84
|
+
end
|
85
|
+
|
37
86
|
it 'sets the template options from metadata on env hash' do
|
38
|
-
env[:lxc_template_opts].
|
87
|
+
expect(env[:lxc_template_opts]).to include(metadata['template-opts'])
|
88
|
+
end
|
89
|
+
|
90
|
+
xit 'sets the template source path on env hash' do
|
91
|
+
expect(env[:lxc_template_src]).to eq(box_directory.join('lxc-template').to_s)
|
39
92
|
end
|
40
93
|
|
41
|
-
it '
|
42
|
-
env[:
|
94
|
+
it 'warns about deprecation' do
|
95
|
+
expect(env[:ui]).to have_received(:warn)
|
43
96
|
end
|
44
97
|
end
|
45
98
|
|
46
99
|
describe 'with invalid contents' do
|
47
100
|
before { File.stub(exists?: true) }
|
48
101
|
|
49
|
-
it '
|
102
|
+
it 'validates box versions' do
|
103
|
+
%w( 2 3 1.0.0 ).each do |v|
|
104
|
+
metadata['version'] = v
|
105
|
+
expect { subject.call(env) }.to_not raise_error
|
106
|
+
end
|
107
|
+
|
50
108
|
metadata['version'] = '1'
|
51
|
-
expect {
|
52
|
-
subject.call(env)
|
53
|
-
}.to raise_error(Vagrant::LXC::Errors::IncompatibleBox)
|
109
|
+
expect { subject.call(env) }.to raise_error
|
54
110
|
end
|
55
111
|
|
56
112
|
it 'raises an error if the rootfs tarball cant be found' do
|
57
|
-
File.
|
113
|
+
allow(File).to receive(:exists?).with(box_directory.join('rootfs.tar.gz').to_s).and_return(false)
|
58
114
|
expect {
|
59
115
|
subject.call(env)
|
60
116
|
}.to raise_error(Vagrant::LXC::Errors::RootFSTarballMissing)
|
61
117
|
end
|
62
118
|
|
63
|
-
it '
|
64
|
-
File.
|
119
|
+
it 'does not raise an error if the lxc-template script cant be found' do
|
120
|
+
allow(File).to receive(:exists?).with(box_directory.join('lxc-template').to_s).and_return(false)
|
65
121
|
expect {
|
66
122
|
subject.call(env)
|
67
|
-
}.
|
123
|
+
}.to_not raise_error
|
68
124
|
end
|
69
125
|
end
|
70
126
|
end
|