vagrant-xhyve 0.2.0 → 0.3.0
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/README.md +5 -3
- data/lib/vagrant-xhyve/action/boot.rb +107 -85
- data/lib/vagrant-xhyve/action/import.rb +37 -26
- data/lib/vagrant-xhyve/action/read_ssh_info.rb +2 -8
- data/lib/vagrant-xhyve/action/read_state.rb +20 -10
- data/lib/vagrant-xhyve/action/stop_instance.rb +20 -16
- data/lib/vagrant-xhyve/action/terminate_instance.rb +5 -21
- data/lib/vagrant-xhyve/action.rb +2 -0
- data/lib/vagrant-xhyve/config.rb +16 -8
- data/lib/vagrant-xhyve/util/vagrant-xhyve.rb +10 -21
- data/lib/vagrant-xhyve/version.rb +1 -1
- metadata +19 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d1b1e29a5e98f8a0d0586c217e0f1ff017b6ca49
|
4
|
+
data.tar.gz: 4bbd11ce1f843b0075ab5b3edb002b437ab283a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12a7c22f6097c8d7b68b4e4a25a85acce82356084175faeda2a900af8e2117730e4b937047bf591e96cddb99161a06bc97a725f5d982be8926f4ddde7dee1530
|
7
|
+
data.tar.gz: f2ae14dbd96964160a76c87387b10b092e1b501388008a7e8418c7b94c25ba1d8517642ee484ae3bf8cb7e07c560f0fe9136f033f7961ea601e4c97211b8d74f
|
data/README.md
CHANGED
@@ -68,7 +68,8 @@ This provider exposes quite a few provider-specific configuration options:
|
|
68
68
|
* `cpus` - The number of CPUs to give the VM
|
69
69
|
* `xhyve_binary` - use a custom xhyve version (for example, the version of xhyve
|
70
70
|
included with [Docker for Mac Beta](https://docs.docker.com/engine/installation/mac/#docker-for-mac)
|
71
|
-
is interesting. The path is `/Applications/Docker.app/Contents/MacOS/com.docker.hyperkit
|
71
|
+
is interesting. The path is `/Applications/Docker.app/Contents/MacOS/com.docker.hyperkit`. )
|
72
|
+
* kernel_command - send a custom kernel boot command
|
72
73
|
|
73
74
|
These can be set like typical provider-specific configuration:
|
74
75
|
|
@@ -79,7 +80,8 @@ Vagrant.configure("2") do |config|
|
|
79
80
|
config.vm.provider :xhyve do |xhyve|
|
80
81
|
xhyve.cpus = 2
|
81
82
|
xhyve.memory = "1G"
|
82
|
-
|
83
|
+
xhyve.xhyve_binary = "/Applications/Docker.app/Contents/MacOS/com.docker.hyperkit"
|
84
|
+
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
|
83
85
|
end
|
84
86
|
end
|
85
87
|
```
|
@@ -133,7 +135,7 @@ $ bundle exec rake
|
|
133
135
|
If those pass, you're ready to start developing the plugin. You can test
|
134
136
|
the plugin without installing it into your Vagrant environment by just
|
135
137
|
creating a `Vagrantfile` in the top level of this directory (it is gitignored)
|
136
|
-
and add the following line to your `Vagrantfile`
|
138
|
+
and add the following line to your `Vagrantfile`
|
137
139
|
```ruby
|
138
140
|
Vagrant.require_plugin "vagrant-xhyve"
|
139
141
|
```
|
@@ -15,107 +15,41 @@ module VagrantPlugins
|
|
15
15
|
include Vagrant::Util::Retryable
|
16
16
|
|
17
17
|
def initialize(app, env)
|
18
|
-
@app
|
19
|
-
@logger = Log4r::Logger.new("vagrant_xhyve::action::run_instance")
|
18
|
+
@app = app
|
20
19
|
end
|
21
20
|
|
22
21
|
def call(env)
|
22
|
+
env[:ui].info(" About to launch vm...")
|
23
23
|
# Initialize metrics if they haven't been
|
24
24
|
env[:metrics] ||= {}
|
25
25
|
|
26
|
-
env[:ui].info(" About to launch vm")
|
27
|
-
|
28
|
-
memory = env[:machine].provider_config.memory
|
29
|
-
cpus = env[:machine].provider_config.cpus
|
30
|
-
xhyve_binary = env[:machine].provider_config.xhyve_binary
|
31
|
-
|
32
|
-
# Launch!
|
33
|
-
env[:ui].info(" -- CPUs: #{cpus}") if cpus
|
34
|
-
env[:ui].info(" -- Memory: #{memory}")
|
35
|
-
env[:ui].info(" -- xhyve binary: #{xhyve_binary.to_s}") if xhyve_binary
|
36
|
-
|
37
26
|
machine_info_path = File.join(env[:machine].data_dir, "xhyve.json")
|
38
|
-
if File.exist?(machine_info_path)
|
27
|
+
if File.exist?(machine_info_path)
|
39
28
|
machine_json = File.read(machine_info_path)
|
40
29
|
machine_options = JSON.parse(machine_json, :symbolize_names => true)
|
30
|
+
log.debug "Machine Options: #{JSON.pretty_generate(machine_options)}"
|
41
31
|
machine_uuid = machine_options[:uuid]
|
42
|
-
|
32
|
+
pid = machine_options[:pid]
|
33
|
+
mac = machine_options[:mac]
|
43
34
|
else
|
44
35
|
machine_uuid = SecureRandom.uuid
|
45
|
-
@logger.debug("Created new UUID: #{machine_uuid}")
|
46
|
-
end
|
47
|
-
|
48
|
-
image_dir = File.join(env[:machine].data_dir, "image")
|
49
|
-
vmlinuz_file = File.join(image_dir, "vmlinuz")
|
50
|
-
initrd_file = File.join(image_dir, "initrd.gz")
|
51
|
-
block_devices = []
|
52
|
-
|
53
|
-
0.upto(10).each do |blockidx|
|
54
|
-
block_file = File.join(image_dir, "block#{blockidx}.img")
|
55
|
-
if (File.exist? block_file) then
|
56
|
-
@logger.debug("Found block device #{block_file}")
|
57
|
-
block_devices.push(block_file)
|
58
|
-
else
|
59
|
-
break
|
60
|
-
end
|
61
36
|
end
|
62
37
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
@logger.debug("Kernel Options: #{kernel_parameters}")
|
75
|
-
@logger.debug("Block Devices: #{block_devices}")
|
76
|
-
|
77
|
-
xhyve_guest = Util::XhyveGuest.new(
|
78
|
-
kernel: vmlinuz_file,
|
79
|
-
initrd: initrd_file,
|
80
|
-
cmdline: kernel_parameters,
|
81
|
-
blockdevs: block_devices,
|
82
|
-
serial: 'com1',
|
83
|
-
memory: memory,
|
84
|
-
processors: cpus,
|
85
|
-
networking: true,
|
86
|
-
xhyve_binary: xhyve_binary,
|
87
|
-
acpi: true
|
88
|
-
)
|
89
|
-
|
90
|
-
xhyve_pid = xhyve_guest.start
|
91
|
-
@logger.debug(xhyve_guest.options().to_json)
|
92
|
-
|
38
|
+
guest_config = {
|
39
|
+
pid: pid,
|
40
|
+
mac: mac,
|
41
|
+
uuid: machine_uuid,
|
42
|
+
cmdline: kernel_command(env),
|
43
|
+
memory: memory(env),
|
44
|
+
processors: cpus(env),
|
45
|
+
binary: xhyve_binary(env),
|
46
|
+
}
|
47
|
+
|
48
|
+
xhyve_guest = start_guest(env, guest_config)
|
93
49
|
# Immediately save the ID since it is created at this point.
|
94
|
-
env[:machine].id =
|
95
|
-
|
96
|
-
# wait for ip
|
97
|
-
network_ready_retries = 0
|
98
|
-
network_ready_retries_max = 5
|
99
|
-
while true
|
100
|
-
break if env[:interrupted]
|
101
|
-
|
102
|
-
if xhyve_guest.ip
|
103
|
-
break
|
104
|
-
end
|
105
|
-
if network_ready_retries < network_ready_retries_max then
|
106
|
-
network_ready_retries += 1
|
107
|
-
env[:ui].info("Waiting for IP to be ready...")
|
108
|
-
else
|
109
|
-
raise 'Waited too long for IP to be ready. Your VM probably did not boot.'
|
110
|
-
end
|
111
|
-
sleep 2
|
112
|
-
end
|
113
|
-
|
114
|
-
machine_info_path = File.join(env[:machine].data_dir, "xhyve.json")
|
115
|
-
File.write(machine_info_path, xhyve_guest.options().to_json)
|
116
|
-
|
117
|
-
@logger.info(" Launched xhyve VM with PID #{xhyve_pid}, MAC: #{xhyve_guest.mac}, and IP #{xhyve_guest.ip}")
|
50
|
+
env[:machine].id = xhyve_guest.uuid
|
118
51
|
|
52
|
+
save_guest_status(env, xhyve_guest)
|
119
53
|
# Terminate the instance if we were interrupted
|
120
54
|
terminate(env) if env[:interrupted]
|
121
55
|
|
@@ -138,6 +72,94 @@ module VagrantPlugins
|
|
138
72
|
destroy_env[:force_confirm_destroy] = true
|
139
73
|
env[:action_runner].run(Action.action_destroy, destroy_env)
|
140
74
|
end
|
75
|
+
|
76
|
+
private
|
77
|
+
|
78
|
+
def block_device_paths(base_path)
|
79
|
+
0.upto(10).map do |blockidx|
|
80
|
+
block_file = File.join(base_path, "block#{blockidx}.img")
|
81
|
+
return block_file if File.exist? block_file
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def kernel_file_path(base_path)
|
86
|
+
File.join(base_path, "vmlinuz")
|
87
|
+
end
|
88
|
+
|
89
|
+
def initrd_file_path(base_path)
|
90
|
+
File.join(base_path, "initrd.gz")
|
91
|
+
end
|
92
|
+
|
93
|
+
def memory(env)
|
94
|
+
provider_config(env).memory
|
95
|
+
end
|
96
|
+
|
97
|
+
def cpus(env)
|
98
|
+
provider_config(env).cpus
|
99
|
+
end
|
100
|
+
|
101
|
+
def xhyve_binary(env)
|
102
|
+
provider_config(env).xhyve_binary
|
103
|
+
end
|
104
|
+
|
105
|
+
def kernel_command(env)
|
106
|
+
provider_config(env).kernel_command
|
107
|
+
end
|
108
|
+
|
109
|
+
def provider_config(env)
|
110
|
+
@provider_config ||= env[:machine].provider_config
|
111
|
+
end
|
112
|
+
|
113
|
+
def start_guest(env, config = {})
|
114
|
+
image_dir = File.join(env[:machine].data_dir, "image")
|
115
|
+
default_config = {
|
116
|
+
kernel: kernel_file_path(image_dir),
|
117
|
+
initrd: initrd_file_path(image_dir),
|
118
|
+
blockdevs: block_device_paths(image_dir),
|
119
|
+
serial: 'com1',
|
120
|
+
networking: true,
|
121
|
+
acpi: true
|
122
|
+
}
|
123
|
+
config = default_config.merge(config)
|
124
|
+
log.debug "xhyve configuration: #{JSON.pretty_generate(config)}"
|
125
|
+
xhyve_guest = Util::XhyveGuest.new config
|
126
|
+
xhyve_guest.start
|
127
|
+
xhyve_guest
|
128
|
+
end
|
129
|
+
|
130
|
+
def save_guest_status(env, guest)
|
131
|
+
wait_for_guest_ip(env, guest)
|
132
|
+
machine_info_path = File.join(env[:machine].data_dir, "xhyve.json")
|
133
|
+
log.debug "xhyve configuration: #{JSON.pretty_generate(guest.options)}"
|
134
|
+
File.write(machine_info_path, guest.options().to_json)
|
135
|
+
log.info(" Launched xhyve VM with PID #{guest.pid}, MAC: #{guest.mac}, and IP #{guest.ip}")
|
136
|
+
end
|
137
|
+
|
138
|
+
def wait_for_guest_ip(env, guest)
|
139
|
+
network_ready_retries = 0
|
140
|
+
network_ready_retries_max = 3
|
141
|
+
update_xhyve_status(env, guest.options)
|
142
|
+
while guest.ip.nil?
|
143
|
+
break if env[:interrupted]
|
144
|
+
|
145
|
+
if network_ready_retries < network_ready_retries_max then
|
146
|
+
network_ready_retries += 1
|
147
|
+
env[:ui].info("Waiting for IP to be ready. Try #{network_ready_retries}/#{network_ready_retries_max}...")
|
148
|
+
else
|
149
|
+
raise 'Waited too long for IP to be ready. Your VM probably did not boot.'
|
150
|
+
end
|
151
|
+
sleep 0.5
|
152
|
+
end
|
153
|
+
update_xhyve_status(env, guest.options)
|
154
|
+
end
|
155
|
+
|
156
|
+
def update_xhyve_status(env, status)
|
157
|
+
env[:xhyve_status] = status
|
158
|
+
end
|
159
|
+
|
160
|
+
def log
|
161
|
+
@logger ||= Log4r::Logger.new("vagrant_xhyve::action::boot")
|
162
|
+
end
|
141
163
|
end
|
142
164
|
end
|
143
165
|
end
|
@@ -8,50 +8,61 @@ module VagrantPlugins
|
|
8
8
|
# This terminates the running instance.
|
9
9
|
class Import
|
10
10
|
def initialize(app, env)
|
11
|
-
@app
|
12
|
-
@logger = Log4r::Logger.new("vagrant_xhyve::action::import")
|
11
|
+
@app = app
|
13
12
|
end
|
14
13
|
|
15
14
|
def call(env)
|
16
15
|
|
17
16
|
#TODO: Progress bar
|
18
17
|
env[:ui].info("Importing box...")
|
19
|
-
# something like:
|
20
|
-
# # tempfile is a File instance
|
21
|
-
# File.open( new_file, 'wb' ) do |f|
|
22
|
-
# # Read in small 65k chunks to limit memory usage
|
23
|
-
# f.write(tempfile.read(2**16)) until tempfile.eof?
|
24
|
-
# end
|
25
18
|
|
26
19
|
image_dir = File.join(env[:machine].data_dir, "image")
|
27
20
|
box_dir = env[:machine].box.directory
|
28
21
|
|
29
|
-
|
22
|
+
log.debug("Importing box from: #{box_dir}")
|
30
23
|
|
24
|
+
create_image_directory(image_dir)
|
25
|
+
copy_kernel_to(box_dir, image_dir)
|
26
|
+
copy_initrd_to(box_dir, image_dir)
|
27
|
+
copy_block_files_to(box_dir, image_dir)
|
28
|
+
env[:ui].info("Done importing box.")
|
29
|
+
|
30
|
+
@app.call(env)
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def copy_kernel_to(from, to)
|
36
|
+
copy_file(from, to, "vmlinuz")
|
37
|
+
end
|
38
|
+
|
39
|
+
def copy_initrd_to(from, to)
|
40
|
+
copy_file(from, to, "initrd.gz")
|
41
|
+
end
|
42
|
+
|
43
|
+
def copy_block_files_to(from, to)
|
31
44
|
0.upto(10).each do |blockidx|
|
32
|
-
|
33
|
-
if
|
34
|
-
box_files.push(block_file)
|
35
|
-
else
|
36
|
-
break
|
37
|
-
end
|
45
|
+
filename = "block#{blockidx}.img"
|
46
|
+
copy_file(from, to, filename) if File.exist? File.join(from, filename)
|
38
47
|
end
|
48
|
+
end
|
39
49
|
|
40
|
-
|
41
|
-
|
50
|
+
def copy_file(from, to, filename)
|
51
|
+
from_box_file_path = File.join(from, filename)
|
52
|
+
to_image_file_path = File.join(to, filename)
|
42
53
|
|
43
|
-
|
54
|
+
unless File.exist? to_image_file_path
|
55
|
+
log.debug("Copying #{from_box_file_path} to #{to} ")
|
56
|
+
FileUtils.cp(from_box_file_path, to)
|
57
|
+
end
|
58
|
+
end
|
44
59
|
|
45
|
-
|
60
|
+
def create_image_directory(path)
|
61
|
+
FileUtils.mkdir_p(path)
|
46
62
|
end
|
47
63
|
|
48
|
-
def
|
49
|
-
|
50
|
-
Process.getpgid(pid)
|
51
|
-
true
|
52
|
-
rescue Errno::ESRCH
|
53
|
-
false
|
54
|
-
end
|
64
|
+
def log
|
65
|
+
@logger ||= Log4r::Logger.new("vagrant_xhyve::action::import")
|
55
66
|
end
|
56
67
|
end
|
57
68
|
end
|
@@ -14,18 +14,12 @@ module VagrantPlugins
|
|
14
14
|
|
15
15
|
def call(env)
|
16
16
|
env[:machine_ssh_info] = read_ssh_info(env)
|
17
|
-
|
18
17
|
@app.call(env)
|
19
18
|
end
|
20
19
|
|
21
20
|
def read_ssh_info(env)
|
22
|
-
|
23
|
-
|
24
|
-
machine_info_path = File.join(env[:machine].data_dir, "xhyve.json")
|
25
|
-
machine_json = File.read(machine_info_path)
|
26
|
-
machine_options = JSON.parse(machine_json, :symbolize_names => true)
|
27
|
-
|
28
|
-
return { :host => machine_options[:ip], :port => 22 }
|
21
|
+
xhyve_status = env[:xhyve_status]
|
22
|
+
return { :host => xhyve_status[:ip], :port => 22 }
|
29
23
|
end
|
30
24
|
end
|
31
25
|
end
|
@@ -7,31 +7,41 @@ module VagrantPlugins
|
|
7
7
|
# `:machine_state_id` key in the environment.
|
8
8
|
class ReadState
|
9
9
|
def initialize(app, env)
|
10
|
-
@app
|
10
|
+
@app = app
|
11
|
+
@env = env
|
11
12
|
@logger = Log4r::Logger.new("vagrant_xhyve::action::read_state")
|
12
13
|
end
|
13
14
|
|
14
15
|
def call(env)
|
15
|
-
env[:machine_state_id] = read_state(env[:machine])
|
16
16
|
|
17
|
+
env[:machine_state_id] = read_state(env)
|
17
18
|
@app.call(env)
|
18
19
|
end
|
19
20
|
|
20
|
-
|
21
|
-
return :not_created if machine.id.nil?
|
21
|
+
private
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
if
|
26
|
-
|
23
|
+
def read_state(env)
|
24
|
+
xhyve_status = read_xhyve_status_file(env)
|
25
|
+
return :not_created if env[:machine].id.nil?
|
26
|
+
env[:xhyve_status] = xhyve_status
|
27
|
+
if process_alive(xhyve_status[:pid])
|
28
|
+
return :running
|
27
29
|
else
|
28
|
-
|
30
|
+
return :stopped
|
29
31
|
end
|
30
32
|
end
|
31
33
|
|
34
|
+
def read_xhyve_status_file(env)
|
35
|
+
xhyve_status_file_path = File.join(env[:machine].data_dir, "xhyve.json")
|
36
|
+
return {} unless File.exist?(xhyve_status_file_path)
|
37
|
+
machine_json = File.read(xhyve_status_file_path)
|
38
|
+
JSON.parse(machine_json, :symbolize_names => true)
|
39
|
+
end
|
40
|
+
|
32
41
|
def process_alive(pid)
|
42
|
+
return false if pid.nil?
|
33
43
|
begin
|
34
|
-
Process.getpgid(pid)
|
44
|
+
Process.getpgid(pid.to_i)
|
35
45
|
true
|
36
46
|
rescue Errno::ESRCH
|
37
47
|
false
|
@@ -11,27 +11,18 @@ module VagrantPlugins
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def call(env)
|
14
|
-
if env
|
15
|
-
env[:ui].info(I18n.t("vagrant_xhyve.
|
14
|
+
if is_process_alive? pid(env)
|
15
|
+
env[:ui].info(I18n.t("vagrant_xhyve.stopping"))
|
16
|
+
kill_xhyve_process(env)
|
16
17
|
else
|
17
|
-
|
18
|
-
|
19
|
-
xhyve_pid = env[:machine].id
|
20
|
-
|
21
|
-
if xhyve_pid == nil then
|
22
|
-
@logger.debug("xhyve already gone")
|
23
|
-
elsif process_alive(Integer(xhyve_pid)) then
|
24
|
-
env[:ui].info(" Terminating xhyve instance with PID #{xhyve_pid}")
|
25
|
-
Process.kill(3, Integer(xhyve_pid))
|
26
|
-
else
|
27
|
-
@logger.debug("xhyve PID already gone #{xhyve_pid}")
|
28
|
-
end
|
18
|
+
env[:ui].info(I18n.t("vagrant_xhyve.already_status", status: env[:machine].state.id))
|
29
19
|
end
|
30
|
-
|
20
|
+
destroy_xhyve_status_file(env)
|
31
21
|
@app.call(env)
|
32
22
|
end
|
33
23
|
|
34
|
-
def
|
24
|
+
def is_process_alive?(pid)
|
25
|
+
return false if pid == 0
|
35
26
|
begin
|
36
27
|
Process.getpgid(pid)
|
37
28
|
true
|
@@ -39,6 +30,19 @@ module VagrantPlugins
|
|
39
30
|
false
|
40
31
|
end
|
41
32
|
end
|
33
|
+
|
34
|
+
def kill_xhyve_process(env)
|
35
|
+
Process.kill(3, pid(env))
|
36
|
+
end
|
37
|
+
|
38
|
+
def destroy_xhyve_status_file(env)
|
39
|
+
xhyve_status_file_path = File.join(env[:machine].data_dir, "xhyve.json")
|
40
|
+
FileUtils.remove_file(xhyve_status_file_path, force: true)
|
41
|
+
end
|
42
|
+
|
43
|
+
def pid(env)
|
44
|
+
@pid ||= env[:xhyve_status][:pid].to_i
|
45
|
+
end
|
42
46
|
end
|
43
47
|
end
|
44
48
|
end
|
@@ -13,33 +13,17 @@ module VagrantPlugins
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def call(env)
|
16
|
-
|
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
|
16
|
+
stop_instance(env)
|
17
|
+
# Remove the tracking ID
|
28
18
|
env[:ui].info(I18n.t("vagrant_xhyve.terminating"))
|
29
|
-
env[:machine].id = nil
|
30
|
-
|
31
19
|
FileUtils.rm_rf(env[:machine].data_dir)
|
32
20
|
|
33
21
|
@app.call(env)
|
34
22
|
end
|
35
23
|
|
36
|
-
def
|
37
|
-
|
38
|
-
|
39
|
-
true
|
40
|
-
rescue Errno::ESRCH
|
41
|
-
false
|
42
|
-
end
|
24
|
+
def stop_instance(env)
|
25
|
+
halt_env = env.dup
|
26
|
+
env[:action_runner].run(Action.action_halt, halt_env)
|
43
27
|
end
|
44
28
|
end
|
45
29
|
end
|
data/lib/vagrant-xhyve/action.rb
CHANGED
@@ -27,6 +27,7 @@ module VagrantPlugins
|
|
27
27
|
def self.action_halt
|
28
28
|
Vagrant::Action::Builder.new.tap do |b|
|
29
29
|
b.use ConfigValidate
|
30
|
+
b.use ReadState
|
30
31
|
b.use Call, IsCreated do |env, b2|
|
31
32
|
if env[:result]
|
32
33
|
b2.use Call, GracefulHalt, :stopped, :running do |env2, b3|
|
@@ -83,6 +84,7 @@ module VagrantPlugins
|
|
83
84
|
def self.action_read_ssh_info
|
84
85
|
Vagrant::Action::Builder.new.tap do |b|
|
85
86
|
b.use ConfigValidate
|
87
|
+
b.use ReadState
|
86
88
|
b.use ReadSSHInfo
|
87
89
|
end
|
88
90
|
end
|
data/lib/vagrant-xhyve/config.rb
CHANGED
@@ -19,7 +19,7 @@ module VagrantPlugins
|
|
19
19
|
#
|
20
20
|
# @return [String]
|
21
21
|
attr_accessor :memory
|
22
|
-
|
22
|
+
|
23
23
|
|
24
24
|
# The path to the xhyve binary if you don't want to
|
25
25
|
# use the one bundled with xhyve-ruby
|
@@ -31,18 +31,26 @@ module VagrantPlugins
|
|
31
31
|
#
|
32
32
|
# @return [String]
|
33
33
|
attr_accessor :mac
|
34
|
-
|
34
|
+
|
35
35
|
# The uuid of the VM
|
36
36
|
#
|
37
37
|
# @return [String]
|
38
38
|
attr_accessor :uuid
|
39
39
|
|
40
|
+
# The kernel command to initialize the machine
|
41
|
+
# The default command assumes that the instalation is done directly on the
|
42
|
+
# disk and not using a lvm. For example, by default, Centos intallation uses
|
43
|
+
# LVM. Moreover, it might be interesting to add new kernel options.
|
44
|
+
# @return [String]
|
45
|
+
attr_accessor :kernel_command
|
46
|
+
|
40
47
|
def initialize(region_specific=false)
|
41
|
-
@cpus
|
42
|
-
@memory
|
43
|
-
@xhyve_binary
|
44
|
-
@mac
|
45
|
-
@uuid
|
48
|
+
@cpus = UNSET_VALUE
|
49
|
+
@memory = UNSET_VALUE
|
50
|
+
@xhyve_binary = UNSET_VALUE
|
51
|
+
@mac = UNSET_VALUE
|
52
|
+
@uuid = UNSET_VALUE
|
53
|
+
@kernel_command = UNSET_VALUE
|
46
54
|
|
47
55
|
# Internal state (prefix with __ so they aren't automatically
|
48
56
|
# merged)
|
@@ -61,7 +69,7 @@ module VagrantPlugins
|
|
61
69
|
@cpus = 1 if @cpus == UNSET_VALUE
|
62
70
|
@memory = 1024 if @memory == UNSET_VALUE
|
63
71
|
@xhyve_binary = nil if @xhyve_binary == UNSET_VALUE
|
64
|
-
|
72
|
+
@kernel_command = %Q{"earlyprintk=serial console=ttyS0 root=/dev/vda1 ro"} if @kernel_command == UNSET_VALUE
|
65
73
|
# Mark that we finalized
|
66
74
|
@__finalized = true
|
67
75
|
end
|
@@ -3,30 +3,19 @@ require 'xhyve'
|
|
3
3
|
module VagrantPlugins
|
4
4
|
module XHYVE
|
5
5
|
module Util
|
6
|
-
|
7
6
|
# TODO: send all this upstream
|
8
7
|
class XhyveGuest < Xhyve::Guest
|
9
8
|
|
10
9
|
def initialize(**opts)
|
11
|
-
|
12
|
-
|
13
|
-
@
|
14
|
-
else
|
15
|
-
@kernel = opts.fetch(:kernel)
|
16
|
-
@initrd = opts.fetch(:initrd)
|
17
|
-
@cmdline = opts.fetch(:cmdline)
|
18
|
-
@blockdevs = [opts[:blockdevs] || []].flatten
|
19
|
-
@memory = opts[:memory] || '500M'
|
20
|
-
@processors = opts[:processors] || '1'
|
21
|
-
@uuid = opts[:uuid] || SecureRandom.uuid
|
22
|
-
@serial = opts[:serial] || 'com1'
|
23
|
-
@acpi = opts[:acpi] || true
|
24
|
-
@networking = opts[:networking] || true
|
25
|
-
@foreground = opts[:foreground] || false
|
26
|
-
@command = build_command
|
27
|
-
@mac = find_mac
|
10
|
+
super.tap do |s|
|
11
|
+
@pid = opts.fetch(:pid, nil)
|
12
|
+
@mac = opts[:mac] unless opts[:mac].nil?
|
28
13
|
end
|
14
|
+
end
|
29
15
|
|
16
|
+
def start
|
17
|
+
return @pid if running?
|
18
|
+
super
|
30
19
|
end
|
31
20
|
|
32
21
|
def options
|
@@ -46,13 +35,13 @@ module VagrantPlugins
|
|
46
35
|
:command => @command,
|
47
36
|
:mac => @mac,
|
48
37
|
:ip => ip,
|
49
|
-
:
|
38
|
+
:binary => @binary
|
50
39
|
}
|
51
40
|
end
|
52
41
|
|
53
42
|
def build_command
|
54
43
|
[
|
55
|
-
"#{@
|
44
|
+
"#{@binary}",
|
56
45
|
"#{'-A' if @acpi}",
|
57
46
|
'-U', @uuid,
|
58
47
|
'-m', @memory,
|
@@ -62,7 +51,7 @@ module VagrantPlugins
|
|
62
51
|
"#{"#{@blockdevs.each_with_index.map { |p, i| "-s #{PCI_BASE + i},virtio-blk,#{p}" }.join(' ')}" unless @blockdevs.empty? }",
|
63
52
|
'-s', '31,lpc',
|
64
53
|
'-l', "#{@serial},stdio",
|
65
|
-
'-f' "kexec,#{@kernel},#{@initrd},'#{@cmdline}'"
|
54
|
+
'-f', "kexec,#{@kernel},#{@initrd},'#{@cmdline}'"
|
66
55
|
].join(' ')
|
67
56
|
end
|
68
57
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-xhyve
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patrick Armstrong
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06
|
11
|
+
date: 2016-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: xhyve-ruby
|
@@ -92,12 +92,19 @@ executables: []
|
|
92
92
|
extensions: []
|
93
93
|
extra_rdoc_files: []
|
94
94
|
files:
|
95
|
+
- .gitignore
|
96
|
+
- .rspec
|
95
97
|
- CHANGELOG.md
|
98
|
+
- Gemfile
|
99
|
+
- LICENSE
|
100
|
+
- README.md
|
101
|
+
- Rakefile
|
102
|
+
- example_box/README.md
|
96
103
|
- example_box/initrd.gz
|
97
104
|
- example_box/metadata.json
|
98
|
-
- example_box/README.md
|
99
105
|
- example_box/vmlinuz
|
100
|
-
-
|
106
|
+
- lib/vagrant-xhyve.rb
|
107
|
+
- lib/vagrant-xhyve/action.rb
|
101
108
|
- lib/vagrant-xhyve/action/boot.rb
|
102
109
|
- lib/vagrant-xhyve/action/import.rb
|
103
110
|
- lib/vagrant-xhyve/action/is_created.rb
|
@@ -111,7 +118,6 @@ files:
|
|
111
118
|
- lib/vagrant-xhyve/action/terminate_instance.rb
|
112
119
|
- lib/vagrant-xhyve/action/timed_provision.rb
|
113
120
|
- lib/vagrant-xhyve/action/wait_for_state.rb
|
114
|
-
- lib/vagrant-xhyve/action.rb
|
115
121
|
- lib/vagrant-xhyve/config.rb
|
116
122
|
- lib/vagrant-xhyve/errors.rb
|
117
123
|
- lib/vagrant-xhyve/plugin.rb
|
@@ -119,39 +125,33 @@ files:
|
|
119
125
|
- lib/vagrant-xhyve/util/timer.rb
|
120
126
|
- lib/vagrant-xhyve/util/vagrant-xhyve.rb
|
121
127
|
- lib/vagrant-xhyve/version.rb
|
122
|
-
- lib/vagrant-xhyve.rb
|
123
|
-
- LICENSE
|
124
128
|
- locales/en.yml
|
125
|
-
- Rakefile
|
126
|
-
- README.md
|
127
129
|
- spec/spec_helper.rb
|
128
130
|
- spec/vagrant-xhyve/config_spec.rb
|
129
131
|
- templates/metadata.json.erb
|
130
132
|
- templates/vagrant-aws_package_Vagrantfile.erb
|
131
133
|
- vagrant-xhyve.gemspec
|
132
|
-
- vendor/xhyve-ruby
|
134
|
+
- vendor/xhyve-ruby/.gitignore
|
135
|
+
- vendor/xhyve-ruby/.travis.yml
|
133
136
|
- vendor/xhyve-ruby/Gemfile
|
137
|
+
- vendor/xhyve-ruby/README.md
|
138
|
+
- vendor/xhyve-ruby/Rakefile
|
139
|
+
- vendor/xhyve-ruby/example/test.rb
|
134
140
|
- vendor/xhyve-ruby/lib/rubygems_plugin.rb
|
141
|
+
- vendor/xhyve-ruby/lib/xhyve.rb
|
135
142
|
- vendor/xhyve-ruby/lib/xhyve/dhcp.rb
|
136
143
|
- vendor/xhyve-ruby/lib/xhyve/guest.rb
|
137
144
|
- vendor/xhyve-ruby/lib/xhyve/vendor/xhyve
|
138
145
|
- vendor/xhyve-ruby/lib/xhyve/version.rb
|
139
|
-
- vendor/xhyve-ruby/lib/xhyve.rb
|
140
|
-
- vendor/xhyve-ruby/Rakefile
|
141
|
-
- vendor/xhyve-ruby/README.md
|
142
146
|
- vendor/xhyve-ruby/spec/fixtures/dhcpd_leases.txt
|
147
|
+
- vendor/xhyve-ruby/spec/fixtures/guest/README.md
|
143
148
|
- vendor/xhyve-ruby/spec/fixtures/guest/initrd
|
144
149
|
- vendor/xhyve-ruby/spec/fixtures/guest/loop.img
|
145
|
-
- vendor/xhyve-ruby/spec/fixtures/guest/README.md
|
146
150
|
- vendor/xhyve-ruby/spec/fixtures/guest/vmlinuz
|
147
151
|
- vendor/xhyve-ruby/spec/lib/dhcp_spec.rb
|
148
152
|
- vendor/xhyve-ruby/spec/lib/guest_spec.rb
|
149
153
|
- vendor/xhyve-ruby/spec/spec_helper.rb
|
150
154
|
- vendor/xhyve-ruby/xhyve-ruby.gemspec
|
151
|
-
- .gitignore
|
152
|
-
- .rspec
|
153
|
-
- vendor/xhyve-ruby/.gitignore
|
154
|
-
- vendor/xhyve-ruby/.travis.yml
|
155
155
|
homepage: http://github.com/oldpatricka/vagrant-xhyve
|
156
156
|
licenses:
|
157
157
|
- MIT
|
@@ -172,7 +172,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
172
172
|
version: 1.3.6
|
173
173
|
requirements: []
|
174
174
|
rubyforge_project: vagrant-xhyve
|
175
|
-
rubygems_version: 2.
|
175
|
+
rubygems_version: 2.6.6
|
176
176
|
signing_key:
|
177
177
|
specification_version: 4
|
178
178
|
summary: Enables Vagrant to manage machines in xhyve.
|