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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- N2FmODU3NGU5ODhkM2Y0NWZlYzJmNTc0NzRmNTBkYzg3NGQyZWU5MA==
4
+ MTZhY2I4Y2U2N2Q1MTI0YzgxOWE4ODIwNDlhMDM2YmJmNTM1NGRkYg==
5
5
  data.tar.gz: !binary |-
6
- MjllNGI4OTA3YjhhZWIzYzBmZGU2MTUwMzNhMTAyMzgwMTQ1MTI2NQ==
6
+ YzEyMmM3ZTFjNTdhMjBjYTI1N2UwZGQwY2Y1NzlmMTFhNzBkMDgxZA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZWY1Y2E1MWQ2MmI5ODlkNWEwNTBmM2FmZGUyMjFmY2Q1MTc4OGZlNjAzNGJk
10
- YzUwNTkxODFjZGUwNmQ0NTgyYjJkNGM0ZDhmZmFlODM3MTJkNzM2YWI5ODNj
11
- YmQ4Zjg5YjA0ZTYwNDRkYjA4MGNhY2ExNDY5MmIzZGNmOWU3MmQ=
9
+ OWY0NzFjZjlkYjFlYzE3MDYxOGZiZGMzN2NiNjMwM2I0Y2QxN2RjNTM3YTFl
10
+ NWM3OTA2NjE1MTdmY2U5YTdhMDI2YjFhYjk4N2E4NTdlMjBmODE3YmUyYjU4
11
+ YzljNTQzNmYwOGE3MTBkMWM0NGQ2OWQ3ODE4MDE2MmUwMGE1MzU=
12
12
  data.tar.gz: !binary |-
13
- MTJmZTZjNGU1YTMzYmNjMzUxZmExNmEzYTEzNTlhMjQ3ZjMwNGZjNzgxMjY0
14
- MTVkNWYyMjRjOWNhZjBjZjhkMGExOTkzN2FmYTdlMmQ5Y2RkODg2ODBmZmU2
15
- YjBiNGU5NjgxZjZjMjNhNjNkZDcwNjdlYmU0MDE1M2UzMDc1ZTc=
13
+ YzBjMTFhOGRjMmNkNWIzYTQxMmYyMmQ2YjA1NDBkYzVhNWE1MDlhYWJkMGJl
14
+ OTk0ZDkzOTExNGU0OTEzMzVkYTNmNzgzNTZhOGVlOTAyYzMxM2M5NmJjYTgx
15
+ Njk2ZDM3MzI5NzIwMGRmMzliMWRlZWM2NmIyMDUxZDE5ODE3ZDY=
@@ -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
- vmname = vbs.vbox_name(self)
96
- vmimg = vbs.vbox_image(self)
97
- # 1. verify config
98
- raise ArgumentError, "Cannot access VBox image #{vmimg}" unless remote(vmimg).file?
99
- # 2. execute virt-install
100
- log("Installing VBox #{vmname}", :bold)
101
- cmdline = 'virt-install --connect qemu:///system --hvm --virt-type kvm --import --wait 0 '
102
- cmdline << "--arch #{vbs.vbox_arch(self)} "
103
- cmdline << '--autostart ' if vbs.vbox_autostart(self)
104
- cmdline << "--name #{vmname} --memory #{vbs.vbox_memory(self)} --vcpus #{vbs.vbox_cpus(self)} "
105
- cmdline << "--os-variant #{vbs.vbox_os(self)} " if vbs.vbox_os(self)
106
- cmdline << case vbs.vbox_network(self)
107
- when :hostnet
108
- "--network network=#{vbs.vbox_netname(self) || 'default'} "
109
- when :bridge
110
- "--network bridge=#{vbs.vbox_netname(self) || 'virbr0' } "
111
- end
112
- cmdline << '--graphics spice '
113
- cmdline << "--disk path=#{vbs.vbox_image(self)},device=disk,boot_order=1"
114
- cmdline << ",bus=#{vbs.vbox_diskbus(self)}" if vbs.vbox_diskbus(self)
115
- cmdline << ",format=#{vbs.vbox_format(self)}" if vbs.vbox_format(self)
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
@@ -5,6 +5,6 @@
5
5
 
6
6
  module Inprovise; module VBox
7
7
 
8
- VERSION = '0.2.5'
8
+ VERSION = '0.2.6'
9
9
 
10
10
  end; 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.5
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-13 00:00:00.000000000 Z
11
+ date: 2016-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: inprovise