foreman_fog_proxmox 0.13.4 → 0.14.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +63 -52
  3. data/app/assets/javascripts/foreman_fog_proxmox/proxmox_compute_resource.js +0 -2
  4. data/app/assets/javascripts/foreman_fog_proxmox/proxmox_vm.js +0 -1
  5. data/app/assets/javascripts/foreman_fog_proxmox/proxmox_vm_server.js +0 -2
  6. data/app/assets/javascripts/foreman_fog_proxmox/proxmox_volume_cloudinit.js +0 -1
  7. data/app/controllers/concerns/foreman_fog_proxmox/compute_resources_vms_controller.rb +17 -7
  8. data/app/controllers/concerns/foreman_fog_proxmox/controller/parameters/compute_resource.rb +1 -1
  9. data/app/controllers/concerns/foreman_fog_proxmox/hosts_controller.rb +58 -0
  10. data/app/controllers/foreman_fog_proxmox/compute_resources_controller.rb +6 -3
  11. data/app/helpers/proxmox_compute_controllers_helper.rb +2 -1
  12. data/app/helpers/proxmox_compute_resources_helper.rb +3 -3
  13. data/app/helpers/proxmox_compute_resources_vms_helper.rb +16 -7
  14. data/app/helpers/proxmox_form_helper.rb +10 -6
  15. data/app/helpers/proxmox_vm_config_helper.rb +16 -25
  16. data/app/helpers/proxmox_vm_interfaces_helper.rb +19 -6
  17. data/app/helpers/proxmox_vm_os_template_helper.rb +2 -5
  18. data/app/helpers/proxmox_vm_uuid_helper.rb +1 -1
  19. data/app/helpers/proxmox_vm_volumes_helper.rb +22 -25
  20. data/app/models/concerns/fog_extensions/proxmox/node.rb +2 -2
  21. data/app/models/concerns/fog_extensions/proxmox/server.rb +10 -6
  22. data/app/models/concerns/host_ext/proxmox/associator.rb +3 -2
  23. data/app/models/concerns/host_ext/proxmox/for_vm.rb +1 -1
  24. data/app/models/concerns/host_ext/proxmox/interfaces.rb +7 -3
  25. data/app/models/concerns/orchestration/proxmox/compute.rb +11 -4
  26. data/app/models/foreman_fog_proxmox/options_select.rb +1 -3
  27. data/app/models/foreman_fog_proxmox/proxmox.rb +12 -10
  28. data/app/models/foreman_fog_proxmox/proxmox_compute_attributes.rb +15 -3
  29. data/app/models/foreman_fog_proxmox/proxmox_connection.rb +6 -2
  30. data/app/models/foreman_fog_proxmox/proxmox_console.rb +3 -1
  31. data/app/models/foreman_fog_proxmox/proxmox_images.rb +2 -2
  32. data/app/models/foreman_fog_proxmox/proxmox_interfaces.rb +37 -14
  33. data/app/models/foreman_fog_proxmox/proxmox_operating_systems.rb +6 -1
  34. data/app/models/foreman_fog_proxmox/proxmox_pools.rb +4 -4
  35. data/app/models/foreman_fog_proxmox/proxmox_version.rb +7 -3
  36. data/app/models/foreman_fog_proxmox/proxmox_vm_commands.rb +9 -7
  37. data/app/models/foreman_fog_proxmox/proxmox_vm_new.rb +37 -24
  38. data/app/models/foreman_fog_proxmox/proxmox_vm_queries.rb +4 -5
  39. data/app/models/foreman_fog_proxmox/proxmox_volumes.rb +23 -12
  40. data/app/models/foreman_fog_proxmox/vms.rb +2 -2
  41. data/app/overrides/compute_resources_vms/form/add_clone_to_new_vm_compute_detail.rb +1 -1
  42. data/app/views/compute_resources_vms/form/proxmox/_add_from_profile_to_compute_form.html.erb +2 -2
  43. data/app/views/compute_resources_vms/form/proxmox/_add_from_profile_to_hosts_compute_detail_form.html.erb +4 -2
  44. data/app/views/compute_resources_vms/form/proxmox/_base.html.erb +0 -1
  45. data/app/views/compute_resources_vms/form/proxmox/container/_config.html.erb +2 -2
  46. data/app/views/compute_resources_vms/form/proxmox/container/_network.html.erb +1 -1
  47. data/app/views/compute_resources_vms/form/proxmox/container/_volume_mp.html.erb +1 -1
  48. data/app/views/compute_resources_vms/form/proxmox/container/_volume_rootfs.html.erb +1 -1
  49. data/app/views/compute_resources_vms/form/proxmox/server/_config.html.erb +3 -3
  50. data/app/views/compute_resources_vms/form/proxmox/server/_network.html.erb +2 -2
  51. data/app/views/compute_resources_vms/form/proxmox/server/_volume_hard_disk.html.erb +1 -1
  52. data/config/routes.rb +8 -4
  53. data/db/migrate/20210312105013_update_proxmox_uuid_host.rb +1 -2
  54. data/lib/foreman_fog_proxmox/engine.rb +5 -3
  55. data/lib/foreman_fog_proxmox/semver.rb +1 -4
  56. data/lib/foreman_fog_proxmox/version.rb +1 -1
  57. data/locale/en/foreman_fog_proxmox.po +140 -47
  58. data/locale/foreman_fog_proxmox.pot +300 -137
  59. data/locale/fr/foreman_fog_proxmox.po +145 -52
  60. data/test/factories/foreman_fog_proxmox/proxmox_container_mock_factory.rb +6 -7
  61. data/test/factories/foreman_fog_proxmox/proxmox_server_mock_factory.rb +6 -7
  62. data/test/functional/compute_resources_controller_test.rb +4 -2
  63. data/test/test_plugin_helper.rb +12 -7
  64. data/test/unit/foreman_fog_proxmox/helpers/proxmox_container_helper_test.rb +38 -47
  65. data/test/unit/foreman_fog_proxmox/helpers/proxmox_server_helper_test.rb +49 -34
  66. data/test/unit/foreman_fog_proxmox/helpers/proxmox_vm_helper_test.rb +29 -65
  67. data/test/unit/foreman_fog_proxmox/helpers/proxmox_vm_volumes_helper_test.rb +3 -3
  68. data/test/unit/foreman_fog_proxmox/proxmox_compute_attributes_test.rb +22 -13
  69. data/test/unit/foreman_fog_proxmox/proxmox_interfaces_test.rb +48 -37
  70. data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_container_test.rb +45 -35
  71. data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_create_test.rb +0 -4
  72. data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_cdrom_test.rb +34 -22
  73. data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_cloudinit_test.rb +20 -14
  74. data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_hard_disk_test.rb +76 -54
  75. data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_test.rb +26 -15
  76. data/test/unit/foreman_fog_proxmox/proxmox_vm_queries_test.rb +1 -1
  77. data/test/unit/foreman_fog_proxmox/semver_test.rb +2 -1
  78. metadata +36 -21
@@ -24,7 +24,7 @@ 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 ProxmoxVmCommandsServerUpdateTest < ActiveSupport::TestCase
27
+ class ProxmoxVmCommandsServerUpdateHardDiskTest < ActiveSupport::TestCase
28
28
  include ComputeResourceTestHelpers
29
29
  include ProxmoxNodeMockFactory
30
30
  include ProxmoxServerMockFactory
@@ -40,10 +40,12 @@ module ForemanFogProxmox
40
40
  config = mock('config')
41
41
  disks = mock('disks')
42
42
  disk = mock('disk')
43
- disk.stubs(:size).returns(1_073_741_824)
43
+ disk.stubs(:size).returns('1')
44
+ disk.stubs(:hard_disk?).returns(true)
45
+ disk.stubs(:cdrom?).returns(false)
44
46
  disk.stubs(:storage).returns('local-lvm')
45
47
  disk.stubs(:id).returns('scsi0')
46
- disk.stubs(:attributes).returns(id: 'scsi0', storage: 'local-lvm', size: 1_073_741_824)
48
+ disk.stubs(:attributes).returns(id: 'scsi0', storage: 'local-lvm', size: '1')
47
49
  disks.stubs(:get).returns
48
50
  config.stubs(:disks).returns(disks)
49
51
  config.stubs(:attributes).returns(:cores => '')
@@ -60,7 +62,7 @@ module ForemanFogProxmox
60
62
  'node_id' => 'proxmox',
61
63
  'config_attributes' => {
62
64
  'cores' => '1',
63
- 'cpulimit' => '1'
65
+ 'cpulimit' => '1',
64
66
  },
65
67
  'volumes_attributes' => {
66
68
  '0' => {
@@ -70,14 +72,15 @@ module ForemanFogProxmox
70
72
  'controller' => 'scsi',
71
73
  'storage_type' => 'hard_disk',
72
74
  'storage' => 'local-lvm',
73
- 'size' => '2147483648',
74
- 'cache' => 'none'
75
- }
76
- }
75
+ 'size' => '2',
76
+ 'cache' => 'none',
77
+ },
78
+ },
77
79
  }.with_indifferent_access
78
- @cr.stubs(:parse_server_vm).returns('vmid' => '100', 'node_id' => 'proxmox', 'type' => 'qemu', 'cores' => '1', 'cpulimit' => '1', 'onboot' => '0')
80
+ @cr.stubs(:parse_server_vm).returns('vmid' => '100', 'node_id' => 'proxmox', 'type' => 'qemu', 'cores' => '1',
81
+ 'cpulimit' => '1', 'onboot' => '0')
79
82
  expected_config_attr = { :cores => '1', :cpulimit => '1' }
80
- expected_volume_attr = { id: 'scsi0', storage: 'local:lvm', size: (2_147_483_648 / GIGA).to_s }
83
+ expected_volume_attr = { id: 'scsi0', storage: 'local:lvm', size: '2' }
81
84
  vm.expects(:attach, expected_volume_attr)
82
85
  vm.expects(:update, expected_config_attr)
83
86
  @cr.save_vm(uuid, new_attributes)
@@ -88,7 +91,9 @@ module ForemanFogProxmox
88
91
  config = mock('config')
89
92
  disks = mock('disks')
90
93
  disk = mock('disk')
91
- disk.stubs(:size).returns(1_073_741_824)
94
+ disk.stubs(:size).returns('1')
95
+ disk.stubs(:hard_disk?).returns(true)
96
+ disk.stubs(:cdrom?).returns(false)
92
97
  disk.stubs(:storage).returns('local-lvm')
93
98
  disk.stubs(:id).returns('virtio0')
94
99
  disks.stubs(:get).returns(disk)
@@ -108,7 +113,7 @@ module ForemanFogProxmox
108
113
  'node_id' => 'proxmox',
109
114
  'config_attributes' => {
110
115
  'cores' => '1',
111
- 'cpulimit' => '1'
116
+ 'cpulimit' => '1',
112
117
  },
113
118
  'volumes_attributes' => {
114
119
  '0' => {
@@ -119,12 +124,13 @@ module ForemanFogProxmox
119
124
  'device' => '0',
120
125
  'controller' => 'scsi',
121
126
  'storage' => 'local-lvm',
122
- 'size' => '2147483648',
123
- 'cache' => 'none'
124
- }
125
- }
127
+ 'size' => '2',
128
+ 'cache' => 'none',
129
+ },
130
+ },
126
131
  }.with_indifferent_access
127
- @cr.stubs(:parse_server_vm).returns('vmid' => '100', 'node_id' => 'proxmox', 'type' => 'qemu', 'cores' => '1', 'cpulimit' => '1', 'config_attributes' => { 'onboot' => '0' })
132
+ @cr.stubs(:parse_server_vm).returns('vmid' => '100', 'node_id' => 'proxmox', 'type' => 'qemu', 'cores' => '1',
133
+ 'cpulimit' => '1', 'config_attributes' => { 'onboot' => '0' })
128
134
  expected_config_attr = { :cores => '1', :cpulimit => '1' }
129
135
  expected_volume_attr = 'scsi0'
130
136
  vm.expects(:detach, expected_volume_attr)
@@ -138,10 +144,13 @@ module ForemanFogProxmox
138
144
  config = mock('config')
139
145
  disks = mock('disks')
140
146
  disk = mock('disk')
141
- disk.stubs(:size).returns(1_073_741_824)
147
+ disk.stubs(:size).returns('1')
148
+ disk.stubs(:hard_disk?).returns(true)
149
+ disk.stubs(:cdrom?).returns(false)
142
150
  disk.stubs(:storage).returns('scsi0')
151
+ disk.stubs(:volid).returns('local-lvm:vm-100-disk-0')
143
152
  disk.stubs(:id).returns('local-lvm')
144
- disk.stubs(:attributes).returns(id: 'scsi0', storage: 'local-lvm', size: 1_073_741_824)
153
+ disk.stubs(:attributes).returns(id: 'scsi0', storage: 'local-lvm', size: 1)
145
154
  disks.stubs(:get).returns(disk)
146
155
  config.stubs(:disks).returns(disks)
147
156
  config.stubs(:attributes).returns(:cores => '')
@@ -159,7 +168,7 @@ module ForemanFogProxmox
159
168
  'node_id' => 'proxmox',
160
169
  'config_attributes' => {
161
170
  'cores' => '1',
162
- 'cpulimit' => '1'
171
+ 'cpulimit' => '1',
163
172
  },
164
173
  'volumes_attributes' => {
165
174
  '0' => {
@@ -170,12 +179,13 @@ module ForemanFogProxmox
170
179
  'device' => '0',
171
180
  'controller' => 'scsi',
172
181
  'storage' => 'local-lvm',
173
- 'size' => '2147483648',
174
- 'cache' => 'none'
175
- }
176
- }
182
+ 'size' => '2',
183
+ 'cache' => 'none',
184
+ },
185
+ },
177
186
  }.with_indifferent_access
178
- @cr.stubs(:parse_server_vm).returns('vmid' => '100', 'node_id' => 'proxmox', 'type' => 'qemu', 'cores' => '1', 'cpulimit' => '1')
187
+ @cr.stubs(:parse_server_vm).returns('vmid' => '100', 'node_id' => 'proxmox', 'type' => 'qemu', 'cores' => '1',
188
+ 'cpulimit' => '1')
179
189
  expected_config_attr = { :cores => '1', :cpulimit => '1' }
180
190
  expected_volume_attr = ['scsi0', '+1G']
181
191
  vm.expects(:extend, expected_volume_attr)
@@ -189,26 +199,30 @@ module ForemanFogProxmox
189
199
  disks = mock('disks')
190
200
  disk = mock('disk')
191
201
  disk.stubs(:id).returns('scsi0')
192
- disk.stubs(:size).returns(1_073_741_824)
202
+ disk.stubs(:size).returns('2')
203
+ disk.stubs(:hard_disk?).returns(true)
204
+ disk.stubs(:cdrom?).returns(false)
193
205
  disk.stubs(:storage).returns('local-lvm')
194
- disk.stubs(:attributes).returns(id: 'scsi0', storage: 'local-lvm', size: 1_073_741_824)
206
+ disk.stubs(:volid).returns('local-lvm:vm-100-disk-0')
207
+ disk.stubs(:attributes).returns(id: 'scsi0', storage: 'local-lvm', size: '2')
195
208
  disks.stubs(:get).returns(disk)
196
209
  config.stubs(:disks).returns(disks)
197
- config.stubs(:attributes).returns(:cores => '')
210
+ config.stubs(:attributes).returns(:cores => '1')
198
211
  vm = mock('vm')
199
212
  vm.stubs(:identity).returns(uuid)
200
213
  vm.stubs(:attributes).returns('scsi0' => '')
201
214
  vm.stubs(:config).returns(config)
202
215
  vm.stubs(:container?).returns(false)
216
+ vm.stubs(:templated?).returns(false)
203
217
  vm.stubs(:type).returns('qemu')
204
- vm.stubs(:node_id).returns('proxmox')
218
+ vm.stubs(:node_id).returns('pve')
205
219
  @cr.stubs(:find_vm_by_uuid).returns(vm)
206
220
  new_attributes = {
207
221
  'templated' => '0',
208
- 'node_id' => 'proxmox',
222
+ 'node_id' => 'pve',
209
223
  'config_attributes' => {
210
224
  'cores' => '1',
211
- 'cpulimit' => '1'
225
+ 'cpulimit' => '1',
212
226
  },
213
227
  'volumes_attributes' => {
214
228
  '0' => {
@@ -219,12 +233,12 @@ module ForemanFogProxmox
219
233
  'device' => '0',
220
234
  'controller' => 'scsi',
221
235
  'storage' => 'local-lvm',
222
- 'size' => '2',
223
- 'cache' => 'none'
224
- }
225
- }
236
+ 'size' => '1',
237
+ 'cache' => 'none',
238
+ },
239
+ },
226
240
  }.with_indifferent_access
227
- @cr.stubs(:parse_server_vm).returns('vmid' => '100', 'node_id' => 'proxmox', 'type' => 'qemu', 'cores' => '1', 'cpulimit' => '1')
241
+ @cr.stubs(:parse_server_vm).returns('vmid' => '100', 'node_id' => 'pve', 'type' => 'qemu', 'cores' => '1', 'cpulimit' => '1')
228
242
  err = assert_raises Foreman::Exception do
229
243
  @cr.save_vm(uuid, new_attributes)
230
244
  end
@@ -237,9 +251,13 @@ module ForemanFogProxmox
237
251
  disks = mock('disks')
238
252
  disk = mock('disk')
239
253
  disk.stubs(:id).returns('scsi0')
240
- disk.stubs(:size).returns(1_073_741_824)
254
+ disk.stubs(:size).returns('1')
255
+ disk.stubs(:hard_disk?).returns(true)
256
+ disk.stubs(:cdrom?).returns(false)
257
+ disk.stubs(:hard_disk?).returns(true)
258
+ disk.stubs(:cdrom?).returns(false)
241
259
  disk.stubs(:storage).returns('local-lvm')
242
- disk.stubs(:attributes).returns(id: 'scsi0', storage: 'local-lvm', size: 1_073_741_824)
260
+ disk.stubs(:attributes).returns(id: 'scsi0', storage: 'local-lvm', size: '1', volid: 'local-lvm:vm-100-disk-0')
243
261
  disks.stubs(:get).returns(disk)
244
262
  config.stubs(:disks).returns(disks)
245
263
  config.stubs(:attributes).returns(:cores => '')
@@ -256,23 +274,24 @@ module ForemanFogProxmox
256
274
  'node_id' => 'proxmox',
257
275
  'config_attributes' => {
258
276
  'cores' => '1',
259
- 'cpulimit' => '1'
277
+ 'cpulimit' => '1',
260
278
  },
261
279
  'volumes_attributes' => {
262
280
  '0' => {
263
281
  'id' => 'scsi0',
264
282
  '_delete' => '',
265
283
  'storage_type' => 'hard_disk',
266
- 'volid' => 'local-lvm:vm-100-disk-0',
284
+ 'volid' => 'local-lvm2:vm-100-disk-0',
267
285
  'device' => '0',
268
286
  'controller' => 'scsi',
269
287
  'storage' => 'local-lvm2',
270
- 'size' => '1073741824',
271
- 'cache' => 'none'
272
- }
273
- }
288
+ 'size' => '1',
289
+ 'cache' => 'none',
290
+ },
291
+ },
274
292
  }.with_indifferent_access
275
- @cr.stubs(:parse_server_vm).returns('vmid' => '100', 'node_id' => 'proxmox', 'type' => 'qemu', 'cores' => '1', 'cpulimit' => '1')
293
+ @cr.stubs(:parse_server_vm).returns('vmid' => '100', 'node_id' => 'proxmox', 'type' => 'qemu', 'cores' => '1',
294
+ 'cpulimit' => '1')
276
295
  expected_config_attr = { :cores => '1', :cpulimit => '1' }
277
296
  expected_volume_attr = ['scsi0', 'local-lvm2']
278
297
  vm.expects(:move, expected_volume_attr)
@@ -285,11 +304,13 @@ module ForemanFogProxmox
285
304
  config = mock('config')
286
305
  disks = mock('disks')
287
306
  disk = mock('disk')
288
- disk.stubs(:size).returns(1_073_741_824)
307
+ disk.stubs(:size).returns('1')
308
+ disk.stubs(:hard_disk?).returns(true)
309
+ disk.stubs(:cdrom?).returns(false)
289
310
  disk.stubs(:storage).returns('local-lvm')
290
311
  disk.stubs(:volid).returns('local-lvm:vm-100-disk-0')
291
312
  disk.stubs(:id).returns('scsi0')
292
- disk.stubs(:attributes).returns(id: 'scsi0', storage: 'local-lvm', volid: 'local-lvm:vm-100-disk-0', size: 1_073_741_824)
313
+ disk.stubs(:attributes).returns(id: 'scsi0', storage: 'local-lvm', volid: 'local-lvm:vm-100-disk-0', size: '1')
293
314
  disks.stubs(:get).returns(disk)
294
315
  config.stubs(:disks).returns(disks)
295
316
  config.stubs(:attributes).returns(:cores => '')
@@ -306,7 +327,7 @@ module ForemanFogProxmox
306
327
  'node_id' => 'proxmox',
307
328
  'config_attributes' => {
308
329
  'cores' => '1',
309
- 'cpulimit' => '1'
330
+ 'cpulimit' => '1',
310
331
  },
311
332
  'volumes_attributes' => {
312
333
  '0' => {
@@ -317,14 +338,15 @@ module ForemanFogProxmox
317
338
  'device' => '0',
318
339
  'controller' => 'scsi',
319
340
  'storage' => 'local-lvm',
320
- 'size' => '1073741824',
321
- 'cache' => 'directsync'
322
- }
323
- }
341
+ 'size' => '1',
342
+ 'cache' => 'directsync',
343
+ },
344
+ },
324
345
  }.with_indifferent_access
325
- @cr.stubs(:parse_server_vm).returns('vmid' => '100', 'node_id' => 'proxmox', 'type' => 'qemu', 'cores' => '1', 'cpulimit' => '1')
346
+ @cr.stubs(:parse_server_vm).returns('vmid' => '100', 'node_id' => 'proxmox', 'type' => 'qemu', 'cores' => '1',
347
+ 'cpulimit' => '1')
326
348
  expected_config_attr = { :cores => '1', :cpulimit => '1' }
327
- expected_volume_attr = { :id => 'scsi0', :volid => 'local-lvm:vm-100-disk-0', :size => 1_073_741_824 }, { :cache => 'directsync' }
349
+ expected_volume_attr = { :id => 'scsi0', :volid => 'local-lvm:vm-100-disk-0', :size => 1 }, { :cache => 'directsync' }
328
350
  vm.expects(:attach, expected_volume_attr)
329
351
  vm.expects(:update, expected_config_attr)
330
352
  @cr.save_vm(uuid, new_attributes)
@@ -62,8 +62,10 @@ module ForemanFogProxmox
62
62
  vm.stubs(:type).returns('qemu')
63
63
  vm.stubs(:node_id).returns('proxmox')
64
64
  @cr.stubs(:find_vm_by_uuid).returns(vm)
65
- attr = { 'templated' => '0', 'node_id' => 'proxmox', 'config_attributes' => { 'cores' => '1', 'cpulimit' => '1', 'onboot' => '0' } }.with_indifferent_access
66
- @cr.stubs(:parse_typed_vm).returns('vmid' => '100', 'node_id' => 'proxmox', 'type' => 'qemu', 'cores' => '1', 'cpulimit' => '1', 'onboot' => '0')
65
+ attr = { 'templated' => '0', 'node_id' => 'proxmox',
66
+ 'config_attributes' => { 'cores' => '1', 'cpulimit' => '1', 'onboot' => '0' } }.with_indifferent_access
67
+ @cr.stubs(:parse_typed_vm).returns('vmid' => '100', 'node_id' => 'proxmox', 'type' => 'qemu', 'cores' => '1',
68
+ 'cpulimit' => '1', 'onboot' => '0')
67
69
  expected_attr = { :cores => '1', :cpulimit => '1' }.with_indifferent_access
68
70
  vm.expects(:update, expected_attr)
69
71
  @cr.save_vm(uuid, attr)
@@ -104,14 +106,14 @@ module ForemanFogProxmox
104
106
  'node_id' => 'proxmox',
105
107
  'config_attributes' => {
106
108
  'cores' => '1',
107
- 'cpulimit' => '1'
109
+ 'cpulimit' => '1',
108
110
  },
109
111
  'interfaces_attributes' => {
110
112
  '0' => {
111
113
  '_delete' => '1',
112
- 'id' => 'net0'
113
- }
114
- }
114
+ 'id' => 'net0',
115
+ },
116
+ },
115
117
  }.with_indifferent_access
116
118
  @cr.stubs(:parse_typed_vm).returns(
117
119
  'vmid' => '100',
@@ -154,9 +156,12 @@ module ForemanFogProxmox
154
156
  pools.expects(:get).with('pool2').returns(pool2)
155
157
  identity_client.stubs(:pools).returns(pools)
156
158
  @cr.stubs(:identity_client).returns(identity_client)
157
- attr = { 'templated' => '0', 'node_id' => 'proxmox', 'pool' => 'pool2', 'config_attributes' => { 'cores' => '1', 'cpulimit' => '1', 'onboot' => '0' } }.with_indifferent_access
158
- @cr.stubs(:parse_typed_vm).returns('vmid' => '100', 'node_id' => 'proxmox', 'type' => 'qemu', 'cores' => '1', 'cpulimit' => '1', 'onboot' => '0', 'pool' => 'pool2')
159
- vm.expects(:update).with({ 'node_id' => 'proxmox', 'type' => 'qemu', 'cores' => '1', 'cpulimit' => '1', 'onboot' => '0' }.with_indifferent_access)
159
+ attr = { 'templated' => '0', 'node_id' => 'proxmox', 'pool' => 'pool2',
160
+ 'config_attributes' => { 'cores' => '1', 'cpulimit' => '1', 'onboot' => '0' } }.with_indifferent_access
161
+ @cr.stubs(:parse_typed_vm).returns('vmid' => '100', 'node_id' => 'proxmox', 'type' => 'qemu', 'cores' => '1',
162
+ 'cpulimit' => '1', 'onboot' => '0', 'pool' => 'pool2')
163
+ vm.expects(:update).with({ 'node_id' => 'proxmox', 'type' => 'qemu', 'cores' => '1', 'cpulimit' => '1',
164
+ 'onboot' => '0' }.with_indifferent_access)
160
165
  @cr.save_vm(uuid, attr)
161
166
  end
162
167
 
@@ -183,9 +188,12 @@ module ForemanFogProxmox
183
188
  pools.expects(:get).with('').returns(nil)
184
189
  identity_client.stubs(:pools).returns(pools)
185
190
  @cr.stubs(:identity_client).returns(identity_client)
186
- attr = { 'templated' => '0', 'node_id' => 'proxmox', 'pool' => '', 'config_attributes' => { 'cores' => '1', 'cpulimit' => '1', 'onboot' => '0' } }.with_indifferent_access
187
- @cr.stubs(:parse_typed_vm).returns('vmid' => '100', 'node_id' => 'proxmox', 'type' => 'qemu', 'cores' => '1', 'cpulimit' => '1', 'onboot' => '0', 'pool' => '')
188
- vm.expects(:update).with({ 'node_id' => 'proxmox', 'type' => 'qemu', 'cores' => '1', 'cpulimit' => '1', 'onboot' => '0' }.with_indifferent_access)
191
+ attr = { 'templated' => '0', 'node_id' => 'proxmox', 'pool' => '',
192
+ 'config_attributes' => { 'cores' => '1', 'cpulimit' => '1', 'onboot' => '0' } }.with_indifferent_access
193
+ @cr.stubs(:parse_typed_vm).returns('vmid' => '100', 'node_id' => 'proxmox', 'type' => 'qemu', 'cores' => '1',
194
+ 'cpulimit' => '1', 'onboot' => '0', 'pool' => '')
195
+ vm.expects(:update).with({ 'node_id' => 'proxmox', 'type' => 'qemu', 'cores' => '1', 'cpulimit' => '1',
196
+ 'onboot' => '0' }.with_indifferent_access)
189
197
  @cr.save_vm(uuid, attr)
190
198
  end
191
199
 
@@ -212,9 +220,12 @@ module ForemanFogProxmox
212
220
  pools.expects(:get).with('').returns(nil)
213
221
  identity_client.stubs(:pools).returns(pools)
214
222
  @cr.stubs(:identity_client).returns(identity_client)
215
- attr = { 'templated' => '0', 'node_id' => 'proxmox', 'pool' => 'pool2', 'config_attributes' => { 'cores' => '1', 'cpulimit' => '1', 'onboot' => '0' } }.with_indifferent_access
216
- @cr.stubs(:parse_typed_vm).returns('vmid' => '100', 'node_id' => 'proxmox', 'type' => 'qemu', 'cores' => '1', 'cpulimit' => '1', 'onboot' => '0', 'pool' => 'pool2')
217
- vm.expects(:update).with({ 'node_id' => 'proxmox', 'type' => 'qemu', 'cores' => '1', 'cpulimit' => '1', 'onboot' => '0' }.with_indifferent_access)
223
+ attr = { 'templated' => '0', 'node_id' => 'proxmox', 'pool' => 'pool2',
224
+ 'config_attributes' => { 'cores' => '1', 'cpulimit' => '1', 'onboot' => '0' } }.with_indifferent_access
225
+ @cr.stubs(:parse_typed_vm).returns('vmid' => '100', 'node_id' => 'proxmox', 'type' => 'qemu', 'cores' => '1',
226
+ 'cpulimit' => '1', 'onboot' => '0', 'pool' => 'pool2')
227
+ vm.expects(:update).with({ 'node_id' => 'proxmox', 'type' => 'qemu', 'cores' => '1', 'cpulimit' => '1',
228
+ 'onboot' => '0' }.with_indifferent_access)
218
229
  @cr.save_vm(uuid, attr)
219
230
  end
220
231
  end
@@ -35,7 +35,7 @@ module ForemanFogProxmox
35
35
  describe 'find_vm_by_uuid' do
36
36
  it 'returns nil when the uuid does not match' do
37
37
  cr = mock_node_servers_containers(ForemanFogProxmox::Proxmox.new, empty_servers, empty_servers)
38
- assert cr.find_vm_by_uuid('1_100').nil?
38
+ assert_nil cr.find_vm_by_uuid('1_100')
39
39
  end
40
40
 
41
41
  it 'raises RecordNotFound when the compute raises error' do
@@ -77,7 +77,8 @@ module ForemanFogProxmox
77
77
  assert ForemanFogProxmox::Semver.to_semver('1.0.10') <= ForemanFogProxmox::Semver.to_semver('1.0.20')
78
78
  end
79
79
  it '#1.2.3-beta == 1.2.3-beta returns true' do
80
- assert_equal ForemanFogProxmox::Semver.to_semver('1.2.3-beta'), ForemanFogProxmox::Semver.to_semver('1.2.3-beta')
80
+ assert_equal ForemanFogProxmox::Semver.to_semver('1.2.3-beta'),
81
+ ForemanFogProxmox::Semver.to_semver('1.2.3-beta')
81
82
  end
82
83
  it '#1.2.3-beta >= 1.-beta raises ArgumentError' do
83
84
  assert_raises ArgumentError do
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.13.4
4
+ version: 0.14.1
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: 2021-07-21 00:00:00.000000000 Z
12
+ date: 2022-12-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: deface
@@ -31,14 +31,14 @@ dependencies:
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: '0.14'
34
+ version: '0.15'
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: '0.14'
41
+ version: '0.15'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: rdoc
44
44
  requirement: !ruby/object:Gem::Requirement
@@ -81,6 +81,20 @@ dependencies:
81
81
  - - ">="
82
82
  - !ruby/object:Gem::Version
83
83
  version: '0'
84
+ - !ruby/object:Gem::Dependency
85
+ name: theforeman-rubocop
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - "~>"
89
+ - !ruby/object:Gem::Version
90
+ version: '0.1'
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: '0.1'
84
98
  description: Foreman plugin adds Proxmox VE compute resource using fog-proxmox. It
85
99
  is compatible with Foreman 1.22+
86
100
  email:
@@ -102,6 +116,7 @@ files:
102
116
  - app/assets/javascripts/foreman_fog_proxmox/proxmox_volume_cloudinit.js
103
117
  - app/controllers/concerns/foreman_fog_proxmox/compute_resources_vms_controller.rb
104
118
  - app/controllers/concerns/foreman_fog_proxmox/controller/parameters/compute_resource.rb
119
+ - app/controllers/concerns/foreman_fog_proxmox/hosts_controller.rb
105
120
  - app/controllers/foreman_fog_proxmox/compute_resources_controller.rb
106
121
  - app/helpers/node_dashboard_helper.rb
107
122
  - app/helpers/proxmox_compute_controllers_helper.rb
@@ -242,34 +257,34 @@ required_rubygems_version: !ruby/object:Gem::Requirement
242
257
  - !ruby/object:Gem::Version
243
258
  version: '0'
244
259
  requirements: []
245
- rubygems_version: 3.2.22
260
+ rubygems_version: 3.1.6
246
261
  signing_key:
247
262
  specification_version: 4
248
263
  summary: Foreman plugin that adds Proxmox VE compute resource using fog-proxmox
249
264
  test_files:
250
- - test/factories/foreman_fog_proxmox/proxmox_container_mock_factory.rb
265
+ - test/functional/compute_resources_controller_test.rb
251
266
  - test/factories/foreman_fog_proxmox/proxmox_node_mock_factory.rb
267
+ - test/factories/foreman_fog_proxmox/proxmox_container_mock_factory.rb
252
268
  - test/factories/foreman_fog_proxmox/proxmox_server_mock_factory.rb
253
269
  - test/factories/proxmox_factory.rb
254
- - test/functional/compute_resources_controller_test.rb
255
- - test/test_plugin_helper.rb
256
- - test/unit/foreman_fog_proxmox/helpers/proxmox_container_helper_test.rb
257
- - test/unit/foreman_fog_proxmox/helpers/proxmox_server_helper_test.rb
258
- - test/unit/foreman_fog_proxmox/helpers/proxmox_vm_helper_test.rb
259
- - test/unit/foreman_fog_proxmox/helpers/proxmox_vm_uuid_helper_test.rb
260
- - test/unit/foreman_fog_proxmox/helpers/proxmox_vm_volumes_helper_test.rb
261
- - test/unit/foreman_fog_proxmox/proxmox_compute_attributes_test.rb
262
- - test/unit/foreman_fog_proxmox/proxmox_images_test.rb
263
- - test/unit/foreman_fog_proxmox/proxmox_interfaces_test.rb
264
- - test/unit/foreman_fog_proxmox/proxmox_test.rb
265
- - test/unit/foreman_fog_proxmox/proxmox_version_test.rb
266
- - test/unit/foreman_fog_proxmox/proxmox_vm_commands_container_test.rb
267
- - test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_create_test.rb
268
270
  - test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_cdrom_test.rb
269
271
  - test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_cloudinit_test.rb
270
272
  - test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_hard_disk_test.rb
273
+ - test/unit/foreman_fog_proxmox/proxmox_interfaces_test.rb
271
274
  - test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_test.rb
275
+ - test/unit/foreman_fog_proxmox/helpers/proxmox_vm_volumes_helper_test.rb
276
+ - test/unit/foreman_fog_proxmox/helpers/proxmox_vm_helper_test.rb
277
+ - test/unit/foreman_fog_proxmox/helpers/proxmox_container_helper_test.rb
278
+ - test/unit/foreman_fog_proxmox/helpers/proxmox_server_helper_test.rb
279
+ - test/unit/foreman_fog_proxmox/helpers/proxmox_vm_uuid_helper_test.rb
280
+ - test/unit/foreman_fog_proxmox/proxmox_version_test.rb
272
281
  - test/unit/foreman_fog_proxmox/proxmox_vm_commands_test.rb
273
282
  - test/unit/foreman_fog_proxmox/proxmox_vm_new_test.rb
274
- - test/unit/foreman_fog_proxmox/proxmox_vm_queries_test.rb
283
+ - test/unit/foreman_fog_proxmox/proxmox_vm_commands_container_test.rb
275
284
  - test/unit/foreman_fog_proxmox/semver_test.rb
285
+ - test/unit/foreman_fog_proxmox/proxmox_images_test.rb
286
+ - test/unit/foreman_fog_proxmox/proxmox_vm_queries_test.rb
287
+ - test/unit/foreman_fog_proxmox/proxmox_compute_attributes_test.rb
288
+ - test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_create_test.rb
289
+ - test/unit/foreman_fog_proxmox/proxmox_test.rb
290
+ - test/test_plugin_helper.rb