vagrant-lxc 0.8.0 → 1.0.0.alpha.1
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -1,225 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
|
3
|
-
# This is a modified version of /usr/share/lxc/templates/lxc-openmandriva
|
4
|
-
# that comes with OpenMandriva changed to suit vagrant-lxc needs
|
5
|
-
|
6
|
-
#
|
7
|
-
# template script for generating openmandriva container for LXC
|
8
|
-
#
|
9
|
-
|
10
|
-
#
|
11
|
-
# lxc: linux Container library
|
12
|
-
|
13
|
-
# Authors:
|
14
|
-
# Alexander Khryukin <alexander@mezon.ru>
|
15
|
-
# Vokhmin Alexey V <avokhmin@gmail.com>
|
16
|
-
|
17
|
-
# This library is free software; you can redistribute it and/or
|
18
|
-
# modify it under the terms of the GNU Lesser General Public
|
19
|
-
# License as published by the Free Software Foundation; either
|
20
|
-
# version 2.1 of the License, or (at your option) any later version.
|
21
|
-
|
22
|
-
# This library is distributed in the hope that it will be useful,
|
23
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
24
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
25
|
-
# Lesser General Public License for more details.
|
26
|
-
|
27
|
-
# You should have received a copy of the GNU Lesser General Public
|
28
|
-
# License along with this library; if not, write to the Free Software
|
29
|
-
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
30
|
-
|
31
|
-
|
32
|
-
set -e
|
33
|
-
|
34
|
-
if [ -r /etc/default/lxc ]; then
|
35
|
-
. /etc/default/lxc
|
36
|
-
fi
|
37
|
-
|
38
|
-
extract_rootfs()
|
39
|
-
{
|
40
|
-
tarball=$1
|
41
|
-
arch=$2
|
42
|
-
rootfs=$3
|
43
|
-
|
44
|
-
echo "Extracting $tarball ..."
|
45
|
-
mkdir -p $(dirname $rootfs)
|
46
|
-
(cd `dirname $rootfs` && tar xfz $tarball)
|
47
|
-
return 0
|
48
|
-
}
|
49
|
-
|
50
|
-
install_openmandriva()
|
51
|
-
{
|
52
|
-
rootfs=$1
|
53
|
-
release=$2
|
54
|
-
tarball=$3
|
55
|
-
mkdir -p /var/lock/subsys/
|
56
|
-
|
57
|
-
(
|
58
|
-
flock -x 200
|
59
|
-
if [ $? -ne 0 ]; then
|
60
|
-
echo "Cache repository is busy."
|
61
|
-
return 1
|
62
|
-
fi
|
63
|
-
|
64
|
-
extract_rootfs $tarball $arch $rootfs
|
65
|
-
if [ $? -ne 0 ]; then
|
66
|
-
echo "Failed to copy rootfs"
|
67
|
-
return 1
|
68
|
-
fi
|
69
|
-
|
70
|
-
return 0
|
71
|
-
|
72
|
-
) 200>/var/lock/subsys/lxc
|
73
|
-
|
74
|
-
return $?
|
75
|
-
}
|
76
|
-
|
77
|
-
copy_configuration()
|
78
|
-
{
|
79
|
-
path=$1
|
80
|
-
rootfs=$2
|
81
|
-
name=$3
|
82
|
-
|
83
|
-
grep -q "^lxc.rootfs" $path/config 2>/dev/null || echo "lxc.rootfs = $rootfs" >> $path/config
|
84
|
-
|
85
|
-
# if there is exactly one veth network entry, make sure it has an
|
86
|
-
# associated hwaddr.
|
87
|
-
nics=`grep -e '^lxc\.network\.type[ \t]*=[ \t]*veth' $path/config | wc -l`
|
88
|
-
if [ $nics -eq 1 ]; then
|
89
|
-
grep -q "^lxc.network.hwaddr" $path/config || sed -i -e "/^lxc\.network\.type[ \t]*=[ \t]*veth/a lxc.network.hwaddr = 00:16:3e:$(openssl rand -hex 3| sed 's/\(..\)/\1:/g; s/.$//')" $path/config
|
90
|
-
fi
|
91
|
-
|
92
|
-
if [ $? -ne 0 ]; then
|
93
|
-
echo "Failed to add configuration"
|
94
|
-
return 1
|
95
|
-
fi
|
96
|
-
|
97
|
-
return 0
|
98
|
-
}
|
99
|
-
|
100
|
-
post_process()
|
101
|
-
{
|
102
|
-
rootfs=$1
|
103
|
-
|
104
|
-
# rmdir /dev/shm for containers that have /run/shm
|
105
|
-
# I'm afraid of doing rm -rf $rootfs/dev/shm, in case it did
|
106
|
-
# get bind mounted to the host's /run/shm. So try to rmdir
|
107
|
-
# it, and in case that fails move it out of the way.
|
108
|
-
if [ ! -L $rootfs/dev/shm ] && [ -d $rootfs/run/shm ] && [ -e $rootfs/dev/shm ]; then
|
109
|
-
mv $rootfs/dev/shm $rootfs/dev/shm.bak
|
110
|
-
ln -s /run/shm $rootfs/dev/shm
|
111
|
-
fi
|
112
|
-
}
|
113
|
-
|
114
|
-
usage()
|
115
|
-
{
|
116
|
-
cat <<EOF
|
117
|
-
usage:
|
118
|
-
$1 -n|--name=<container_name>
|
119
|
-
[-p|--path=<path>] [-c|--clean] [-R|--release=<openmandriva2013.0/rosa2012.1/cooker/ release>]
|
120
|
-
[-4|--ipv4=<ipv4 address>] [-6|--ipv6=<ipv6 address>]
|
121
|
-
[-g|--gw=<gw address>] [-d|--dns=<dns address>]
|
122
|
-
[-P|--profile=<name of the profile>] [--rootfs=<path>]
|
123
|
-
[-A|--arch=<arch of the container>]
|
124
|
-
[-T|--tarball <tarball path>]
|
125
|
-
[-S|--auth-key <auth-key path>]
|
126
|
-
[-h|--help]
|
127
|
-
Mandatory args:
|
128
|
-
-n,--name container name, used to as an identifier for that container from now on
|
129
|
-
Optional args:
|
130
|
-
-p,--path path to where the container rootfs will be created, defaults to /var/lib/lxc. The container config will go under /var/lib/lxc in that case
|
131
|
-
-c,--clean clean the cache
|
132
|
-
-R,--release openmandriva2013.0/cooker/rosa2012.1 release for the new container. if the host is OpenMandriva, then it will default to the host's release.
|
133
|
-
-4,--ipv4 specify the ipv4 address to assign to the virtualized interface, eg. 192.168.1.123/24
|
134
|
-
-6,--ipv6 specify the ipv6 address to assign to the virtualized interface, eg. 2003:db8:1:0:214:1234:fe0b:3596/64
|
135
|
-
-g,--gw specify the default gw, eg. 192.168.1.1
|
136
|
-
-G,--gw6 specify the default gw, eg. 2003:db8:1:0:214:1234:fe0b:3596
|
137
|
-
-d,--dns specify the DNS server, eg. 192.168.1.2
|
138
|
-
-P,--profile Profile name is the file name in /etc/lxc/profiles contained packages name for install to cache.
|
139
|
-
-A,--arch Define what arch the container will be [i586,x86_64,armv7l,armv7hl]
|
140
|
-
---rootfs rootfs path
|
141
|
-
-h,--help print this help
|
142
|
-
EOF
|
143
|
-
return 0
|
144
|
-
}
|
145
|
-
|
146
|
-
options=$(getopt -o hp:n:P:cR:4:6:g:d:A:S:T: -l help,rootfs:,path:,name:,profile:,clean:,release:,ipv4:,ipv6:,gw:,dns:,arch:,auth-key:,tarball: -- "$@")
|
147
|
-
if [ $? -ne 0 ]; then
|
148
|
-
usage $(basename $0)
|
149
|
-
exit 1
|
150
|
-
fi
|
151
|
-
eval set -- "$options"
|
152
|
-
|
153
|
-
# doesn't use
|
154
|
-
release=${release:-"cooker"}
|
155
|
-
|
156
|
-
hostarch=$(uname -m)
|
157
|
-
while true
|
158
|
-
do
|
159
|
-
case "$1" in
|
160
|
-
-h|--help) usage $0 && exit 0;;
|
161
|
-
-p|--path) path=$2; shift 2;;
|
162
|
-
--rootfs) rootfs_path=$2; shift 2;;
|
163
|
-
-n|--name) name=$2; shift 2;;
|
164
|
-
-P|--profile) profile=$2; shift 2;;
|
165
|
-
-c|--clean) clean=$2; shift 2;;
|
166
|
-
-R|--release) release=$2; shift 2;;
|
167
|
-
-T|--tarball) tarball=$2; shift 2;;
|
168
|
-
-S|--auth-key) auth_key=$2; shift 2;;
|
169
|
-
-A|--arch) arch=$2; shift 2;;
|
170
|
-
-4|--ipv4) ipv4=$2; shift 2;;
|
171
|
-
-6|--ipv6) ipv6=$2; shift 2;;
|
172
|
-
-g|--gw) gw=$2; shift 2;;
|
173
|
-
-d|--dns) dns=$2; shift 2;;
|
174
|
-
--) shift 1; break ;;
|
175
|
-
*) break ;;
|
176
|
-
esac
|
177
|
-
done
|
178
|
-
|
179
|
-
arch=${arch:-$hostarch}
|
180
|
-
if [ $hostarch = "i586" -a $arch = "x86_64" ]; then
|
181
|
-
echo "can't create x86_64 container on i586"
|
182
|
-
exit 1
|
183
|
-
fi
|
184
|
-
|
185
|
-
if [ -z "$path" ]; then
|
186
|
-
echo "'path' parameter is required"
|
187
|
-
exit 1
|
188
|
-
fi
|
189
|
-
|
190
|
-
if [ "$(id -u)" != "0" ]; then
|
191
|
-
echo "This script should be run as 'root'"
|
192
|
-
exit 1
|
193
|
-
fi
|
194
|
-
|
195
|
-
# detect rootfs
|
196
|
-
config="$path/config"
|
197
|
-
# if $rootfs exists here, it was passed in with --rootfs
|
198
|
-
if [ -z "$rootfs" ]; then
|
199
|
-
if grep -q '^lxc.rootfs' $config 2>/dev/null ; then
|
200
|
-
rootfs=`grep 'lxc.rootfs =' $config | awk -F= '{ print $2 }'`
|
201
|
-
else
|
202
|
-
rootfs=$path/rootfs
|
203
|
-
fi
|
204
|
-
fi
|
205
|
-
|
206
|
-
install_openmandriva $rootfs $release $tarball
|
207
|
-
if [ $? -ne 0 ]; then
|
208
|
-
echo "failed to install openmandriva $release"
|
209
|
-
exit 1
|
210
|
-
fi
|
211
|
-
|
212
|
-
copy_configuration $path $rootfs $name $arch
|
213
|
-
if [ $? -ne 0 ]; then
|
214
|
-
echo "failed write configuration file"
|
215
|
-
exit 1
|
216
|
-
fi
|
217
|
-
|
218
|
-
post_process $rootfs $release
|
219
|
-
|
220
|
-
echo ""
|
221
|
-
echo "##"
|
222
|
-
echo "# The default user is 'vagrant' with password 'vagrant'!"
|
223
|
-
echo "# Use the 'sudo' command to run tasks as root in the container."
|
224
|
-
echo "##"
|
225
|
-
echo ""
|
data/boxes/common/lxc.conf
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
lxc.network.type=veth
|
2
|
-
lxc.network.link=lxcbr0
|
3
|
-
lxc.network.flags=up
|
4
|
-
|
5
|
-
lxc.pivotdir = lxc_putold
|
6
|
-
|
7
|
-
lxc.devttydir = lxc
|
8
|
-
lxc.tty = 4
|
9
|
-
lxc.pts = 1024
|
10
|
-
|
11
|
-
lxc.arch = amd64
|
12
|
-
lxc.cap.drop = sys_module mac_admin mac_override
|
13
|
-
|
14
|
-
# When using LXC with apparmor, uncomment the next line to run unconfined:
|
15
|
-
#lxc.aa_profile = unconfined
|
16
|
-
|
17
|
-
lxc.cgroup.devices.deny = a
|
18
|
-
# Allow any mknod (but not using the node)
|
19
|
-
lxc.cgroup.devices.allow = c *:* m
|
20
|
-
lxc.cgroup.devices.allow = b *:* m
|
21
|
-
# /dev/null and zero
|
22
|
-
lxc.cgroup.devices.allow = c 1:3 rwm
|
23
|
-
lxc.cgroup.devices.allow = c 1:5 rwm
|
24
|
-
# consoles
|
25
|
-
lxc.cgroup.devices.allow = c 5:1 rwm
|
26
|
-
lxc.cgroup.devices.allow = c 5:0 rwm
|
27
|
-
#lxc.cgroup.devices.allow = c 4:0 rwm
|
28
|
-
#lxc.cgroup.devices.allow = c 4:1 rwm
|
29
|
-
# /dev/{,u}random
|
30
|
-
lxc.cgroup.devices.allow = c 1:9 rwm
|
31
|
-
lxc.cgroup.devices.allow = c 1:8 rwm
|
32
|
-
lxc.cgroup.devices.allow = c 136:* rwm
|
33
|
-
lxc.cgroup.devices.allow = c 5:2 rwm
|
34
|
-
# rtc
|
35
|
-
lxc.cgroup.devices.allow = c 254:0 rwm
|
36
|
-
#fuse
|
37
|
-
lxc.cgroup.devices.allow = c 10:229 rwm
|
38
|
-
#tun
|
39
|
-
lxc.cgroup.devices.allow = c 10:200 rwm
|
40
|
-
#full
|
41
|
-
lxc.cgroup.devices.allow = c 1:7 rwm
|
42
|
-
#hpet
|
43
|
-
lxc.cgroup.devices.allow = c 10:228 rwm
|
44
|
-
#kvm
|
45
|
-
lxc.cgroup.devices.allow = c 10:232 rwm
|
46
|
-
|
47
|
-
# mounts point
|
48
|
-
lxc.mount.entry = proc proc proc nodev,noexec,nosuid 0 0
|
49
|
-
lxc.mount.entry = sysfs sys sysfs defaults 0 0
|
data/boxes/common/metadata.json
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
module Vagrant
|
2
|
-
module LXC
|
3
|
-
module Action
|
4
|
-
class CheckCreated
|
5
|
-
def initialize(app, env)
|
6
|
-
@app = app
|
7
|
-
end
|
8
|
-
|
9
|
-
def call(env)
|
10
|
-
if env[:machine].state.id == :not_created
|
11
|
-
raise Vagrant::Errors::VMNotCreatedError
|
12
|
-
end
|
13
|
-
|
14
|
-
# Call the next if we have one (but we shouldn't, since this
|
15
|
-
# middleware is built to run with the Call-type middlewares)
|
16
|
-
@app.call(env)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module Vagrant
|
2
|
-
module LXC
|
3
|
-
module Action
|
4
|
-
class CheckRunning
|
5
|
-
def initialize(app, env)
|
6
|
-
@app = app
|
7
|
-
end
|
8
|
-
|
9
|
-
def call(env)
|
10
|
-
if env[:machine].state.id != :running
|
11
|
-
raise Vagrant::Errors::VMNotRunningError
|
12
|
-
end
|
13
|
-
|
14
|
-
# Call the next if we have one (but we shouldn't, since this
|
15
|
-
# middleware is built to run with the Call-type middlewares)
|
16
|
-
@app.call(env)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
module Vagrant
|
2
|
-
module LXC
|
3
|
-
module Action
|
4
|
-
class Created
|
5
|
-
def initialize(app, env)
|
6
|
-
@app = app
|
7
|
-
end
|
8
|
-
|
9
|
-
def call(env)
|
10
|
-
# Set the result to be true if the machine is created.
|
11
|
-
env[:result] = env[:machine].state.id != :not_created
|
12
|
-
|
13
|
-
# Call the next if we have one (but we shouldn't, since this
|
14
|
-
# middleware is built to run with the Call-type middlewares)
|
15
|
-
@app.call(env)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
module Vagrant
|
2
|
-
module LXC
|
3
|
-
module Action
|
4
|
-
class Disconnect
|
5
|
-
def initialize(app, env)
|
6
|
-
@app = app
|
7
|
-
end
|
8
|
-
|
9
|
-
def call(env)
|
10
|
-
@app.call env
|
11
|
-
# FIXME: Vagrant >= 1.1.3 should not need this
|
12
|
-
# https://github.com/mitchellh/vagrant/compare/715539eac30bc9ae62ddbb6337d13f036f7b774d...ec1bae0#L2R128
|
13
|
-
env[:machine].instance_variable_set(:@communicator, nil)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module Vagrant
|
2
|
-
module LXC
|
3
|
-
module Action
|
4
|
-
class IsRunning
|
5
|
-
def initialize(app, env)
|
6
|
-
@app = app
|
7
|
-
end
|
8
|
-
|
9
|
-
def call(env)
|
10
|
-
env[:result] = env[:machine].state.id == :running
|
11
|
-
|
12
|
-
# Call the next if we have one (but we shouldn't, since this
|
13
|
-
# middleware is built to run with the Call-type middlewares)
|
14
|
-
@app.call(env)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,111 +0,0 @@
|
|
1
|
-
require 'acceptance_helper'
|
2
|
-
|
3
|
-
describe 'Sanity check' do
|
4
|
-
after(:all) { destroy_container }
|
5
|
-
|
6
|
-
context 'running `vagrant up` from scratch' do
|
7
|
-
before(:all) do
|
8
|
-
destroy_container
|
9
|
-
vagrant_up
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'creates a container' do
|
13
|
-
containers = `sudo lxc-ls`.chomp.split(/\s+/).uniq
|
14
|
-
expect(containers).to include vagrant_container_name
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'starts the newly created container' do
|
18
|
-
status = `sudo lxc-info -n #{vagrant_container_name}`
|
19
|
-
expect(status).to include 'RUNNING'
|
20
|
-
end
|
21
|
-
|
22
|
-
it "is able to be SSH'ed" do
|
23
|
-
expect(vagrant_ssh('hostname')).to eq 'lxc-test-box'
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'mounts shared folders with the right permissions' do
|
27
|
-
vagrant_ssh 'mkdir -p /vagrant/tmp && echo -n "Shared" > /vagrant/tmp/shared'
|
28
|
-
shared_file_contents = File.read('/vagrant/spec/tmp/shared')
|
29
|
-
expect(shared_file_contents).to eq 'Shared'
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'provisions the container based on Vagrantfile configs' do
|
33
|
-
provisioned_file_contents = File.read('/vagrant/spec/tmp/provisioning')
|
34
|
-
expect(provisioned_file_contents).to eq 'Provisioned'
|
35
|
-
end
|
36
|
-
|
37
|
-
it 'forwards configured ports' do
|
38
|
-
output = `curl -s localhost:8080`.strip.chomp
|
39
|
-
expect(output).to include 'It works!'
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
context '`vagrant halt` on a running container' do
|
44
|
-
before(:all) do
|
45
|
-
destroy_container
|
46
|
-
vagrant_up
|
47
|
-
vagrant_ssh 'touch /tmp/{some,files}'
|
48
|
-
vagrant_halt
|
49
|
-
end
|
50
|
-
|
51
|
-
it 'shuts down the container' do
|
52
|
-
status = `sudo lxc-info -n #{vagrant_container_name}`
|
53
|
-
expect(status).to include 'STOPPED'
|
54
|
-
end
|
55
|
-
|
56
|
-
it 'clears forwarded ports' do
|
57
|
-
`curl -s localhost:8080 --connect-timeout 2`
|
58
|
-
expect($?.exitstatus).to_not eq 0
|
59
|
-
end
|
60
|
-
|
61
|
-
it 'kills redir processes' do
|
62
|
-
processes = `pgrep redir`
|
63
|
-
expect($?.exitstatus).to_not eq 0
|
64
|
-
end
|
65
|
-
|
66
|
-
xit 'removes files under `/tmp`' do
|
67
|
-
container_tmp_files = `sudo ls -l "/var/lib/lxc/#{vagrant_container_name}/rootfs/tmp"`.split("\n")
|
68
|
-
puts container_tmp_files.join("\n")
|
69
|
-
expect(container_tmp_files).to be_empty
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
context '`vagrant destroy`' do
|
74
|
-
before(:all) do
|
75
|
-
destroy_container
|
76
|
-
vagrant_up
|
77
|
-
@container_name = vagrant_container_name
|
78
|
-
vagrant_destroy
|
79
|
-
end
|
80
|
-
|
81
|
-
it 'destroys the underlying container' do
|
82
|
-
containers = `sudo lxc-ls`.chomp.split(/\s+/).uniq
|
83
|
-
expect(containers).to_not include @container_name
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
pending 'box packaging' do
|
88
|
-
before(:all) do
|
89
|
-
destroy_container
|
90
|
-
vagrant_box_remove('new-box')
|
91
|
-
vagrant_up
|
92
|
-
vagrant_package
|
93
|
-
@box_name = ENV['BOX_NAME']
|
94
|
-
# This will make
|
95
|
-
ENV["BOX_NAME"] = 'new-box'
|
96
|
-
ENV['BOX_URL'] = '/vagrant/spec/tmp/package.box'
|
97
|
-
end
|
98
|
-
|
99
|
-
after(:all) do
|
100
|
-
vagrant_box_remove('new-box')
|
101
|
-
ENV["BOX_NAME"] = @box_name
|
102
|
-
ENV['BOX_URL'] = nil
|
103
|
-
end
|
104
|
-
|
105
|
-
it 'creates a package that can be successfully brought up on a later `vagrant up`' do
|
106
|
-
vagrant_up
|
107
|
-
# Just to make sure we packaged it properly
|
108
|
-
expect(vagrant_ssh('cat /home/vagrant/original-box')).to eq @box_name
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|