foreman_fog_proxmox 0.14.2 → 0.14.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (26) hide show
  1. checksums.yaml +4 -4
  2. data/app/helpers/proxmox_vm_cloudinit_helper.rb +1 -0
  3. data/app/helpers/proxmox_vm_config_helper.rb +9 -4
  4. data/app/helpers/proxmox_vm_interfaces_helper.rb +3 -3
  5. data/app/models/concerns/fog_extensions/proxmox/server.rb +1 -1
  6. data/app/models/foreman_fog_proxmox/proxmox.rb +9 -3
  7. data/app/models/foreman_fog_proxmox/proxmox_compute_attributes.rb +1 -1
  8. data/app/models/foreman_fog_proxmox/proxmox_console.rb +3 -1
  9. data/app/models/foreman_fog_proxmox/proxmox_images.rb +5 -8
  10. data/app/models/foreman_fog_proxmox/proxmox_vm_commands.rb +18 -8
  11. data/app/models/foreman_fog_proxmox/proxmox_vm_new.rb +1 -1
  12. data/app/models/foreman_fog_proxmox/proxmox_volumes.rb +7 -5
  13. data/app/views/compute_resources/form/_proxmox.html.erb +1 -1
  14. data/app/views/compute_resources_vms/form/proxmox/_general.html.erb +4 -1
  15. data/lib/foreman_fog_proxmox/engine.rb +3 -1
  16. data/lib/foreman_fog_proxmox/version.rb +1 -1
  17. data/locale/en/foreman_fog_proxmox.po +13 -4
  18. data/locale/foreman_fog_proxmox.pot +22 -9
  19. data/locale/fr/foreman_fog_proxmox.po +16 -7
  20. data/test/unit/foreman_fog_proxmox/helpers/proxmox_vm_helper_test.rb +2 -2
  21. data/test/unit/foreman_fog_proxmox/proxmox_images_test.rb +2 -5
  22. data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_container_test.rb +8 -2
  23. data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_create_test.rb +8 -2
  24. data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_cdrom_test.rb +3 -0
  25. data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_hard_disk_test.rb +9 -3
  26. metadata +18 -18
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dba360e94210ac6442155e678bc2fd6cc3f4fcccb29ff219abb7746981e7dcc6
4
- data.tar.gz: 614badb0bcdf2a98d154735788e0ea34f434f09588644a42d79f6db4054bd054
3
+ metadata.gz: 48f67a6be462ff0c8dcbaf74676828eb72dcb028d09984e64652eabd224f5202
4
+ data.tar.gz: b480687763ab5d18283b40eccd8625e117a7e057517a1de268e448de3c6de428
5
5
  SHA512:
6
- metadata.gz: 1dd4fa2f0d4ae18a4b2ae0bea8448e67304f7d94e65d837c15a25a6f19df60aadcb3da568ee757573537621ef2ca512deaba6a79d11087f020d66575b74aeed2
7
- data.tar.gz: 4ae5d901c8c714b108221860cf922882d791e1bfb85c2913487fbf48814ac767d447092c6304e775774c8c1e94f09af33d26bbab41ff7a330dcd60c8e5231c7d
6
+ metadata.gz: '0608143b5b0742f00ea77306f785d6bfa0d4023f23ce1c8331c503ba7c1a87d0039bb83b5c350ca48787509e1c0aae08942d8539b2883da85539789ffdd10f9e'
7
+ data.tar.gz: 4f58946907839513c8bea07021a9375a81c5bfb1a8fba62c8fc9605571626e0d62e79415a08095da8f4ac42210f99770c15a8c7f123518b20df4775f70df687a
@@ -37,6 +37,7 @@ module ProxmoxVmCloudinitHelper
37
37
  id = "#{controller}#{device}" if controller && device
38
38
  cloudinit_h.store(:id, id.to_sym) if id
39
39
  cloudinit_h.store(:volid, cloudinit_volid) if cloudinit_volid
40
+ cloudinit_h.store(:media, 'cdrom')
40
41
  end
41
42
  cloudinit_h
42
43
  end
@@ -27,11 +27,11 @@ require 'foreman_fog_proxmox/hash_collection'
27
27
  module ProxmoxVmConfigHelper
28
28
  def object_to_config_hash(vm, type)
29
29
  vm_h = ActiveSupport::HashWithIndifferentAccess.new
30
- main_a = ['vmid']
31
- main = vm.attributes.select { |key, _value| main_a.include? key }
30
+ main_a = ['vmid', 'type']
31
+ main = vm.attributes.select { |key, _value| main_a.include? key.to_s }
32
32
  main_a += ['templated']
33
33
  config = vm.config.attributes.reject do |key, _value|
34
- main_a.include?(key) || Fog::Proxmox::DiskHelper.disk?(key) || Fog::Proxmox::NicHelper.nic?(key)
34
+ main_a.include?(key.to_s) || Fog::Proxmox::DiskHelper.disk?(key) || Fog::Proxmox::NicHelper.nic?(key)
35
35
  end
36
36
  vm_h = vm_h.merge(main)
37
37
  vm_h = vm_h.merge('config_attributes': config)
@@ -40,7 +40,7 @@ module ProxmoxVmConfigHelper
40
40
  end
41
41
 
42
42
  def general_a(type)
43
- general_a = ['node_id', 'type', 'config_attributes', 'volumes_attributes', 'interfaces_attributes']
43
+ general_a = ['node_id', 'type', 'config_attributes', 'volumes_attributes', 'interfaces_attributes', 'image_id']
44
44
  general_a += ['firmware_type', 'provision_method', 'container_volumes', 'server_volumes', 'start_after_create']
45
45
  general_a += ['name'] if type == 'lxc'
46
46
  general_a
@@ -126,6 +126,11 @@ module ProxmoxVmConfigHelper
126
126
  def parse_typed_memory(args, type)
127
127
  ForemanFogProxmox::HashCollection.remove_empty_values(args)
128
128
  logger.debug("parse_typed_memory(#{type}): args=#{args}")
129
+ # Convert balloon value from bytes to expected MiB if its not already
130
+ if args.key?('balloon')
131
+ mb = (args['balloon'].to_i / 1024**2).to_s
132
+ args['balloon'] = (mb == '0') ? args['balloon'] : mb
133
+ end
129
134
  args
130
135
  end
131
136
 
@@ -56,7 +56,7 @@ module ProxmoxVmInterfacesHelper
56
56
  end
57
57
 
58
58
  def interface_common_typed_keys(type)
59
- [{ origin: 'id', dest: 'id' }, { origin: 'mac', dest: type == 'qemu' ? 'macaddr' : 'hwaddr' }]
59
+ ['id', type == 'qemu' ? 'macaddr' : 'hwaddr']
60
60
  end
61
61
 
62
62
  def compute_dhcps(interface_attributes_h)
@@ -80,8 +80,8 @@ module ProxmoxVmInterfacesHelper
80
80
  interfaces_to_delete.push(id.to_s)
81
81
  else
82
82
  interface_common_typed_keys(type).each do |key|
83
- ForemanFogProxmox::HashCollection.add_and_format_element(nic, key[:dest].to_sym, interface_attributes,
84
- key[:origin])
83
+ ForemanFogProxmox::HashCollection.add_and_format_element(nic, key.to_sym, interface_attributes,
84
+ key)
85
85
  end
86
86
  interface_attributes_h = interface_attributes['compute_attributes']
87
87
  if ForemanFogProxmox::Value.empty?(interface_attributes['compute_attributes'])
@@ -53,7 +53,7 @@ module FogExtensions
53
53
  end
54
54
 
55
55
  def state
56
- qmpstatus
56
+ status
57
57
  end
58
58
 
59
59
  delegate :description, to: :config
@@ -154,7 +154,7 @@ module ForemanFogProxmox
154
154
  raise ::Foreman::Exception, 'User token expired' if token_expired?(e)
155
155
  rescue StandardError => e
156
156
  logger.warn("failed to create compute client: #{e}")
157
- raise e
157
+ raise ::Foreman::Exception, error_message(e)
158
158
  end
159
159
 
160
160
  def identity_client
@@ -163,7 +163,7 @@ module ForemanFogProxmox
163
163
  raise ::Foreman::Exception, 'User token expired' if token_expired?(e)
164
164
  rescue StandardError => e
165
165
  logger.warn("failed to create identity client: #{e}")
166
- raise e
166
+ raise ::Foreman::Exception, error_message(e)
167
167
  end
168
168
 
169
169
  def network_client
@@ -172,7 +172,13 @@ module ForemanFogProxmox
172
172
  raise ::Foreman::Exception, 'User token expired' if token_expired?(e)
173
173
  rescue StandardError => e
174
174
  logger.warn("failed to create network client: #{e}")
175
- raise e
175
+ raise ::Foreman::Exception, error_message(e)
176
+ end
177
+
178
+ def error_message(e)
179
+ "Failed to create Proxmox compute resource: #{e.message}.
180
+ Either provided credentials or FQDN is wrong or
181
+ your server cannot connect to Proxmox due to network issues."
176
182
  end
177
183
 
178
184
  def host
@@ -41,7 +41,7 @@ ostype: ostype)
41
41
  end
42
42
 
43
43
  def interface_compute_attributes(interface_attributes)
44
- vm_attrs = ForemanFogProxmox::HashCollection.new_hash_reject_keys(interface_attributes, [:identifier, :mac])
44
+ vm_attrs = ForemanFogProxmox::HashCollection.new_hash_reject_keys(interface_attributes, [:identifier, :macaddr, :hwaddr])
45
45
  vm_attrs[:dhcp] = interface_attributes[:ip] == 'dhcp' ? '1' : '0'
46
46
  vm_attrs[:dhcp6] = interface_attributes[:ip6] == 'dhcp' ? '1' : '0'
47
47
  vm_attrs
@@ -31,7 +31,9 @@ module ForemanFogProxmox
31
31
  options.store(:websocket, 1) if type_console == 'vnc'
32
32
  begin
33
33
  vnc_console = vm.start_console(options)
34
- WsProxy.start(:host => host, :host_port => vnc_console['port'], :password => vnc_console['ticket']).merge(
34
+ vmid = extract_vmid(uuid).to_i
35
+ vnc_host_port = vnc_console['port'].to_i + vmid
36
+ WsProxy.start(:host => host, :host_port => vnc_host_port, :password => vnc_console['ticket']).merge(
35
37
  :name => vm.name, :type => type_console
36
38
  )
37
39
  rescue StandardError => e
@@ -47,8 +47,9 @@ module ForemanFogProxmox
47
47
  def templates
48
48
  volumes = []
49
49
  nodes.each do |node|
50
- storage = storages(node.node).first
51
- volumes += storage.volumes.list_by_content_type('images')
50
+ storages(node.node).each do |storage|
51
+ volumes += storage.volumes.list_by_content_type('images')
52
+ end
52
53
  end
53
54
  volumes.select(&:template?)
54
55
  end
@@ -57,15 +58,11 @@ module ForemanFogProxmox
57
58
  find_vm_by_uuid(uuid)
58
59
  end
59
60
 
60
- def clone_from_image(image_id, args, vmid)
61
+ def clone_from_image(image_id, vmid)
61
62
  logger.debug("create_vm(): clone #{image_id} in #{vmid}")
62
63
  image = find_vm_by_uuid(image_id)
63
64
  image.clone(vmid)
64
- clone = find_vm_by_uuid(id.to_s + '_' + vmid.to_s)
65
- options = {}
66
- options.store(:name, args[:name]) unless clone.container?
67
- options.store(:hostname, args[:name]) if clone.container?
68
- clone.update(options)
65
+ find_vm_by_uuid(id.to_s + '_' + vmid.to_s)
69
66
  end
70
67
  end
71
68
  end
@@ -39,26 +39,36 @@ module ForemanFogProxmox
39
39
  raise ::Foreman::Exception, format(N_('invalid vmid=%<vmid>s'), vmid: vmid) unless node.servers.id_valid?(vmid)
40
40
 
41
41
  image_id = args[:image_id]
42
+ remove_volume_keys(args)
42
43
  if image_id
43
- clone_from_image(image_id, args, vmid)
44
+ vm = clone_from_image(image_id, vmid)
45
+ vm.update(compute_clone_attributes(args, vm.container?, type))
46
+ update_pool(vm, args[:pool]) if args[:pool]
44
47
  else
45
- remove_volume_keys(args)
46
48
  logger.warn("create vm: args=#{args}")
47
49
  vm = node.send(vm_collection(type)).create(parse_typed_vm(args, type))
48
- start_on_boot(vm, args)
49
50
  end
51
+ start_on_boot(vm, args)
50
52
  rescue StandardError => e
51
53
  logger.warn("failed to create vm: #{e}")
52
- destroy_vm client.identity + '_' + vm.id if vm
54
+ destroy_vm id.to_s + '_' + vm.vmid.to_s if vm
53
55
  raise e
54
56
  end
55
57
 
58
+ def compute_clone_attributes(args, container, type)
59
+ parsed_args = parse_typed_vm(args, type)
60
+ if container
61
+ options = { :hostname => args[:name] }
62
+ parsed_args.merge(options)
63
+ end
64
+ parsed_args.reject { |k| k == 'pool' }
65
+ end
66
+
56
67
  def destroy_vm(uuid)
57
68
  vm = find_vm_by_uuid(uuid)
58
- unless vm.nil?
59
- vm.stop if vm.ready?
60
- vm.destroy
61
- end
69
+ return true if vm.nil?
70
+ vm.stop if vm.ready?
71
+ vm.destroy
62
72
  rescue ActiveRecord::RecordNotFound
63
73
  # if the VM does not exists, we don't really care.
64
74
  true
@@ -142,7 +142,7 @@ module ForemanFogProxmox
142
142
  config_attributes = {
143
143
  cores: '1',
144
144
  sockets: '1',
145
- kvm: '0',
145
+ kvm: '1',
146
146
  vga: 'std',
147
147
  memory: '1024',
148
148
  ostype: 'l26',
@@ -104,12 +104,14 @@ module ForemanFogProxmox
104
104
 
105
105
  def volume_exists?(vm, volume_attributes)
106
106
  disk = vm.config.disks.get(volume_attributes['id'])
107
- exists = false
108
- return exists unless disk
107
+ return false unless disk
109
108
 
110
- exists = !volume_attributes['volid'].empty? if disk.hard_disk? || disk.cloud_init?
111
- exists = !volume_attributes['cdrom'].empty? if disk.cdrom?
112
- exists
109
+ # Return boolean if disk of type hard_disk, cloud_init, cdrom or rootfs(LXC container) exists
110
+ if disk.hard_disk? || disk.cloud_init? || disk.rootfs?
111
+ volume_attributes['volid'].present?
112
+ elsif disk.cdrom?
113
+ volume_attributes['cdrom'].present?
114
+ end
113
115
  end
114
116
 
115
117
  def volume_to_delete?(volume_attributes)
@@ -38,5 +38,5 @@ along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>. %>
38
38
  :placeholder => _("Optionally provide a CA, or a correctly ordered CA chain. If left blank, disable ssl_verify_peer.") %>
39
39
  <% end %>
40
40
  <div class="col-md-offset-2">
41
- <%= test_connection_button_f(f, (f.object.nodes rescue false)) %>
41
+ <%= test_connection_button_f(f, (f.object.nodes rescue true)) %>
42
42
  </div>
@@ -21,7 +21,10 @@ along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>. %>
21
21
  <%= checkbox_f f, :templated, :label => _('Create image?'), :disabled => untemplatable, :class => ('hide' if untemplatable), :no_label => untemplatable %>
22
22
  <%= counter_f f, :vmid, :label => _('VM ID'), :label_size => "col-md-2", :required => true, :disabled => (!new_vm || from_profile) %>
23
23
  <%= select_f f, :node_id, compute_resource.nodes, :node, :node, { }, :label => _('Node'), :label_size => "col-md-2", :required => true, :onchange => 'nodeSelected(this)' %>
24
- <%= checkbox_f f, :start_after_create, :label => _('Start after creation?'), :disabled => !new_vm, :class => ('hide' if !new_vm), :no_label => !new_vm %>
24
+ <% unless !new_vm || from_profile %>
25
+ <% checked = params[:host] && params[:host][:compute_attributes] && params[:host][:compute_attributes][:start_after_create] || '1' %>
26
+ <%= checkbox_f f, :start_after_create, {:checked => (checked == '1'), :label => _('Start after creation?')} %>
27
+ <% end %>
25
28
  <% unless local_assigns[:hide_image] && !new_vm %>
26
29
  <%
27
30
  arch ||= nil ; os ||= nil
@@ -40,13 +40,15 @@ module ForemanFogProxmox
40
40
  initializer 'foreman_fog_proxmox.register_plugin', :before => :finisher_hook do |_app|
41
41
  Foreman::Plugin.register :foreman_fog_proxmox do
42
42
  requires_foreman '>= 1.22.0'
43
+ # Add Global files for extending foreman-core components and routes
44
+ register_global_js_file 'global'
43
45
  # Register Proxmox VE compute resource in foreman
44
46
  compute_resource ForemanFogProxmox::Proxmox
45
47
  parameter_filter(ComputeResource, :uuid)
46
48
  # add dashboard widget
47
49
  widget 'foreman_fog_proxmox_widget', name: N_('Foreman Fog Proxmox widget'), sizex: 8, sizey: 1
48
50
  security_block :foreman_fog_proxmox do
49
- permission :view_compute_resource, { :compute_resources =>
51
+ permission :view_compute_resources, { :'foreman_fog_proxmox/compute_resources' =>
50
52
  [:ostemplates_by_id_and_node_and_storage,
51
53
  :isos_by_id_and_node_and_storage,
52
54
  :ostemplates_by_id_and_node,
@@ -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.2'
21
+ VERSION = '0.14.3'
22
22
  end
@@ -244,7 +244,10 @@ msgstr ""
244
244
  msgid "Memory"
245
245
  msgstr ""
246
246
 
247
- msgid "Minimum memory"
247
+ msgid "Memory (MB)"
248
+ msgstr ""
249
+
250
+ msgid "Minimum memory (MB)"
248
251
  msgstr ""
249
252
 
250
253
  msgid "Mount point"
@@ -340,10 +343,10 @@ msgstr ""
340
343
  msgid "Search domain"
341
344
  msgstr ""
342
345
 
343
- msgid "Shares"
346
+ msgid "Shares (MB)"
344
347
  msgstr ""
345
348
 
346
- msgid "Size"
349
+ msgid "Size (GB)"
347
350
  msgstr ""
348
351
 
349
352
  msgid "Sockets"
@@ -358,7 +361,7 @@ msgstr ""
358
361
  msgid "Storage"
359
362
  msgstr ""
360
363
 
361
- msgid "Swap"
364
+ msgid "Swap (MB)"
362
365
  msgstr ""
363
366
 
364
367
  msgid "Template storage"
@@ -472,6 +475,12 @@ msgstr ""
472
475
  msgid "net[n] with n integer >= 0, e.g. net0"
473
476
  msgstr ""
474
477
 
478
+ msgid "new_typed_vm(%<type>s) with vm_typed_instance_defaults: vm_h=%<vm_h>s"
479
+ msgstr ""
480
+
481
+ msgid "parse_hard_disk_volume(): args=%<args>s"
482
+ msgstr ""
483
+
475
484
  msgid "remove CDROM"
476
485
  msgstr ""
477
486
 
@@ -8,8 +8,8 @@ msgid ""
8
8
  msgstr ""
9
9
  "Project-Id-Version: foreman_fog_proxmox 1.0.0\n"
10
10
  "Report-Msgid-Bugs-To: \n"
11
- "POT-Creation-Date: 2022-12-07 18:29+0100\n"
12
- "PO-Revision-Date: 2022-12-07 18:29+0100\n"
11
+ "POT-Creation-Date: 2022-12-16 17:29+0100\n"
12
+ "PO-Revision-Date: 2022-12-16 17:29+0100\n"
13
13
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
14
  "Language-Team: LANGUAGE <LL@li.org>\n"
15
15
  "Language: \n"
@@ -89,6 +89,10 @@ msgstr ""
89
89
  msgid "Change the password"
90
90
  msgstr ""
91
91
 
92
+ #: ../app/helpers/proxmox_vm_volumes_helper.rb:52
93
+ msgid "parse_hard_disk_volume(): args=%<args>s"
94
+ msgstr ""
95
+
92
96
  #: ../app/models/concerns/fog_extensions/proxmox/server.rb:62
93
97
  msgid "Type %<type>s, node %<node>s, %<cpus>s CPUs and %<memory>s MB memory"
94
98
  msgstr ""
@@ -129,10 +133,15 @@ msgstr ""
129
133
  msgid "invalid vmid=%<vmid>s"
130
134
  msgstr ""
131
135
 
132
- #: ../app/models/foreman_fog_proxmox/proxmox_vm_queries.rb:79
136
+ #: ../app/models/foreman_fog_proxmox/proxmox_vm_new.rb:199
137
+ msgid "new_typed_vm(%<type>s) with vm_typed_instance_defaults: vm_h=%<vm_h>s"
138
+ msgstr ""
139
+
140
+ #: ../app/models/foreman_fog_proxmox/proxmox_vm_queries.rb:78
133
141
  msgid "Failed retrieving proxmox server vm by vmid=%<vmid>s"
134
142
  msgstr ""
135
143
 
144
+ #: ../app/models/foreman_fog_proxmox/proxmox_volumes.rb:88
136
145
  #: ../app/models/foreman_fog_proxmox/proxmox_volumes.rb:91
137
146
  msgid "Unable to shrink %<id>s size. Proxmox allows only increasing size."
138
147
  msgstr ""
@@ -365,10 +374,8 @@ msgstr ""
365
374
  #:
366
375
  #: ../app/views/compute_resources_vms/form/proxmox/container/_advanced.html.erb:10
367
376
  #: ../app/views/compute_resources_vms/form/proxmox/container/_config.html.erb:15
368
- #: ../app/views/compute_resources_vms/form/proxmox/container/_config.html.erb:16
369
377
  #: ../app/views/compute_resources_vms/form/proxmox/server/_advanced.html.erb:10
370
378
  #: ../app/views/compute_resources_vms/form/proxmox/server/_config.html.erb:32
371
- #: ../app/views/compute_resources_vms/form/proxmox/server/_config.html.erb:33
372
379
  #: ../app/views/compute_resources_vms/index/_proxmox.html.erb:10
373
380
  msgid "Memory"
374
381
  msgstr ""
@@ -418,9 +425,15 @@ msgstr ""
418
425
  msgid "CPU units"
419
426
  msgstr ""
420
427
 
428
+ #:
429
+ #: ../app/views/compute_resources_vms/form/proxmox/container/_config.html.erb:16
430
+ #: ../app/views/compute_resources_vms/form/proxmox/server/_config.html.erb:33
431
+ msgid "Memory (MB)"
432
+ msgstr ""
433
+
421
434
  #:
422
435
  #: ../app/views/compute_resources_vms/form/proxmox/container/_config.html.erb:17
423
- msgid "Swap"
436
+ msgid "Swap (MB)"
424
437
  msgstr ""
425
438
 
426
439
  #:
@@ -598,7 +611,7 @@ msgstr ""
598
611
  #: ../app/views/compute_resources_vms/form/proxmox/container/_volume_mp.html.erb:11
599
612
  #: ../app/views/compute_resources_vms/form/proxmox/container/_volume_rootfs.html.erb:8
600
613
  #: ../app/views/compute_resources_vms/form/proxmox/server/_volume_hard_disk.html.erb:16
601
- msgid "Size"
614
+ msgid "Size (GB)"
602
615
  msgstr ""
603
616
 
604
617
  #:
@@ -660,11 +673,11 @@ msgid "CPU Flags"
660
673
  msgstr ""
661
674
 
662
675
  #: ../app/views/compute_resources_vms/form/proxmox/server/_config.html.erb:34
663
- msgid "Minimum memory"
676
+ msgid "Minimum memory (MB)"
664
677
  msgstr ""
665
678
 
666
679
  #: ../app/views/compute_resources_vms/form/proxmox/server/_config.html.erb:35
667
- msgid "Shares"
680
+ msgid "Shares (MB)"
668
681
  msgstr ""
669
682
 
670
683
  #: ../app/views/compute_resources_vms/form/proxmox/server/_config.html.erb:40
@@ -244,8 +244,11 @@ msgstr ""
244
244
  msgid "Memory"
245
245
  msgstr "Mémoire"
246
246
 
247
- msgid "Minimum memory"
248
- msgstr "Mémoire minimale"
247
+ msgid "Memory (MB)"
248
+ msgstr ""
249
+
250
+ msgid "Minimum memory (MB)"
251
+ msgstr ""
249
252
 
250
253
  msgid "Mount point"
251
254
  msgstr "Point de montage"
@@ -340,11 +343,11 @@ msgstr ""
340
343
  msgid "Search domain"
341
344
  msgstr "Domaine de recherche"
342
345
 
343
- msgid "Shares"
344
- msgstr "Partages"
346
+ msgid "Shares (MB)"
347
+ msgstr ""
345
348
 
346
- msgid "Size"
347
- msgstr "Taille"
349
+ msgid "Size (GB)"
350
+ msgstr ""
348
351
 
349
352
  msgid "Sockets"
350
353
  msgstr ""
@@ -358,7 +361,7 @@ msgstr "Démarrer au boot"
358
361
  msgid "Storage"
359
362
  msgstr "Stockage"
360
363
 
361
- msgid "Swap"
364
+ msgid "Swap (MB)"
362
365
  msgstr ""
363
366
 
364
367
  msgid "Template storage"
@@ -472,6 +475,12 @@ msgstr "vmid=%<vmid>s incorrect"
472
475
  msgid "net[n] with n integer >= 0, e.g. net0"
473
476
  msgstr ""
474
477
 
478
+ msgid "new_typed_vm(%<type>s) with vm_typed_instance_defaults: vm_h=%<vm_h>s"
479
+ msgstr ""
480
+
481
+ msgid "parse_hard_disk_volume(): args=%<args>s"
482
+ msgstr ""
483
+
475
484
  msgid "remove CDROM"
476
485
  msgstr ""
477
486
 
@@ -140,8 +140,8 @@ module ForemanFogProxmox
140
140
  describe 'object_to_config_hash' do
141
141
  setup { Fog.mock! }
142
142
  teardown { Fog.unmock! }
143
- excluded_qemu_keys = ['templated', 'ide2', 'scsi0', 'net0', 'net1']
144
- excluded_lxc_keys = ['templated', 'rootfs', 'mp0', 'net0', 'net1']
143
+ excluded_qemu_keys = ['vmid', 'type', 'templated', 'ide2', 'scsi0', 'net0', 'net1']
144
+ excluded_lxc_keys = ['vmid', 'type', 'templated', 'rootfs', 'mp0', 'net0', 'net1']
145
145
 
146
146
  it '#server qemu' do
147
147
  config_hash = object_to_config_hash(server, 'qemu')
@@ -27,7 +27,6 @@ module ForemanFogProxmox
27
27
  describe 'clone_from_image' do
28
28
  before do
29
29
  @cr = FactoryBot.build_stubbed(:proxmox_cr)
30
- @args = { :name => 'name' }
31
30
  @image_id = @cr.id.to_s + '_' + 100.to_s
32
31
  @vmid = 101
33
32
  @image = mock('vm')
@@ -36,16 +35,14 @@ module ForemanFogProxmox
36
35
  @clone = mock('vm')
37
36
  end
38
37
  it 'clones server from image' do
39
- @clone.expects(:update).with(:name => 'name')
40
38
  @clone.stubs(:container?).returns(false)
41
39
  @cr.stubs(:find_vm_by_uuid).with(@cr.id.to_s + '_' + @vmid.to_s).returns(@clone)
42
- @cr.clone_from_image(@image_id, @args, @vmid)
40
+ @cr.clone_from_image(@image_id, @vmid)
43
41
  end
44
42
  it 'clones container from image' do
45
43
  @clone.stubs(:container?).returns(true)
46
- @clone.expects(:update).with(:hostname => 'name')
47
44
  @cr.stubs(:find_vm_by_uuid).with(@cr.id.to_s + '_' + @vmid.to_s).returns(@clone)
48
- @cr.clone_from_image(@image_id, @args, @vmid)
45
+ @cr.clone_from_image(@image_id, @vmid)
49
46
  end
50
47
  end
51
48
  end
@@ -291,8 +291,14 @@ module ForemanFogProxmox
291
291
  args = { vmid: '100', type: 'lxc', image_id: '999', name: 'name' }
292
292
  servers = mock('servers')
293
293
  servers.stubs(:id_valid?).returns(true)
294
- cr = mock_node_servers(ForemanFogProxmox::Proxmox.new, servers)
295
- cr.expects(:clone_from_image).with('999', args, 100)
294
+ containers = mock('containers')
295
+ cr = mock_node_servers_containers(ForemanFogProxmox::Proxmox.new, servers, containers)
296
+ vm = mock('vm')
297
+ cr.expects(:clone_from_image).with('999', 100).returns(vm)
298
+ vm.expects(:container?).returns(true)
299
+ expected_args = { :vmid => "100", :type => "lxc" }
300
+ cr.stubs(:parse_typed_vm).with(args, 'lxc').returns(expected_args)
301
+ vm.expects(:update).with(expected_args)
296
302
  cr.create_vm(args)
297
303
  end
298
304
  end
@@ -96,9 +96,15 @@ module ForemanFogProxmox
96
96
  it 'clones server' do
97
97
  args = { vmid: '100', type: 'qemu', image_id: '999', name: 'name' }
98
98
  servers = mock('servers')
99
+ containers = mock('containers')
99
100
  servers.stubs(:id_valid?).returns(true)
100
- cr = mock_node_servers(ForemanFogProxmox::Proxmox.new, servers)
101
- cr.expects(:clone_from_image).with('999', args, 100)
101
+ cr = mock_node_servers_containers(ForemanFogProxmox::Proxmox.new, servers, containers)
102
+ vm = mock('vm')
103
+ cr.expects(:clone_from_image).with('999', 100).returns(vm)
104
+ vm.expects(:container?).returns(false)
105
+ expected_args = { :vmid => "100", :type => "qemu", :name => "name" }
106
+ cr.stubs(:parse_typed_vm).with(args, 'qemu').returns(expected_args)
107
+ vm.expects(:update).with(expected_args)
102
108
  cr.create_vm(args)
103
109
  end
104
110
  end
@@ -44,6 +44,7 @@ module ForemanFogProxmox
44
44
  disk.stubs(:id).returns('ide2')
45
45
  disk.stubs(:hard_disk?).returns(false)
46
46
  disk.stubs(:cdrom?).returns(true)
47
+ disk.stubs(:rootfs?).returns(false)
47
48
  disks.stubs(:get).returns
48
49
  config.stubs(:disks).returns(disks)
49
50
  config.stubs(:attributes).returns(:cores => '')
@@ -93,6 +94,7 @@ module ForemanFogProxmox
93
94
  disk.stubs(:size).returns('1')
94
95
  disk.stubs(:hard_disk?).returns(false)
95
96
  disk.stubs(:cdrom?).returns(true)
97
+ disk.stubs(:rootfs?).returns(false)
96
98
  disk.stubs(:cloud_init?).returns(false)
97
99
  disk.stubs(:storage).returns('local-lvm')
98
100
  disk.stubs(:volid).returns('local-lvm:iso/ubuntu-20_4.iso')
@@ -145,6 +147,7 @@ module ForemanFogProxmox
145
147
  disk.stubs(:size).returns('1')
146
148
  disk.stubs(:hard_disk?).returns(false)
147
149
  disk.stubs(:cdrom?).returns(true)
150
+ disk.stubs(:rootfs?).returns(false)
148
151
  disk.stubs(:cloud_init?).returns(false)
149
152
  disk.stubs(:storage).returns('local-lvm')
150
153
  disk.stubs(:volid).returns('local-lvm:iso/ubuntu-20_4.iso')
@@ -24,12 +24,13 @@ require 'factories/foreman_fog_proxmox/proxmox_server_mock_factory'
24
24
  require 'active_support/core_ext/hash/indifferent_access'
25
25
 
26
26
  module ForemanFogProxmox
27
- class ProxmoxVmCommandsServerUpdateHardDiskTest < ActiveSupport::TestCase
27
+ class ProxmoxVmCommandsServerUpdateHardDiskTest < ActiveSupport::TestCase # rubocop:disable Metrics/ClassLength
28
28
  include ComputeResourceTestHelpers
29
29
  include ProxmoxNodeMockFactory
30
30
  include ProxmoxServerMockFactory
31
31
  include ProxmoxVmHelper
32
32
 
33
+ # rubocop:disable Metrics/BlockLength
33
34
  describe 'save_vm' do
34
35
  before do
35
36
  @cr = FactoryBot.build_stubbed(:proxmox_cr)
@@ -43,6 +44,7 @@ module ForemanFogProxmox
43
44
  disk.stubs(:size).returns('1')
44
45
  disk.stubs(:hard_disk?).returns(true)
45
46
  disk.stubs(:cdrom?).returns(false)
47
+ disk.stubs(:rootfs?).returns(false)
46
48
  disk.stubs(:storage).returns('local-lvm')
47
49
  disk.stubs(:id).returns('scsi0')
48
50
  disk.stubs(:attributes).returns(id: 'scsi0', storage: 'local-lvm', size: '1')
@@ -94,6 +96,7 @@ module ForemanFogProxmox
94
96
  disk.stubs(:size).returns('1')
95
97
  disk.stubs(:hard_disk?).returns(true)
96
98
  disk.stubs(:cdrom?).returns(false)
99
+ disk.stubs(:rootfs?).returns(false)
97
100
  disk.stubs(:storage).returns('local-lvm')
98
101
  disk.stubs(:id).returns('virtio0')
99
102
  disks.stubs(:get).returns(disk)
@@ -147,6 +150,7 @@ module ForemanFogProxmox
147
150
  disk.stubs(:size).returns('1')
148
151
  disk.stubs(:hard_disk?).returns(true)
149
152
  disk.stubs(:cdrom?).returns(false)
153
+ disk.stubs(:rootfs?).returns(false)
150
154
  disk.stubs(:storage).returns('scsi0')
151
155
  disk.stubs(:volid).returns('local-lvm:vm-100-disk-0')
152
156
  disk.stubs(:id).returns('local-lvm')
@@ -202,6 +206,7 @@ module ForemanFogProxmox
202
206
  disk.stubs(:size).returns('2')
203
207
  disk.stubs(:hard_disk?).returns(true)
204
208
  disk.stubs(:cdrom?).returns(false)
209
+ disk.stubs(:rootfs?).returns(false)
205
210
  disk.stubs(:storage).returns('local-lvm')
206
211
  disk.stubs(:volid).returns('local-lvm:vm-100-disk-0')
207
212
  disk.stubs(:attributes).returns(id: 'scsi0', storage: 'local-lvm', size: '2')
@@ -254,8 +259,7 @@ module ForemanFogProxmox
254
259
  disk.stubs(:size).returns('1')
255
260
  disk.stubs(:hard_disk?).returns(true)
256
261
  disk.stubs(:cdrom?).returns(false)
257
- disk.stubs(:hard_disk?).returns(true)
258
- disk.stubs(:cdrom?).returns(false)
262
+ disk.stubs(:rootfs?).returns(false)
259
263
  disk.stubs(:storage).returns('local-lvm')
260
264
  disk.stubs(:attributes).returns(id: 'scsi0', storage: 'local-lvm', size: '1', volid: 'local-lvm:vm-100-disk-0')
261
265
  disks.stubs(:get).returns(disk)
@@ -307,6 +311,7 @@ module ForemanFogProxmox
307
311
  disk.stubs(:size).returns('1')
308
312
  disk.stubs(:hard_disk?).returns(true)
309
313
  disk.stubs(:cdrom?).returns(false)
314
+ disk.stubs(:rootfs?).returns(false)
310
315
  disk.stubs(:storage).returns('local-lvm')
311
316
  disk.stubs(:volid).returns('local-lvm:vm-100-disk-0')
312
317
  disk.stubs(:id).returns('scsi0')
@@ -352,5 +357,6 @@ module ForemanFogProxmox
352
357
  @cr.save_vm(uuid, new_attributes)
353
358
  end
354
359
  end
360
+ # rubocop:enable Metrics/BlockLength
355
361
  end
356
362
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_fog_proxmox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.2
4
+ version: 0.14.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tristan Robert
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-12-16 00:00:00.000000000 Z
12
+ date: 2023-08-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: deface
@@ -262,29 +262,29 @@ signing_key:
262
262
  specification_version: 4
263
263
  summary: Foreman plugin that adds Proxmox VE compute resource using fog-proxmox
264
264
  test_files:
265
- - test/test_plugin_helper.rb
266
- - test/factories/foreman_fog_proxmox/proxmox_node_mock_factory.rb
267
265
  - test/factories/foreman_fog_proxmox/proxmox_server_mock_factory.rb
266
+ - test/factories/foreman_fog_proxmox/proxmox_node_mock_factory.rb
268
267
  - test/factories/foreman_fog_proxmox/proxmox_container_mock_factory.rb
269
268
  - test/factories/proxmox_factory.rb
270
- - test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_create_test.rb
269
+ - test/unit/foreman_fog_proxmox/proxmox_test.rb
270
+ - test/unit/foreman_fog_proxmox/proxmox_vm_commands_test.rb
271
+ - test/unit/foreman_fog_proxmox/helpers/proxmox_container_helper_test.rb
272
+ - test/unit/foreman_fog_proxmox/helpers/proxmox_vm_uuid_helper_test.rb
273
+ - test/unit/foreman_fog_proxmox/helpers/proxmox_vm_helper_test.rb
271
274
  - test/unit/foreman_fog_proxmox/helpers/proxmox_vm_volumes_helper_test.rb
272
275
  - test/unit/foreman_fog_proxmox/helpers/proxmox_server_helper_test.rb
273
- - test/unit/foreman_fog_proxmox/helpers/proxmox_vm_helper_test.rb
274
- - test/unit/foreman_fog_proxmox/helpers/proxmox_vm_uuid_helper_test.rb
275
- - test/unit/foreman_fog_proxmox/helpers/proxmox_container_helper_test.rb
276
- - test/unit/foreman_fog_proxmox/proxmox_version_test.rb
277
- - test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_cdrom_test.rb
278
276
  - test/unit/foreman_fog_proxmox/proxmox_vm_commands_container_test.rb
279
- - test/unit/foreman_fog_proxmox/proxmox_vm_commands_test.rb
280
- - test/unit/foreman_fog_proxmox/semver_test.rb
281
- - test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_hard_disk_test.rb
282
- - test/unit/foreman_fog_proxmox/proxmox_vm_queries_test.rb
283
- - test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_test.rb
284
277
  - test/unit/foreman_fog_proxmox/proxmox_interfaces_test.rb
285
- - test/unit/foreman_fog_proxmox/proxmox_compute_attributes_test.rb
278
+ - test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_hard_disk_test.rb
286
279
  - test/unit/foreman_fog_proxmox/proxmox_images_test.rb
287
- - test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_cloudinit_test.rb
288
- - test/unit/foreman_fog_proxmox/proxmox_test.rb
280
+ - test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_cdrom_test.rb
281
+ - test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_test.rb
282
+ - test/unit/foreman_fog_proxmox/proxmox_version_test.rb
283
+ - test/unit/foreman_fog_proxmox/proxmox_vm_queries_test.rb
289
284
  - test/unit/foreman_fog_proxmox/proxmox_vm_new_test.rb
285
+ - test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_cloudinit_test.rb
286
+ - test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_create_test.rb
287
+ - test/unit/foreman_fog_proxmox/proxmox_compute_attributes_test.rb
288
+ - test/unit/foreman_fog_proxmox/semver_test.rb
290
289
  - test/functional/compute_resources_controller_test.rb
290
+ - test/test_plugin_helper.rb