Module: ProxmoxVmCloudinitHelper

Included in:
ProxmoxVmVolumesHelper
Defined in:
app/helpers/proxmox_vm_cloudinit_helper.rb

Overview

Convert a foreman form server hash into a fog-proxmox server attributes hash

Instance Method Summary collapse

Instance Method Details

#parse_server_cloudinit(args) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'app/helpers/proxmox_vm_cloudinit_helper.rb', line 27

def parse_server_cloudinit(args)
  cloudinit_h = {}
  cloudinit = args['cloudinit']
  unless ['none'].include? cloudinit
    volid = args['volid']
    storage = args['storage']
    cloudinit_volid = volid if volid
    cloudinit_volid ||= "#{storage}:cloudinit" if storage
    controller = args['controller']
    device = args['device']
    id = "#{controller}#{device}" if controller && device
    cloudinit_h.store(:id, id.to_sym) if id
    cloudinit_h.store(:volid, cloudinit_volid) if cloudinit_volid
    cloudinit_h.store(:media, 'cdrom')
  end
  cloudinit_h
end