diff --git a/app/helpers/proxmox_vm_attrs_helper.rb b/app/helpers/proxmox_vm_attrs_helper.rb index 07b91a72d..23bf8b2ff 100644 --- a/app/helpers/proxmox_vm_attrs_helper.rb +++ b/app/helpers/proxmox_vm_attrs_helper.rb @@ -24,7 +24,7 @@ require 'foreman_fog_proxmox/hash_collection' # Convert a foreman form server hash into a fog-proxmox server attributes hash -module ProxmoxVmAttrsHelper +module ProxmoxVMAttrsHelper def object_to_attributes_hash(vms, from_profile, start_checked) param_scope = from_profile ? "compute_attribute[vm_attrs]" : "host[compute_attributes]" vm_h = ActiveSupport::HashWithIndifferentAccess.new @@ -62,7 +62,7 @@ def volumes_attrs(param_scope, volumes) keys = ['id', 'volid', 'storage', 'size', 'storage_type'] type = 'rootfs' elsif vol.hard_disk? - keys = ['id', 'volid', 'storage_type', 'storage', 'controller', 'device', 'cache', 'size', 'backup' ] + keys = ['id', 'volid', 'storage_type', 'storage', 'controller', 'device', 'cache', 'backup', 'size' ] type = 'hard_disk' elsif vol.cdrom? keys = ['id', 'storage_type', 'cdrom', 'storage', 'volid'] diff --git a/app/helpers/proxmox_vm_volumes_helper.rb b/app/helpers/proxmox_vm_volumes_helper.rb index 9c8013594..305cfbb5b 100644 --- a/app/helpers/proxmox_vm_volumes_helper.rb +++ b/app/helpers/proxmox_vm_volumes_helper.rb @@ -23,9 +23,9 @@ require 'foreman_fog_proxmox/hash_collection' # Convert a foreman form server hash into a fog-proxmox server attributes hash -module ProxmoxVmVolumesHelper - include ProxmoxVmCdromHelper - include ProxmoxVmCloudinitHelper +module ProxmoxVMVolumesHelper + include ProxmoxVMCdromHelper + include ProxmoxVMCloudinitHelper def add_disk_options(disk, args) options = ForemanFogProxmox::HashCollection.new_hash_reject_keys(args, @@ -55,7 +55,7 @@ def parse_hard_disk_volume(args) disk[:volid] = args['volid'] if args.key?('volid') && !args['volid'].empty? disk[:storage] = args['storage'].to_s if args.key?('storage') && !args['storage'].empty? disk[:size] = args['size'].to_i if args.key?('size') && !args['size'].empty? - args['backup'] = '1' if args.key?('backup') && args['backup'].nil? + args['backup'] = '1' if args['backup'].nil? add_disk_options(disk, args) unless args.key?('options') disk[:options] = args['options'] if args.key?('options') disk.key?(:storage) ? disk : {} diff --git a/app/models/concerns/host_ext/proxmox/interfaces.rb b/app/models/concerns/host_ext/proxmox/interfaces.rb index fbc633a8d..6685af1dc 100644 --- a/app/models/concerns/host_ext/proxmox/interfaces.rb +++ b/app/models/concerns/host_ext/proxmox/interfaces.rb @@ -49,12 +49,11 @@ def cidr_ip(interface_attributes, v = 4) def add_interface_to_compute_attributes(index, interface_attributes, compute_attributes) compute_attributes[index] = {} - compute_attributes[index].store('id', interface_attributes['identifier']) compute_attributes[index].store('_delete', interface_attributes['_destroy']) compute_attributes[index].store('macaddr', interface_attributes['mac']) compute_attributes[index].store('ip', cidr_ip(interface_attributes)) compute_attributes[index].store('ip6', cidr_ip(interface_attributes, 6)) - compute_attributes[index].merge!(interface_attributes['compute_attributes'].reject { |k, _v| k == 'id' }) + compute_attributes[index].merge(interface_attributes['compute_attributes']) end end end diff --git a/app/models/foreman_fog_proxmox/proxmox_vm_new.rb b/app/models/foreman_fog_proxmox/proxmox_vm_new.rb index 7d100e1b3..dd369f546 100644 --- a/app/models/foreman_fog_proxmox/proxmox_vm_new.rb +++ b/app/models/foreman_fog_proxmox/proxmox_vm_new.rb @@ -23,8 +23,8 @@ require 'foreman_fog_proxmox/hash_collection' module ForemanFogProxmox - module ProxmoxVmNew - include ProxmoxVmHelper + module ProxmoxVMNew + include ProxmoxVMHelper def cdrom_defaults { storage_type: 'cdrom', id: 'ide2', volid: 'none', media: 'cdrom' } diff --git a/app/models/foreman_fog_proxmox/proxmox_volumes.rb b/app/models/foreman_fog_proxmox/proxmox_volumes.rb index ab0144869..2fb6d53f3 100644 --- a/app/models/foreman_fog_proxmox/proxmox_volumes.rb +++ b/app/models/foreman_fog_proxmox/proxmox_volumes.rb @@ -22,7 +22,7 @@ module ForemanFogProxmox module ProxmoxVolumes - include ProxmoxVmHelper + include ProxmoxVMHelper def delete_volume(vm, id, volume_attributes) logger.info("vm #{vm.identity} delete volume #{id}") @@ -35,18 +35,11 @@ def delete_volume(vm, id, volume_attributes) def volume_options(vm, id, volume_attributes) options = {} - # Default to iothread and backup being enabled, as they are enabled by default - # This will pickup and set value properly if run before this change was - # implemented - volume_attributes['iothread'] = '1' if volume_attributes['iothread'].empty? volume_attributes['backup'] = '1' if volume_attributes['backup'].empty? - # Fixes issue with cache being blank when it should be 'none' if nothing is selected - volume_attributes['cache'] = 'none' if volume_attributes['cache'].empty? options.store(:mp, volume_attributes['mp']) if vm.container? && id != 'rootfs' options.store(:cache, volume_attributes['cache']) unless vm.container? || volume_attributes['cache'].empty? options.store(:backup, volume_attributes['backup']) unless vm.container? || volume_attributes['backup'].empty? - options.store(:iothread, volume_attributes['iothread']) unless vm.container? || volume_attributes['iothread'].empty? options end diff --git a/app/views/compute_resources_vms/form/proxmox/server/_volume_hard_disk.html.erb b/app/views/compute_resources_vms/form/proxmox/server/_volume_hard_disk.html.erb index 9f10eb432..42c165242 100644 --- a/app/views/compute_resources_vms/form/proxmox/server/_volume_hard_disk.html.erb +++ b/app/views/compute_resources_vms/form/proxmox/server/_volume_hard_disk.html.erb @@ -33,5 +33,4 @@ along with ForemanFogProxmox. If not, see . %> <%= select_f f, :cache, proxmox_caches_map, :id, :name, { include_blank: true }, :label => _('Cache'), :label_size => "col-md-2" %> <%= text_f f, :size, :class => "input-mini", :label => _("Size (GB)"), :label_size => "col-md-2", :disabled => !hard_disk %> <%= checkbox_f f, :backup, :checked => (f.object.backup == '1' || f.object.backup.nil? ), :label => _('Backup'), :label_help => _('Enable/disable volume backup') %> - <%= checkbox_f f, :iothread, :checked => (f.object.iothread== '1' || f.object.iothread.nil? ), :label => _('IO Thread'), :label_help => _('Enable/disable IO Thread') %> <% end %> diff --git a/lib/foreman_fog_proxmox/version.rb b/lib/foreman_fog_proxmox/version.rb index 76b5a7923..d7d35e50f 100644 --- a/lib/foreman_fog_proxmox/version.rb +++ b/lib/foreman_fog_proxmox/version.rb @@ -18,5 +18,5 @@ # along with ForemanFogProxmox. If not, see . module ForemanFogProxmox - VERSION = '0.16.2.3' + VERSION = '0.17.0' end diff --git a/webpack/components/ProxmoxComputeSelectors.js b/webpack/components/ProxmoxComputeSelectors.js index 784b005fe..10a3706f7 100644 --- a/webpack/components/ProxmoxComputeSelectors.js +++ b/webpack/components/ProxmoxComputeSelectors.js @@ -73,6 +73,11 @@ const ProxmoxComputeSelectors = { { value: 'unsafe', label: 'Write back unsafe' }, { value: 'none', label: 'No cache' }, ], + + proxmoxBackupsMap: [ + { value: '1', label: 'Yes' }, + { value: '0', label: 'No' }, + ], proxmoxCpusMap: [ { value: 'athlon', label: 'athlon' }, diff --git a/webpack/components/ProxmoxServer/ProxmoxServerStorage.js b/webpack/components/ProxmoxServer/ProxmoxServerStorage.js index 386c08ebb..09a78e8bb 100644 --- a/webpack/components/ProxmoxServer/ProxmoxServerStorage.js +++ b/webpack/components/ProxmoxServer/ProxmoxServerStorage.js @@ -127,10 +127,6 @@ const ProxmoxServerStorage = ({ storage, storages, paramScope, nodeId }) => { name: `${paramScope}[volumes_attributes][${nextId}][backup]`, value: 1, }, - iothread: { - name: `${paramScope}[volumes_attributes][${nextId}][iothread]`, - value: null, - }, size: { name: `${paramScope}[volumes_attributes][${nextId}][size]`, value: 8, diff --git a/webpack/components/ProxmoxServer/components/HardDisk.js b/webpack/components/ProxmoxServer/components/HardDisk.js index d66367afb..4f80019a1 100644 --- a/webpack/components/ProxmoxServer/components/HardDisk.js +++ b/webpack/components/ProxmoxServer/components/HardDisk.js @@ -29,7 +29,7 @@ const HardDisk = ({ const handleChange = e => { const { name, value } = e.target; const updatedKey = Object.keys(hdd).find(key => hdd[key].name === name); - + if (updatedKey === 'controller') { const updatedDeviceInfo = createUniqueDevice('hard_disk', value); if (updatedDeviceInfo) { @@ -121,20 +121,10 @@ const HardDisk = ({ -