foreman_fog_proxmox 0.14.0 → 0.14.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +42 -29
  3. data/app/controllers/concerns/foreman_fog_proxmox/compute_resources_vms_controller.rb +17 -7
  4. data/app/controllers/concerns/foreman_fog_proxmox/controller/parameters/compute_resource.rb +1 -1
  5. data/app/controllers/concerns/foreman_fog_proxmox/hosts_controller.rb +8 -3
  6. data/app/controllers/foreman_fog_proxmox/compute_resources_controller.rb +6 -3
  7. data/app/helpers/proxmox_compute_controllers_helper.rb +2 -1
  8. data/app/helpers/proxmox_compute_resources_helper.rb +3 -3
  9. data/app/helpers/proxmox_compute_resources_vms_helper.rb +16 -7
  10. data/app/helpers/proxmox_form_helper.rb +9 -5
  11. data/app/helpers/proxmox_vm_config_helper.rb +16 -25
  12. data/app/helpers/proxmox_vm_interfaces_helper.rb +19 -6
  13. data/app/helpers/proxmox_vm_os_template_helper.rb +2 -5
  14. data/app/helpers/proxmox_vm_uuid_helper.rb +1 -1
  15. data/app/helpers/proxmox_vm_volumes_helper.rb +22 -25
  16. data/app/models/concerns/fog_extensions/proxmox/node.rb +2 -2
  17. data/app/models/concerns/fog_extensions/proxmox/server.rb +9 -5
  18. data/app/models/concerns/host_ext/proxmox/associator.rb +3 -2
  19. data/app/models/concerns/host_ext/proxmox/for_vm.rb +1 -1
  20. data/app/models/concerns/host_ext/proxmox/interfaces.rb +7 -3
  21. data/app/models/concerns/orchestration/proxmox/compute.rb +11 -4
  22. data/app/models/foreman_fog_proxmox/options_select.rb +1 -3
  23. data/app/models/foreman_fog_proxmox/proxmox.rb +12 -10
  24. data/app/models/foreman_fog_proxmox/proxmox_compute_attributes.rb +15 -3
  25. data/app/models/foreman_fog_proxmox/proxmox_connection.rb +6 -2
  26. data/app/models/foreman_fog_proxmox/proxmox_console.rb +3 -1
  27. data/app/models/foreman_fog_proxmox/proxmox_images.rb +2 -2
  28. data/app/models/foreman_fog_proxmox/proxmox_interfaces.rb +28 -6
  29. data/app/models/foreman_fog_proxmox/proxmox_operating_systems.rb +6 -1
  30. data/app/models/foreman_fog_proxmox/proxmox_pools.rb +4 -4
  31. data/app/models/foreman_fog_proxmox/proxmox_version.rb +7 -3
  32. data/app/models/foreman_fog_proxmox/proxmox_vm_commands.rb +9 -7
  33. data/app/models/foreman_fog_proxmox/proxmox_vm_new.rb +37 -24
  34. data/app/models/foreman_fog_proxmox/proxmox_vm_queries.rb +4 -5
  35. data/app/models/foreman_fog_proxmox/proxmox_volumes.rb +23 -12
  36. data/app/models/foreman_fog_proxmox/vms.rb +2 -2
  37. data/app/views/compute_resources_vms/form/proxmox/container/_config.html.erb +2 -2
  38. data/app/views/compute_resources_vms/form/proxmox/container/_volume_mp.html.erb +1 -1
  39. data/app/views/compute_resources_vms/form/proxmox/container/_volume_rootfs.html.erb +1 -1
  40. data/app/views/compute_resources_vms/form/proxmox/server/_config.html.erb +3 -3
  41. data/app/views/compute_resources_vms/form/proxmox/server/_volume_hard_disk.html.erb +1 -1
  42. data/config/routes.rb +8 -4
  43. data/db/migrate/20210312105013_update_proxmox_uuid_host.rb +1 -2
  44. data/lib/foreman_fog_proxmox/engine.rb +4 -3
  45. data/lib/foreman_fog_proxmox/semver.rb +1 -4
  46. data/lib/foreman_fog_proxmox/version.rb +1 -1
  47. data/locale/en/foreman_fog_proxmox.po +140 -47
  48. data/locale/foreman_fog_proxmox.pot +300 -137
  49. data/locale/fr/foreman_fog_proxmox.po +145 -52
  50. data/test/factories/foreman_fog_proxmox/proxmox_container_mock_factory.rb +6 -7
  51. data/test/factories/foreman_fog_proxmox/proxmox_server_mock_factory.rb +6 -7
  52. data/test/functional/compute_resources_controller_test.rb +4 -2
  53. data/test/test_plugin_helper.rb +12 -7
  54. data/test/unit/foreman_fog_proxmox/helpers/proxmox_container_helper_test.rb +38 -47
  55. data/test/unit/foreman_fog_proxmox/helpers/proxmox_server_helper_test.rb +49 -34
  56. data/test/unit/foreman_fog_proxmox/helpers/proxmox_vm_helper_test.rb +29 -65
  57. data/test/unit/foreman_fog_proxmox/helpers/proxmox_vm_volumes_helper_test.rb +3 -3
  58. data/test/unit/foreman_fog_proxmox/proxmox_compute_attributes_test.rb +22 -13
  59. data/test/unit/foreman_fog_proxmox/proxmox_interfaces_test.rb +18 -9
  60. data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_container_test.rb +45 -35
  61. data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_create_test.rb +0 -4
  62. data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_cdrom_test.rb +34 -22
  63. data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_cloudinit_test.rb +20 -14
  64. data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_hard_disk_test.rb +76 -54
  65. data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_test.rb +26 -15
  66. data/test/unit/foreman_fog_proxmox/proxmox_vm_queries_test.rb +1 -1
  67. data/test/unit/foreman_fog_proxmox/semver_test.rb +2 -1
  68. metadata +35 -21
@@ -36,7 +36,7 @@ module ForemanFogProxmox
36
36
 
37
37
  def hard_disk_typed_defaults(vm_type)
38
38
  options = {}
39
- volume_attributes_h = { storage: storages.first.identity.to_s, size: (8 * GIGA) }
39
+ volume_attributes_h = { storage: storages.first.identity.to_s, size: '8' }
40
40
  case vm_type
41
41
  when 'qemu'
42
42
  controller = 'virtio'
@@ -74,8 +74,14 @@ module ForemanFogProxmox
74
74
 
75
75
  def interface_typed_defaults(type)
76
76
  interface_attributes_h = { id: 'net0', compute_attributes: {} }
77
- interface_attributes_h[:compute_attributes] = { model: 'virtio', bridge: bridges.first.identity.to_s } if type == 'qemu'
78
- interface_attributes_h[:compute_attributes] = { name: 'eth0', bridge: bridges.first.identity.to_s, dhcp: 1, dhcp6: 1 } if type == 'lxc'
77
+ if type == 'qemu'
78
+ interface_attributes_h[:compute_attributes] =
79
+ { model: 'virtio', bridge: bridges.first.identity.to_s }
80
+ end
81
+ if type == 'lxc'
82
+ interface_attributes_h[:compute_attributes] =
83
+ { name: 'eth0', bridge: bridges.first.identity.to_s, dhcp: 1, dhcp6: 1 }
84
+ end
79
85
  interface_attributes_h
80
86
  end
81
87
 
@@ -106,7 +112,7 @@ module ForemanFogProxmox
106
112
  interfaces_attributes = []
107
113
  interfaces_attributes.push(interface_typed_defaults(type))
108
114
  new_attr = new_attr.merge(interfaces_attributes: interfaces_attributes.map.with_index.to_h.invert)
109
- logger.debug(format(_('add_default_typed_interface(%<type>s) to new_attr=%<new_attr>s'), type: type, new_attr: new_attr))
115
+ logger.debug("add_default_typed_interface(#{type}) to new_attr=#{new_attr}")
110
116
  new_attr
111
117
  end
112
118
 
@@ -115,7 +121,7 @@ module ForemanFogProxmox
115
121
  volumes_attributes.push(hard_disk_typed_defaults('qemu'))
116
122
  volumes_attributes.push(hard_disk_typed_defaults('lxc'))
117
123
  new_attr = new_attr.merge(volumes_attributes: volumes_attributes.map.with_index.to_h.invert)
118
- logger.debug(format(_('add_default_typed_volume(%<type>s) to new_attr=%<new_attr>s'), type: type, new_attr: new_attr))
124
+ logger.debug("add_default_typed_volume(#{type}) to new_attr=#{new_attr}")
119
125
  new_attr
120
126
  end
121
127
 
@@ -127,29 +133,28 @@ module ForemanFogProxmox
127
133
  defaults = vm_instance_defaults
128
134
  defaults = defaults.merge(config_attributes: config_attributes(type))
129
135
  defaults = add_default_typed_volume(defaults)
130
- defaults = add_default_typed_interface(type, defaults)
131
- defaults
136
+ add_default_typed_interface(type, defaults)
132
137
  end
133
138
 
134
139
  def config_attributes(type = 'qemu')
135
140
  case type
136
141
  when 'qemu'
137
142
  config_attributes = {
138
- cores: 1,
139
- sockets: 1,
140
- kvm: 0,
143
+ cores: '1',
144
+ sockets: '1',
145
+ kvm: '0',
141
146
  vga: 'std',
142
- memory: 512 * MEGA,
147
+ memory: '1024',
143
148
  ostype: 'l26',
144
149
  cpu: 'cputype=kvm64',
145
150
  scsihw: 'virtio-scsi-pci',
146
- templated: 0
151
+ templated: '0',
147
152
  }
148
153
  config_attributes = config_attributes
149
154
  when 'lxc'
150
155
  config_attributes = {
151
- memory: 512 * MEGA,
152
- templated: 0
156
+ memory: '1024',
157
+ templated: '0',
153
158
  }
154
159
  end
155
160
  config_attributes
@@ -159,14 +164,21 @@ module ForemanFogProxmox
159
164
  new_attr = ActiveSupport::HashWithIndifferentAccess.new(new_attr)
160
165
  type = new_attr['type']
161
166
  type ||= 'qemu'
162
- vm = new_typed_vm(new_attr, type)
163
- vm
167
+ new_typed_vm(new_attr, type)
164
168
  end
165
169
 
166
170
  def convert_config_attributes(new_attr)
167
171
  config_attributes = new_attr[:config_attributes]
168
- config_attributes[:volumes_attributes] = Hash[config_attributes[:disks].each_with_index.map { |disk, idx| [idx.to_s, disk.attributes] }] if config_attributes.key?(:disks)
169
- config_attributes[:interfaces_attributes] = Hash[config_attributes[:interfaces].each_with_index.map { |interface, idx| [idx.to_s, interface_compute_attributes(interface.attributes)] }] if config_attributes.key?(:interfaces)
172
+ if config_attributes.key?(:disks)
173
+ config_attributes[:volumes_attributes] = Hash[config_attributes[:disks].each_with_index.map do |disk, idx|
174
+ [idx.to_s, disk.attributes]
175
+ end ]
176
+ end
177
+ if config_attributes.key?(:interfaces)
178
+ config_attributes[:interfaces_attributes] = Hash[config_attributes[:interfaces].each_with_index.map do |interface, idx|
179
+ [idx.to_s, interface_compute_attributes(interface.attributes)]
180
+ end ]
181
+ end
170
182
  config_attributes.delete_if { |key, _value| ['disks', 'interfaces'].include?(key) }
171
183
  end
172
184
 
@@ -177,14 +189,15 @@ module ForemanFogProxmox
177
189
  new_attr_type = new_attr['type']
178
190
  new_attr_type ||= new_attr['config_attributes']['type'] if new_attr.key?('config_attributes')
179
191
  new_attr_type ||= type
180
- logger.debug(format(_('new_typed_vm(%<type>s): new_attr_type=%<new_attr_type>s'), type: type, new_attr_type: new_attr_type))
181
- logger.debug(format(_('new_typed_vm(%<type>s): new_attr=%<new_attr>s'), type: type, new_attr: new_attr))
192
+ logger.debug("new_typed_vm(#{type}): new_attr_type=#{new_attr_type}")
193
+ logger.debug("new_typed_vm(#{type}): new_attr=#{new_attr}'")
182
194
  options = !new_attr.key?('vmid') || ForemanFogProxmox::Value.empty?(new_attr['vmid']) ? vm_typed_instance_defaults(type).merge(new_attr).merge(type: type) : new_attr
183
- logger.debug(format(_('new_typed_vm(%<type>s): options=%<options>s'), type: type, options: options))
195
+ logger.debug("new_typed_vm(#{type}): options=#{options}")
184
196
  vm_h = parse_typed_vm(options, type).deep_symbolize_keys
185
- logger.debug(format(_('new_typed_vm(%<type>s): vm_h=%<vm_h>s'), type: type, vm_h: vm_h))
186
- vm = node.send(vm_collection(type)).new(vm_h)
187
- vm
197
+ logger.debug("new_typed_vm(#{type}): vm_h=#{vm_h}")
198
+ vm_h = vm_h.merge(vm_typed_instance_defaults(type)) if vm_h.empty?
199
+ logger.debug(format(_('new_typed_vm(%<type>s) with vm_typed_instance_defaults: vm_h=%<vm_h>s'), type: type, vm_h: vm_h))
200
+ node.send(vm_collection(type)).new(vm_h)
188
201
  end
189
202
  end
190
203
  end
@@ -31,7 +31,7 @@ module ForemanFogProxmox
31
31
  node = client.nodes.get node_id
32
32
  node ||= default_node
33
33
  storages = node.storages.list_by_content_type type
34
- logger.debug(format(_('storages(): node_id %<node_id>s type %<type>s'), node_id: node_id, type: type))
34
+ logger.debug("storages(): node_id #{node_id} type #{type}")
35
35
  storages.sort_by(&:storage)
36
36
  end
37
37
 
@@ -61,10 +61,9 @@ module ForemanFogProxmox
61
61
  nodes.each do |node|
62
62
  vm = find_vm_in_servers_by_vmid(node.servers, vmid)
63
63
  vm ||= find_vm_in_servers_by_vmid(node.containers, vmid)
64
- unless vm.nil?
65
- logger.debug("found vm #{vmid} on node #{node.node}")
66
- break
67
- end
64
+ next if vm.nil?
65
+ logger.debug("found vm #{vmid} on node #{node.node}")
66
+ break
68
67
  end
69
68
  vm
70
69
  end
@@ -25,7 +25,7 @@ module ForemanFogProxmox
25
25
  include ProxmoxVmHelper
26
26
 
27
27
  def delete_volume(vm, id, volume_attributes)
28
- logger.info(format(_('vm %<vmid>s delete volume %<volume_id>s'), vmid: vm.identity, volume_id: id))
28
+ logger.info("vm #{vm.identity} delete volume #{id}")
29
29
  vm.detach(id)
30
30
  return unless volume_type?(volume_attributes, 'hard_disk')
31
31
 
@@ -36,7 +36,7 @@ module ForemanFogProxmox
36
36
  def volume_options(vm, id, volume_attributes)
37
37
  options = {}
38
38
  options.store(:mp, volume_attributes['mp']) if vm.container? && id != 'rootfs'
39
- options.store(:cache, volume_attributes['cache']) unless vm.container?
39
+ options.store(:cache, volume_attributes['cache']) unless vm.container? || volume_attributes['cache'].empty?
40
40
  options
41
41
  end
42
42
 
@@ -59,19 +59,19 @@ module ForemanFogProxmox
59
59
  end
60
60
 
61
61
  def extend_volume(vm, id, diff_size)
62
- extension = '+' + (diff_size / GIGA).to_s + 'G'
63
- logger.info(format(_('vm %<vmid>s extend volume %<volume_id>s to %<extension>s'), vmid: vm.identity, volume_id: id, extension: extension))
62
+ extension = "+#{diff_size}G"
63
+ logger.info("vm #{vm.identity} extend volume #{id} to #{extension}")
64
64
  vm.extend(id, extension)
65
65
  end
66
66
 
67
67
  def move_volume(id, vm, new_storage)
68
- logger.info(format(_('vm %<vmid>s move volume %<volume_id>s into %<new_storage>s'), vmid: vm.identity, volume_id: id, new_storage: new_storage))
68
+ logger.info("vm #{vm.identity} move volume #{id} into #{new_storage}")
69
69
  vm.move(id, new_storage)
70
70
  end
71
71
 
72
72
  def update_options(disk, vm, volume_attributes)
73
73
  options = volume_options(vm, disk.id, volume_attributes) if volume_type?(volume_attributes, 'hard_disk')
74
- logger.info(format(_('vm %<vmid>s update volume %<volume_id>s to %<options>s'), vmid: vm.identity, volume_id: disk.id, options: options))
74
+ logger.info("vm #{vm.identity} update volume #{disk.id} to #{options}")
75
75
  new_disk = { id: disk.id }
76
76
  new_disk[:volid] = disk.volid
77
77
  vm.attach(new_disk, options)
@@ -82,7 +82,12 @@ module ForemanFogProxmox
82
82
  if volume_type?(volume_attributes, 'cdrom')
83
83
  update_cdrom(vm, disk, volume_attributes)
84
84
  elsif volume_type?(volume_attributes, 'hard_disk')
85
- diff_size = volume_attributes['size'].to_i - disk.size if volume_attributes['size'] && disk.size
85
+ diff_size = volume_attributes['size'].to_i - disk.size.to_i if volume_attributes['size'] && disk.size
86
+ unless diff_size >= 0
87
+ raise ::Foreman::Exception,
88
+ format(_('Unable to shrink %<id>s size. Proxmox allows only increasing size.'), id: id)
89
+ end
90
+ diff_size = volume_attributes['size'].to_i - disk.size.to_i if volume_attributes['size'] && disk.size
86
91
  raise ::Foreman::Exception, format(_('Unable to shrink %<id>s size. Proxmox allows only increasing size.'), id: id) unless diff_size >= 0
87
92
 
88
93
  new_storage = volume_attributes['storage']
@@ -98,7 +103,13 @@ module ForemanFogProxmox
98
103
  end
99
104
 
100
105
  def volume_exists?(vm, volume_attributes)
101
- vm.attributes.key?(volume_attributes['id'])
106
+ disk = vm.config.disks.get(volume_attributes['id'])
107
+ exists = false
108
+ return exists unless disk
109
+
110
+ exists = !volume_attributes['volid'].empty? if disk.hard_disk? || disk.cloud_init?
111
+ exists = !volume_attributes['cdrom'].empty? if disk.cdrom?
112
+ exists
102
113
  end
103
114
 
104
115
  def volume_to_delete?(volume_attributes)
@@ -121,20 +132,20 @@ module ForemanFogProxmox
121
132
  if volume_type?(volume_attributes, 'hard_disk')
122
133
  options = volume_options(vm, id, volume_attributes)
123
134
  disk_attributes[:storage] = volume_attributes['storage']
124
- disk_attributes[:size] = (volume_attributes['size'].to_i / GIGA).to_s
135
+ disk_attributes[:size] = volume_attributes['size']
125
136
  elsif volume_type?(volume_attributes, 'cdrom')
126
137
  disk_attributes[:volid] = volume_attributes[:iso]
127
138
  elsif volume_type?(volume_attributes, 'cloud_init')
128
139
  disk_attributes[:storage] = volume_attributes['storage']
129
140
  disk_attributes[:volid] = "#{volume_attributes['storage']}:cloudinit"
130
141
  end
131
- logger.info(format(_('vm %<vmid>s add volume %<volume_id>s'), vmid: vm.identity, volume_id: id))
132
- logger.debug(format(_('add_volume(%<vmid>s) disk_attributes=%<disk_attributes>s'), vmid: vm.identity, disk_attributes: disk_attributes))
142
+ logger.info("vm #{vm.identity} add volume #{id}")
143
+ logger.debug("add_volume(#{vm.identity}) disk_attributes=#{disk_attributes}")
133
144
  vm.attach(disk_attributes, options)
134
145
  end
135
146
 
136
147
  def save_volume(vm, volume_attributes)
137
- logger.debug(format(_('save_volume(%<vmid>s) volume_attributes=%<volume_attributes>s'), vmid: vm.identity, volume_attributes: volume_attributes))
148
+ logger.debug("save_volume(#{vm.identity}) volume_attributes=#{volume_attributes}")
138
149
  id = extract_id(vm, volume_attributes)
139
150
  if volume_exists?(vm, volume_attributes)
140
151
  if volume_to_delete?(volume_attributes)
@@ -21,8 +21,8 @@ module ForemanFogProxmox
21
21
  class Vms
22
22
  attr_reader :items
23
23
 
24
- def each
25
- @items.each { |item| yield item }
24
+ def each(&block)
25
+ @items.each(&block)
26
26
  end
27
27
 
28
28
  # TODO: Pagination with filters
@@ -28,8 +28,8 @@ along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>. %>
28
28
  <%= counter_f f, :cpuunits, :class => "input-mini", :label => _('CPU units'), :label_size => "col-md-2" %>
29
29
  <% end %>
30
30
  <%= field_set_tag _("Memory"), :id => "container_config_memory", :class => 'hide', :disabled => !container do %>
31
- <%= byte_size_f f, :memory, :class => "input-mini", :label => _('Memory'), :label_size => "col-md-2" %>
32
- <%= byte_size_f f, :swap, :class => "input-mini", :label => _('Swap'), :label_size => "col-md-2" %>
31
+ <%= text_f f, :memory, :class => "input-mini", :label => _('Memory (MB)'), :label_size => "col-md-2" %>
32
+ <%= text_f f, :swap, :class => "input-mini", :label => _('Swap (MB)'), :label_size => "col-md-2" %>
33
33
  <% end %>
34
34
  <%= field_set_tag _("DNS"), :id => "container_config_dns", :class => 'hide', :disabled => !container do %>
35
35
  <%= text_f f, :hostname, :label => _('Hostname'), :label_size => "col-md-2", :disabled => true %>
@@ -23,5 +23,5 @@ along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>. %>
23
23
  <%= select_f f, :storage, compute_resource.storages(node_id), :storage, :storage, { }, :label => _('Storage'), :label_size => "col-md-2" %>
24
24
  <%= text_f f, :mp, :label => _('Path'), :label_size => "col-md-2", :required => true, :help_inline => _("e.g. /path/to/") %>
25
25
  <%= text_f f, :device, :label => _('Device'), :label_size => "col-md-2", :class => ('hide' if f.object.rootfs?), :disabled => (!new_volume || f.object.rootfs?), :'data-soft-max' => 10 %>
26
- <%= byte_size_f f, :size, :class => "input-mini", :label => _("Size"), :label_size => "col-md-2" %>
26
+ <%= text_f f, :size, :class => "input-mini", :label => _("Size (GB)"), :label_size => "col-md-2" %>
27
27
  <% end %>
@@ -20,5 +20,5 @@ along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>. %>
20
20
  <%= field_set_tag _("Rootfs"), :id => "container_volume_rootfs", :class => ('hide' unless container), :disabled => !container do %>
21
21
  <%= f.hidden_field :volid if !new_vm %>
22
22
  <%= select_f f, :storage, compute_resource.storages(node_id), :storage, :storage, { }, :label => _('Storage'), :label_size => "col-md-2" %>
23
- <%= byte_size_f f, :size, :class => "input-mini", :label => _("Size"), :label_size => "col-md-2" %>
23
+ <%= text_f f, :size, :class => "input-mini", :label => _("Size (GB)"), :label_size => "col-md-2" %>
24
24
  <% end %>
@@ -45,9 +45,9 @@ along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>. %>
45
45
  <% end %>
46
46
  <% end %>
47
47
  <%= field_set_tag _("Memory"), :id => "server_config_memory", :class => 'hide', :disabled => !server do %>
48
- <%= byte_size_f f, :memory, :class => "input-mini", :label => _('Memory'), :label_size => "col-md-2" %>
49
- <%= byte_size_f f, :balloon, :class => "input-mini", :label => _('Minimum memory'), :label_size => "col-md-2" %>
50
- <%= counter_f f, :shares, :class => "input-mini", :label => _('Shares'), :label_size => "col-md-2" %>
48
+ <%= text_f f, :memory, :class => "input-mini", :label => _('Memory (MB)'), :label_size => "col-md-2" %>
49
+ <%= text_f f, :balloon, :class => "input-mini", :label => _('Minimum memory (MB)'), :label_size => "col-md-2" %>
50
+ <%= text_f f, :shares, :class => "input-mini", :label => _('Shares (MB)'), :label_size => "col-md-2" %>
51
51
  <% end %>
52
52
  <%= field_set_tag _("Operating System"), :id => "server_config_os", :class => 'hide', :disabled => !server do %>
53
53
  <%= select_f f, :ostype, proxmox_operating_systems_map, :id, :name, { :include_blank => true }, :label => _('OS type'), :label_size => "col-md-2" %>
@@ -28,5 +28,5 @@ along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>. %>
28
28
  <%= select_f f, :controller, proxmox_controllers_map, :id, :name, { }, :label => _('Controller'), :label_size => "col-md-2", :disabled => !new_volume, :onchange => 'controllerSelected(this)' %>
29
29
  <%= text_f f, :device, :label => _('Device'), :label_size => "col-md-2", :disabled => !new_volume, :'data-min' => 0, :'data-soft-max' => proxmox_max_device(f.object.controller), :onchange => 'deviceSelected(this)' %>
30
30
  <%= select_f f, :cache, proxmox_caches_map, :id, :name, { include_blank: true }, :label => _('Cache'), :label_size => "col-md-2" %>
31
- <%= byte_size_f f, :size, :class => "input-mini", :label => _("Size"), :label_size => "col-md-2" %>
31
+ <%= text_f f, :size, :class => "input-mini", :label => _("Size (GB)"), :label_size => "col-md-2", :disabled => !hard_disk %>
32
32
  <% end %>
data/config/routes.rb CHANGED
@@ -19,12 +19,16 @@
19
19
 
20
20
  Rails.application.routes.draw do
21
21
  namespace :foreman_fog_proxmox do
22
- match 'isos/:compute_resource_id/:node_id/:storage', :to => 'compute_resources#isos_by_id_and_node_and_storage', :via => 'get'
23
- match 'ostemplates/:compute_resource_id/:node_id/:storage', :to => 'compute_resources#ostemplates_by_id_and_node_and_storage', :via => 'get'
22
+ match 'isos/:compute_resource_id/:node_id/:storage', :to => 'compute_resources#isos_by_id_and_node_and_storage',
23
+ :via => 'get'
24
+ match 'ostemplates/:compute_resource_id/:node_id/:storage',
25
+ :to => 'compute_resources#ostemplates_by_id_and_node_and_storage', :via => 'get'
24
26
  match 'isos/:compute_resource_id/:node_id', :to => 'compute_resources#isos_by_id_and_node', :via => 'get'
25
- match 'ostemplates/:compute_resource_id/:node_id', :to => 'compute_resources#ostemplates_by_id_and_node', :via => 'get'
27
+ match 'ostemplates/:compute_resource_id/:node_id', :to => 'compute_resources#ostemplates_by_id_and_node',
28
+ :via => 'get'
26
29
  match 'storages/:compute_resource_id/:node_id', :to => 'compute_resources#storages_by_id_and_node', :via => 'get'
27
- match 'isostorages/:compute_resource_id/:node_id', :to => 'compute_resources#iso_storages_by_id_and_node', :via => 'get'
30
+ match 'isostorages/:compute_resource_id/:node_id', :to => 'compute_resources#iso_storages_by_id_and_node',
31
+ :via => 'get'
28
32
  match 'bridges/:compute_resource_id/:node_id', :to => 'compute_resources#bridges_by_id_and_node', :via => 'get'
29
33
  end
30
34
  end
@@ -1,6 +1,5 @@
1
1
  include ProxmoxVmUuidHelper
2
2
  class UpdateProxmoxUuidHost < ActiveRecord::Migration[6.0]
3
-
4
3
  def up
5
4
  execute(sql(:concat))
6
5
  end
@@ -9,7 +8,7 @@ class UpdateProxmoxUuidHost < ActiveRecord::Migration[6.0]
9
8
  execute(sql(:substring))
10
9
  end
11
10
 
12
- private
11
+ private
13
12
 
14
13
  def concat
15
14
  "concat(h.compute_resource_id, '_', h.uuid) "
@@ -63,7 +63,8 @@ module ForemanFogProxmox
63
63
  # content twice.
64
64
  assets_to_precompile =
65
65
  Dir.chdir(root) do
66
- Dir['app/assets/javascripts/foreman_fog_proxmox/**/*', 'app/assets/stylesheets/foreman_fog_proxmox/**/*'].map do |f|
66
+ Dir['app/assets/javascripts/foreman_fog_proxmox/**/*',
67
+ 'app/assets/stylesheets/foreman_fog_proxmox/**/*'].map do |f|
67
68
  f.split(File::SEPARATOR, 4).last
68
69
  end
69
70
  end
@@ -73,8 +74,8 @@ module ForemanFogProxmox
73
74
  initializer 'foreman_fog_proxmox.configure_assets', group: :assets do
74
75
  SETTINGS[:foreman_fog_proxmox] = {
75
76
  assets: {
76
- precompile: assets_to_precompile
77
- }
77
+ precompile: assets_to_precompile,
78
+ },
78
79
  }
79
80
  end
80
81
 
@@ -21,10 +21,7 @@ module ForemanFogProxmox
21
21
  module Semver
22
22
  SEMVER_REGEX = /^(\d+)[.](\d+)([.](\d+))?(-([.\w]+))?$/.freeze
23
23
  class SemverClass
24
- attr_accessor :major
25
- attr_accessor :minor
26
- attr_accessor :patch
27
- attr_accessor :qualifier
24
+ attr_accessor :major, :minor, :patch, :qualifier
28
25
 
29
26
  def initialize(major, minor, patch, qualifier = '')
30
27
  @major = major.to_i
@@ -18,5 +18,5 @@
18
18
  # along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>.
19
19
 
20
20
  module ForemanFogProxmox
21
- VERSION = '0.14.0'
21
+ VERSION = '0.14.1'
22
22
  end