Class: VagrantPlugins::Proxmox::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-proxmox/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/vagrant-proxmox/config.rb', line 100

def initialize
	@endpoint = UNSET_VALUE
	@selected_node = UNSET_VALUE
	@user_name = UNSET_VALUE
	@password = UNSET_VALUE
	@vm_type = UNSET_VALUE
	@openvz_os_template = UNSET_VALUE
	@openvz_template_file = UNSET_VALUE
	@vm_id_range = 900..999
	@vm_name_prefix = 'vagrant_'
	@vm_memory = 512
	@task_timeout = 60
	@task_status_check_interval = 2
	@ssh_timeout = 60
	@ssh_status_check_interval = 5
	@imgcopy_timeout = 120
	@qemu_os = UNSET_VALUE
	@qemu_iso = UNSET_VALUE
	@qemu_iso_file = UNSET_VALUE
	@qemu_disk_size = UNSET_VALUE
end

Instance Attribute Details

#endpointString

The Proxmox REST API endpoint

Returns:

  • (String)


8
9
10
# File 'lib/vagrant-proxmox/config.rb', line 8

def endpoint
  @endpoint
end

#imgcopy_timeoutInteger

The maximum timeout for a proxmox server task if it’s an upload (in seconds)

Returns:

  • (Integer)


78
79
80
# File 'lib/vagrant-proxmox/config.rb', line 78

def imgcopy_timeout
  @imgcopy_timeout
end

#openvz_os_templateString

The openvz os template to use for the virtual machine

Returns:

  • (String)


33
34
35
# File 'lib/vagrant-proxmox/config.rb', line 33

def openvz_os_template
  @openvz_os_template
end

#openvz_template_fileString

The openvz os template file to upload and use for the virtual machine

Returns:

  • (String)


38
39
40
# File 'lib/vagrant-proxmox/config.rb', line 38

def openvz_template_file
  @openvz_template_file
end

#passwordString

The Proxmox password

Returns:

  • (String)


23
24
25
# File 'lib/vagrant-proxmox/config.rb', line 23

def password
  @password
end

#qemu_disk_sizeString

The qemu disk size to use for the virtual machine, e.g. ‘30G’

Returns:

  • (String)


98
99
100
# File 'lib/vagrant-proxmox/config.rb', line 98

def qemu_disk_size
  @qemu_disk_size
end

#qemu_isoString

The qemu iso file to use for the virtual machine

Returns:

  • (String)


88
89
90
# File 'lib/vagrant-proxmox/config.rb', line 88

def qemu_iso
  @qemu_iso
end

#qemu_iso_fileString

The qemu iso file to upload and use for the virtual machine

Returns:

  • (String)


93
94
95
# File 'lib/vagrant-proxmox/config.rb', line 93

def qemu_iso_file
  @qemu_iso_file
end

#qemu_osSymbol

The qemu virtual machine operating system, e.g. :l26

Returns:

  • (Symbol)


83
84
85
# File 'lib/vagrant-proxmox/config.rb', line 83

def qemu_os
  @qemu_os
end

#selected_nodeString

The Proxmox preferred cluster node

Returns:

  • (String)


13
14
15
# File 'lib/vagrant-proxmox/config.rb', line 13

def selected_node
  @selected_node
end

#ssh_status_check_intervalInteger, Proc

The interval between two ssh reachability status retrievals (in seconds)

Returns:

  • (Integer, Proc)


73
74
75
# File 'lib/vagrant-proxmox/config.rb', line 73

def ssh_status_check_interval
  @ssh_status_check_interval
end

#ssh_timeoutInteger

The maximum timeout for a ssh connection to a virtual machine (in seconds)

Returns:

  • (Integer)


68
69
70
# File 'lib/vagrant-proxmox/config.rb', line 68

def ssh_timeout
  @ssh_timeout
end

#task_status_check_intervalInteger, Proc

The interval between two proxmox task status retrievals (in seconds)

Returns:

  • (Integer, Proc)


63
64
65
# File 'lib/vagrant-proxmox/config.rb', line 63

def task_status_check_interval
  @task_status_check_interval
end

#task_timeoutInteger

The maximum timeout for a proxmox server task (in seconds)

Returns:

  • (Integer)


58
59
60
# File 'lib/vagrant-proxmox/config.rb', line 58

def task_timeout
  @task_timeout
end

#user_nameString

The Proxmox user name

Returns:

  • (String)


18
19
20
# File 'lib/vagrant-proxmox/config.rb', line 18

def user_name
  @user_name
end

#vm_id_rangeRange

The id range to use for the virtual machines

Returns:

  • (Range)


43
44
45
# File 'lib/vagrant-proxmox/config.rb', line 43

def vm_id_range
  @vm_id_range
end

#vm_memoryInteger

Amount of RAM for the virtual machine in MB

Returns:

  • (Integer)


53
54
55
# File 'lib/vagrant-proxmox/config.rb', line 53

def vm_memory
  @vm_memory
end

#vm_name_prefixString

The prefix for the virtual machine name

Returns:

  • (String)


48
49
50
# File 'lib/vagrant-proxmox/config.rb', line 48

def vm_name_prefix
  @vm_name_prefix
end

#vm_typeSymbol

The virtual machine type, e.g. :openvz or :qemu

Returns:

  • (Symbol)


28
29
30
# File 'lib/vagrant-proxmox/config.rb', line 28

def vm_type
  @vm_type
end

Instance Method Details

#finalize!Object

This is the hook that is called to finalize the object before it is put into use.



123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/vagrant-proxmox/config.rb', line 123

def finalize!
	@endpoint = nil if @endpoint == UNSET_VALUE
	@selected_node = nil if @endpoint == UNSET_VALUE
	@user_name = nil if @user_name == UNSET_VALUE
	@password = nil if @password == UNSET_VALUE
	@vm_type = nil if @vm_type == UNSET_VALUE
	@openvz_template_file = nil if @openvz_template_file == UNSET_VALUE
	@openvz_os_template = "local:vztmpl/#{File.basename @openvz_template_file}" if @openvz_template_file
	@openvz_os_template = nil if @openvz_os_template == UNSET_VALUE
	@qemu_os = nil if @qemu_os == UNSET_VALUE
	@qemu_iso_file = nil if @qemu_iso_file == UNSET_VALUE
	@qemu_iso = "local:iso/#{File.basename @qemu_iso_file}" if @qemu_iso_file
	@qemu_iso = nil if @qemu_iso == UNSET_VALUE
	@qemu_disk_size = nil if @qemu_disk_size == UNSET_VALUE
	@qemu_disk_size = convert_disk_size_to_gigabyte @qemu_disk_size if @qemu_disk_size
end

#validate(machine) ⇒ Object



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

def validate machine
	errors = []
	errors << I18n.t('vagrant_proxmox.errors.no_endpoint_specified') unless @endpoint
	errors << I18n.t('vagrant_proxmox.errors.no_user_name_specified') unless @user_name
	errors << I18n.t('vagrant_proxmox.errors.no_password_specified') unless @password
	errors << I18n.t('vagrant_proxmox.errors.no_vm_type_specified') unless @vm_type
	if @vm_type == :openvz
		errors << I18n.t('vagrant_proxmox.errors.no_openvz_os_template_or_openvz_template_file_specified_for_type_openvz') unless @openvz_os_template || @openvz_template_file
	end
	if @vm_type == :qemu
		errors << I18n.t('vagrant_proxmox.errors.no_qemu_os_specified_for_vm_type_qemu') unless @qemu_os
		errors << I18n.t('vagrant_proxmox.errors.no_qemu_iso_or_qemu_iso_file_specified_for_vm_type_qemu') unless @qemu_iso || @qemu_iso_file
		errors << I18n.t('vagrant_proxmox.errors.no_qemu_disk_size_specified_for_vm_type_qemu') unless @qemu_disk_size
	end
	{'Proxmox Provider' => errors}
end