vagrant-ovirt4 1.2.0 → 2.1.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 +5 -5
- data/.github/FUNDING.yml +3 -0
- data/.github/workflows/release.yml +20 -0
- data/.gitignore +1 -1
- data/CHANGELOG +31 -0
- data/Dockerfile +11 -0
- data/Gemfile +6 -7
- data/Gemfile.lock +98 -87
- data/README.md +27 -3
- data/Rakefile +1 -7
- data/SECURITY.md +23 -0
- data/lib/vagrant-ovirt4.rb +4 -0
- data/lib/vagrant-ovirt4/action.rb +29 -9
- data/lib/vagrant-ovirt4/action/connect_ovirt.rb +19 -6
- data/lib/vagrant-ovirt4/action/create_network_interfaces.rb +57 -43
- data/lib/vagrant-ovirt4/action/create_vm.rb +87 -7
- data/lib/vagrant-ovirt4/action/destroy_vm.rb +14 -1
- data/lib/vagrant-ovirt4/action/disconnect_ovirt.rb +25 -0
- data/lib/vagrant-ovirt4/action/halt_vm.rb +11 -0
- data/lib/vagrant-ovirt4/action/read_ssh_info.rb +6 -1
- data/lib/vagrant-ovirt4/action/read_state.rb +7 -1
- data/lib/vagrant-ovirt4/action/resize_disk.rb +18 -17
- data/lib/vagrant-ovirt4/action/snapshot_list.rb +15 -19
- data/lib/vagrant-ovirt4/action/start_vm.rb +37 -23
- data/lib/vagrant-ovirt4/action/wait_til_suspended.rb +1 -1
- data/lib/vagrant-ovirt4/action/wait_till_down.rb +13 -2
- data/lib/vagrant-ovirt4/action/wait_till_up.rb +35 -6
- data/lib/vagrant-ovirt4/config.rb +60 -2
- data/lib/vagrant-ovirt4/errors.rb +20 -0
- data/lib/vagrant-ovirt4/plugin.rb +3 -3
- data/lib/vagrant-ovirt4/version.rb +1 -1
- data/locales/en.yml +17 -1
- data/spec/vagrant-ovirt4/config_spec.rb +33 -8
- data/templates/Vagrantfile.erb +199 -0
- data/tools/prepare_redhat_for_box.sh +6 -1
- data/vagrant-ovirt4.gemspec +2 -1
- metadata +26 -15
- data/lib/vagrant-ovirt4/action/sync_folders.rb +0 -69
- data/lib/vagrant-ovirt4/cap/nic_mac_addresses.rb +0 -15
- data/test.rb +0 -3
data/SECURITY.md
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
## Security
|
2
|
+
|
3
|
+
If you believe you have found a security vulnerability, please report it to me as described below.
|
4
|
+
|
5
|
+
## Reporting Security Issues
|
6
|
+
|
7
|
+
**Please do not report security vulnerabilities through public GitHub issues.** Instead, please report them to me directly at [myoung34@my.apsu.edu](mailto:myoung34@my.apsu.edu).
|
8
|
+
|
9
|
+
If you'd like to communicate securely, my keybase is [here](https://keybase.io/3vilpenguin)
|
10
|
+
|
11
|
+
Please include the requested information listed below (as much as you can provide) to help better understand the nature and scope of the possible issue:
|
12
|
+
|
13
|
+
* Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
|
14
|
+
* Full paths of source file(s) related to the manifestation of the issue
|
15
|
+
* The location of the affected source code (tag/branch/commit or direct URL)
|
16
|
+
* Any special configuration required to reproduce the issue
|
17
|
+
* Step-by-step instructions to reproduce the issue
|
18
|
+
* Proof-of-concept or exploit code (if possible)
|
19
|
+
* Impact of the issue, including how an attacker might exploit the issue
|
20
|
+
|
21
|
+
## Preferred Languages
|
22
|
+
|
23
|
+
I prefer all communications to be in English.
|
data/lib/vagrant-ovirt4.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'log4r'
|
1
2
|
require 'pathname'
|
2
3
|
require 'vagrant-ovirt4/plugin'
|
3
4
|
|
@@ -8,9 +9,11 @@ module VagrantPlugins
|
|
8
9
|
autoload :Errors, lib_path.join("errors")
|
9
10
|
autoload :Util, lib_path.join("util")
|
10
11
|
|
12
|
+
@@logger = Log4r::Logger.new("vagrant_ovirt4::provider")
|
11
13
|
@@ovirt_connection = nil
|
12
14
|
@@vms_service = nil
|
13
15
|
def self.ovirt_connection
|
16
|
+
@@logger.warn('Use of deprecated OVirtProvider.ovirt_connection detected.')
|
14
17
|
@@ovirt_connection
|
15
18
|
end
|
16
19
|
|
@@ -19,6 +22,7 @@ module VagrantPlugins
|
|
19
22
|
end
|
20
23
|
|
21
24
|
def self.vms_service
|
25
|
+
@@logger.warn('Use of deprecated OVirtProvider.vms_service detected.')
|
22
26
|
@@vms_service
|
23
27
|
end
|
24
28
|
|
@@ -9,11 +9,15 @@ module VagrantPlugins
|
|
9
9
|
# This action is called to bring the box up from nothing.
|
10
10
|
def self.action_up
|
11
11
|
Vagrant::Action::Builder.new.tap do |b|
|
12
|
+
b.use HandleBox
|
12
13
|
b.use ConfigValidate
|
13
14
|
b.use ConnectOVirt
|
14
15
|
b.use Call, ReadState do |env, b2|
|
16
|
+
# synced_folders defaults to NFS on linux. Make it default to rsync as before.
|
17
|
+
env[:machine].config.nfs.functional = false
|
15
18
|
if env[:machine_state_id] == :up
|
16
|
-
b2.use
|
19
|
+
b2.use SyncedFolderCleanup
|
20
|
+
b2.use SyncedFolders
|
17
21
|
b2.use MessageAlreadyUp
|
18
22
|
next
|
19
23
|
end
|
@@ -26,7 +30,7 @@ module VagrantPlugins
|
|
26
30
|
if env[:machine_state_id] == :not_created
|
27
31
|
b2.use SetNameOfDomain
|
28
32
|
b2.use CreateVM
|
29
|
-
|
33
|
+
b2.use ResizeDisk
|
30
34
|
|
31
35
|
b2.use Provision
|
32
36
|
b2.use CreateNetworkInterfaces
|
@@ -36,8 +40,10 @@ module VagrantPlugins
|
|
36
40
|
|
37
41
|
b2.use StartVM
|
38
42
|
b2.use WaitTillUp
|
39
|
-
b2.use
|
43
|
+
b2.use SyncedFolderCleanup
|
44
|
+
b2.use SyncedFolders
|
40
45
|
end
|
46
|
+
b.use DisconnectOVirt
|
41
47
|
end
|
42
48
|
end
|
43
49
|
|
@@ -52,9 +58,10 @@ module VagrantPlugins
|
|
52
58
|
|
53
59
|
b2.use ConnectOVirt
|
54
60
|
b2.use ProvisionerCleanup, :before if defined?(ProvisionerCleanup)
|
55
|
-
b2.use HaltVM
|
56
|
-
b2.use WaitTillDown
|
61
|
+
b2.use HaltVM unless env[:machine].state.id == :down
|
62
|
+
b2.use WaitTillDown unless env[:machine].state.id == :down
|
57
63
|
b2.use DestroyVM
|
64
|
+
b2.use DisconnectOVirt
|
58
65
|
end
|
59
66
|
end
|
60
67
|
end
|
@@ -63,12 +70,15 @@ module VagrantPlugins
|
|
63
70
|
Vagrant::Action::Builder.new.tap do |b|
|
64
71
|
b.use ConfigValidate
|
65
72
|
b.use Call, IsCreated do |env, b2|
|
73
|
+
# synced_folders defaults to NFS on linux. Make it default to rsync as before.
|
74
|
+
env[:machine].config.nfs.functional = false
|
66
75
|
if !env[:result]
|
67
76
|
b2.use MessageNotCreated
|
68
77
|
next
|
69
78
|
end
|
70
79
|
b2.use Provision
|
71
|
-
b2.use
|
80
|
+
b2.use SyncedFolderCleanup
|
81
|
+
b2.use SyncedFolders
|
72
82
|
end
|
73
83
|
end
|
74
84
|
end
|
@@ -77,9 +87,11 @@ module VagrantPlugins
|
|
77
87
|
# state is expected to be put into the `:machine_state_id` key.
|
78
88
|
def self.action_read_state
|
79
89
|
Vagrant::Action::Builder.new.tap do |b|
|
90
|
+
b.use HandleBox
|
80
91
|
b.use ConfigValidate
|
81
92
|
b.use ConnectOVirt
|
82
93
|
b.use ReadState
|
94
|
+
b.use DisconnectOVirt
|
83
95
|
end
|
84
96
|
end
|
85
97
|
|
@@ -91,6 +103,7 @@ module VagrantPlugins
|
|
91
103
|
b.use ConfigValidate
|
92
104
|
b.use ConnectOVirt
|
93
105
|
b.use ReadSSHInfo
|
106
|
+
b.use DisconnectOVirt
|
94
107
|
end
|
95
108
|
end
|
96
109
|
|
@@ -111,6 +124,7 @@ module VagrantPlugins
|
|
111
124
|
raise Errors::NoIPError if env[:ip_address].nil?
|
112
125
|
b2.use SSHExec
|
113
126
|
end
|
127
|
+
b.use DisconnectOVirt
|
114
128
|
end
|
115
129
|
end
|
116
130
|
|
@@ -131,6 +145,7 @@ module VagrantPlugins
|
|
131
145
|
raise Errors::NoIPError if env[:ip_address].nil?
|
132
146
|
b2.use SSHRun
|
133
147
|
end
|
148
|
+
b.use DisconnectOVirt
|
134
149
|
end
|
135
150
|
end
|
136
151
|
|
@@ -153,7 +168,7 @@ module VagrantPlugins
|
|
153
168
|
end
|
154
169
|
|
155
170
|
def self.action_reload
|
156
|
-
|
171
|
+
Vagrant::Action::Builder.new.tap do |b|
|
157
172
|
b.use action_halt
|
158
173
|
b.use action_up
|
159
174
|
end
|
@@ -186,7 +201,8 @@ module VagrantPlugins
|
|
186
201
|
b.use MessageNotSuspended
|
187
202
|
next
|
188
203
|
end
|
189
|
-
b.use
|
204
|
+
b.use StartVM
|
205
|
+
b.use WaitTillUp
|
190
206
|
end
|
191
207
|
end
|
192
208
|
|
@@ -210,6 +226,7 @@ module VagrantPlugins
|
|
210
226
|
|
211
227
|
action_root = Pathname.new(File.expand_path("../action", __FILE__))
|
212
228
|
autoload :ConnectOVirt, action_root.join("connect_ovirt")
|
229
|
+
autoload :DisconnectOVirt, action_root.join("disconnect_ovirt")
|
213
230
|
autoload :CreateNetworkInterfaces, action_root.join("create_network_interfaces")
|
214
231
|
autoload :CreateVM, action_root.join("create_vm")
|
215
232
|
autoload :DestroyVM, action_root.join("destroy_vm")
|
@@ -218,13 +235,15 @@ module VagrantPlugins
|
|
218
235
|
autoload :IsRunning, action_root.join("is_running")
|
219
236
|
autoload :ReadSSHInfo, action_root.join("read_ssh_info")
|
220
237
|
autoload :ReadState, action_root.join("read_state")
|
238
|
+
autoload :ResizeDisk, action_root.join("resize_disk")
|
221
239
|
autoload :SetNameOfDomain, action_root.join("set_name_of_domain")
|
222
240
|
autoload :SnapshotDelete, action_root.join("snapshot_delete")
|
223
241
|
autoload :SnapshotList, action_root.join("snapshot_list")
|
224
242
|
autoload :SnapshotSave, action_root.join("snapshot_save")
|
225
243
|
autoload :StartVM, action_root.join("start_vm")
|
226
244
|
autoload :SuspendVM, action_root.join("suspend_vm")
|
227
|
-
autoload :
|
245
|
+
autoload :SyncedFolders, 'vagrant/action/builtin/synced_folders'
|
246
|
+
autoload :SyncedFolderCleanup, 'vagrant/action/builtin/synced_folder_cleanup'
|
228
247
|
autoload :WaitTillDown, action_root.join("wait_till_down")
|
229
248
|
autoload :WaitTillUp, action_root.join("wait_till_up")
|
230
249
|
autoload :WaitTilSuspended, action_root.join("wait_til_suspended")
|
@@ -248,6 +267,7 @@ module VagrantPlugins
|
|
248
267
|
end
|
249
268
|
yield env, b2
|
250
269
|
end
|
270
|
+
b.use DisconnectOVirt
|
251
271
|
end
|
252
272
|
end
|
253
273
|
end
|
@@ -21,14 +21,27 @@ module VagrantPlugins
|
|
21
21
|
conn_attr[:password] = config.password if config.password
|
22
22
|
conn_attr[:debug] = config.debug if config.debug
|
23
23
|
conn_attr[:insecure] = true if config.insecure
|
24
|
+
conn_attr[:headers] = {'Filter' => true} if config.filtered_api
|
24
25
|
|
25
26
|
@logger.info("Connecting to oVirt (#{config.url}) ...")
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
27
|
+
ovirt_connection = OvirtSDK4::Connection.new(conn_attr)
|
28
|
+
vms_service = ovirt_connection.system_service.vms_service
|
29
|
+
|
30
|
+
# XXX: Continue setting deprecated global properties. Use of the
|
31
|
+
# related values from env should be preferred.
|
32
|
+
OVirtProvider.ovirt_connection = ovirt_connection
|
33
|
+
OVirtProvider.vms_service = vms_service
|
34
|
+
|
35
|
+
begin
|
36
|
+
ovirt_connection.test(true, 30)
|
37
|
+
rescue => error
|
38
|
+
raise Errors::ServiceConnectionError,
|
39
|
+
:error_message => error.message
|
40
|
+
else
|
41
|
+
env[:connection] = ovirt_connection
|
42
|
+
env[:vms_service] = vms_service
|
43
|
+
@app.call(env)
|
44
|
+
end
|
32
45
|
end
|
33
46
|
|
34
47
|
end
|
@@ -16,58 +16,72 @@ module VagrantPlugins
|
|
16
16
|
|
17
17
|
def call(env)
|
18
18
|
|
19
|
-
iface_options = nil
|
20
19
|
config = env[:machine].provider_config
|
21
|
-
env[:machine].config.vm.networks.each do |config|
|
22
|
-
type, options = config
|
23
|
-
# We support private networks only. They mean both the same right now.
|
24
|
-
next unless [:private_network].include? type
|
25
20
|
|
26
|
-
|
21
|
+
# FIX MULTIPLE NETWORK INTERFACES
|
22
|
+
vagrantfile_networks = []
|
23
|
+
@logger.info("Found next configured networks in Vagrantfile:")
|
24
|
+
env[:machine].config.vm.networks.each do |network|
|
25
|
+
type, options = network
|
26
|
+
|
27
|
+
# We support private networks only
|
28
|
+
next unless type == :private_network
|
29
|
+
@logger.info("#{network}")
|
30
|
+
|
31
|
+
vagrantfile_networks << [type, options]
|
27
32
|
end
|
28
33
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
34
|
+
@logger.info("Processing each found configured network")
|
35
|
+
vagrantfile_networks.each do |network|
|
36
|
+
type, options = network
|
37
|
+
|
38
|
+
iface_options = scoped_hash_override(options, :ovirt)
|
39
|
+
@logger.info("Interface options: #{iface_options}")
|
40
|
+
|
41
|
+
begin
|
42
|
+
nics_service = env[:vms_service].vm_service(env[:machine].id).nics_service
|
43
|
+
if iface_options.nil?
|
44
|
+
# throw an error if they didn't provide any sort of information on interfaces _and_ the VM has none
|
45
|
+
raise Errors::NoNetworkError if nics_service.list.count == 0
|
46
|
+
else
|
47
|
+
# provided a network block of some sort. Search oVirt for the corresponding network_profile_ids
|
48
|
+
@logger.info("Finding network #{iface_options[:network_name]} for given cluster #{config.cluster}")
|
49
|
+
clusters_service = env[:connection].system_service.clusters_service
|
50
|
+
cluster = clusters_service.list(search: "name=#{config.cluster}").first
|
51
|
+
profiles_service = env[:connection].system_service.vnic_profiles_service
|
52
|
+
network_profile_ids = profiles_service.list.map do |profile|
|
53
|
+
if env[:connection].follow_link(profile.network).data_center.id == cluster.data_center.id and
|
54
|
+
profile.name == iface_options[:network_name]
|
55
|
+
profile.id
|
56
|
+
end
|
44
57
|
end
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
raise Errors::NetworkNotFoundError, :network_name => iface_options[:network_name] if network_profile_id.nil? and !iface_options[:network_name].nil?
|
58
|
+
network_profile_id = network_profile_ids.compact.first
|
59
|
+
# error if they provided a 'network name' but it could not be located in the previous search
|
60
|
+
raise Errors::NetworkNotFoundError, :network_name => iface_options[:network_name] if network_profile_id.nil? and !iface_options[:network_name].nil?
|
49
61
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
62
|
+
# quick and dirty way to look for a 'nic#' that is not already attached to the machine
|
63
|
+
iface = (("nic1".."nic8").flat_map { |x| x } - env[:vms_service].vm_service(env[:machine].id).nics_service.list.map(&:name)).first rescue "vagrant_nic1"
|
64
|
+
@logger.info("Creating network interface #{iface}")
|
65
|
+
nics_service.add(
|
66
|
+
OvirtSDK4::Nic.new(
|
67
|
+
name: iface,
|
68
|
+
vnic_profile: {
|
69
|
+
id: network_profile_id
|
70
|
+
}
|
71
|
+
)
|
59
72
|
)
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
73
|
+
end
|
74
|
+
rescue => e
|
75
|
+
if config.debug
|
76
|
+
raise e
|
77
|
+
else
|
78
|
+
fault_message = /Fault detail is \"\[?(.+?)\]?\".*/.match(e.message)[1] rescue e.message
|
79
|
+
raise Errors::AddInterfaceError,
|
80
|
+
:error_message => fault_message
|
81
|
+
end
|
69
82
|
end
|
70
83
|
end
|
84
|
+
# END FIX MULTIPLE NETWORK INTERFACES
|
71
85
|
|
72
86
|
# Continue the middleware chain.
|
73
87
|
@app.call(env)
|
@@ -25,10 +25,19 @@ module VagrantPlugins
|
|
25
25
|
env[:ui].info(" -- Cluster: #{config.cluster}")
|
26
26
|
env[:ui].info(" -- Template: #{config.template}")
|
27
27
|
env[:ui].info(" -- Console Type: #{config.console}")
|
28
|
+
env[:ui].info(" -- BIOS Serial: #{config.bios_serial}")
|
29
|
+
env[:ui].info(" -- Optimized For: #{config.optimized_for}")
|
30
|
+
env[:ui].info(" -- Description: #{config.description}")
|
31
|
+
env[:ui].info(" -- Comment: #{config.comment}")
|
32
|
+
env[:ui].info(" -- Disk: #{Filesize.from("#{config.disk_size} B").to_f('GiB').to_i} GiB") unless config.disk_size.nil?
|
33
|
+
env[:ui].info(" -- Additional Disks:") unless config.disks.empty?
|
34
|
+
config.disks.each do |disk|
|
35
|
+
env[:ui].info(" ---- name=#{disk[:name]} size=#{Filesize.from("#{disk[:size]} B").to_f('GiB').to_i} GiB")
|
36
|
+
end
|
28
37
|
env[:ui].info(" -- Memory: ")
|
29
|
-
env[:ui].info(" ---- Memory: #{Filesize.from("#{config.memory_size} B").to_f('
|
30
|
-
env[:ui].info(" ---- Maximum: #{Filesize.from("#{config.memory_maximum} B").to_f('
|
31
|
-
env[:ui].info(" ---- Guaranteed: #{Filesize.from("#{config.memory_guaranteed} B").to_f('
|
38
|
+
env[:ui].info(" ---- Memory: #{Filesize.from("#{config.memory_size} B").to_f('MiB').to_i} MiB")
|
39
|
+
env[:ui].info(" ---- Maximum: #{Filesize.from("#{config.memory_maximum} B").to_f('MiB').to_i} MiB")
|
40
|
+
env[:ui].info(" ---- Guaranteed: #{Filesize.from("#{config.memory_guaranteed} B").to_f('MiB').to_i} MiB")
|
32
41
|
env[:ui].info(" -- Cpu: ")
|
33
42
|
env[:ui].info(" ---- Cores: #{config.cpu_cores}")
|
34
43
|
env[:ui].info(" ---- Sockets: #{config.cpu_sockets}")
|
@@ -38,6 +47,8 @@ module VagrantPlugins
|
|
38
47
|
# Create oVirt VM.
|
39
48
|
attr = {
|
40
49
|
:name => hostname,
|
50
|
+
:description => config.description,
|
51
|
+
:comment => config.comment,
|
41
52
|
:cpu => {
|
42
53
|
:architecture => 'x86_64',
|
43
54
|
:topology => {
|
@@ -61,15 +72,18 @@ module VagrantPlugins
|
|
61
72
|
:display => {
|
62
73
|
:type => config.console,
|
63
74
|
},
|
75
|
+
:type => config.optimized_for,
|
64
76
|
}
|
65
77
|
|
66
78
|
begin
|
67
|
-
server = env[:vms_service].add(attr)
|
79
|
+
server = env[:vms_service].add(attr)
|
68
80
|
rescue OvirtSDK4::Error => e
|
81
|
+
fault_message = /Fault detail is \"\[?(.+?)\]?\".*/.match(e.message)[1] rescue e.message
|
82
|
+
retry if e.message =~ /Related operation is currently in progress/
|
83
|
+
|
69
84
|
if config.debug
|
70
85
|
raise e
|
71
86
|
else
|
72
|
-
fault_message = /Fault detail is \"\[?(.+?)\]?\".*/.match(e.message)[1] rescue e.message
|
73
87
|
raise Errors::CreateVMError,
|
74
88
|
:error_message => fault_message
|
75
89
|
end
|
@@ -81,17 +95,21 @@ module VagrantPlugins
|
|
81
95
|
# Wait till all volumes are ready.
|
82
96
|
env[:ui].info(I18n.t("vagrant_ovirt4.wait_for_ready_vm"))
|
83
97
|
for i in 0..300
|
84
|
-
|
98
|
+
disk_ready = true
|
85
99
|
vm_service = env[:vms_service].vm_service(env[:machine].id)
|
86
100
|
disk_attachments_service = vm_service.disk_attachments_service
|
87
101
|
disk_attachments = disk_attachments_service.list
|
88
102
|
disk_attachments.each do |disk_attachment|
|
89
103
|
disk = env[:connection].follow_link(disk_attachment.disk)
|
104
|
+
if config.debug
|
105
|
+
env[:ui].info("Checking disk status id=#{disk.id} name=#{disk.name} status=#{disk.status}")
|
106
|
+
end
|
90
107
|
if disk.status != 'ok'
|
91
|
-
|
108
|
+
disk_ready = false
|
92
109
|
break
|
93
110
|
end
|
94
111
|
end
|
112
|
+
ready = (disk_ready and env[:vms_service].vm_service(server.id).get.status.to_sym == :down)
|
95
113
|
break if ready
|
96
114
|
sleep 2
|
97
115
|
end
|
@@ -100,6 +118,67 @@ module VagrantPlugins
|
|
100
118
|
raise Errors::WaitForReadyVmTimeout
|
101
119
|
end
|
102
120
|
|
121
|
+
# add storage disks
|
122
|
+
vm_service = env[:vms_service].vm_service(env[:machine].id)
|
123
|
+
disk_attachments_service = vm_service.disk_attachments_service
|
124
|
+
storage_disks = []
|
125
|
+
config.disks.each do |disk|
|
126
|
+
disk_attachment = disk_attachments_service.add(
|
127
|
+
OvirtSDK4::DiskAttachment.new(
|
128
|
+
disk: {
|
129
|
+
name: disk[:name],
|
130
|
+
description: '#{hostname} storage disk',
|
131
|
+
format: disk[:type] == 'qcow2' ? OvirtSDK4::DiskFormat::COW : OvirtSDK4::DiskFormat::RAW,
|
132
|
+
provisioned_size: disk[:size],
|
133
|
+
storage_domains: [{
|
134
|
+
name: disk[:storage_domain]
|
135
|
+
}]
|
136
|
+
},
|
137
|
+
interface: disk[:bus] == 'virtio' ? OvirtSDK4::DiskInterface::VIRTIO : OvirtSDK4::DiskInterface::IDE,
|
138
|
+
bootable: false,
|
139
|
+
active: true
|
140
|
+
)
|
141
|
+
)
|
142
|
+
storage_disks << disk_attachment
|
143
|
+
env[:ui].info("Added storage disk id=#{disk_attachment.disk.id} name=#{disk[:name]} size=#{disk[:size]}")
|
144
|
+
end
|
145
|
+
|
146
|
+
disks_service = env[:connection].system_service.disks_service
|
147
|
+
storage_disks.each do |s_disk|
|
148
|
+
disk_service = disks_service.disk_service(s_disk.disk.id)
|
149
|
+
loop do
|
150
|
+
sleep(5)
|
151
|
+
disk = disk_service.get
|
152
|
+
if config.debug
|
153
|
+
env[:ui].info("Checking disk status id=#{disk.id} name=#{disk.name} status=#{disk.status}")
|
154
|
+
end
|
155
|
+
break if disk.status == OvirtSDK4::DiskStatus::OK
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
begin
|
160
|
+
if config.bios_serial
|
161
|
+
vm_service = env[:vms_service].vm_service(env[:machine].id)
|
162
|
+
vm_service.update(
|
163
|
+
serial_number: {
|
164
|
+
policy: OvirtSDK4::SerialNumberPolicy::CUSTOM,
|
165
|
+
value: config.bios_serial,
|
166
|
+
}
|
167
|
+
)
|
168
|
+
end
|
169
|
+
rescue OvirtSDK4::Error => e
|
170
|
+
fault_message = /Fault detail is \"\[?(.+?)\]?\".*/.match(e.message)[1] rescue e.message
|
171
|
+
retry if e.message =~ /Related operation is currently in progress/
|
172
|
+
|
173
|
+
if config.debug
|
174
|
+
raise e
|
175
|
+
else
|
176
|
+
raise Errors::UpdateBiosError,
|
177
|
+
:error_message => fault_message
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
|
103
182
|
@app.call(env)
|
104
183
|
end
|
105
184
|
|
@@ -113,6 +192,7 @@ module VagrantPlugins
|
|
113
192
|
destroy_env[:config_validate] = false
|
114
193
|
destroy_env[:force_confirm_destroy] = true
|
115
194
|
env[:action_runner].run(Action.action_destroy, destroy_env)
|
195
|
+
env[:connection].close()
|
116
196
|
end
|
117
197
|
end
|
118
198
|
end
|