18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/vagrant-qubes/action/createvm.rb', line 18
def createvm(env)
@logger.info('vagrant-qubes, createvm: start...')
machine = env[:machine]
config = env[:machine].provider_config
if env[:machine_state].to_s == 'not_created'
env[:ui].info I18n.t('vagrant_qubes.vmbuild_not_done')
else
env[:ui].info I18n.t('vagrant_qubes.vmbuild_already_done')
return
end
if env[:machine].config.vm.hostname.nil?
raise Errors::GeneralError,
message: 'Hostname is not set, fix Vagrantfile'
return
end
if config.guest_type.is_a? String
case config.guest_type
when 'AppVM'
command = 'echo "' + config.guest_type\
+ ' ' + config.guest_label\
+ ' ' + config.guest_template\
+ ' ' + config.guest_numvcpus.to_s\
+ ' ' + config.guest_memsize.to_s\
+ ' ' + config.guest_netvm\
+ '" | qrexec-client-vm dom0 vagrant_create+' + env[:machine].config.vm.hostname
stdout, stderr, status = Open3.capture3(command)
if status != 0
raise Errors::QRExecError,
message: 'qrexec failed with status' + status.to_s
end
env[:machine].id = 1
else
raise Errors::GeneralError,
message: 'guest type ' + config.guest_type + ' is not supported'
return
end
else
raise Errors::GeneralError,
message: 'Type is not a string, fix Vagrantfile'
return
end
end
|