vagrant-lxc 0.3.3 → 0.3.4
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 +14 -0
- data/Gemfile +3 -6
- data/Gemfile.lock +25 -25
- data/README.md +44 -32
- data/boxes/common/cleanup +7 -0
- data/boxes/common/install-babushka +15 -0
- data/boxes/{ubuntu → common}/install-chef +0 -0
- data/boxes/{ubuntu → common}/install-puppet +1 -1
- data/boxes/debian/download +156 -0
- data/boxes/debian/lxc-template +363 -0
- data/boxes/debian/metadata.json.template +9 -0
- data/boxes/ubuntu/download +11 -0
- data/boxes/ubuntu/lxc-template +14 -23
- data/development/Vagrantfile +69 -95
- data/development/lxc-configs/sid +37 -0
- data/development/lxc-configs/squeeze +37 -0
- data/development/lxc-configs/wheezy +37 -0
- data/development/shell-provisioning/upgrade-kernel +2 -2
- data/development/site.pp +3 -0
- data/example/Vagrantfile +15 -1
- data/lib/vagrant-lxc/action.rb +3 -1
- data/lib/vagrant-lxc/action/forced_halt.rb +1 -3
- data/lib/vagrant-lxc/action/remove_temporary_files.rb +23 -0
- data/lib/vagrant-lxc/driver.rb +3 -3
- data/lib/vagrant-lxc/driver/cli.rb +20 -2
- data/lib/vagrant-lxc/version.rb +1 -1
- data/spec/Vagrantfile +10 -19
- data/spec/acceptance/sanity_check_spec.rb +11 -2
- data/spec/acceptance/support/test_ui.rb +1 -1
- data/spec/unit/driver/cli_spec.rb +5 -6
- data/spec/unit/driver_spec.rb +10 -2
- data/tasks/boxes.rake +136 -36
- metadata +13 -4
data/development/Vagrantfile
CHANGED
@@ -1,112 +1,86 @@
|
|
1
1
|
# -*- mode: ruby -*-
|
2
2
|
# vi: set ft=ruby :
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
4
|
+
require 'pathname'
|
5
|
+
BASE_URL = 'http://dl.dropbox.com/u/13510779'
|
6
|
+
LAST_RELEASE_DATE = '2013-05-08'
|
7
|
+
LOCAL_BOXES_PATH = Pathname('../boxes/output').expand_path
|
8
|
+
def lxc_box_url(release_name)
|
9
|
+
file_name = "lxc-#{release_name}-amd64-#{LAST_RELEASE_DATE}.box"
|
10
|
+
local_box_file = LOCAL_BOXES_PATH.join(file_name)
|
11
|
+
|
12
|
+
local_box_file.exist? ?
|
13
|
+
local_box_file.to_s :
|
14
|
+
"#{BASE_URL}/#{file_name}"
|
12
15
|
end
|
13
16
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
17
|
+
BOXES = {
|
18
|
+
precise: {
|
19
|
+
lxc_url: lxc_box_url('precise'),
|
20
|
+
vbox_url: 'http://files.vagrantup.com/precise64.box'
|
21
|
+
},
|
22
|
+
quantal: {
|
23
|
+
lxc_url: lxc_box_url('quantal'),
|
24
|
+
vbox_url: 'https://github.com/downloads/roderik/VagrantQuantal64Box/quantal64.box'
|
25
|
+
},
|
26
|
+
raring: {
|
27
|
+
lxc_url: lxc_box_url('raring'),
|
28
|
+
vbox_url: 'http://cloud-images.ubuntu.com/vagrant/raring/current/raring-server-cloudimg-amd64-vagrant-disk1.box'
|
29
|
+
},
|
30
|
+
squeeze: {
|
31
|
+
lxc_url: lxc_box_url('squeeze'),
|
32
|
+
vbox_url: 'http://f.willianfernandes.com.br/vagrant-boxes/DebianSqueeze64.box'
|
33
|
+
},
|
34
|
+
wheezy: {
|
35
|
+
lxc_url: lxc_box_url('wheezy'),
|
36
|
+
},
|
37
|
+
sid: {
|
38
|
+
lxc_url: lxc_box_url('sid'),
|
39
|
+
}
|
40
|
+
}
|
23
41
|
|
24
|
-
# Required to make sure vagrant picks it up during development
|
25
42
|
Vagrant.require_plugin 'vagrant-lxc'
|
43
|
+
Vagrant.require_plugin 'vagrant-cachier'
|
26
44
|
|
27
45
|
Vagrant.configure("2") do |config|
|
28
46
|
config.vm.synced_folder "../", "/vagrant", id: 'vagrant-root', nfs: true
|
29
47
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
"modifyvm", :id,
|
62
|
-
"--memory", '1536',
|
63
|
-
"--cpus", '2'
|
64
|
-
]
|
65
|
-
end
|
66
|
-
|
67
|
-
cache_dir = local_apt_cache(precise.vm.box)
|
68
|
-
precise.vm.synced_folder cache_dir, "/var/cache/apt/archives", id: "vagrant-apt-cache"
|
69
|
-
|
70
|
-
cache_dir = local_gem_cache(precise.vm.box)
|
71
|
-
precise.vm.synced_folder cache_dir, "/home/vagrant/gems/cache", id: "vagrant-gem-cache"
|
72
|
-
end
|
73
|
-
|
74
|
-
config.vm.define :raring do |raring|
|
75
|
-
raring.vm.network :private_network, ip: "192.168.50.34"
|
76
|
-
raring.vm.box = 'raring64'
|
77
|
-
raring.vm.hostname = 'vbox'
|
78
|
-
raring.vm.box_url = 'http://cloud-images.ubuntu.com/vagrant/raring/current/raring-server-cloudimg-amd64-vagrant-disk1.box'
|
79
|
-
|
80
|
-
raring.vm.provider :virtualbox do |vb|
|
81
|
-
# Configure VM to use 1.5gb of ram and 2 cpus
|
82
|
-
vb.customize [
|
83
|
-
"modifyvm", :id,
|
84
|
-
"--memory", '1536',
|
85
|
-
"--cpus", '2'
|
86
|
-
]
|
87
|
-
end
|
88
|
-
|
89
|
-
cache_dir = local_apt_cache(raring.vm.box)
|
90
|
-
raring.vm.synced_folder cache_dir, "/var/cache/apt/archives", id: "vagrant-apt-cache"
|
91
|
-
|
92
|
-
cache_dir = local_gem_cache(raring.vm.box)
|
93
|
-
raring.vm.synced_folder cache_dir, "/home/vagrant/gems/cache", id: "vagrant-gem-cache"
|
94
|
-
end
|
95
|
-
|
96
|
-
config.vm.define :lxc do |lxc_config|
|
97
|
-
lxc_config.vm.box = 'quantal64'
|
98
|
-
lxc_config.vm.hostname = 'lxc-dev-box'
|
99
|
-
lxc_config.vm.box_url = 'http://dl.dropbox.com/u/13510779/lxc-quantal64-2013-04-21.box'
|
100
|
-
# Uncomment to test boxes built locally:
|
101
|
-
# lxc_config.vm.box_url = '../boxes/output/lxc-quantal64.box'
|
102
|
-
|
103
|
-
lxc_config.vm.provider :lxc do |lxc|
|
104
|
-
# Required to boot nested containers
|
105
|
-
lxc.customize 'aa_profile', 'unconfined'
|
48
|
+
ip_suffix = 30
|
49
|
+
BOXES.each do |box_name, box_config|
|
50
|
+
config.vm.define(box_name.to_sym) do |vm_config|
|
51
|
+
vm_config.vm.network :private_network, ip: "192.168.50.#{ip_suffix += 1}"
|
52
|
+
vm_config.vm.box = "#{box_name}64"
|
53
|
+
|
54
|
+
if box_config[:vbox_url]
|
55
|
+
vm_config.vm.provider :virtualbox do |vb, vb_config|
|
56
|
+
vb_config.vm.box_url = box_config[:vbox_url]
|
57
|
+
vb_config.vm.hostname = 'vbox'
|
58
|
+
|
59
|
+
vb.customize [
|
60
|
+
"modifyvm", :id,
|
61
|
+
"--memory", '1536',
|
62
|
+
"--cpus", '2'
|
63
|
+
]
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
if box_config[:lxc_url]
|
68
|
+
vm_config.vm.provider :lxc do |lxc, lxc_config|
|
69
|
+
lxc_config.vm.box_url = box_config[:lxc_url]
|
70
|
+
lxc_config.vm.hostname = 'lxc-dev-box' unless %w(squeeze wheezy sid).include? box_name.to_s
|
71
|
+
|
72
|
+
# Required to boot nested containers
|
73
|
+
lxc.customize 'aa_profile', 'unconfined' unless %w(squeeze wheezy sid).include? box_name.to_s
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
vm_config.cache.enable :apt
|
78
|
+
vm_config.cache.enable :gem
|
106
79
|
end
|
107
80
|
end
|
108
81
|
|
109
|
-
config.vm.provision :shell, :
|
82
|
+
config.vm.provision :shell, :inline => 'sudo apt-get update'
|
83
|
+
config.vm.provision :shell, :path => 'shell-provisioning/upgrade-kernel'
|
110
84
|
|
111
85
|
config.vm.provision :puppet do |puppet|
|
112
86
|
puppet.manifests_path = "."
|
@@ -0,0 +1,37 @@
|
|
1
|
+
###############################################################################
|
2
|
+
# This file has the same configs as the built in /etc/default/lxc on Ubuntu,
|
3
|
+
# we only changed IPs to 10.0.254.* to avoid collision with LXC default 10.0.3.*
|
4
|
+
# which is likely to be running from the host machine
|
5
|
+
###############################################################################
|
6
|
+
|
7
|
+
|
8
|
+
# MIRROR to be used by ubuntu template at container creation:
|
9
|
+
# Leaving it undefined is fine
|
10
|
+
#MIRROR="http://archive.ubuntu.com/ubuntu"
|
11
|
+
# or
|
12
|
+
#MIRROR="http://<host-ip-addr>:3142/archive.ubuntu.com/ubuntu"
|
13
|
+
|
14
|
+
# LXC_AUTO - whether or not to start containers symlinked under
|
15
|
+
# /etc/lxc/auto
|
16
|
+
LXC_AUTO="true"
|
17
|
+
|
18
|
+
# Leave USE_LXC_BRIDGE as "true" if you want to use lxcbr0 for your
|
19
|
+
# containers. Set to "false" if you'll use virbr0 or another existing
|
20
|
+
# bridge, or mavlan to your host's NIC.
|
21
|
+
USE_LXC_BRIDGE="true"
|
22
|
+
|
23
|
+
# If you change the LXC_BRIDGE to something other than lxcbr1, then
|
24
|
+
# you will also need to update your /etc/lxc/lxc.conf as well as the
|
25
|
+
# configuration (/var/lib/lxc/<container>/config) for any containers
|
26
|
+
# already created using the default config to reflect the new bridge
|
27
|
+
# name.
|
28
|
+
# If you have the dnsmasq daemon installed, you'll also have to update
|
29
|
+
# /etc/dnsmasq.d/lxc and restart the system wide dnsmasq daemon.
|
30
|
+
LXC_BRIDGE="lxcbr0"
|
31
|
+
LXC_ADDR="10.0.251.1"
|
32
|
+
LXC_NETMASK="255.255.255.0"
|
33
|
+
LXC_NETWORK="10.0.251.0/24"
|
34
|
+
LXC_DHCP_RANGE="10.0.253.2,10.0.251.254"
|
35
|
+
LXC_DHCP_MAX="253"
|
36
|
+
|
37
|
+
LXC_SHUTDOWN_TIMEOUT=120
|
@@ -0,0 +1,37 @@
|
|
1
|
+
###############################################################################
|
2
|
+
# This file has the same configs as the built in /etc/default/lxc on Ubuntu,
|
3
|
+
# we only changed IPs to 10.0.254.* to avoid collision with LXC default 10.0.3.*
|
4
|
+
# which is likely to be running from the host machine
|
5
|
+
###############################################################################
|
6
|
+
|
7
|
+
|
8
|
+
# MIRROR to be used by ubuntu template at container creation:
|
9
|
+
# Leaving it undefined is fine
|
10
|
+
#MIRROR="http://archive.ubuntu.com/ubuntu"
|
11
|
+
# or
|
12
|
+
#MIRROR="http://<host-ip-addr>:3142/archive.ubuntu.com/ubuntu"
|
13
|
+
|
14
|
+
# LXC_AUTO - whether or not to start containers symlinked under
|
15
|
+
# /etc/lxc/auto
|
16
|
+
LXC_AUTO="true"
|
17
|
+
|
18
|
+
# Leave USE_LXC_BRIDGE as "true" if you want to use lxcbr0 for your
|
19
|
+
# containers. Set to "false" if you'll use virbr0 or another existing
|
20
|
+
# bridge, or mavlan to your host's NIC.
|
21
|
+
USE_LXC_BRIDGE="true"
|
22
|
+
|
23
|
+
# If you change the LXC_BRIDGE to something other than lxcbr1, then
|
24
|
+
# you will also need to update your /etc/lxc/lxc.conf as well as the
|
25
|
+
# configuration (/var/lib/lxc/<container>/config) for any containers
|
26
|
+
# already created using the default config to reflect the new bridge
|
27
|
+
# name.
|
28
|
+
# If you have the dnsmasq daemon installed, you'll also have to update
|
29
|
+
# /etc/dnsmasq.d/lxc and restart the system wide dnsmasq daemon.
|
30
|
+
LXC_BRIDGE="lxcbr0"
|
31
|
+
LXC_ADDR="10.0.250.1"
|
32
|
+
LXC_NETMASK="255.255.255.0"
|
33
|
+
LXC_NETWORK="10.0.250.0/24"
|
34
|
+
LXC_DHCP_RANGE="10.0.253.2,10.0.250.254"
|
35
|
+
LXC_DHCP_MAX="253"
|
36
|
+
|
37
|
+
LXC_SHUTDOWN_TIMEOUT=120
|
@@ -0,0 +1,37 @@
|
|
1
|
+
###############################################################################
|
2
|
+
# This file has the same configs as the built in /etc/default/lxc on Ubuntu,
|
3
|
+
# we only changed IPs to 10.0.254.* to avoid collision with LXC default 10.0.3.*
|
4
|
+
# which is likely to be running from the host machine
|
5
|
+
###############################################################################
|
6
|
+
|
7
|
+
|
8
|
+
# MIRROR to be used by ubuntu template at container creation:
|
9
|
+
# Leaving it undefined is fine
|
10
|
+
#MIRROR="http://archive.ubuntu.com/ubuntu"
|
11
|
+
# or
|
12
|
+
#MIRROR="http://<host-ip-addr>:3142/archive.ubuntu.com/ubuntu"
|
13
|
+
|
14
|
+
# LXC_AUTO - whether or not to start containers symlinked under
|
15
|
+
# /etc/lxc/auto
|
16
|
+
LXC_AUTO="true"
|
17
|
+
|
18
|
+
# Leave USE_LXC_BRIDGE as "true" if you want to use lxcbr0 for your
|
19
|
+
# containers. Set to "false" if you'll use virbr0 or another existing
|
20
|
+
# bridge, or mavlan to your host's NIC.
|
21
|
+
USE_LXC_BRIDGE="true"
|
22
|
+
|
23
|
+
# If you change the LXC_BRIDGE to something other than lxcbr1, then
|
24
|
+
# you will also need to update your /etc/lxc/lxc.conf as well as the
|
25
|
+
# configuration (/var/lib/lxc/<container>/config) for any containers
|
26
|
+
# already created using the default config to reflect the new bridge
|
27
|
+
# name.
|
28
|
+
# If you have the dnsmasq daemon installed, you'll also have to update
|
29
|
+
# /etc/dnsmasq.d/lxc and restart the system wide dnsmasq daemon.
|
30
|
+
LXC_BRIDGE="lxcbr0"
|
31
|
+
LXC_ADDR="10.0.252.1"
|
32
|
+
LXC_NETMASK="255.255.255.0"
|
33
|
+
LXC_NETWORK="10.0.252.0/24"
|
34
|
+
LXC_DHCP_RANGE="10.0.253.2,10.0.252.254"
|
35
|
+
LXC_DHCP_MAX="253"
|
36
|
+
|
37
|
+
LXC_SHUTDOWN_TIMEOUT=120
|
@@ -9,6 +9,6 @@ fi
|
|
9
9
|
echo 'An old kernel was found on the guest machine and it will be upgraded' 1>&2
|
10
10
|
echo 'Please reload the box after provisioning when finished' 1>&2
|
11
11
|
sudo apt-get update
|
12
|
-
sudo apt-get install linux-image-3.5.0-
|
13
|
-
sudo apt-get
|
12
|
+
sudo apt-get install linux-image-3.5.0-28-generic linux-headers-3.5.0-28-generic -y
|
13
|
+
sudo apt-get upgrade -y
|
14
14
|
sudo apt-get autoremove -y
|
data/development/site.pp
CHANGED
@@ -5,6 +5,9 @@ exec {
|
|
5
5
|
'echo "alias be=\"bundle exec\"" >> /home/vagrant/.bashrc':
|
6
6
|
unless => 'grep -q "bundle exec" /home/vagrant/.bashrc';
|
7
7
|
|
8
|
+
'echo "export VAGRANT_DEFAULT_PROVIDER=lxc" >> /home/vagrant/.bashrc':
|
9
|
+
unless => 'grep -q "VAGRANT_DEFAULT_PROVIDER" /home/vagrant/.bashrc';
|
10
|
+
|
8
11
|
'echo "cd /vagrant" >> /home/vagrant/.bashrc':
|
9
12
|
unless => 'grep -q "cd /vagrant" /home/vagrant/.bashrc';
|
10
13
|
}
|
data/example/Vagrantfile
CHANGED
@@ -32,11 +32,25 @@ echo "Hi there I'm a shell script used for provisioning"
|
|
32
32
|
releases.each do |release|
|
33
33
|
config.vm.define(release) do |lxc_config|
|
34
34
|
lxc_config.vm.box = "#{release}64"
|
35
|
-
lxc_config.vm.box_url = "http://dl.dropbox.com/u/13510779/lxc-#{release}-amd64-2013-
|
35
|
+
lxc_config.vm.box_url = "http://dl.dropbox.com/u/13510779/lxc-#{release}-amd64-2013-05-08.box"
|
36
|
+
lxc_config.vm.network :forwarded_port, guest: 80, host: (port += 1)
|
36
37
|
# Uncomment if you want to try out a box built locally
|
37
38
|
# lxc_config.vm.box_url = "../boxes/output/lxc-#{release}64.box"
|
38
39
|
lxc_config.vm.hostname = "lxc-#{release}64-example"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
port = 8090
|
44
|
+
releases = %w(wheezy squeeze sid)
|
45
|
+
releases.each do |release|
|
46
|
+
config.vm.define(release) do |lxc_config|
|
47
|
+
lxc_config.vm.box = "#{release}64"
|
48
|
+
lxc_config.vm.box_url = "http://dl.dropbox.com/u/13510779/lxc-#{release}-amd64-2013-05-08.box"
|
39
49
|
lxc_config.vm.network :forwarded_port, guest: 80, host: (port += 1)
|
50
|
+
# Uncomment if you want to try out a box built locally
|
51
|
+
# lxc_config.vm.box_url = "../boxes/output/lxc-#{release}64.box"
|
52
|
+
# Does not work yet:
|
53
|
+
# lxc_config.vm.hostname = "lxc-#{release}64-example"
|
40
54
|
end
|
41
55
|
end
|
42
56
|
end
|
data/lib/vagrant-lxc/action.rb
CHANGED
@@ -13,6 +13,7 @@ require 'vagrant-lxc/action/forward_ports'
|
|
13
13
|
require 'vagrant-lxc/action/handle_box_metadata'
|
14
14
|
require 'vagrant-lxc/action/is_running'
|
15
15
|
require 'vagrant-lxc/action/message'
|
16
|
+
require 'vagrant-lxc/action/remove_temporary_files'
|
16
17
|
require 'vagrant-lxc/action/setup_package_files'
|
17
18
|
require 'vagrant-lxc/action/share_folders'
|
18
19
|
|
@@ -117,9 +118,10 @@ module Vagrant
|
|
117
118
|
# b.use CheckDependencies
|
118
119
|
b.use Vagrant::Action::Builtin::Call, Created do |env, b2|
|
119
120
|
if env[:result]
|
120
|
-
# TODO:
|
121
|
+
# TODO: Remove this on / after 0.4
|
121
122
|
b2.use Disconnect
|
122
123
|
b2.use ClearForwardedPorts
|
124
|
+
b2.use RemoveTemporaryFiles
|
123
125
|
b2.use Vagrant::Action::Builtin::Call, Vagrant::Action::Builtin::GracefulHalt, :stopped, :running do |env2, b3|
|
124
126
|
if !env2[:result]
|
125
127
|
b3.use ForcedHalt
|
@@ -9,9 +9,7 @@ module Vagrant
|
|
9
9
|
def call(env)
|
10
10
|
if env[:machine].provider.state.id == :running
|
11
11
|
env[:ui].info I18n.t("vagrant_lxc.messages.force_shutdown")
|
12
|
-
|
13
|
-
# work we can issue a lxc-stop.
|
14
|
-
env[:machine].provider.driver.halt
|
12
|
+
env[:machine].provider.driver.forced_halt
|
15
13
|
end
|
16
14
|
|
17
15
|
@app.call(env)
|
@@ -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
|
+
# Continue execution, we need the container to be stopped
|
12
|
+
@app.call env
|
13
|
+
|
14
|
+
if env[:machine].state.id == :stopped
|
15
|
+
@logger.debug 'Removing temporary files'
|
16
|
+
tmp_path = env[:machine].provider.driver.rootfs_path.join('tmp')
|
17
|
+
system "sudo rm -rf #{tmp_path}/*"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/vagrant-lxc/driver.rb
CHANGED
@@ -69,11 +69,11 @@ module Vagrant
|
|
69
69
|
@cli.transition_to(:running) { |c| c.start(customizations, (extra || nil)) }
|
70
70
|
end
|
71
71
|
|
72
|
-
def
|
72
|
+
def forced_halt
|
73
73
|
@logger.info('Shutting down container...')
|
74
|
-
|
75
|
-
# TODO: issue an lxc-stop if a timeout gets reached
|
76
74
|
@cli.transition_to(:stopped) { |c| c.shutdown }
|
75
|
+
rescue CLI::TargetStateNotReached
|
76
|
+
@cli.transition_to(:stopped) { |c| c.stop }
|
77
77
|
end
|
78
78
|
|
79
79
|
def destroy
|
@@ -10,6 +10,12 @@ module Vagrant
|
|
10
10
|
attr_accessor :name
|
11
11
|
|
12
12
|
class TransitionBlockNotProvided < RuntimeError; end
|
13
|
+
class TargetStateNotReached < RuntimeError
|
14
|
+
def initialize(target_state, state)
|
15
|
+
msg = "Target state '#{target_state}' not reached, currently on '#{state}'"
|
16
|
+
super(msg)
|
17
|
+
end
|
18
|
+
end
|
13
19
|
|
14
20
|
# Include this so we can use `Subprocess` more easily.
|
15
21
|
include Vagrant::Util::Retryable
|
@@ -60,6 +66,10 @@ module Vagrant
|
|
60
66
|
run :start, '-d', '--name', @name, *options
|
61
67
|
end
|
62
68
|
|
69
|
+
def stop
|
70
|
+
run :stop, '--name', @name
|
71
|
+
end
|
72
|
+
|
63
73
|
def shutdown
|
64
74
|
run :shutdown, '--name', @name
|
65
75
|
end
|
@@ -76,12 +86,20 @@ module Vagrant
|
|
76
86
|
run :attach, '--name', @name, *((extra || []) + cmd)
|
77
87
|
end
|
78
88
|
|
79
|
-
def transition_to(
|
89
|
+
def transition_to(target_state, tries = 30, timeout = 1, &block)
|
80
90
|
raise TransitionBlockNotProvided unless block_given?
|
81
91
|
|
82
92
|
yield self
|
83
93
|
|
84
|
-
|
94
|
+
while (last_state = self.state) != target_state && tries > 0
|
95
|
+
@logger.debug "Target state '#{target_state}' not reached, currently on '#{last_state}'"
|
96
|
+
sleep timeout
|
97
|
+
tries -= 1
|
98
|
+
end
|
99
|
+
|
100
|
+
unless last_state == target_state
|
101
|
+
raise TargetStateNotReached.new target_state, last_state
|
102
|
+
end
|
85
103
|
end
|
86
104
|
|
87
105
|
private
|