vagrant-xhyve 0.1.0.pre
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 +7 -0
- data/.gitignore +22 -0
- data/.rspec +1 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile +13 -0
- data/LICENSE +9 -0
- data/README.md +140 -0
- data/Rakefile +22 -0
- data/example_box/README.md +31 -0
- data/example_box/initrd.gz +0 -0
- data/example_box/metadata.json +3 -0
- data/example_box/vmlinuz +0 -0
- data/lib/vagrant-xhyve/action/boot.rb +142 -0
- data/lib/vagrant-xhyve/action/import.rb +59 -0
- data/lib/vagrant-xhyve/action/is_created.rb +18 -0
- data/lib/vagrant-xhyve/action/is_stopped.rb +18 -0
- data/lib/vagrant-xhyve/action/message_already_created.rb +16 -0
- data/lib/vagrant-xhyve/action/message_not_created.rb +16 -0
- data/lib/vagrant-xhyve/action/message_will_not_destroy.rb +16 -0
- data/lib/vagrant-xhyve/action/read_ssh_info.rb +33 -0
- data/lib/vagrant-xhyve/action/read_state.rb +43 -0
- data/lib/vagrant-xhyve/action/stop_instance.rb +45 -0
- data/lib/vagrant-xhyve/action/terminate_instance.rb +47 -0
- data/lib/vagrant-xhyve/action/timed_provision.rb +21 -0
- data/lib/vagrant-xhyve/action/wait_for_state.rb +41 -0
- data/lib/vagrant-xhyve/action.rb +193 -0
- data/lib/vagrant-xhyve/config.rb +66 -0
- data/lib/vagrant-xhyve/errors.rb +19 -0
- data/lib/vagrant-xhyve/plugin.rb +73 -0
- data/lib/vagrant-xhyve/provider.rb +50 -0
- data/lib/vagrant-xhyve/util/timer.rb +17 -0
- data/lib/vagrant-xhyve/util/vagrant-xhyve.rb +50 -0
- data/lib/vagrant-xhyve/version.rb +5 -0
- data/lib/vagrant-xhyve.rb +18 -0
- data/locales/en.yml +83 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/vagrant-xhyve/config_spec.rb +33 -0
- data/templates/metadata.json.erb +3 -0
- data/templates/vagrant-aws_package_Vagrantfile.erb +5 -0
- data/vagrant-xhyve.gemspec +60 -0
- metadata +158 -0
@@ -0,0 +1,47 @@
|
|
1
|
+
require "log4r"
|
2
|
+
require "json"
|
3
|
+
require "fileutils"
|
4
|
+
|
5
|
+
module VagrantPlugins
|
6
|
+
module XHYVE
|
7
|
+
module Action
|
8
|
+
# This terminates the running instance.
|
9
|
+
class TerminateInstance
|
10
|
+
def initialize(app, env)
|
11
|
+
@app = app
|
12
|
+
@logger = Log4r::Logger.new("vagrant_xhyve::action::terminate_instance")
|
13
|
+
end
|
14
|
+
|
15
|
+
def call(env)
|
16
|
+
xhyve_pid = env[:machine].id
|
17
|
+
|
18
|
+
if xhyve_pid == nil then
|
19
|
+
@logger.debug("xhyve already gone")
|
20
|
+
elsif process_alive(Integer(xhyve_pid)) then
|
21
|
+
env[:ui].info(" Terminating xhyve instance with PID #{xhyve_pid}")
|
22
|
+
Process.kill(3, Integer(xhyve_pid))
|
23
|
+
else
|
24
|
+
@logger.debug("xhyve PID already gone #{xhyve_pid}")
|
25
|
+
end
|
26
|
+
|
27
|
+
# Destroy the server and remove the tracking ID
|
28
|
+
env[:ui].info(I18n.t("vagrant_xhyve.terminating"))
|
29
|
+
env[:machine].id = nil
|
30
|
+
|
31
|
+
FileUtils.rm_rf(env[:machine].data_dir)
|
32
|
+
|
33
|
+
@app.call(env)
|
34
|
+
end
|
35
|
+
|
36
|
+
def process_alive(pid)
|
37
|
+
begin
|
38
|
+
Process.getpgid(pid)
|
39
|
+
true
|
40
|
+
rescue Errno::ESRCH
|
41
|
+
false
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require "vagrant-xhyve/util/timer"
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module XHYVE
|
5
|
+
module Action
|
6
|
+
# This is the same as the builtin provision except it times the
|
7
|
+
# provisioner runs.
|
8
|
+
class TimedProvision < Vagrant::Action::Builtin::Provision
|
9
|
+
def run_provisioner(env, name, p)
|
10
|
+
timer = Util::Timer.time do
|
11
|
+
super
|
12
|
+
end
|
13
|
+
|
14
|
+
env[:metrics] ||= {}
|
15
|
+
env[:metrics]["provisioner_times"] ||= []
|
16
|
+
env[:metrics]["provisioner_times"] << [name, timer]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require "log4r"
|
2
|
+
require "timeout"
|
3
|
+
|
4
|
+
module VagrantPlugins
|
5
|
+
module XHYVE
|
6
|
+
module Action
|
7
|
+
# This action will wait for a machine to reach a specific state or quit by timeout
|
8
|
+
class WaitForState
|
9
|
+
# env[:result] will be false in case of timeout.
|
10
|
+
# @param [Symbol] state Target machine state.
|
11
|
+
# @param [Number] timeout Timeout in seconds.
|
12
|
+
def initialize(app, env, state, timeout)
|
13
|
+
@app = app
|
14
|
+
@logger = Log4r::Logger.new("vagrant_xhyve::action::wait_for_state")
|
15
|
+
@state = state
|
16
|
+
@timeout = timeout
|
17
|
+
end
|
18
|
+
|
19
|
+
def call(env)
|
20
|
+
env[:result] = true
|
21
|
+
if env[:machine].state.id == @state
|
22
|
+
@logger.info(I18n.t("vagrant_xhyve.already_status", :status => @state))
|
23
|
+
else
|
24
|
+
@logger.info("Waiting for machine to reach state #{@state}")
|
25
|
+
begin
|
26
|
+
Timeout.timeout(@timeout) do
|
27
|
+
until env[:machine].state.id == @state
|
28
|
+
sleep 2
|
29
|
+
end
|
30
|
+
end
|
31
|
+
rescue Timeout::Error
|
32
|
+
env[:result] = false # couldn't reach state in time
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
@app.call(env)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,193 @@
|
|
1
|
+
require "pathname"
|
2
|
+
|
3
|
+
require "vagrant/action/builder"
|
4
|
+
|
5
|
+
module VagrantPlugins
|
6
|
+
module XHYVE
|
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 Call, IsCreated do |env, b2|
|
31
|
+
if env[:result]
|
32
|
+
b2.use Call, GracefulHalt, :stopped, :running do |env2, b3|
|
33
|
+
if !env2[:result]
|
34
|
+
b3.use StopInstance
|
35
|
+
end
|
36
|
+
end
|
37
|
+
else
|
38
|
+
b2.use MessageNotCreated
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# This action is called to terminate the remote machine.
|
45
|
+
def self.action_destroy
|
46
|
+
Vagrant::Action::Builder.new.tap do |b|
|
47
|
+
b.use Call, DestroyConfirm do |env, b2|
|
48
|
+
if env[:result]
|
49
|
+
b2.use ConfigValidate
|
50
|
+
b2.use Call, IsCreated do |env2, b3|
|
51
|
+
if !env2[:result]
|
52
|
+
b3.use MessageNotCreated
|
53
|
+
next
|
54
|
+
end
|
55
|
+
b3.use TerminateInstance
|
56
|
+
#b3.use ProvisionerCleanup if defined?(ProvisionerCleanup)
|
57
|
+
end
|
58
|
+
else
|
59
|
+
b2.use MessageWillNotDestroy
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
# This action is called when `vagrant provision` is called.
|
66
|
+
def self.action_provision
|
67
|
+
Vagrant::Action::Builder.new.tap do |b|
|
68
|
+
b.use ConfigValidate
|
69
|
+
b.use Call, IsCreated do |env, b2|
|
70
|
+
if !env[:result]
|
71
|
+
b2.use MessageNotCreated
|
72
|
+
next
|
73
|
+
end
|
74
|
+
|
75
|
+
b2.use Provision
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
# This action is called to read the SSH info of the machine. The
|
81
|
+
# resulting state is expected to be put into the `:machine_ssh_info`
|
82
|
+
# key.
|
83
|
+
def self.action_read_ssh_info
|
84
|
+
Vagrant::Action::Builder.new.tap do |b|
|
85
|
+
b.use ConfigValidate
|
86
|
+
b.use ReadSSHInfo
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
# This action is called to read the state of the machine. The
|
91
|
+
# resulting state is expected to be put into the `:machine_state_id`
|
92
|
+
# key.
|
93
|
+
def self.action_read_state
|
94
|
+
Vagrant::Action::Builder.new.tap do |b|
|
95
|
+
b.use ConfigValidate
|
96
|
+
b.use ReadState
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
# This action is called to SSH into the machine.
|
101
|
+
def self.action_ssh
|
102
|
+
Vagrant::Action::Builder.new.tap do |b|
|
103
|
+
b.use ConfigValidate
|
104
|
+
b.use Call, IsCreated do |env, b2|
|
105
|
+
if !env[:result]
|
106
|
+
b2.use MessageNotCreated
|
107
|
+
next
|
108
|
+
end
|
109
|
+
|
110
|
+
b2.use SSHExec
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
def self.action_ssh_run
|
116
|
+
Vagrant::Action::Builder.new.tap do |b|
|
117
|
+
b.use ConfigValidate
|
118
|
+
b.use Call, IsCreated do |env, b2|
|
119
|
+
if !env[:result]
|
120
|
+
b2.use MessageNotCreated
|
121
|
+
next
|
122
|
+
end
|
123
|
+
|
124
|
+
b2.use SSHRun
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
def self.action_prepare_boot
|
130
|
+
Vagrant::Action::Builder.new.tap do |b|
|
131
|
+
b.use Import
|
132
|
+
b.use Provision
|
133
|
+
b.use SyncedFolders
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
# This action is called to bring the box up from nothing.
|
138
|
+
def self.action_up
|
139
|
+
Vagrant::Action::Builder.new.tap do |b|
|
140
|
+
b.use HandleBox
|
141
|
+
b.use ConfigValidate
|
142
|
+
b.use BoxCheckOutdated
|
143
|
+
b.use Call, IsCreated do |env1, b1|
|
144
|
+
if not env1[:result]
|
145
|
+
b1.use action_prepare_boot
|
146
|
+
end
|
147
|
+
|
148
|
+
b1.use Boot # launch a new instance
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
def self.action_reload
|
154
|
+
Vagrant::Action::Builder.new.tap do |b|
|
155
|
+
b.use ConfigValidate
|
156
|
+
b.use Call, IsCreated do |env, b2|
|
157
|
+
if !env[:result]
|
158
|
+
b2.use MessageNotCreated
|
159
|
+
next
|
160
|
+
end
|
161
|
+
|
162
|
+
b2.use action_halt
|
163
|
+
b2.use Call, WaitForState, :stopped, 120 do |env2, b3|
|
164
|
+
if env2[:result]
|
165
|
+
b3.use action_up
|
166
|
+
else
|
167
|
+
# TODO we couldn't reach :stopped, what now?
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
# The autoload farm
|
175
|
+
action_root = Pathname.new(File.expand_path("../action", __FILE__))
|
176
|
+
autoload :IsCreated, action_root.join("is_created")
|
177
|
+
autoload :IsStopped, action_root.join("is_stopped")
|
178
|
+
autoload :MessageAlreadyCreated, action_root.join("message_already_created")
|
179
|
+
autoload :MessageNotCreated, action_root.join("message_not_created")
|
180
|
+
autoload :MessageWillNotDestroy, action_root.join("message_will_not_destroy")
|
181
|
+
autoload :PackageInstance, action_root.join("package_instance")
|
182
|
+
autoload :ReadSSHInfo, action_root.join("read_ssh_info")
|
183
|
+
autoload :ReadState, action_root.join("read_state")
|
184
|
+
autoload :Import, action_root.join("import")
|
185
|
+
autoload :Boot, action_root.join("boot")
|
186
|
+
autoload :StartInstance, action_root.join("start_instance")
|
187
|
+
autoload :StopInstance, action_root.join("stop_instance")
|
188
|
+
autoload :TerminateInstance, action_root.join("terminate_instance")
|
189
|
+
autoload :TimedProvision, action_root.join("timed_provision") # some plugins now expect this action to exist
|
190
|
+
autoload :WaitForState, action_root.join("wait_for_state")
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require "vagrant"
|
2
|
+
require "iniparse"
|
3
|
+
|
4
|
+
module VagrantPlugins
|
5
|
+
module XHYVE
|
6
|
+
class Config < Vagrant.plugin("2", :config)
|
7
|
+
|
8
|
+
|
9
|
+
# The number of CPUs to give the VM
|
10
|
+
#
|
11
|
+
# @return [Fixnum]
|
12
|
+
attr_accessor :cpus
|
13
|
+
|
14
|
+
# The amount of memory to give the VM
|
15
|
+
#
|
16
|
+
# This can just be a simple integer for memory in MB
|
17
|
+
# or you can use the suffixed style, eg. 2G for two
|
18
|
+
# Gigabytes
|
19
|
+
#
|
20
|
+
# @return [String]
|
21
|
+
attr_accessor :memory
|
22
|
+
|
23
|
+
# The mac address of the VM
|
24
|
+
#
|
25
|
+
# @return [String]
|
26
|
+
attr_accessor :mac
|
27
|
+
|
28
|
+
# The uuid of the VM
|
29
|
+
#
|
30
|
+
# @return [String]
|
31
|
+
attr_accessor :uuid
|
32
|
+
|
33
|
+
def initialize(region_specific=false)
|
34
|
+
@cpus = UNSET_VALUE
|
35
|
+
@memory = UNSET_VALUE
|
36
|
+
@mac = UNSET_VALUE
|
37
|
+
@uuid = UNSET_VALUE
|
38
|
+
|
39
|
+
# Internal state (prefix with __ so they aren't automatically
|
40
|
+
# merged)
|
41
|
+
@__compiled_region_configs = {}
|
42
|
+
@__finalized = false
|
43
|
+
@__region_config = {}
|
44
|
+
@__region_specific = region_specific
|
45
|
+
end
|
46
|
+
|
47
|
+
#-------------------------------------------------------------------
|
48
|
+
# Internal methods.
|
49
|
+
#-------------------------------------------------------------------
|
50
|
+
|
51
|
+
def finalize!
|
52
|
+
|
53
|
+
@cpus = 1 if @cpus == UNSET_VALUE
|
54
|
+
@memory = 1024 if @cpus == UNSET_VALUE
|
55
|
+
|
56
|
+
# Mark that we finalized
|
57
|
+
@__finalized = true
|
58
|
+
end
|
59
|
+
|
60
|
+
def validate(machine)
|
61
|
+
errors = _detected_errors
|
62
|
+
{ "XHYVE Provider" => errors }
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "vagrant"
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module XHYVE
|
5
|
+
module Errors
|
6
|
+
class VagrantXHYVEError < Vagrant::Errors::VagrantError
|
7
|
+
error_namespace("vagrant_xhyve.errors")
|
8
|
+
end
|
9
|
+
|
10
|
+
class RsyncError < VagrantXYHVEError
|
11
|
+
error_key(:rsync_error)
|
12
|
+
end
|
13
|
+
|
14
|
+
class MkdirError < VagrantXHYVEError
|
15
|
+
error_key(:mkdir_error)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
begin
|
2
|
+
require "vagrant"
|
3
|
+
rescue LoadError
|
4
|
+
raise "The Vagrant XHYVE plugin must be run within Vagrant."
|
5
|
+
end
|
6
|
+
|
7
|
+
# This is a sanity check to make sure no one is attempting to install
|
8
|
+
# this into an early Vagrant version.
|
9
|
+
if Vagrant::VERSION < "1.2.0"
|
10
|
+
raise "The Vagrant XHYVE plugin is only compatible with Vagrant 1.2+"
|
11
|
+
end
|
12
|
+
|
13
|
+
module VagrantPlugins
|
14
|
+
module XHYVE
|
15
|
+
class Plugin < Vagrant.plugin("2")
|
16
|
+
name "XHYVE"
|
17
|
+
description <<-DESC
|
18
|
+
This plugin installs a provider that allows Vagrant to manage
|
19
|
+
machines in XHYVE.
|
20
|
+
DESC
|
21
|
+
|
22
|
+
config(:xhyve, :provider) do
|
23
|
+
require_relative "config"
|
24
|
+
Config
|
25
|
+
end
|
26
|
+
|
27
|
+
provider(:xhyve) do
|
28
|
+
# Setup logging and i18n
|
29
|
+
setup_logging
|
30
|
+
setup_i18n
|
31
|
+
|
32
|
+
# Return the provider
|
33
|
+
require_relative "provider"
|
34
|
+
Provider
|
35
|
+
end
|
36
|
+
|
37
|
+
# This initializes the internationalization strings.
|
38
|
+
def self.setup_i18n
|
39
|
+
I18n.load_path << File.expand_path("locales/en.yml", XHYVE.source_root)
|
40
|
+
I18n.reload!
|
41
|
+
end
|
42
|
+
|
43
|
+
# This sets up our log level to be whatever VAGRANT_LOG is.
|
44
|
+
def self.setup_logging
|
45
|
+
require "log4r"
|
46
|
+
|
47
|
+
level = nil
|
48
|
+
begin
|
49
|
+
level = Log4r.const_get(ENV["VAGRANT_LOG"].upcase)
|
50
|
+
rescue NameError
|
51
|
+
# This means that the logging constant wasn't found,
|
52
|
+
# which is fine. We just keep `level` as `nil`. But
|
53
|
+
# we tell the user.
|
54
|
+
level = nil
|
55
|
+
end
|
56
|
+
|
57
|
+
# Some constants, such as "true" resolve to booleans, so the
|
58
|
+
# above error checking doesn't catch it. This will check to make
|
59
|
+
# sure that the log level is an integer, as Log4r requires.
|
60
|
+
level = nil if !level.is_a?(Integer)
|
61
|
+
|
62
|
+
# Set the logging level on all "vagrant" namespaced
|
63
|
+
# logs as long as we have a valid level.
|
64
|
+
if level
|
65
|
+
logger = Log4r::Logger.new("vagrant_xhyve")
|
66
|
+
logger.outputters = Log4r::Outputter.stderr
|
67
|
+
logger.level = level
|
68
|
+
logger = nil
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require "log4r"
|
2
|
+
require "vagrant"
|
3
|
+
|
4
|
+
module VagrantPlugins
|
5
|
+
module XHYVE
|
6
|
+
class Provider < Vagrant.plugin("2", :provider)
|
7
|
+
def initialize(machine)
|
8
|
+
@machine = machine
|
9
|
+
end
|
10
|
+
|
11
|
+
def action(name)
|
12
|
+
# Attempt to get the action method from the Action class if it
|
13
|
+
# exists, otherwise return nil to show that we don't support the
|
14
|
+
# given action.
|
15
|
+
action_method = "action_#{name}"
|
16
|
+
return Action.send(action_method) if Action.respond_to?(action_method)
|
17
|
+
nil
|
18
|
+
end
|
19
|
+
|
20
|
+
def ssh_info
|
21
|
+
# Run a custom action called "read_ssh_info" which does what it
|
22
|
+
# says and puts the resulting SSH info into the `:machine_ssh_info`
|
23
|
+
# key in the environment.
|
24
|
+
env = @machine.action("read_ssh_info")
|
25
|
+
env[:machine_ssh_info]
|
26
|
+
end
|
27
|
+
|
28
|
+
def state
|
29
|
+
# Run a custom action we define called "read_state" which does
|
30
|
+
# what it says. It puts the state in the `:machine_state_id`
|
31
|
+
# key in the environment.
|
32
|
+
env = @machine.action("read_state")
|
33
|
+
|
34
|
+
state_id = env[:machine_state_id]
|
35
|
+
|
36
|
+
# Get the short and long description
|
37
|
+
short = I18n.t("vagrant_xhyve.states.short_#{state_id}")
|
38
|
+
long = I18n.t("vagrant_xhyve.states.long_#{state_id}")
|
39
|
+
|
40
|
+
# Return the MachineState object
|
41
|
+
Vagrant::MachineState.new(state_id, short, long)
|
42
|
+
end
|
43
|
+
|
44
|
+
def to_s
|
45
|
+
id = @machine.id.nil? ? "new" : @machine.id
|
46
|
+
"XHYVE (#{id})"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module XHYVE
|
3
|
+
module Util
|
4
|
+
class Timer
|
5
|
+
# A basic utility method that times the execution of the given
|
6
|
+
# block and returns it.
|
7
|
+
def self.time
|
8
|
+
start_time = Time.now.to_f
|
9
|
+
yield
|
10
|
+
end_time = Time.now.to_f
|
11
|
+
|
12
|
+
end_time - start_time
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'xhyve'
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module XHYVE
|
5
|
+
module Util
|
6
|
+
class XhyveGuest < Xhyve::Guest
|
7
|
+
|
8
|
+
def initialize(**opts)
|
9
|
+
if opts.has_key? "pid"
|
10
|
+
@pid = pid
|
11
|
+
else
|
12
|
+
@kernel = opts.fetch(:kernel)
|
13
|
+
@initrd = opts.fetch(:initrd)
|
14
|
+
@cmdline = opts.fetch(:cmdline)
|
15
|
+
@blockdevs = [opts[:blockdevs] || []].flatten
|
16
|
+
@memory = opts[:memory] || '500M'
|
17
|
+
@processors = opts[:processors] || '1'
|
18
|
+
@uuid = opts[:uuid] || SecureRandom.uuid
|
19
|
+
@serial = opts[:serial] || 'com1'
|
20
|
+
@acpi = opts[:acpi] || true
|
21
|
+
@networking = opts[:networking] || true
|
22
|
+
@foreground = opts[:foreground] || false
|
23
|
+
@command = build_command
|
24
|
+
@mac = find_mac
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def options
|
29
|
+
{
|
30
|
+
:pid => @pid,
|
31
|
+
:kernel => @kernel,
|
32
|
+
:initrd => @initrd,
|
33
|
+
:cmdline => @cmdline,
|
34
|
+
:blockdevs => @blockdevs,
|
35
|
+
:memory => @memory,
|
36
|
+
:processors => @processors,
|
37
|
+
:uuid => @uuid,
|
38
|
+
:serial => @serial,
|
39
|
+
:acpi => @acpi,
|
40
|
+
:networking => @networking,
|
41
|
+
:foreground => @foreground,
|
42
|
+
:command => @command,
|
43
|
+
:mac => @mac,
|
44
|
+
:ip => ip
|
45
|
+
}
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require "pathname"
|
2
|
+
|
3
|
+
require "vagrant-xhyve/plugin"
|
4
|
+
|
5
|
+
module VagrantPlugins
|
6
|
+
module XHYVE
|
7
|
+
lib_path = Pathname.new(File.expand_path("../vagrant-xhyve", __FILE__))
|
8
|
+
autoload :Action, lib_path.join("action")
|
9
|
+
autoload :Errors, lib_path.join("errors")
|
10
|
+
|
11
|
+
# This returns the path to the source of this plugin.
|
12
|
+
#
|
13
|
+
# @return [Pathname]
|
14
|
+
def self.source_root
|
15
|
+
@source_root ||= Pathname.new(File.expand_path("../../", __FILE__))
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/locales/en.yml
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
en:
|
2
|
+
vagrant_xhyve:
|
3
|
+
already_status: |-
|
4
|
+
The machine is already %{status}.
|
5
|
+
launching_instance: |-
|
6
|
+
Launching an instance with the following settings...
|
7
|
+
not_created: |-
|
8
|
+
Instance is not created. Please run `vagrant up` first.
|
9
|
+
ready: |-
|
10
|
+
Machine is booted and ready for use!
|
11
|
+
rsync_not_found_warning: |-
|
12
|
+
Warning! Folder sync disabled because the rsync binary is missing in the %{side}.
|
13
|
+
Make sure rsync is installed and the binary can be found in the PATH.
|
14
|
+
rsync_folder: |-
|
15
|
+
Rsyncing folder: %{hostpath} => %{guestpath}
|
16
|
+
source_dest_checks_no_vpc: |-
|
17
|
+
Warning! Ignoring source_dest_checks flag as it can only be configured on
|
18
|
+
a VPC instance.
|
19
|
+
starting: |-
|
20
|
+
Starting the instance...
|
21
|
+
stopping: |-
|
22
|
+
Stopping the instance...
|
23
|
+
terminating: |-
|
24
|
+
Terminating the instance...
|
25
|
+
waiting_for_ready: |-
|
26
|
+
Waiting for instance to become "ready"...
|
27
|
+
waiting_for_ssh: |-
|
28
|
+
Waiting for SSH to become available...
|
29
|
+
warn_ssh_access: |-
|
30
|
+
Warning! Vagrant might not be able to SSH into the instance.
|
31
|
+
Please check your security groups settings.
|
32
|
+
will_not_destroy: |-
|
33
|
+
The instance '%{name}' will not be destroyed, since the confirmation
|
34
|
+
was declined.
|
35
|
+
|
36
|
+
errors:
|
37
|
+
rsync_error: |-
|
38
|
+
There was an error when attempting to rsync a shared folder.
|
39
|
+
Please inspect the error message below for more info.
|
40
|
+
|
41
|
+
Host path: %{hostpath}
|
42
|
+
Guest path: %{guestpath}
|
43
|
+
Error: %{stderr}
|
44
|
+
mkdir_error: |-
|
45
|
+
There was an error when attempting to create a shared host folder.
|
46
|
+
Please inspect the error message below for more info.
|
47
|
+
|
48
|
+
Host path: %{hostpath}
|
49
|
+
Error: %{err}
|
50
|
+
|
51
|
+
states:
|
52
|
+
short_not_created: |-
|
53
|
+
not created
|
54
|
+
long_not_created: |-
|
55
|
+
The xhyve VM is not created. Run `vagrant up` to create it.
|
56
|
+
|
57
|
+
short_stopped: |-
|
58
|
+
stopped
|
59
|
+
long_stopped: |-
|
60
|
+
The xhyve VM is stopped. Run `vagrant up` to start it.
|
61
|
+
|
62
|
+
short_stopping: |-
|
63
|
+
stopping
|
64
|
+
long_stopping: |-
|
65
|
+
The xhyve VM is stopping. Wait until is completely stopped to
|
66
|
+
run `vagrant up` and start it.
|
67
|
+
|
68
|
+
short_pending: |-
|
69
|
+
pending
|
70
|
+
long_pending: |-
|
71
|
+
The xhyve VM is pending a start (i.e. this is a transition state).
|
72
|
+
|
73
|
+
short_running: |-
|
74
|
+
running
|
75
|
+
long_running: |-
|
76
|
+
The xhyve VM is running. To stop this machine, you can run
|
77
|
+
`vagrant halt`. To destroy the machine, you can run `vagrant destroy`.
|
78
|
+
|
79
|
+
short_pending: |-
|
80
|
+
pending
|
81
|
+
long_pending: |-
|
82
|
+
The xhyve VM is still being initialized. To destroy this machine,
|
83
|
+
you can run `vagrant destroy`.
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
|