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/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/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

Defined Under Namespace

Classes: CleanupAfterDestroy, 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.



108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/vagrant-proxmox/action.rb', line 108

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



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/vagrant-proxmox/action.rb', line 87

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



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/vagrant-proxmox/action.rb', line 67

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



133
134
135
136
137
138
139
# File 'lib/vagrant-proxmox/action.rb', line 133

def self.action_read_ssh_info
	Vagrant::Action::Builder.new.tap do |b|
		b.use ConfigValidate
		b.use ConnectProxmox
		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



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

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



160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# File 'lib/vagrant-proxmox/action.rb', line 160

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
# 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 == :qemu
					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
				end
			end
		end
	end
end