Module: VagrantPlugins::Proxmox::Action

Includes:
Vagrant::Action::Builtin
Defined in:
lib/vagrant-proxmox/action.rb,
lib/vagrant-proxmox/action/stop_vm.rb,
lib/vagrant-proxmox/action/clone_vm.rb,
lib/vagrant-proxmox/action/start_vm.rb,
lib/vagrant-proxmox/action/create_vm.rb,
lib/vagrant-proxmox/action/destroy_vm.rb,
lib/vagrant-proxmox/action/is_created.rb,
lib/vagrant-proxmox/action/is_stopped.rb,
lib/vagrant-proxmox/action/read_state.rb,
lib/vagrant-proxmox/action/select_node.rb,
lib/vagrant-proxmox/action/shutdown_vm.rb,
lib/vagrant-proxmox/action/config_clone.rb,
lib/vagrant-proxmox/action/sync_folders.rb,
lib/vagrant-proxmox/action/get_node_list.rb,
lib/vagrant-proxmox/action/read_ssh_info.rb,
lib/vagrant-proxmox/action/proxmox_action.rb,
lib/vagrant-proxmox/action/connect_proxmox.rb,
lib/vagrant-proxmox/action/upload_iso_file.rb,
lib/vagrant-proxmox/action/message_not_created.rb,
lib/vagrant-proxmox/action/message_not_running.rb,
lib/vagrant-proxmox/action/upload_template_file.rb,
lib/vagrant-proxmox/action/cleanup_after_destroy.rb,
lib/vagrant-proxmox/action/message_file_not_found.rb,
lib/vagrant-proxmox/action/message_already_running.rb,
lib/vagrant-proxmox/action/message_already_stopped.rb,
lib/vagrant-proxmox/action/message_upload_server_error.rb,
lib/vagrant-proxmox/action/adjust_forwarded_port_params.rb

Defined Under Namespace

Classes: AdjustForwardedPortParams, CleanupAfterDestroy, CloneVm, ConfigClone, ConnectProxmox, CreateVm, DestroyVm, GetNodeList, IsCreated, IsStopped, MessageAlreadyRunning, MessageAlreadyStopped, MessageFileNotFound, MessageNotCreated, MessageNotRunning, MessageUploadServerError, ProxmoxAction, ReadSSHInfo, ReadState, SelectNode, ShutdownVm, StartVm, StopVm, SyncFolders, UploadIsoFile, UploadTemplateFile

Class Method Summary collapse

Class Method Details

.action_destroyObject

This action is called to destroy the remote machine.



136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'lib/vagrant-proxmox/action.rb', line 136

def self.action_destroy
	Vagrant::Action::Builder.new.tap do |b|
		b.use ConfigValidate
		b.use ConnectProxmox
		b.use Call, IsCreated do |env1, b1|
			if env1[:result]
				b1.use Call, ::Vagrant::Action::Builtin::DestroyConfirm do |env2, b2|
					if env2[:result]
						b2.use Call, IsStopped do |env3, b3|
							b3.use ShutdownVm unless env3[:result]
							b3.use DestroyVm
							b3.use ::Vagrant::Action::Builtin::ProvisionerCleanup
							b3.use CleanupAfterDestroy
						end
					else
						b2.use ::VagrantPlugins::ProviderVirtualBox::Action::MessageWillNotDestroy
					end
				end
			else
				b1.use MessageNotCreated
			end
		end
	end
end

.action_haltObject



115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/vagrant-proxmox/action.rb', line 115

def self.action_halt
	Vagrant::Action::Builder.new.tap do |b|
		b.use ConfigValidate
		b.use Call, IsCreated do |env1, b1|
			if env1[:result]
				b1.use Call, IsStopped do |env2, b2|
					if env2[:result]
						b2.use MessageAlreadyStopped
					else
						b2.use ConnectProxmox
						b2.use ShutdownVm
					end
				end
			else
				b1.use MessageNotCreated
			end
		end
	end
end

.action_provisionObject



95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/vagrant-proxmox/action.rb', line 95

def self.action_provision
	Vagrant::Action::Builder.new.tap do |b|
		b.use ConfigValidate
		b.use Call, IsCreated do |env1, b1|
			if env1[:result]
				b1.use Call, IsStopped do |env2, b2|
					if env2[:result]
						b2.use MessageNotRunning
					else
						b2.use Provision
						b2.use SyncFolders
					end
				end
			else
				b1.use MessageNotCreated
			end
		end
	end
end

.action_read_ssh_infoObject



161
162
163
164
165
166
167
168
169
170
# File 'lib/vagrant-proxmox/action.rb', line 161

def self.action_read_ssh_info
	Vagrant::Action::Builder.new.tap do |b|
		b.use ConfigValidate
		b.use ConnectProxmox
		b.use GetNodeList
		b.use SelectNode
		b.use AdjustForwardedPortParams
		b.use ReadSSHInfo
	end
end

.action_read_stateObject



10
11
12
13
14
15
16
# File 'lib/vagrant-proxmox/action.rb', line 10

def self.action_read_state
	Vagrant::Action::Builder.new.tap do |b|
		b.use ConfigValidate
		b.use ConnectProxmox
		b.use ReadState
	end
end

.action_sshObject



172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# File 'lib/vagrant-proxmox/action.rb', line 172

def self.action_ssh
	Vagrant::Action::Builder.new.tap do |b|
		b.use ConfigValidate
		b.use Call, IsCreated do |env1, b1|
			if env1[:result]
				b1.use Call, IsStopped do |env2, b2|
					if env2[:result]
						b2.use MessageNotRunning
					else
						b2.use SSHExec
					end
				end
			else
				b1.use MessageNotCreated
			end
		end
	end
end

.action_ssh_runObject



191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
# File 'lib/vagrant-proxmox/action.rb', line 191

def self.action_ssh_run
	Vagrant::Action::Builder.new.tap do |b|
		b.use ConfigValidate
		b.use Call, IsCreated do |env1, b1|
			if env1[:result]
				b1.use Call, IsStopped do |env2, b2|
            if env2[:result]
						b2.use MessageNotRunning
            else
						b2.use SSHRun
					end
				end
			else
				b1.use MessageNotCreated
			end
		end
	end
end

.action_upObject



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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/vagrant-proxmox/action.rb', line 18

def self.action_up
	Vagrant::Action::Builder.new.tap do |b|
		b.use ConfigValidate
		b.use ConnectProxmox
		b.use Call, IsCreated do |env1, b1|
			if env1[:result]
				b1.use Call, IsStopped do |env2, b2|
					if env2[:result]
						b2.use Provision
						b2.use StartVm
						b2.use SyncFolders
					else
						b2.use MessageAlreadyRunning
					end
				end
			else
				b1.use GetNodeList
				b1.use SelectNode
				b1.use Provision
				if env1[:machine].provider_config.vm_type == :openvz
					b1.use Call, UploadTemplateFile do |env2, b2|
						if env2[:result] == :ok
							b2.use CreateVm
							b2.use StartVm
							b2.use SyncFolders
						elsif env2[:result] == :file_not_found
							b2.use MessageFileNotFound
						elsif env2[:result] == :server_upload_error
							b2.use MessageUploadServerError
						end
					end
				elsif env1[:machine].provider_config.vm_type == :lxc
					b1.use Call, UploadTemplateFile do |env2, b2|
						if env2[:result] == :ok
							b2.use CreateVm
							b2.use StartVm
							b2.use SyncFolders
						elsif env2[:result] == :file_not_found
							b2.use MessageFileNotFound
						elsif env2[:result] == :server_upload_error
							b2.use MessageUploadServerError
						end
					end
				elsif env1[:machine].provider_config.vm_type == :qemu
					if env1[:machine].provider_config.qemu_iso
						b1.use Call, UploadIsoFile do |env2, b2|
							if env2[:result] == :ok
								b2.use CreateVm
								b2.use StartVm
								b2.use SyncFolders
							elsif env2[:result] == :file_not_found
								b2.use MessageFileNotFound
							elsif env2[:result] == :server_upload_error
								b2.use MessageUploadServerError
							end
						end
					else
						b1.use CloneVm
						b1.use Call, IsCreated do |env2, b2|
							if env2[:result]
								b2.use AdjustForwardedPortParams
								b2.use ConfigClone
								b2.use StartVm
								b2.use SyncFolders
							elsif env2[:result] == :file_not_found
								b2.use MessageFileNotFound
							elsif env2[:result] == :server_upload_error
								b2.use MessageUploadServerError
							end
						end
					end
				end
			end
		end
	end
end