File tree Expand file tree Collapse file tree 3 files changed +47
-8
lines changed Expand file tree Collapse file tree 3 files changed +47
-8
lines changed Original file line number Diff line number Diff line change
1
+ # frozen_string_literal: true
2
+
3
+ module VagrantPlugins
4
+ module Utm
5
+ module Action
6
+ # This action waits for a given amount of seconds.
7
+ # This is a workaround for the UTM provider, which does not
8
+ # report when the VM is running. As soon as UTM reports the
9
+ # state as 'running', this action can and will be removed.
10
+ # Then we use the state 'running', rather than 'started'
11
+ class WaitForRunning
12
+ def initialize ( app , _env )
13
+ @app = app
14
+ end
15
+
16
+ def call ( env )
17
+ # set the wait time to use configures time or
18
+ # default to 10 seconds.
19
+ wait_time = env [ :machine ] . provider_config . wait_time
20
+ env [ :ui ] . info I18n . t ( "vagrant.boot_waiting" )
21
+ sleep ( wait_time )
22
+
23
+ @app . call ( env )
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
Original file line number Diff line number Diff line change @@ -28,13 +28,19 @@ class Config < Vagrant.plugin("2", :config)
28
28
# @return [Array]
29
29
attr_reader :customizations
30
30
31
+ # The time to wait for the VM to be 'running' after 'started'.
32
+ #
33
+ # @return [Integer]
34
+ attr_accessor :wait_time
35
+
31
36
# Initialize the configuration with unset values.
32
37
def initialize
33
38
super
34
39
@check_guest_additions = UNSET_VALUE
35
40
@customizations = [ ]
36
41
@name = UNSET_VALUE
37
42
@utm_file_url = UNSET_VALUE
43
+ @wait_time = UNSET_VALUE
38
44
end
39
45
40
46
# Customize the VM by calling 'osascript' with the given
@@ -71,8 +77,11 @@ def cpus=(count)
71
77
# This is the hook that is called to finalize the object before it
72
78
# is put into use.
73
79
def finalize!
80
+ @check_guest_additions = true if @check_guest_additions == UNSET_VALUE
81
+ # The default name is just nothing, and we default it
74
82
@name = nil if @name == UNSET_VALUE
75
83
@utm_file_url = nil if @utm_file_url == UNSET_VALUE
84
+ @wait_time = 10 if @wait_time == UNSET_VALUE
76
85
end
77
86
end
78
87
end
Original file line number Diff line number Diff line change @@ -43,6 +43,14 @@ def initialize(machine)
43
43
machine_id_changed
44
44
end
45
45
46
+ # Execute the action with the given name.
47
+ def action ( name )
48
+ action_method = "action_#{ name } "
49
+ return Action . send ( action_method ) if Action . respond_to? ( action_method )
50
+
51
+ nil
52
+ end
53
+
46
54
# If the machine ID changed, then we need to rebuild our underlying
47
55
# driver.
48
56
def machine_id_changed
@@ -63,6 +71,8 @@ def machine_id_changed
63
71
# Returns the SSH info for accessing the UTM VM.
64
72
def ssh_info
65
73
# If the VM is not running (utm, started) that we can't possibly SSH into it
74
+ # TODO: We should use the state 'running', rather than 'started'
75
+ # This is a workaround for the UTM provider, which does not expose 'running' state
66
76
return nil if state . id != :started
67
77
68
78
# If there is port forwarding, GuestPort 22 to HostPort XXXX,
@@ -81,14 +91,6 @@ def ssh_info
81
91
}
82
92
end
83
93
84
- # Execute the action with the given name.
85
- def action ( name )
86
- action_method = "action_#{ name } "
87
- return Action . send ( action_method ) if Action . respond_to? ( action_method )
88
-
89
- nil
90
- end
91
-
92
94
# Return the state of UTM virtual machine by actually
93
95
# querying utmctl.
94
96
#
You can’t perform that action at this time.
0 commit comments