foreman_fog_proxmox 0.13.0 → 0.13.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +42 -9
  3. data/app/assets/javascripts/foreman_fog_proxmox/proxmox_compute_resource.js +25 -13
  4. data/app/assets/javascripts/foreman_fog_proxmox/proxmox_vm.js +62 -60
  5. data/app/assets/javascripts/foreman_fog_proxmox/proxmox_vm_server.js +2 -2
  6. data/app/assets/javascripts/foreman_fog_proxmox/proxmox_volume.js +10 -10
  7. data/app/controllers/concerns/foreman_fog_proxmox/compute_resources_vms_controller.rb +80 -0
  8. data/app/controllers/foreman_fog_proxmox/compute_resources_controller.rb +23 -25
  9. data/app/helpers/proxmox_compute_resources_vms_helper.rb +99 -0
  10. data/app/helpers/proxmox_vm_config_helper.rb +5 -4
  11. data/app/helpers/proxmox_vm_uuid_helper.rb +34 -0
  12. data/app/models/concerns/fog_extensions/proxmox/server.rb +4 -0
  13. data/app/models/concerns/host_ext/proxmox/associator.rb +46 -0
  14. data/app/models/concerns/host_ext/proxmox/for_vm.rb +33 -0
  15. data/app/models/concerns/orchestration/proxmox/compute.rb +65 -7
  16. data/app/models/foreman_fog_proxmox/proxmox.rb +4 -0
  17. data/app/models/foreman_fog_proxmox/proxmox_compute_attributes.rb +3 -6
  18. data/app/models/foreman_fog_proxmox/proxmox_images.rb +13 -4
  19. data/app/models/foreman_fog_proxmox/proxmox_interfaces.rb +2 -1
  20. data/app/models/foreman_fog_proxmox/proxmox_vm_commands.rb +5 -3
  21. data/app/models/foreman_fog_proxmox/proxmox_vm_new.rb +2 -4
  22. data/app/models/foreman_fog_proxmox/proxmox_vm_queries.rb +14 -7
  23. data/app/models/foreman_fog_proxmox/vms.rb +1 -1
  24. data/app/services/concerns/foreman_fog_proxmox/compute_resource_host_associator.rb +34 -0
  25. data/app/services/foreman_fog_proxmox/node_dashboard/data.rb +6 -2
  26. data/app/views/api/v2/compute_resources/proxmox.json.rabl +1 -1
  27. data/app/views/compute_resources_vms/form/proxmox/server/_volume_cdrom.html.erb +1 -1
  28. data/app/views/compute_resources_vms/index/_proxmox.html.erb +2 -2
  29. data/config/routes.rb +7 -7
  30. data/db/migrate/20210312105013_update_proxmox_uuid_host.rb +29 -0
  31. data/lib/foreman_fog_proxmox/engine.rb +13 -2
  32. data/lib/foreman_fog_proxmox/version.rb +1 -1
  33. data/test/functional/compute_resources_controller_test.rb +4 -4
  34. data/test/unit/foreman_fog_proxmox/helpers/proxmox_container_helper_test.rb +4 -3
  35. data/test/unit/foreman_fog_proxmox/helpers/proxmox_server_helper_test.rb +3 -1
  36. data/test/unit/foreman_fog_proxmox/helpers/proxmox_vm_uuid_helper_test.rb +38 -0
  37. data/test/unit/foreman_fog_proxmox/proxmox_images_test.rb +3 -3
  38. data/test/unit/foreman_fog_proxmox/proxmox_interfaces_test.rb +2 -2
  39. data/test/unit/foreman_fog_proxmox/proxmox_vm_queries_test.rb +3 -3
  40. metadata +12 -3
@@ -33,10 +33,11 @@ module ForemanFogProxmox
33
33
 
34
34
  let(:host_form) do
35
35
  { 'vmid' => '100',
36
- 'name' => 'test',
36
+ 'name' => 'toto-tata.pve',
37
37
  'node_id' => 'proxmox',
38
38
  'type' => 'qemu',
39
39
  'config_attributes' => {
40
+ 'name' => 'toto-tata.pve',
40
41
  'memory' => '536870912',
41
42
  'balloon' => '268435456',
42
43
  'shares' => '5',
@@ -111,6 +112,7 @@ module ForemanFogProxmox
111
112
  assert_equal 5, vm[:shares]
112
113
  assert_equal 'local-lvm:1073741824,cache=none', vm[:scsi0]
113
114
  assert_equal 'model=virtio,bridge=vmbr0,firewall=0,link_down=0', vm[:net0]
115
+ assert_equal 'toto-tata.pve', vm[:name]
114
116
  assert_not vm.key?(:config)
115
117
  assert_not vm.key?(:node)
116
118
  end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2018 Tristan Robert
4
+
5
+ # This file is part of ForemanFogProxmox.
6
+
7
+ # ForemanFogProxmox is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU General Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+
12
+ # ForemanFogProxmox is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU General Public License for more details.
16
+
17
+ # You should have received a copy of the GNU General Public License
18
+ # along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>.
19
+
20
+ require 'test_plugin_helper'
21
+
22
+ module ForemanFogProxmox
23
+ class ProxmoxVmUuidHelperTest < ActiveSupport::TestCase
24
+ include ProxmoxVmUuidHelper
25
+
26
+ describe 'extract_vmid' do
27
+ setup { Fog.mock! }
28
+ teardown { Fog.unmock! }
29
+
30
+ it '#uuid=1_100 returns 100' do
31
+ assert_equal '100', extract_vmid('1_100')
32
+ end
33
+ it '#uuid=pve_100 returns ' do
34
+ assert_equal '', extract_vmid('pve_100')
35
+ end
36
+ end
37
+ end
38
+ end
@@ -28,7 +28,7 @@ module ForemanFogProxmox
28
28
  before do
29
29
  @cr = FactoryBot.build_stubbed(:proxmox_cr)
30
30
  @args = { :name => 'name' }
31
- @image_id = 100
31
+ @image_id = @cr.id.to_s + '_' + 100.to_s
32
32
  @vmid = 101
33
33
  @image = mock('vm')
34
34
  @image.expects(:clone)
@@ -38,13 +38,13 @@ module ForemanFogProxmox
38
38
  it 'clones server from image' do
39
39
  @clone.expects(:update).with(:name => 'name')
40
40
  @clone.stubs(:container?).returns(false)
41
- @cr.stubs(:find_vm_by_uuid).with(@vmid).returns(@clone)
41
+ @cr.stubs(:find_vm_by_uuid).with(@cr.id.to_s + '_' + @vmid.to_s).returns(@clone)
42
42
  @cr.clone_from_image(@image_id, @args, @vmid)
43
43
  end
44
44
  it 'clones container from image' do
45
45
  @clone.stubs(:container?).returns(true)
46
46
  @clone.expects(:update).with(:hostname => 'name')
47
- @cr.stubs(:find_vm_by_uuid).with(@vmid).returns(@clone)
47
+ @cr.stubs(:find_vm_by_uuid).with(@cr.id.to_s + '_' + @vmid.to_s).returns(@clone)
48
48
  @cr.clone_from_image(@image_id, @args, @vmid)
49
49
  end
50
50
  end
@@ -48,7 +48,7 @@ module ForemanFogProxmox
48
48
 
49
49
  it 'sets server compute id with identifier, ip and ip6 and mac adress' do
50
50
  ip = '192.168.56.100'
51
- mac_address = '36:25:8C:53:0C:50'
51
+ mac_address = '36:25:8c:53:0c:50'
52
52
  ip6 = Array.new(4) { format('%<x>s', x: rand(16**4)) }.join(':') + '::1'
53
53
  physical_nic = FactoryBot.build(:nic_base_empty, :identifier => 'net0', :ip => ip, :ip6 => ip6, :mac => mac_address)
54
54
  host = FactoryBot.build(
@@ -117,7 +117,7 @@ module ForemanFogProxmox
117
117
 
118
118
  it 'sets container compute id with identifier, ip DHCP, mac adress and firewall' do
119
119
  ip = '192.168.56.100'
120
- mac_address = '36:25:8C:53:0C:50'
120
+ mac_address = '36:25:8c:53:0c:50'
121
121
  ip6 = '2001:0:1234::c1c0:abcd:876'
122
122
  firewall = '1'
123
123
  compute_attributes = { 'dhcp' => '1', 'ip6' => ip6, 'firewall' => firewall }
@@ -35,14 +35,14 @@ 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('100').nil?
38
+ assert cr.find_vm_by_uuid('1_100').nil?
39
39
  end
40
40
 
41
41
  it 'raises RecordNotFound when the compute raises error' do
42
42
  exception = Fog::Errors::Error.new
43
43
  cr = mock_node_servers(ForemanFogProxmox::Proxmox.new, servers_raising_exception(exception))
44
44
  assert_raises ActiveRecord::RecordNotFound do
45
- cr.find_vm_by_uuid('100')
45
+ cr.find_vm_by_uuid('1_100')
46
46
  end
47
47
  end
48
48
 
@@ -61,7 +61,7 @@ module ForemanFogProxmox
61
61
  empty_servers, empty_servers, # node1
62
62
  servers, empty_servers # node2
63
63
  )
64
- assert_equal vm, cr.find_vm_by_uuid(args[:vmid])
64
+ assert_equal vm, cr.find_vm_by_uuid('1_' + args[:vmid])
65
65
  end
66
66
  end
67
67
  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.13.0
4
+ version: 0.13.4
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-02-23 00:00:00.000000000 Z
12
+ date: 2021-07-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: deface
@@ -100,11 +100,13 @@ files:
100
100
  - app/assets/javascripts/foreman_fog_proxmox/proxmox_volume.js
101
101
  - app/assets/javascripts/foreman_fog_proxmox/proxmox_volume_cdrom.js
102
102
  - app/assets/javascripts/foreman_fog_proxmox/proxmox_volume_cloudinit.js
103
+ - app/controllers/concerns/foreman_fog_proxmox/compute_resources_vms_controller.rb
103
104
  - app/controllers/concerns/foreman_fog_proxmox/controller/parameters/compute_resource.rb
104
105
  - app/controllers/foreman_fog_proxmox/compute_resources_controller.rb
105
106
  - app/helpers/node_dashboard_helper.rb
106
107
  - app/helpers/proxmox_compute_controllers_helper.rb
107
108
  - app/helpers/proxmox_compute_resources_helper.rb
109
+ - app/helpers/proxmox_compute_resources_vms_helper.rb
108
110
  - app/helpers/proxmox_compute_selectors_helper.rb
109
111
  - app/helpers/proxmox_form_helper.rb
110
112
  - app/helpers/proxmox_storages_helper.rb
@@ -114,12 +116,15 @@ files:
114
116
  - app/helpers/proxmox_vm_helper.rb
115
117
  - app/helpers/proxmox_vm_interfaces_helper.rb
116
118
  - app/helpers/proxmox_vm_os_template_helper.rb
119
+ - app/helpers/proxmox_vm_uuid_helper.rb
117
120
  - app/helpers/proxmox_vm_volumes_helper.rb
118
121
  - app/models/concerns/fog_extensions/proxmox/disk.rb
119
122
  - app/models/concerns/fog_extensions/proxmox/interface.rb
120
123
  - app/models/concerns/fog_extensions/proxmox/node.rb
121
124
  - app/models/concerns/fog_extensions/proxmox/server.rb
122
125
  - app/models/concerns/fog_extensions/proxmox/server_config.rb
126
+ - app/models/concerns/host_ext/proxmox/associator.rb
127
+ - app/models/concerns/host_ext/proxmox/for_vm.rb
123
128
  - app/models/concerns/host_ext/proxmox/interfaces.rb
124
129
  - app/models/concerns/orchestration/proxmox/compute.rb
125
130
  - app/models/foreman_fog_proxmox/options_select.rb
@@ -145,6 +150,7 @@ files:
145
150
  - app/overrides/compute_resources_vms/form/add_vm_type_to_volumes_edit.rb
146
151
  - app/overrides/compute_resources_vms/form/add_vm_type_to_volumes_new_volume.rb
147
152
  - app/overrides/compute_resources_vms/form/remove_new_vm_from_removable_layout.rb
153
+ - app/services/concerns/foreman_fog_proxmox/compute_resource_host_associator.rb
148
154
  - app/services/foreman_fog_proxmox/node_dashboard/data.rb
149
155
  - app/views/api/v2/compute_resources/proxmox.json.rabl
150
156
  - app/views/compute_resources/form/_proxmox.html.erb
@@ -178,6 +184,7 @@ files:
178
184
  - app/views/dashboard/_foreman_fog_proxmox_widget.erb
179
185
  - app/views/images/form/_proxmox.html.erb
180
186
  - config/routes.rb
187
+ - db/migrate/20210312105013_update_proxmox_uuid_host.rb
181
188
  - lib/foreman_fog_proxmox.rb
182
189
  - lib/foreman_fog_proxmox/engine.rb
183
190
  - lib/foreman_fog_proxmox/hash_collection.rb
@@ -199,6 +206,7 @@ files:
199
206
  - test/unit/foreman_fog_proxmox/helpers/proxmox_container_helper_test.rb
200
207
  - test/unit/foreman_fog_proxmox/helpers/proxmox_server_helper_test.rb
201
208
  - test/unit/foreman_fog_proxmox/helpers/proxmox_vm_helper_test.rb
209
+ - test/unit/foreman_fog_proxmox/helpers/proxmox_vm_uuid_helper_test.rb
202
210
  - test/unit/foreman_fog_proxmox/helpers/proxmox_vm_volumes_helper_test.rb
203
211
  - test/unit/foreman_fog_proxmox/proxmox_compute_attributes_test.rb
204
212
  - test/unit/foreman_fog_proxmox/proxmox_images_test.rb
@@ -234,7 +242,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
234
242
  - !ruby/object:Gem::Version
235
243
  version: '0'
236
244
  requirements: []
237
- rubygems_version: 3.2.3
245
+ rubygems_version: 3.2.22
238
246
  signing_key:
239
247
  specification_version: 4
240
248
  summary: Foreman plugin that adds Proxmox VE compute resource using fog-proxmox
@@ -248,6 +256,7 @@ test_files:
248
256
  - test/unit/foreman_fog_proxmox/helpers/proxmox_container_helper_test.rb
249
257
  - test/unit/foreman_fog_proxmox/helpers/proxmox_server_helper_test.rb
250
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
251
260
  - test/unit/foreman_fog_proxmox/helpers/proxmox_vm_volumes_helper_test.rb
252
261
  - test/unit/foreman_fog_proxmox/proxmox_compute_attributes_test.rb
253
262
  - test/unit/foreman_fog_proxmox/proxmox_images_test.rb