Module: ProxmoxVMHelper
- Includes:
- ProxmoxVMConfigHelper, ProxmoxVMEfidiskHelper, ProxmoxVMImageTemplateHelper, ProxmoxVMInterfacesHelper, ProxmoxVMOsTemplateHelper, ProxmoxVMVolumesHelper
- Included in:
- ForemanFogProxmox::Proxmox, ForemanFogProxmox::ProxmoxEfidisks, ForemanFogProxmox::ProxmoxVMCommands, ForemanFogProxmox::ProxmoxVMNew, ForemanFogProxmox::ProxmoxVolumes
- Defined in:
- app/helpers/proxmox_vm_helper.rb
Instance Method Summary collapse
-
#parse_typed_vm(args, type) ⇒ Object
Convert a foreman form server/container vm hash into a fog-proxmox server/container attributes hash.
- #parse_vm_update_attributes(attributes, type) ⇒ Object
- #update_boot_order(instance, exclude_cdrom: false, include_network: false) ⇒ Object
- #vm_collection(type) ⇒ Object
Methods included from ProxmoxVMEfidiskHelper
#efidisk_defaults, #normalize_pre_enrolled_keys, #parse_typed_efidisk, #parsed_typed_efidisk, #process_firmware_attributes, #process_secure_boot_efidisk, #secure_boot_efidisk_attributes
Methods included from ProxmoxVMOsTemplateHelper
#ostemplate_keys, #parse_container_ostemplate, #parse_ostemplate, #parse_ostemplate_without_keys
Methods included from ProxmoxVMConfigHelper
#args_a, #config_a, #config_general_or_ostemplate_key?, #config_options, #config_typed_keys, #general_a, #object_to_config_hash, #parse_typed_cpu, #parse_typed_memory, #parsed_typed_config
Methods included from ProxmoxVMImageTemplateHelper
#hard_disk_slot, #validate_image_template_disk_slots!
Methods included from ProxmoxVMVolumesHelper
#add_disk_options, #add_typed_volume, #parse_hard_disk_volume, #parse_typed_volume, #parse_typed_volumes, #parsed_typed_volumes, #remove_volume_keys, #rootfs_volume?, #set_disk_attributes, #validate_cdrom_image_permission!, #volume_type?
Methods included from ProxmoxVMCloudinitHelper
#attach_cloudinit_iso, #check_template_format, #create_cloudinit_iso, #create_temp_directory, #default_iso_path, #delete_temp_dir, #generate_iso_command, #parse_cloudinit_config, #parse_server_cloudinit, #vm_ssh
Methods included from ProxmoxVMCdromHelper
Methods included from ProxmoxVMInterfacesHelper
#add_or_delete_typed_interface, #compute_dhcps, #interface_common_typed_keys, #interface_compute_attributes_required_typed_keys, #interface_compute_attributes_typed_keys, #parse_typed_interfaces, #parsed_typed_interfaces, #sync_dhcp_for_ip
Instance Method Details
#parse_typed_vm(args, type) ⇒ Object
Convert a foreman form server/container vm hash into a fog-proxmox server/container attributes hash
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'app/helpers/proxmox_vm_helper.rb', line 59 def parse_typed_vm(args, type) args = process_firmware_attributes(args, type) args = ActiveSupport::HashWithIndifferentAccess.new(args) return {} unless args return {} if args.empty? return {} unless args['type'] == type logger.debug("parse_typed_vm(#{type}): args=#{args}") parsed_vm = parsed_typed_config(args, type) parsed_vm = parsed_typed_efidisk(args, type, parsed_vm) parsed_vm = parsed_typed_interfaces(args, type, parsed_vm) parsed_vm = parsed_typed_volumes(args, type, parsed_vm) logger.debug("parse_typed_vm(#{type}): parsed_vm=#{parsed_vm}") parsed_vm end |
#parse_vm_update_attributes(attributes, type) ⇒ Object
39 40 41 42 43 |
# File 'app/helpers/proxmox_vm_helper.rb', line 39 def parse_vm_update_attributes(attributes, type) ForemanFogProxmox::HashCollection.new_hash_reject_keys( attributes, ['volumes_attributes'] ).merge(type: type) end |
#update_boot_order(instance, exclude_cdrom: false, include_network: false) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/helpers/proxmox_vm_helper.rb', line 45 def update_boot_order(instance, exclude_cdrom: false, include_network: false) return {} unless instance disks = Array(instance.disks).map { |disk| disk.split(":")[0] } disks.delete("ide2") if exclude_cdrom network_interfaces = include_network ? Array(instance.interfaces).map(&:id) : [] boot_devices = network_interfaces + disks return {} if boot_devices.empty? { boot: "order=" + boot_devices.join(";") } end |
#vm_collection(type) ⇒ Object
33 34 35 36 37 |
# File 'app/helpers/proxmox_vm_helper.rb', line 33 def vm_collection(type) collection = :servers collection = :containers if type == 'lxc' collection end |