inprovise-vbox 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/inprovise/vbox/vbox.rb +74 -24
- data/lib/inprovise/vbox/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MTZhY2I4Y2U2N2Q1MTI0YzgxOWE4ODIwNDlhMDM2YmJmNTM1NGRkYg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YzEyMmM3ZTFjNTdhMjBjYTI1N2UwZGQwY2Y1NzlmMTFhNzBkMDgxZA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OWY0NzFjZjlkYjFlYzE3MDYxOGZiZGMzN2NiNjMwM2I0Y2QxN2RjNTM3YTFl
|
10
|
+
NWM3OTA2NjE1MTdmY2U5YTdhMDI2YjFhYjk4N2E4NTdlMjBmODE3YmUyYjU4
|
11
|
+
YzljNTQzNmYwOGE3MTBkMWM0NGQ2OWQ3ODE4MDE2MmUwMGE1MzU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YzBjMTFhOGRjMmNkNWIzYTQxMmYyMmQ2YjA1NDBkYzVhNWE1MDlhYWJkMGJl
|
14
|
+
OTk0ZDkzOTExNGU0OTEzMzVkYTNmNzgzNTZhOGVlOTAyYzMxM2M5NmJjYTgx
|
15
|
+
Njk2ZDM3MzI5NzIwMGRmMzliMWRlZWM2NmIyMDUxZDE5ODE3ZDY=
|
data/lib/inprovise/vbox/vbox.rb
CHANGED
@@ -35,21 +35,50 @@ module Inprovise::VBox
|
|
35
35
|
end
|
36
36
|
result
|
37
37
|
end
|
38
|
+
action 'vbox-install' do |vboxname, cfg|
|
39
|
+
log("Installing VBox #{vboxname}", :bold)
|
40
|
+
log("VBox config :\n#{JSON.pretty_generate(cfg)}") if Inprovise.verbosity > 1
|
41
|
+
cmdline = "virt-install --connect qemu:///system --hvm --virt-type #{cfg[:virt_type] || 'kvm'} --import --wait 0 "
|
42
|
+
cmdline << "--arch #{cfg[:arch]} "
|
43
|
+
cmdline << '--autostart ' if cfg[:autostart]
|
44
|
+
cmdline << "--name #{vboxname} --memory #{cfg[:memory]} --vcpus #{cfg[:cpus]} "
|
45
|
+
cmdline << "--os-variant #{cfg[:os]} " if cfg[:os]
|
46
|
+
cmdline << case cfg[:network]
|
47
|
+
when :hostnet
|
48
|
+
"--network network=#{cfg[:netname] || 'default'} "
|
49
|
+
when :bridge
|
50
|
+
"--network bridge=#{cfg[:netname] || 'virbr0' } "
|
51
|
+
end
|
52
|
+
cmdline << "--graphics #{cfg[:graphics] || 'spice'} "
|
53
|
+
cmdline << "--disk path=#{cfg[:image]},device=disk,boot_order=1"
|
54
|
+
cmdline << ",bus=#{cfg[:diskbus]}" if cfg[:diskbus]
|
55
|
+
cmdline << ",format=#{cfg[:format]}" if cfg[:format]
|
56
|
+
cmdline << " --disk device=cdrom,boot_order=2,bus=#{cfg[:cdrombus] || 'ide'}" unless cfg[:cdrom] == false
|
57
|
+
cmdline << %{ --boot "kernel=#{cfg[:kernel]},kernel_args=#{cfg[:kernel_args]}"} if cfg[:kernel]
|
58
|
+
cmdline << " #{cfg[:install_opts]}" if cfg[:install_opts]
|
59
|
+
sudo(cmdline, :log => true)
|
60
|
+
end
|
38
61
|
end
|
39
62
|
|
40
63
|
class VBoxScript < Inprovise::Script
|
41
64
|
|
42
65
|
# configuration
|
43
66
|
# :name
|
67
|
+
# :virt_type
|
68
|
+
# :arch
|
44
69
|
# :image
|
45
70
|
# :format
|
46
71
|
# :diskbus
|
47
72
|
# :memory
|
73
|
+
# :cdrom
|
74
|
+
# :cdrombus
|
48
75
|
# :cpus
|
49
76
|
# :os
|
50
77
|
# :network
|
51
78
|
# :netname
|
52
79
|
# :autostart
|
80
|
+
# :kernel
|
81
|
+
# :kernel_args
|
53
82
|
# :install_opts
|
54
83
|
|
55
84
|
def initialize(name)
|
@@ -92,30 +121,27 @@ module Inprovise::VBox
|
|
92
121
|
|
93
122
|
# apply : installation
|
94
123
|
apply do
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
cmdline << ' --disk device=cdrom,boot_order=2,bus=ide'
|
117
|
-
cmdline << " #{vbs.vbox_install_opts(self)}" if vbs.vbox_install_opts(self)
|
118
|
-
sudo(cmdline)
|
124
|
+
# 1. trigger virt-install
|
125
|
+
trigger('vbox:vbox-install', vbs.vbox_name(self), {
|
126
|
+
:virt_type => vbs.vbox_virt_type(self),
|
127
|
+
:arch => vbs.vbox_arch(self),
|
128
|
+
:autostart => vbs.vbox_autostart(self),
|
129
|
+
:memory => vbs.vbox_memory(self),
|
130
|
+
:cpus => vbs.vbox_cpus(self),
|
131
|
+
:os => vbs.vbox_os(self),
|
132
|
+
:network => vbs.vbox_network(self) || :hostnet,
|
133
|
+
:netname => vbs.vbox_netname(self),
|
134
|
+
:graphics => vbs.vbox_graphics(self),
|
135
|
+
:image => vbs.vbox_image(self),
|
136
|
+
:diskbus => vbs.vbox_diskbus(self),
|
137
|
+
:format => vbs.vbox_format(self),
|
138
|
+
:cdrom => vbs.vbox_cdrom(self),
|
139
|
+
:cdrombus => vbs.vbox_cdrombus(self),
|
140
|
+
:kernel => vbs.vbox_kernel(self),
|
141
|
+
:kernel_args => vbs.vbox_kernel_args(self),
|
142
|
+
:install_opts => vbs.vbox_install_opts(self)
|
143
|
+
})
|
144
|
+
# wait to startup
|
119
145
|
10.times do
|
120
146
|
sleep(1)
|
121
147
|
break if trigger 'vbox:vbox-verify', vmname, true, vbs.vbox_autostart(self)
|
@@ -222,6 +248,10 @@ module Inprovise::VBox
|
|
222
248
|
value_for context, context.config[name.to_sym][:name]
|
223
249
|
end
|
224
250
|
|
251
|
+
def vbox_virt_type(context)
|
252
|
+
value_for context, context.config[name.to_sym][:virt_type]
|
253
|
+
end
|
254
|
+
|
225
255
|
def vbox_autostart(context)
|
226
256
|
value_for context, context.config[name.to_sym][:autostart]
|
227
257
|
end
|
@@ -258,6 +288,10 @@ module Inprovise::VBox
|
|
258
288
|
value_for context, context.config[name.to_sym][:netname]
|
259
289
|
end
|
260
290
|
|
291
|
+
def vbox_graphics(context)
|
292
|
+
value_for context, context.config[name.to_sym][:graphics]
|
293
|
+
end
|
294
|
+
|
261
295
|
def vbox_os(context)
|
262
296
|
value_for context, context.config[name.to_sym][:os]
|
263
297
|
end
|
@@ -274,6 +308,22 @@ module Inprovise::VBox
|
|
274
308
|
value_for context, context.config[name.to_sym][:format]
|
275
309
|
end
|
276
310
|
|
311
|
+
def vbox_cdrom(context)
|
312
|
+
value_for context, context.config[name.to_sym][:cdrom]
|
313
|
+
end
|
314
|
+
|
315
|
+
def vbox_cdrombus(context)
|
316
|
+
value_for context, context.config[name.to_sym][:cdrombus]
|
317
|
+
end
|
318
|
+
|
319
|
+
def vbox_kernel(context)
|
320
|
+
value_for context, context.config[name.to_sym][:kernel]
|
321
|
+
end
|
322
|
+
|
323
|
+
def vbox_kernel_args(context)
|
324
|
+
value_for context, context.config[name.to_sym][:kernel_args]
|
325
|
+
end
|
326
|
+
|
277
327
|
def vbox_install_opts(context)
|
278
328
|
value_for context, context.config[name.to_sym][:install_opts]
|
279
329
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inprovise-vbox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Corino
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: inprovise
|