vagrant-ovirt4 1.0.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.
Files changed (63) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +8 -0
  3. data/.rspec +1 -0
  4. data/Gemfile +18 -0
  5. data/Gemfile.lock +54 -0
  6. data/README.md +110 -0
  7. data/Rakefile +22 -0
  8. data/example_box/README.md +13 -0
  9. data/example_box/Vagrantfile +14 -0
  10. data/example_box/metadata.json +4 -0
  11. data/lib/vagrant-ovirt4/action/connect_ovirt.rb +38 -0
  12. data/lib/vagrant-ovirt4/action/create_network_interfaces.rb +58 -0
  13. data/lib/vagrant-ovirt4/action/create_vm.rb +92 -0
  14. data/lib/vagrant-ovirt4/action/destroy_vm.rb +25 -0
  15. data/lib/vagrant-ovirt4/action/halt_vm.rb +23 -0
  16. data/lib/vagrant-ovirt4/action/is_created.rb +19 -0
  17. data/lib/vagrant-ovirt4/action/is_running.rb +19 -0
  18. data/lib/vagrant-ovirt4/action/message_already_up.rb +16 -0
  19. data/lib/vagrant-ovirt4/action/message_not_created.rb +16 -0
  20. data/lib/vagrant-ovirt4/action/message_not_suspended.rb +16 -0
  21. data/lib/vagrant-ovirt4/action/message_not_up.rb +16 -0
  22. data/lib/vagrant-ovirt4/action/message_powering_up.rb +16 -0
  23. data/lib/vagrant-ovirt4/action/message_saving_state.rb +16 -0
  24. data/lib/vagrant-ovirt4/action/read_ssh_info.rb +56 -0
  25. data/lib/vagrant-ovirt4/action/read_state.rb +47 -0
  26. data/lib/vagrant-ovirt4/action/set_name_of_domain.rb +24 -0
  27. data/lib/vagrant-ovirt4/action/snapshot_delete.rb +37 -0
  28. data/lib/vagrant-ovirt4/action/snapshot_list.rb +58 -0
  29. data/lib/vagrant-ovirt4/action/snapshot_save.rb +28 -0
  30. data/lib/vagrant-ovirt4/action/start_vm.rb +80 -0
  31. data/lib/vagrant-ovirt4/action/suspend_vm.rb +24 -0
  32. data/lib/vagrant-ovirt4/action/sync_folders.rb +69 -0
  33. data/lib/vagrant-ovirt4/action/wait_til_suspended.rb +44 -0
  34. data/lib/vagrant-ovirt4/action/wait_till_down.rb +47 -0
  35. data/lib/vagrant-ovirt4/action/wait_till_up.rb +83 -0
  36. data/lib/vagrant-ovirt4/action.rb +255 -0
  37. data/lib/vagrant-ovirt4/cap/snapshot_list.rb +12 -0
  38. data/lib/vagrant-ovirt4/cap/snapshot_save.rb +12 -0
  39. data/lib/vagrant-ovirt4/config.rb +49 -0
  40. data/lib/vagrant-ovirt4/errors.rb +48 -0
  41. data/lib/vagrant-ovirt4/plugin.rb +80 -0
  42. data/lib/vagrant-ovirt4/provider.rb +76 -0
  43. data/lib/vagrant-ovirt4/util/collection.rb +21 -0
  44. data/lib/vagrant-ovirt4/util/timer.rb +17 -0
  45. data/lib/vagrant-ovirt4/util.rb +9 -0
  46. data/lib/vagrant-ovirt4/version.rb +6 -0
  47. data/lib/vagrant-ovirt4.rb +38 -0
  48. data/locales/en.yml +74 -0
  49. data/spec/spec_helper.rb +1 -0
  50. data/spec/vagrant-ovirt4/action/is_created_spec.rb +40 -0
  51. data/spec/vagrant-ovirt4/action/is_running_spec.rb +40 -0
  52. data/spec/vagrant-ovirt4/action/message_already_up_spec.rb +20 -0
  53. data/spec/vagrant-ovirt4/action/message_not_created_spec.rb +20 -0
  54. data/spec/vagrant-ovirt4/action/message_not_suspended_spec.rb +20 -0
  55. data/spec/vagrant-ovirt4/action/message_not_up_spec.rb +20 -0
  56. data/spec/vagrant-ovirt4/action/message_powering_up_spec.rb +20 -0
  57. data/spec/vagrant-ovirt4/action/message_saving_state_spec.rb +20 -0
  58. data/spec/vagrant-ovirt4/action/read_ssh_info_spec.rb +73 -0
  59. data/spec/vagrant-ovirt4/action/read_state_spec.rb +68 -0
  60. data/spec/vagrant-ovirt4/config_spec.rb +55 -0
  61. data/tools/prepare_redhat_for_box.sh +113 -0
  62. data/vagrant-ovirt4.gemspec +26 -0
  63. metadata +180 -0
@@ -0,0 +1,56 @@
1
+ require "log4r"
2
+
3
+ module VagrantPlugins
4
+ module OVirtProvider
5
+ module Action
6
+ # This action reads the SSH info for the machine and puts it into the
7
+ # `:machine_ssh_info` key in the environment.
8
+ class ReadSSHInfo
9
+ def initialize(app, env)
10
+ @app = app
11
+ @logger = Log4r::Logger.new("vagrant_ovirt4::action::read_ssh_info")
12
+ end
13
+
14
+ def call(env)
15
+ env[:machine_ssh_info] = read_ssh_info(env)
16
+
17
+ @app.call(env)
18
+ end
19
+
20
+ def read_ssh_info(env)
21
+ vms_service, machine = env[:vms_service], env[:machine]
22
+ return :not_created if machine.id.nil?
23
+
24
+ # Find the machine
25
+ server = vms_service.vm_service(machine.id)
26
+ begin
27
+ if server.get.nil?
28
+ machine.id = nil
29
+ return :not_created
30
+ end
31
+ rescue Exception => e
32
+ machine.id = nil
33
+ return :not_created
34
+ raise e
35
+ end
36
+
37
+ nics_service = server.nics_service
38
+ nics = nics_service.list
39
+ ip_addr = nics.collect { |nic_attachment| env[:connection].follow_link(nic_attachment).reported_devices.collect { |dev| dev.ips.collect { |ip| ip.address if ip.version == 'v4' } } }.flatten.reject { |ip| ip.nil? }.first rescue nil
40
+
41
+ # Return the info
42
+ # TODO: Some info should be configurable in Vagrantfile
43
+ return {
44
+ :host => ip_addr,
45
+ :port => machine.config.ssh.guest_port,
46
+ :username => machine.config.ssh.username,
47
+ :private_key_path => machine.config.ssh.private_key_path,
48
+ :forward_agent => machine.config.ssh.forward_agent,
49
+ :forward_x11 => machine.config.ssh.forward_x11,
50
+ }
51
+
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,47 @@
1
+ require "log4r"
2
+
3
+ module VagrantPlugins
4
+ module OVirtProvider
5
+ module Action
6
+ # This action reads the state of the machine and puts it in the
7
+ # `:machine_state_id` key in the environment.
8
+ class ReadState
9
+ def initialize(app, env)
10
+ @app = app
11
+ @logger = Log4r::Logger.new("vagrant_ovirt4::action::read_state")
12
+ end
13
+
14
+ def call(env)
15
+ env[:machine_state_id] = read_state(env)
16
+ @app.call(env)
17
+ end
18
+
19
+ def read_state(env)
20
+ vms_service = env[:vms_service]
21
+ machine = env[:machine]
22
+ return :not_created if machine.id.nil?
23
+
24
+ server = vms_service.vm_service(machine.id)
25
+ begin
26
+ if server.get.nil?
27
+ machine.id = nil
28
+ return :not_created
29
+ end
30
+ rescue
31
+ machine.id = nil
32
+ return :not_created
33
+ end
34
+ nics_service = server.nics_service
35
+ nics = nics_service.list
36
+ ip_addr = nics.collect { |nic_attachment| env[:connection].follow_link(nic_attachment).reported_devices.collect { |dev| dev.ips.collect { |ip| ip.address if ip.version == 'v4' } } }.flatten.reject { |ip| ip.nil? }.first rescue nil
37
+ unless ip_addr.nil?
38
+ env[:ip_address] = ip_addr
39
+ @logger.debug("Got output #{env[:ip_address]}")
40
+ end
41
+
42
+ return server.get.status.to_sym
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,24 @@
1
+ module VagrantPlugins
2
+ module OVirtProvider
3
+ module Action
4
+
5
+ class SetNameOfDomain
6
+ @@MAX_NAME_LENGTH = 64
7
+ def initialize(app, env)
8
+ @app = app
9
+ end
10
+
11
+ def call(env)
12
+ dir_name = env[:root_path].basename.to_s.dup.gsub(/[^-a-z0-9_]/i, "")
13
+ timestamp = "_#{Time.now.to_f}"
14
+ max_dir_name_length = dir_name.length-[(dir_name + timestamp).length-(@@MAX_NAME_LENGTH-1), 0].max
15
+ env[:domain_name] = dir_name[0..max_dir_name_length] << timestamp
16
+
17
+ @app.call(env)
18
+ end
19
+ end
20
+
21
+ end
22
+ end
23
+ end
24
+
@@ -0,0 +1,37 @@
1
+ require 'log4r'
2
+
3
+ module VagrantPlugins
4
+ module OVirtProvider
5
+ module Action
6
+ class SnapshotDelete
7
+ def initialize(app, env)
8
+ @logger = Log4r::Logger.new("vagrant_ovirt4::action::snapshot_delete")
9
+ @app = app
10
+ end
11
+
12
+ def call(env)
13
+ env[:ui].info(I18n.t("vagrant_ovirt4.snapshot_delete"))
14
+
15
+ snapshots_service = env[:vms_service].vm_service(env[:machine].id).snapshots_service
16
+ require 'pry'
17
+
18
+ snapshot = snapshots_service.snapshot_service(env[:snapshot_name])
19
+
20
+ begin
21
+ raise RemoveActiveSnapshotError, :id => env[:snapshot_name] if snapshot.get.snapshot_type == 'active'
22
+ snapshot.remove
23
+ rescue OvirtSDK4::Error => e
24
+ fault_detail = /Fault detail is \"\[(.*)\]\".*/.match(e.message)
25
+ error_message = e.message
26
+ error_message = fault_detail[1] unless fault_detail.nil?
27
+ raise Errors::RemoveSnapshotError,
28
+ :id => env[:snapshot_name],
29
+ :error_message => error_message
30
+ end
31
+
32
+ @app.call(env)
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,58 @@
1
+ require 'log4r'
2
+
3
+ module VagrantPlugins
4
+ module OVirtProvider
5
+ module Action
6
+ class SnapshotList
7
+ def initialize(app, env)
8
+ @logger = Log4r::Logger.new("vagrant_ovirt4::action::snapshot_list")
9
+ @app = app
10
+ end
11
+
12
+ def call(env)
13
+ env[:ui].info(I18n.t("vagrant_ovirt4.snapshot_list"))
14
+
15
+ system_service = env[:connection].system_service
16
+
17
+ # Find all the virtual machines and store the id and name in a
18
+ # hash, so that looking them up later will be faster:
19
+ vms_map = Hash[env[:vms_service].list.map { |vm| [vm.id, vm.name] }]
20
+
21
+ # Same for storage domains:
22
+ sds_service = system_service.storage_domains_service
23
+ sds_map = Hash[sds_service.list.map { |sd| [sd.id, sd.name] }]
24
+
25
+ # For each virtual machine find its snapshots, then for each snapshot
26
+ # find its disks:
27
+ xs = [['id', 'description', 'date']]
28
+ vms_map.each do |vm_id, vm_name|
29
+ vm_service = env[:vms_service].vm_service(vm_id)
30
+ snaps_service = vm_service.snapshots_service
31
+ snaps_map = Hash[snaps_service.list.map { |snap| [snap.id, { description: snap.description, date: snap.date }] }]
32
+ snaps_map.each do |snap_id, metadata|
33
+ snap_description = metadata[:description]
34
+ snap_date = metadata[:date]
35
+ snap_service = snaps_service.snapshot_service(snap_id)
36
+ disks_service = snap_service.disks_service
37
+ disks_service.list.each do |disk|
38
+ next unless disk.storage_domains.any?
39
+ sd_id = disk.storage_domains.first.id
40
+ sd_name = sds_map[sd_id]
41
+ xs.push([snap_id, snap_description, snap_date.to_s])
42
+ end
43
+ end
44
+ end
45
+ widths = xs.transpose.map { |column_arr| column_arr.map(&:size).max }
46
+ env[:machine_snapshot_list] =
47
+ xs.map { |row_arr|
48
+ row_arr.map.with_index { |str, idx|
49
+ "%#{widths[idx]}s" % str
50
+ } .join(" " * 5)
51
+ }
52
+
53
+ @app.call(env)
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,28 @@
1
+ require 'log4r'
2
+
3
+ module VagrantPlugins
4
+ module OVirtProvider
5
+ module Action
6
+ class SnapshotSave
7
+ def initialize(app, env)
8
+ @logger = Log4r::Logger.new("vagrant_ovirt4::action::snapshot_save")
9
+ @app = app
10
+ end
11
+
12
+ def call(env)
13
+ env[:ui].info(I18n.t("vagrant_ovirt4.snapshot_save"))
14
+
15
+ snapshots_service = env[:vms_service].vm_service(env[:machine].id).snapshots_service
16
+
17
+ snapshots_service.add(
18
+ OvirtSDK4::Snapshot.new(
19
+ description: env[:snapshot_name]
20
+ )
21
+ )
22
+
23
+ @app.call(env)
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,80 @@
1
+ require 'log4r'
2
+ require 'vagrant/util/scoped_hash_override'
3
+
4
+ module VagrantPlugins
5
+ module OVirtProvider
6
+ module Action
7
+
8
+ # Just start the VM.
9
+ class StartVM
10
+ include Vagrant::Util::ScopedHashOverride
11
+
12
+ def initialize(app, env)
13
+ @logger = Log4r::Logger.new("vagrant_ovirt::action::start_vm")
14
+ @app = app
15
+ end
16
+
17
+ def call(env)
18
+ env[:ui].info(I18n.t("vagrant_ovirt4.starting_vm"))
19
+
20
+ machine = env[:vms_service].vm_service(env[:machine].id)
21
+ if machine.get.status == nil
22
+ raise Errors::NoVMError,
23
+ :vm_name => env[:machine].id.to_s
24
+ end
25
+
26
+ iface_options = nil
27
+ env[:machine].config.vm.networks.each do |config|
28
+ type, options = config
29
+ next unless [:private_network].include? type
30
+
31
+ iface_options = scoped_hash_override(options, :ovirt)
32
+ end
33
+
34
+ my_script = ""
35
+ #runcmd:
36
+ # - [ service, network, restart]
37
+ #"
38
+
39
+ hostname = env[:machine].config.vm.hostname
40
+ hostname = 'vagrant' if hostname.nil?
41
+
42
+ nic_configuration = nil
43
+ if iface_options[:ip] then
44
+ nic_configuration = {
45
+ name: 'eth0',
46
+ on_boot: true,
47
+ boot_protocol: OvirtSDK4::BootProtocol::STATIC,
48
+ ip: {
49
+ version: OvirtSDK4::IpVersion::V4,
50
+ address: iface_options[:ip],
51
+ gateway: iface_options[:gateway],
52
+ }
53
+ }
54
+ else
55
+ nic_configuration = {
56
+ name: 'eth0',
57
+ on_boot: true,
58
+ boot_protocol: OvirtSDK4::BootProtocol::DYNAMIC,
59
+ }
60
+ end
61
+
62
+ vm_configuration = {
63
+ initialization: {
64
+ host_name: hostname,
65
+ nic_configurations: [nic_configuration],
66
+ custom_script: my_script,
67
+ }
68
+ }
69
+
70
+ machine.start(
71
+ use_cloud_init: true,
72
+ vm: vm_configuration
73
+ )
74
+
75
+ @app.call(env)
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,24 @@
1
+ require 'log4r'
2
+
3
+ module VagrantPlugins
4
+ module OVirtProvider
5
+ module Action
6
+ class SuspendVM
7
+ def initialize(app, env)
8
+ @logger = Log4r::Logger.new("vagrant_ovirt4::action::suspend_vm")
9
+ @app = app
10
+ end
11
+
12
+ def call(env)
13
+ env[:ui].info(I18n.t("vagrant_ovirt4.suspend_vm"))
14
+
15
+ machine = env[:vms_service].vm_service(env[:machine].id)
16
+ machine.suspend
17
+
18
+ @app.call(env)
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+
@@ -0,0 +1,69 @@
1
+ require "log4r"
2
+ require "vagrant/util/subprocess"
3
+
4
+ module VagrantPlugins
5
+ module OVirtProvider
6
+ module Action
7
+ class SyncFolders
8
+ def initialize(app, env)
9
+ @app = app
10
+ @logger = Log4r::Logger.new("vagrant_ovirt::action::sync_folders")
11
+ end
12
+
13
+ def call(env)
14
+ @app.call(env)
15
+
16
+ ssh_info = env[:machine].ssh_info
17
+
18
+ env[:machine].config.vm.synced_folders.each do |id, data|
19
+ next if data[:disabled]
20
+ hostpath = File.expand_path(data[:hostpath], env[:root_path])
21
+ guestpath = data[:guestpath]
22
+
23
+ # Make sure there is a trailing slash on the host path to avoid creating an additional directory with rsync
24
+ hostpath = "#{hostpath}/" if hostpath !~ /\/$/
25
+
26
+ # on windows rsync.exe requires cygdrive-style paths.
27
+ # assumes: /c/...
28
+ # Should be msysgit and cygwin compatible if /etc/fstab in cygwin contains:
29
+ # none / cygdrive binary,posix=0,user 0 0
30
+ if Vagrant::Util::Platform.windows?
31
+ hostpath = hostpath.gsub(/^(\w):/) { "/#{$1}" }
32
+ end
33
+
34
+ env[:ui].info(I18n.t("vagrant_ovirt4.rsync_folder", :hostpath => hostpath, :guestpath => guestpath))
35
+
36
+ # Create the guest path
37
+ env[:machine].communicate.sudo("mkdir -p '#{guestpath}'")
38
+ env[:machine].communicate.sudo("chown #{ssh_info[:username]} '#{guestpath}'")
39
+
40
+ # Rsync over to the guest path using the SSH info
41
+ command = [
42
+ "rsync",
43
+ "--verbose",
44
+ "--archive",
45
+ "-z",
46
+ "--owner",
47
+ "--perms",
48
+ "--exclude",
49
+ ".vagrant/",
50
+ "-e",
51
+ "ssh -p #{ssh_info[:port]} -o StrictHostKeyChecking=no -i '#{ssh_info[:private_key_path][0]}'",
52
+ hostpath,
53
+ "#{ssh_info[:username]}@#{ssh_info[:host]}:#{guestpath}"
54
+ ]
55
+
56
+ r = Vagrant::Util::Subprocess.execute(*command)
57
+ if r.exit_code != 0
58
+ raise Errors::RsyncError,
59
+ :guestpath => guestpath,
60
+ :hostpath => hostpath,
61
+ :stderr => r.stderr
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
69
+
@@ -0,0 +1,44 @@
1
+ require 'log4r'
2
+ require 'vagrant-ovirt4/util/timer'
3
+ require 'vagrant/util/retryable'
4
+
5
+ module VagrantPlugins
6
+ module OVirtProvider
7
+ module Action
8
+ class WaitTilSuspended
9
+ include Vagrant::Util::Retryable
10
+
11
+ def initialize(app, env)
12
+ @logger = Log4r::Logger.new("vagrant_ovirt4::action::wait_til_suspended")
13
+ @app = app
14
+ end
15
+
16
+ def call(env)
17
+ vm_service = env[:vms_service].vm_service(env[:machine].id)
18
+
19
+ env[:ui].info(I18n.t("vagrant_ovirt4.wait_til_suspended"))
20
+ for i in 1..300
21
+ ready = true
22
+ if vm_service.get == nil
23
+ raise NoVMError, :vm_name => ''
24
+ end
25
+
26
+ if vm_service.get.status.to_sym != :suspended
27
+ ready = false
28
+ end
29
+ break if ready
30
+ sleep 2
31
+ end
32
+
33
+ if not ready
34
+ raise Errors::WaitForShutdownVmTimeout
35
+ end
36
+
37
+
38
+ @app.call(env)
39
+ end
40
+
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,47 @@
1
+ require 'log4r'
2
+ require 'vagrant-ovirt4/util/timer'
3
+ require 'vagrant/util/retryable'
4
+
5
+ module VagrantPlugins
6
+ module OVirtProvider
7
+ module Action
8
+
9
+ # Wait till VM is stopped
10
+ class WaitTillDown
11
+ include Vagrant::Util::Retryable
12
+
13
+ def initialize(app, env)
14
+ @logger = Log4r::Logger.new("vagrant_ovirt4::action::wait_till_down")
15
+ @app = app
16
+ end
17
+
18
+ def call(env)
19
+ vm_service = env[:vms_service].vm_service(env[:machine].id)
20
+
21
+ env[:ui].info(I18n.t("vagrant_ovirt4.wait_till_down"))
22
+ for i in 1..300
23
+ ready = true
24
+ if vm_service.get == nil
25
+ raise NoVMError, :vm_name => ''
26
+ end
27
+
28
+ if vm_service.get.status.to_sym != :down
29
+ ready = false
30
+ end
31
+ break if ready
32
+ sleep 2
33
+ end
34
+
35
+ if not ready
36
+ raise Errors::WaitForShutdownVmTimeout
37
+ end
38
+
39
+
40
+ @app.call(env)
41
+ end
42
+
43
+ end
44
+ end
45
+ end
46
+ end
47
+
@@ -0,0 +1,83 @@
1
+ require 'log4r'
2
+ require 'vagrant-ovirt4/util/timer'
3
+ require 'vagrant/util/retryable'
4
+
5
+ module VagrantPlugins
6
+ module OVirtProvider
7
+ module Action
8
+
9
+ # Wait till VM is started, till it obtains an IP address and is
10
+ # accessible via ssh.
11
+ class WaitTillUp
12
+ include Vagrant::Util::Retryable
13
+
14
+ def initialize(app, env)
15
+ @logger = Log4r::Logger.new("vagrant_ovirt4::action::wait_till_up")
16
+ @app = app
17
+ end
18
+
19
+ def call(env)
20
+ # Initialize metrics if they haven't been
21
+ env[:metrics] ||= {}
22
+
23
+ # Get config.
24
+ config = env[:machine].provider_config
25
+
26
+ # Wait for VM to obtain an ip address.
27
+ env[:metrics]["instance_ip_time"] = Util::Timer.time do
28
+ env[:ui].info(I18n.t("vagrant_ovirt4.waiting_for_ip"))
29
+ for i in 1..300
30
+ # If we're interrupted don't worry about waiting
31
+ next if env[:interrupted]
32
+
33
+ # Get VM.
34
+ server = env[:vms_service].vm_service(env[:machine].id)
35
+ if server == nil
36
+ raise NoVMError, :vm_name => ''
37
+ end
38
+
39
+ nics_service = server.nics_service
40
+ nics = nics_service.list
41
+ ip_addr = nics.collect { |nic_attachment| env[:connection].follow_link(nic_attachment).reported_devices.collect { |dev| dev.ips.collect { |ip| ip.address if ip.version == 'v4' } } }.flatten.reject { |ip| ip.nil? }.first rescue nil
42
+ unless ip_addr.nil?
43
+ env[:ip_address] = ip_addr
44
+ break
45
+ @logger.debug("Got output #{env[:ip_address]}")
46
+ end
47
+ sleep 5
48
+ end
49
+ end
50
+ terminate(env) if env[:interrupted]
51
+ @logger.info("Got IP address #{env[:ip_address]}")
52
+ @logger.info("Time for getting IP: #{env[:metrics]["instance_ip_time"]}")
53
+
54
+ terminate(env) if env[:interrupted]
55
+ @logger.info("Time for SSH ready: #{env[:metrics]["instance_ssh_time"]}")
56
+
57
+ # Booted and ready for use.
58
+ env[:ui].info(I18n.t("vagrant_ovirt4.ready"))
59
+
60
+ @app.call(env)
61
+ end
62
+
63
+ def recover(env)
64
+ return if env["vagrant.error"].is_a?(Vagrant::Errors::VagrantError)
65
+
66
+ if env[:machine].provider.state.id != :not_created
67
+ # Undo the import
68
+ terminate(env)
69
+ end
70
+ end
71
+
72
+ def terminate(env)
73
+ destroy_env = env.dup
74
+ destroy_env.delete(:interrupted)
75
+ destroy_env[:config_validate] = false
76
+ destroy_env[:force_confirm_destroy] = true
77
+ env[:action_runner].run(Action.action_destroy, destroy_env)
78
+ end
79
+ end
80
+ end
81
+ end
82
+ end
83
+