Class: VagrantPlugins::Proxmox::Config
- Inherits:
-
Object
- Object
- VagrantPlugins::Proxmox::Config
- Defined in:
- lib/vagrant-proxmox/config.rb
Instance Attribute Summary collapse
-
#endpoint ⇒ String
The Proxmox REST API endpoint.
-
#imgcopy_timeout ⇒ Integer
The maximum timeout for a proxmox server task if it’s an upload (in seconds).
-
#openvz_os_template ⇒ String
The openvz os template to use for the virtual machine.
-
#openvz_template_file ⇒ String
The openvz os template file to upload and use for the virtual machine.
-
#password ⇒ String
The Proxmox password.
-
#qemu_bridge ⇒ String
The qemu network bridge, e.g.
-
#qemu_cores ⇒ Integer
The number of cores per socket.
-
#qemu_disk_size ⇒ String
The qemu disk size to use for the virtual machine, e.g.
-
#qemu_iso ⇒ String
The qemu iso file to use for the virtual machine.
-
#qemu_iso_file ⇒ String
The qemu iso file to upload and use for the virtual machine.
-
#qemu_nic_model ⇒ String
The qemu network interface card model, e.g.
-
#qemu_os ⇒ Symbol
The qemu virtual machine operating system, e.g.
-
#qemu_sockets ⇒ Integer
The number of CPU sockets.
-
#qemu_storage ⇒ String
The qemu storage to use for the virtual machine, e.g.
-
#qemu_template ⇒ String
The qemu template to clone for the virtual machine.
-
#replace_openvz_template_file ⇒ Boolean
Should the openvz os template be replaced (deleted before upload)?.
-
#replace_qemu_iso_file ⇒ Boolean
Should the qemu iso file replaced (deleted before upload)?.
-
#selected_node ⇒ String
The Proxmox preferred cluster node.
-
#ssh_status_check_interval ⇒ Integer, Proc
The interval between two ssh reachability status retrievals (in seconds).
-
#ssh_timeout ⇒ Integer
The maximum timeout for a ssh connection to a virtual machine (in seconds).
-
#task_status_check_interval ⇒ Integer, Proc
The interval between two proxmox task status retrievals (in seconds).
-
#task_timeout ⇒ Integer
The maximum timeout for a proxmox server task (in seconds).
-
#user_name ⇒ String
The Proxmox user name.
-
#vm_disk_size ⇒ String
The vm disk size to use for the virtual machine, e.g.
-
#vm_id_range ⇒ Range
The id range to use for the virtual machines.
-
#vm_memory ⇒ Integer
Amount of RAM for the virtual machine in MB.
-
#vm_name_prefix ⇒ String
The prefix for the virtual machine name.
-
#vm_storage ⇒ String
The vm storage to use for the virtual machine, e.g.
-
#vm_type ⇒ Symbol
The virtual machine type, e.g.
Instance Method Summary collapse
-
#finalize! ⇒ Object
This is the hook that is called to finalize the object before it is put into use.
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #validate(machine) ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/vagrant-proxmox/config.rb', line 154 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 @replace_openvz_template_file = false @vm_id_range = 900..999 @vm_name_prefix = 'vagrant_' @vm_memory = 512 @vm_disk_size = '20G' @vm_storage = 'local' @task_timeout = 60 @task_status_check_interval = 2 @ssh_timeout = 60 @ssh_status_check_interval = 5 @imgcopy_timeout = 120 @qemu_os = UNSET_VALUE @qemu_cores = 1 @qemu_sockets = 1 @qemu_template = UNSET_VALUE @qemu_iso = UNSET_VALUE @qemu_iso_file = UNSET_VALUE @replace_qemu_iso_file = false @qemu_disk_size = UNSET_VALUE @qemu_storage = 'raid' @qemu_nic_model = 'e1000' @qemu_bridge = 'vmbr0' end |
Instance Attribute Details
#endpoint ⇒ String
The Proxmox REST API endpoint
8 9 10 |
# File 'lib/vagrant-proxmox/config.rb', line 8 def endpoint @endpoint end |
#imgcopy_timeout ⇒ Integer
The maximum timeout for a proxmox server task if it’s an upload (in seconds)
94 95 96 |
# File 'lib/vagrant-proxmox/config.rb', line 94 def imgcopy_timeout @imgcopy_timeout end |
#openvz_os_template ⇒ String
The openvz os template to use for the virtual machine
33 34 35 |
# File 'lib/vagrant-proxmox/config.rb', line 33 def openvz_os_template @openvz_os_template end |
#openvz_template_file ⇒ String
The openvz os template file to upload and use for the virtual machine
38 39 40 |
# File 'lib/vagrant-proxmox/config.rb', line 38 def openvz_template_file @openvz_template_file end |
#password ⇒ String
The Proxmox password
23 24 25 |
# File 'lib/vagrant-proxmox/config.rb', line 23 def password @password end |
#qemu_bridge ⇒ String
The qemu network bridge, e.g. ‘vmbr0’ defaults to ‘vmbr0’ for backwards compatability
152 153 154 |
# File 'lib/vagrant-proxmox/config.rb', line 152 def qemu_bridge @qemu_bridge end |
#qemu_cores ⇒ Integer
The number of cores per socket
104 105 106 |
# File 'lib/vagrant-proxmox/config.rb', line 104 def qemu_cores @qemu_cores end |
#qemu_disk_size ⇒ String
The qemu disk size to use for the virtual machine, e.g. ‘30G’
134 135 136 |
# File 'lib/vagrant-proxmox/config.rb', line 134 def qemu_disk_size @qemu_disk_size end |
#qemu_iso ⇒ String
The qemu iso file to use for the virtual machine
119 120 121 |
# File 'lib/vagrant-proxmox/config.rb', line 119 def qemu_iso @qemu_iso end |
#qemu_iso_file ⇒ String
The qemu iso file to upload and use for the virtual machine
124 125 126 |
# File 'lib/vagrant-proxmox/config.rb', line 124 def qemu_iso_file @qemu_iso_file end |
#qemu_nic_model ⇒ String
The qemu network interface card model, e.g. ‘e1000’, ‘virtio’ defaults to ‘e1000’ for backwards compatability
146 147 148 |
# File 'lib/vagrant-proxmox/config.rb', line 146 def qemu_nic_model @qemu_nic_model end |
#qemu_os ⇒ Symbol
The qemu virtual machine operating system, e.g. :l26
99 100 101 |
# File 'lib/vagrant-proxmox/config.rb', line 99 def qemu_os @qemu_os end |
#qemu_sockets ⇒ Integer
The number of CPU sockets
109 110 111 |
# File 'lib/vagrant-proxmox/config.rb', line 109 def qemu_sockets @qemu_sockets end |
#qemu_storage ⇒ String
The qemu storage to use for the virtual machine, e.g. ‘local’, ‘raid’, ‘cephstore’ defaults to ‘raid’ for backwards compatability
140 141 142 |
# File 'lib/vagrant-proxmox/config.rb', line 140 def qemu_storage @qemu_storage end |
#qemu_template ⇒ String
The qemu template to clone for the virtual machine
114 115 116 |
# File 'lib/vagrant-proxmox/config.rb', line 114 def qemu_template @qemu_template end |
#replace_openvz_template_file ⇒ Boolean
Should the openvz os template be replaced (deleted before upload)?
43 44 45 |
# File 'lib/vagrant-proxmox/config.rb', line 43 def replace_openvz_template_file @replace_openvz_template_file end |
#replace_qemu_iso_file ⇒ Boolean
Should the qemu iso file replaced (deleted before upload)?
129 130 131 |
# File 'lib/vagrant-proxmox/config.rb', line 129 def replace_qemu_iso_file @replace_qemu_iso_file end |
#selected_node ⇒ String
The Proxmox preferred cluster node
13 14 15 |
# File 'lib/vagrant-proxmox/config.rb', line 13 def selected_node @selected_node end |
#ssh_status_check_interval ⇒ Integer, Proc
The interval between two ssh reachability status retrievals (in seconds)
89 90 91 |
# File 'lib/vagrant-proxmox/config.rb', line 89 def ssh_status_check_interval @ssh_status_check_interval end |
#ssh_timeout ⇒ Integer
The maximum timeout for a ssh connection to a virtual machine (in seconds)
84 85 86 |
# File 'lib/vagrant-proxmox/config.rb', line 84 def ssh_timeout @ssh_timeout end |
#task_status_check_interval ⇒ Integer, Proc
The interval between two proxmox task status retrievals (in seconds)
79 80 81 |
# File 'lib/vagrant-proxmox/config.rb', line 79 def task_status_check_interval @task_status_check_interval end |
#task_timeout ⇒ Integer
The maximum timeout for a proxmox server task (in seconds)
74 75 76 |
# File 'lib/vagrant-proxmox/config.rb', line 74 def task_timeout @task_timeout end |
#user_name ⇒ String
The Proxmox user name
18 19 20 |
# File 'lib/vagrant-proxmox/config.rb', line 18 def user_name @user_name end |
#vm_disk_size ⇒ String
The vm disk size to use for the virtual machine, e.g. ‘30G’
63 64 65 |
# File 'lib/vagrant-proxmox/config.rb', line 63 def vm_disk_size @vm_disk_size end |
#vm_id_range ⇒ Range
The id range to use for the virtual machines
48 49 50 |
# File 'lib/vagrant-proxmox/config.rb', line 48 def vm_id_range @vm_id_range end |
#vm_memory ⇒ Integer
Amount of RAM for the virtual machine in MB
58 59 60 |
# File 'lib/vagrant-proxmox/config.rb', line 58 def vm_memory @vm_memory end |
#vm_name_prefix ⇒ String
The prefix for the virtual machine name
53 54 55 |
# File 'lib/vagrant-proxmox/config.rb', line 53 def vm_name_prefix @vm_name_prefix end |
#vm_storage ⇒ String
The vm storage to use for the virtual machine, e.g. ‘local’, ‘raid’, ‘cephstore’ defaults to ‘raid’ for backwards compatability
69 70 71 |
# File 'lib/vagrant-proxmox/config.rb', line 69 def vm_storage @vm_storage end |
#vm_type ⇒ Symbol
The virtual machine type, e.g. :openvz or :qemu or :lxc
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.
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
# File 'lib/vagrant-proxmox/config.rb', line 187 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_template = nil if @qemu_os == 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 @vm_disk_size = convert_disk_size_to_gigabyte @vm_disk_size if @vm_disk_size end |
#validate(machine) ⇒ Object
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
# File 'lib/vagrant-proxmox/config.rb', line 206 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 if @qemu_template else 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 end {'Proxmox Provider' => errors} end |