vagrant-hyperkit 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/.rspec +1 -0
- data/CHANGELOG.md +20 -0
- data/Gemfile +14 -0
- data/LICENSE +9 -0
- data/README.md +221 -0
- data/Rakefile +22 -0
- data/lib/vagrant-hyperkit.rb +22 -0
- data/lib/vagrant-hyperkit/action.rb +195 -0
- data/lib/vagrant-hyperkit/action/boot.rb +185 -0
- data/lib/vagrant-hyperkit/action/import.rb +69 -0
- data/lib/vagrant-hyperkit/action/is_created.rb +18 -0
- data/lib/vagrant-hyperkit/action/is_stopped.rb +18 -0
- data/lib/vagrant-hyperkit/action/message_already_created.rb +16 -0
- data/lib/vagrant-hyperkit/action/message_not_created.rb +16 -0
- data/lib/vagrant-hyperkit/action/message_will_not_destroy.rb +16 -0
- data/lib/vagrant-hyperkit/action/read_ssh_info.rb +27 -0
- data/lib/vagrant-hyperkit/action/read_state.rb +53 -0
- data/lib/vagrant-hyperkit/action/stop_instance.rb +49 -0
- data/lib/vagrant-hyperkit/action/terminate_instance.rb +31 -0
- data/lib/vagrant-hyperkit/action/timed_provision.rb +21 -0
- data/lib/vagrant-hyperkit/action/wait_for_state.rb +41 -0
- data/lib/vagrant-hyperkit/config.rb +83 -0
- data/lib/vagrant-hyperkit/errors.rb +19 -0
- data/lib/vagrant-hyperkit/plugin.rb +73 -0
- data/lib/vagrant-hyperkit/provider.rb +67 -0
- data/lib/vagrant-hyperkit/util/timer.rb +17 -0
- data/lib/vagrant-hyperkit/util/vagrant-hyperkit.rb +79 -0
- data/lib/vagrant-hyperkit/version.rb +5 -0
- data/locales/en.yml +83 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/vagrant-hyperkit/config_spec.rb +33 -0
- data/templates/metadata.json.erb +3 -0
- data/templates/vagrant-aws_package_Vagrantfile.erb +5 -0
- data/vagrant-hyperkit.gemspec +61 -0
- data/vendor/xhyve-ruby/.gitignore +8 -0
- data/vendor/xhyve-ruby/.travis.yml +10 -0
- data/vendor/xhyve-ruby/Gemfile +3 -0
- data/vendor/xhyve-ruby/README.md +33 -0
- data/vendor/xhyve-ruby/Rakefile +42 -0
- data/vendor/xhyve-ruby/example/test.rb +17 -0
- data/vendor/xhyve-ruby/lib/rubygems_plugin.rb +7 -0
- data/vendor/xhyve-ruby/lib/xhyve.rb +4 -0
- data/vendor/xhyve-ruby/lib/xhyve/dhcp.rb +54 -0
- data/vendor/xhyve-ruby/lib/xhyve/guest.rb +92 -0
- data/vendor/xhyve-ruby/lib/xhyve/vendor/xhyve +0 -0
- data/vendor/xhyve-ruby/lib/xhyve/version.rb +4 -0
- data/vendor/xhyve-ruby/spec/fixtures/dhcpd_leases.txt +42 -0
- data/vendor/xhyve-ruby/spec/fixtures/guest/README.md +33 -0
- data/vendor/xhyve-ruby/spec/fixtures/guest/initrd +0 -0
- data/vendor/xhyve-ruby/spec/fixtures/guest/vmlinuz +0 -0
- data/vendor/xhyve-ruby/spec/lib/dhcp_spec.rb +35 -0
- data/vendor/xhyve-ruby/spec/lib/guest_spec.rb +51 -0
- data/vendor/xhyve-ruby/spec/spec_helper.rb +52 -0
- data/vendor/xhyve-ruby/xhyve-ruby.gemspec +23 -0
- metadata +192 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f5ce45036bd7a7d3f65d972301650b4700baf1d2
|
4
|
+
data.tar.gz: 68a19a45835c28643262be39618916132eb7aa21
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3fa1b42098d6f408c4ca34408a25b2d527699cdbcc470d4326b2bc9b199a824477d81f9fc8f2a72334a1aebba668cf845fa6e9fc8880b362a31ed050f9dca004
|
7
|
+
data.tar.gz: 9f7865ae40d23bc5fef0e6ec5cf94bfa01c5a7c4b316f573fd00bed66824c4ccf4b8d8e93910bb15e5758e6f705b1ad9dc0315a23f22ebf057304b83cb63d4a8
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# OS-specific
|
2
|
+
.DS_Store
|
3
|
+
|
4
|
+
# editors
|
5
|
+
*.swp
|
6
|
+
|
7
|
+
# Bundler/Rubygems
|
8
|
+
*.gem
|
9
|
+
.bundle
|
10
|
+
pkg/*
|
11
|
+
tags
|
12
|
+
Gemfile.lock
|
13
|
+
|
14
|
+
# Vagrant
|
15
|
+
.vagrant
|
16
|
+
Vagrantfile
|
17
|
+
example_box
|
18
|
+
example.box
|
19
|
+
|
20
|
+
# RVM files for gemset/ruby setting
|
21
|
+
.ruby-*
|
22
|
+
.rvmrc
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--format doc --order random --color --fail-fast
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# 0.4.1 (December 10th, 2016)
|
2
|
+
|
3
|
+
* Put the embedded version of xhyve-ruby first in the LOAD_PATH (Guy Pascarella)
|
4
|
+
|
5
|
+
# 0.4.0 (December 10th, 2016)
|
6
|
+
|
7
|
+
* Added qcow support to use with hyperkit
|
8
|
+
* Fixed intermittent failures with certain MAC addresses
|
9
|
+
|
10
|
+
# 0.3.0 (December 5th, 2016)
|
11
|
+
|
12
|
+
* Added `kernel_command` option to set custom kernel parameters (Nuno Passaro)
|
13
|
+
|
14
|
+
# 0.2.0 (July 23, 2016)
|
15
|
+
|
16
|
+
* Added ability to set custom binary (to work with docker beta etc)
|
17
|
+
|
18
|
+
# 0.1.1 (April 5, 2016)
|
19
|
+
|
20
|
+
* Initial release.
|
data/Gemfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
group :plugins do
|
4
|
+
gemspec
|
5
|
+
gem "xhyve-ruby", :path => "vendor/xhyve-ruby"
|
6
|
+
end
|
7
|
+
|
8
|
+
group :development do
|
9
|
+
# We depend on Vagrant for development, but we don't add it as a
|
10
|
+
# gem dependency because we expect to be installed within the
|
11
|
+
# Vagrant environment itself using `vagrant plugin`.
|
12
|
+
gem "vagrant", :git => "https://github.com/mitchellh/vagrant.git"
|
13
|
+
end
|
14
|
+
|
data/LICENSE
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
Copyright (c) 2016 Patrick Armstrong
|
3
|
+
Copyright (c) 2014 Mitchell Hashimoto
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
6
|
+
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
8
|
+
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,221 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
bundle install
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
508 bundler build
|
10
|
+
509 bundle build
|
11
|
+
510 bundle gem vagrant-xhyve
|
12
|
+
511 ls -l
|
13
|
+
512 ls -ltr
|
14
|
+
513 find . -name '*gem' -print
|
15
|
+
514 bundle package
|
16
|
+
515 rake build
|
17
|
+
516 ls -l
|
18
|
+
517 df -h
|
19
|
+
518 rake build --trace
|
20
|
+
519 ruby --version
|
21
|
+
520 rake build --help
|
22
|
+
521 rake build -v
|
23
|
+
522 rake build --help
|
24
|
+
523 rake build -t
|
25
|
+
524 pwd
|
26
|
+
525 rake build
|
27
|
+
526 vagrant plugin list
|
28
|
+
527 pwd
|
29
|
+
528 rake build
|
30
|
+
529 rake build
|
31
|
+
530 ls -l
|
32
|
+
531 sudo rm Gemfile.lock
|
33
|
+
532 rake build
|
34
|
+
533 pwd
|
35
|
+
534 sudo bundle install
|
36
|
+
535 rake build
|
37
|
+
536 ls -l
|
38
|
+
537 ls -l pkg/
|
39
|
+
538 vagrant plugin list
|
40
|
+
539 vagrant plugin --help
|
41
|
+
540 vagrant plugin uninstall vagrant-xhyve
|
42
|
+
541 vagrant plugin install pkg/vagrant-xhyve-0.4.2.gem
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
# Vagrant xhyve Provider
|
64
|
+
|
65
|
+
[![Gem Version](https://badge.fury.io/rb/vagrant-xhyve.svg)](https://badge.fury.io/rb/vagrant-xhyve)
|
66
|
+
|
67
|
+
This is a [Vagrant](http://www.vagrantup.com) plugin that adds an [xhyve](http://xhyve.org)
|
68
|
+
provider to Vagrant.
|
69
|
+
|
70
|
+
## Features
|
71
|
+
|
72
|
+
* Basic features work
|
73
|
+
* Can work with Hyperkit fork of Xhyve
|
74
|
+
* qcow image support
|
75
|
+
|
76
|
+
## Limitations
|
77
|
+
|
78
|
+
You need to use sudo for most vagrant actions with the xhyve driver,
|
79
|
+
due to the entitlements needed for xhyve to run without sudo. More details
|
80
|
+
in the [xhyve github issue](https://github.com/mist64/xhyve/issues/60).
|
81
|
+
|
82
|
+
## Usage
|
83
|
+
|
84
|
+
Install using standard Vagrant plugin installation methods. After
|
85
|
+
installing, `vagrant up` and specify the `xhyve` provider. An example is
|
86
|
+
shown below.
|
87
|
+
|
88
|
+
```
|
89
|
+
$ vagrant plugin install vagrant-xhyve
|
90
|
+
...
|
91
|
+
$ sudo vagrant up --provider=xhyve
|
92
|
+
...
|
93
|
+
```
|
94
|
+
|
95
|
+
Of course prior to doing this, you'll need to obtain an xhyve-compatible
|
96
|
+
box file for Vagrant.
|
97
|
+
|
98
|
+
## Quick Start
|
99
|
+
|
100
|
+
After installing the plugin (instructions above), you can try an xhyve ubuntu
|
101
|
+
linux example. This is similar to the example from the xhyve intro blog post.
|
102
|
+
|
103
|
+
```
|
104
|
+
$ mkdir xhyve-vagrant
|
105
|
+
$ cd xhyve-vagrant
|
106
|
+
$ vagrant init oldpatricka/ubuntu-14.04
|
107
|
+
$ sudo vagrant up --provider xhyve
|
108
|
+
...
|
109
|
+
```
|
110
|
+
|
111
|
+
This will start an Ubuntu Linux instance. you can log in with:
|
112
|
+
|
113
|
+
```
|
114
|
+
$ sudo vagrant ssh
|
115
|
+
```
|
116
|
+
|
117
|
+
## Box Format
|
118
|
+
|
119
|
+
The vagrant-xhyve box format is pretty straightforward. See
|
120
|
+
the [example_box/ directory](https://github.com/oldpatricka/vagrant-xhyve/tree/master/example_box).
|
121
|
+
That directory also contains instructions on how to build a box.
|
122
|
+
|
123
|
+
## Configuration
|
124
|
+
|
125
|
+
This provider exposes quite a few provider-specific configuration options:
|
126
|
+
|
127
|
+
* `memory` - The amount of memory to give the VM. This can just be a simple
|
128
|
+
integer for memory in MB or you can use the suffixed style, eg. 2G for two
|
129
|
+
Gigabytes
|
130
|
+
* `cpus` - The number of CPUs to give the VM
|
131
|
+
* `xhyve_binary` - use a custom xhyve version
|
132
|
+
* kernel_command - send a custom kernel boot command
|
133
|
+
|
134
|
+
These can be set like typical provider-specific configuration:
|
135
|
+
|
136
|
+
```ruby
|
137
|
+
Vagrant.configure("2") do |config|
|
138
|
+
# ... other stuff
|
139
|
+
|
140
|
+
config.vm.provider :xhyve do |xhyve|
|
141
|
+
xhyve.cpus = 2
|
142
|
+
xhyve.memory = "1G"
|
143
|
+
xhyve.xhyve_binary = "/Applications/Docker.app/Contents/MacOS/com.docker.hyperkit"
|
144
|
+
xhyve.kernel_command = "root=/dev/mapper/centos-root ro crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap acpi=off console=ttyS0 LANG=en_GB.UTF-8" # example for a CentOS installed in a LVM filesystem
|
145
|
+
end
|
146
|
+
end
|
147
|
+
```
|
148
|
+
## Synced Folders
|
149
|
+
|
150
|
+
There is minimal support for synced folders. Upon `vagrant up`,
|
151
|
+
`vagrant reload`, and `vagrant provision`, the XHYVE provider will use
|
152
|
+
`rsync` (if available) to uni-directionally sync the folder to
|
153
|
+
the remote machine over SSH.
|
154
|
+
|
155
|
+
## Using Docker's HyperKit Fork of Xhyve
|
156
|
+
|
157
|
+
Docker has a very nice port of Xhyve called [HyperKit](https://github.com/docker/hyperkit). It has some interesting features like better stability and qcow support (which this provider can't use yet).
|
158
|
+
|
159
|
+
If you want to try it out, either install hyperkit directly, or you can use the version bundled with [Docker for Mac](https://docs.docker.com/engine/installation/mac/). The path to the binary is `/Applications/Docker.app/Contents/MacOS/com.docker.hyperkit`. See the configuration section above for how to use this with the `xhyve_binary` option.
|
160
|
+
|
161
|
+
## Questions
|
162
|
+
|
163
|
+
Q. Should I use this for my work?
|
164
|
+
|
165
|
+
A. Do you want to keep your job? I'm not even sure you should use this for toy
|
166
|
+
projects.
|
167
|
+
|
168
|
+
Q. Why?
|
169
|
+
|
170
|
+
A. This project is powered by ignorance and good intentions.
|
171
|
+
|
172
|
+
Q. Will I ever not have to use sudo or setuid root?
|
173
|
+
|
174
|
+
A. There's a theory in that issue linked above that wrapping xhyve in an
|
175
|
+
app store app would help. If that were the case, you could probably use the
|
176
|
+
embedded binary with vagrant-xhyve. Another option is to use setuid root.
|
177
|
+
|
178
|
+
Q. This sucks.
|
179
|
+
|
180
|
+
A. That's not a question, but why don't you try out [another implementation](https://github.com/sirn/vagrant-xhyve). Looks pretty nice.
|
181
|
+
|
182
|
+
## Acknowledgements
|
183
|
+
|
184
|
+
This plugin was heavilly cribbed from the vagrant-aws and vagrant-virtualbox
|
185
|
+
providers. So thanks for those.
|
186
|
+
|
187
|
+
This also uses the nice [xhyve-ruby](https://github.com/dalehamel/xhyve-ruby)
|
188
|
+
gem, by Dale Hamel.
|
189
|
+
|
190
|
+
## Development
|
191
|
+
|
192
|
+
To work on the `vagrant-xhyve` plugin, clone this repository out, and use
|
193
|
+
[Bundler](http://gembundler.com) to get the dependencies:
|
194
|
+
|
195
|
+
```
|
196
|
+
$ bundle
|
197
|
+
```
|
198
|
+
|
199
|
+
Once you have the dependencies, verify the unit tests pass with `rake`:
|
200
|
+
|
201
|
+
```
|
202
|
+
$ bundle exec rake
|
203
|
+
```
|
204
|
+
|
205
|
+
If those pass, you're ready to start developing the plugin. You can test
|
206
|
+
the plugin without installing it into your Vagrant environment by just
|
207
|
+
creating a `Vagrantfile` in the top level of this directory (it is gitignored)
|
208
|
+
and add the following line to your `Vagrantfile`
|
209
|
+
```ruby
|
210
|
+
Vagrant.require_plugin "vagrant-xhyve"
|
211
|
+
```
|
212
|
+
Use bundler to execute Vagrant:
|
213
|
+
```
|
214
|
+
$ bundle exec vagrant up --provider=xhyve
|
215
|
+
```
|
216
|
+
|
217
|
+
## Contributors
|
218
|
+
|
219
|
+
* Patrick Armstrong
|
220
|
+
* Nuno Passaro
|
221
|
+
* Guy Pascarella
|
data/Rakefile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
require 'rspec/core/rake_task'
|
4
|
+
|
5
|
+
# Immediately sync all stdout so that tools like buildbot can
|
6
|
+
# immediately load in the output.
|
7
|
+
$stdout.sync = true
|
8
|
+
$stderr.sync = true
|
9
|
+
|
10
|
+
# Change to the directory of this file.
|
11
|
+
Dir.chdir(File.expand_path("../", __FILE__))
|
12
|
+
|
13
|
+
# This installs the tasks that help with gem creation and
|
14
|
+
# publishing.
|
15
|
+
Bundler::GemHelper.install_tasks
|
16
|
+
|
17
|
+
# Install the `spec` task so that we can run tests.
|
18
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
19
|
+
t.rspec_opts = "--order defined"
|
20
|
+
end
|
21
|
+
# Default task is to run the unit tests
|
22
|
+
task :default => :spec
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require "pathname"
|
2
|
+
|
3
|
+
require "vagrant-hyperkit/plugin"
|
4
|
+
|
5
|
+
module VagrantPlugins
|
6
|
+
module HYPERKIT
|
7
|
+
lib_path = Pathname.new(File.expand_path("../vagrant-hyperkit", __FILE__))
|
8
|
+
autoload :Action, lib_path.join("action")
|
9
|
+
autoload :Errors, lib_path.join("errors")
|
10
|
+
|
11
|
+
# Put vagrant-xhyve-x.y.z/vendor/xhyve-ruby/lib on the LOAD_PATH before
|
12
|
+
# the auto-loaded xhyve-ruby-a.b.c
|
13
|
+
$LOAD_PATH.unshift(Pathname.new(File.expand_path("../../vendor/xhyve-ruby/lib", __FILE__)))
|
14
|
+
|
15
|
+
# This returns the path to the source of this plugin.
|
16
|
+
#
|
17
|
+
# @return [Pathname]
|
18
|
+
def self.source_root
|
19
|
+
@source_root ||= Pathname.new(File.expand_path("../../", __FILE__))
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,195 @@
|
|
1
|
+
require "pathname"
|
2
|
+
|
3
|
+
require "vagrant/action/builder"
|
4
|
+
|
5
|
+
module VagrantPlugins
|
6
|
+
module HYPERKIT
|
7
|
+
module Action
|
8
|
+
# Include the built-in modules so we can use them as top-level things.
|
9
|
+
include Vagrant::Action::Builtin
|
10
|
+
|
11
|
+
def self.action_package
|
12
|
+
Vagrant::Action::Builder.new.tap do |b|
|
13
|
+
b.use Call, IsCreated do |env, b2|
|
14
|
+
if !env[:result]
|
15
|
+
b2.use MessageNotCreated
|
16
|
+
next
|
17
|
+
end
|
18
|
+
|
19
|
+
# Connect to AWS and then Create a package from the server instance
|
20
|
+
#b2.use ConnectAWS
|
21
|
+
b2.use PackageInstance
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# This action is called to halt the remote machine.
|
27
|
+
def self.action_halt
|
28
|
+
Vagrant::Action::Builder.new.tap do |b|
|
29
|
+
b.use ConfigValidate
|
30
|
+
b.use ReadState
|
31
|
+
b.use Call, IsCreated do |env, b2|
|
32
|
+
if env[:result]
|
33
|
+
b2.use Call, GracefulHalt, :stopped, :running do |env2, b3|
|
34
|
+
if !env2[:result]
|
35
|
+
b3.use StopInstance
|
36
|
+
end
|
37
|
+
end
|
38
|
+
else
|
39
|
+
b2.use MessageNotCreated
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
# This action is called to terminate the remote machine.
|
46
|
+
def self.action_destroy
|
47
|
+
Vagrant::Action::Builder.new.tap do |b|
|
48
|
+
b.use Call, DestroyConfirm do |env, b2|
|
49
|
+
if env[:result]
|
50
|
+
b2.use ConfigValidate
|
51
|
+
b2.use Call, IsCreated do |env2, b3|
|
52
|
+
if !env2[:result]
|
53
|
+
b3.use MessageNotCreated
|
54
|
+
next
|
55
|
+
end
|
56
|
+
b3.use TerminateInstance
|
57
|
+
#b3.use ProvisionerCleanup if defined?(ProvisionerCleanup)
|
58
|
+
end
|
59
|
+
else
|
60
|
+
b2.use MessageWillNotDestroy
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# This action is called when `vagrant provision` is called.
|
67
|
+
def self.action_provision
|
68
|
+
Vagrant::Action::Builder.new.tap do |b|
|
69
|
+
b.use ConfigValidate
|
70
|
+
b.use Call, IsCreated do |env, b2|
|
71
|
+
if !env[:result]
|
72
|
+
b2.use MessageNotCreated
|
73
|
+
next
|
74
|
+
end
|
75
|
+
|
76
|
+
b2.use Provision
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
# This action is called to read the SSH info of the machine. The
|
82
|
+
# resulting state is expected to be put into the `:machine_ssh_info`
|
83
|
+
# key.
|
84
|
+
def self.action_read_ssh_info
|
85
|
+
Vagrant::Action::Builder.new.tap do |b|
|
86
|
+
b.use ConfigValidate
|
87
|
+
b.use ReadState
|
88
|
+
b.use ReadSSHInfo
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
# This action is called to read the state of the machine. The
|
93
|
+
# resulting state is expected to be put into the `:machine_state_id`
|
94
|
+
# key.
|
95
|
+
def self.action_read_state
|
96
|
+
Vagrant::Action::Builder.new.tap do |b|
|
97
|
+
b.use ConfigValidate
|
98
|
+
b.use ReadState
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
# This action is called to SSH into the machine.
|
103
|
+
def self.action_ssh
|
104
|
+
Vagrant::Action::Builder.new.tap do |b|
|
105
|
+
b.use ConfigValidate
|
106
|
+
b.use Call, IsCreated do |env, b2|
|
107
|
+
if !env[:result]
|
108
|
+
b2.use MessageNotCreated
|
109
|
+
next
|
110
|
+
end
|
111
|
+
|
112
|
+
b2.use SSHExec
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
def self.action_ssh_run
|
118
|
+
Vagrant::Action::Builder.new.tap do |b|
|
119
|
+
b.use ConfigValidate
|
120
|
+
b.use Call, IsCreated do |env, b2|
|
121
|
+
if !env[:result]
|
122
|
+
b2.use MessageNotCreated
|
123
|
+
next
|
124
|
+
end
|
125
|
+
|
126
|
+
b2.use SSHRun
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
def self.action_prepare_boot
|
132
|
+
Vagrant::Action::Builder.new.tap do |b|
|
133
|
+
b.use Import
|
134
|
+
b.use Provision
|
135
|
+
b.use SyncedFolders
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
# This action is called to bring the box up from nothing.
|
140
|
+
def self.action_up
|
141
|
+
Vagrant::Action::Builder.new.tap do |b|
|
142
|
+
b.use HandleBox
|
143
|
+
b.use ConfigValidate
|
144
|
+
b.use BoxCheckOutdated
|
145
|
+
b.use Call, IsCreated do |env1, b1|
|
146
|
+
if not env1[:result]
|
147
|
+
b1.use action_prepare_boot
|
148
|
+
end
|
149
|
+
|
150
|
+
b1.use Boot # launch a new instance
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
def self.action_reload
|
156
|
+
Vagrant::Action::Builder.new.tap do |b|
|
157
|
+
b.use ConfigValidate
|
158
|
+
b.use Call, IsCreated do |env, b2|
|
159
|
+
if !env[:result]
|
160
|
+
b2.use MessageNotCreated
|
161
|
+
next
|
162
|
+
end
|
163
|
+
|
164
|
+
b2.use action_halt
|
165
|
+
b2.use Call, WaitForState, :stopped, 120 do |env2, b3|
|
166
|
+
if env2[:result]
|
167
|
+
b3.use action_up
|
168
|
+
else
|
169
|
+
# TODO we couldn't reach :stopped, what now?
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
# The autoload farm
|
177
|
+
action_root = Pathname.new(File.expand_path("../action", __FILE__))
|
178
|
+
autoload :IsCreated, action_root.join("is_created")
|
179
|
+
autoload :IsStopped, action_root.join("is_stopped")
|
180
|
+
autoload :MessageAlreadyCreated, action_root.join("message_already_created")
|
181
|
+
autoload :MessageNotCreated, action_root.join("message_not_created")
|
182
|
+
autoload :MessageWillNotDestroy, action_root.join("message_will_not_destroy")
|
183
|
+
autoload :PackageInstance, action_root.join("package_instance")
|
184
|
+
autoload :ReadSSHInfo, action_root.join("read_ssh_info")
|
185
|
+
autoload :ReadState, action_root.join("read_state")
|
186
|
+
autoload :Import, action_root.join("import")
|
187
|
+
autoload :Boot, action_root.join("boot")
|
188
|
+
autoload :StartInstance, action_root.join("start_instance")
|
189
|
+
autoload :StopInstance, action_root.join("stop_instance")
|
190
|
+
autoload :TerminateInstance, action_root.join("terminate_instance")
|
191
|
+
autoload :TimedProvision, action_root.join("timed_provision") # some plugins now expect this action to exist
|
192
|
+
autoload :WaitForState, action_root.join("wait_for_state")
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|