foreman_fog_proxmox 0.11.1 → 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of foreman_fog_proxmox might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +12 -3
- data/app/assets/javascripts/foreman_fog_proxmox/proxmox_compute_resource.js +24 -2
- data/app/assets/javascripts/foreman_fog_proxmox/proxmox_vm.js +124 -52
- data/app/assets/javascripts/foreman_fog_proxmox/proxmox_vm_server.js +0 -48
- data/app/assets/javascripts/foreman_fog_proxmox/proxmox_volume.js +39 -0
- data/app/assets/javascripts/foreman_fog_proxmox/proxmox_volume_cdrom.js +63 -0
- data/app/assets/javascripts/foreman_fog_proxmox/proxmox_volume_cloudinit.js +25 -0
- data/app/controllers/concerns/foreman_fog_proxmox/controller/parameters/compute_resource.rb +1 -1
- data/app/helpers/proxmox_compute_controllers_helper.rb +39 -0
- data/app/helpers/proxmox_compute_resources_helper.rb +49 -0
- data/app/helpers/proxmox_compute_selectors_helper.rb +11 -44
- data/app/helpers/proxmox_form_helper.rb +12 -4
- data/app/{models/concerns/fog_extensions/proxmox/volume.rb → helpers/proxmox_storages_helper.rb} +5 -8
- data/app/{models/foreman_fog_proxmox/proxmox_token_expiration.rb → helpers/proxmox_vm_cdrom_helper.rb} +15 -10
- data/app/helpers/proxmox_vm_cloudinit_helper.rb +43 -0
- data/app/helpers/proxmox_vm_config_helper.rb +159 -0
- data/app/helpers/proxmox_vm_helper.rb +24 -70
- data/app/helpers/proxmox_vm_interfaces_helper.rb +85 -0
- data/app/helpers/proxmox_vm_os_template_helper.rb +47 -0
- data/app/helpers/proxmox_vm_volumes_helper.rb +105 -0
- data/app/models/concerns/fog_extensions/proxmox/disk.rb +17 -2
- data/app/models/concerns/fog_extensions/proxmox/interface.rb +19 -4
- data/app/models/concerns/fog_extensions/proxmox/server.rb +8 -3
- data/app/models/concerns/fog_extensions/proxmox/server_config.rb +8 -30
- data/app/models/concerns/host_ext/proxmox/interfaces.rb +7 -2
- data/app/models/concerns/orchestration/proxmox/compute.rb +1 -0
- data/app/models/foreman_fog_proxmox/proxmox.rb +58 -15
- data/app/models/foreman_fog_proxmox/proxmox_compute_attributes.rb +20 -12
- data/app/models/foreman_fog_proxmox/proxmox_connection.rb +14 -9
- data/app/models/foreman_fog_proxmox/proxmox_images.rb +2 -1
- data/app/models/foreman_fog_proxmox/proxmox_interfaces.rb +53 -28
- data/app/models/foreman_fog_proxmox/proxmox_operating_systems.rb +1 -1
- data/app/models/foreman_fog_proxmox/proxmox_version.rb +7 -2
- data/app/models/foreman_fog_proxmox/proxmox_vm_commands.rb +19 -30
- data/app/models/foreman_fog_proxmox/proxmox_vm_new.rb +108 -94
- data/app/models/foreman_fog_proxmox/proxmox_vm_queries.rb +2 -1
- data/app/models/foreman_fog_proxmox/proxmox_volumes.rb +79 -22
- data/app/views/compute_resources/form/_proxmox.html.erb +23 -10
- data/app/views/compute_resources/show/_proxmox.html.erb +6 -6
- data/app/views/compute_resources_vms/form/proxmox/_add_vm_type_to_nic_provider_specific_form.html.erb +4 -2
- data/app/views/compute_resources_vms/form/proxmox/_add_vm_type_to_volumes_edit.html.erb +46 -29
- data/app/views/compute_resources_vms/form/proxmox/_base.html.erb +3 -3
- data/app/views/compute_resources_vms/form/proxmox/_removable_layout.html.erb +2 -1
- data/app/views/compute_resources_vms/form/proxmox/container/_network.html.erb +8 -7
- data/app/views/compute_resources_vms/form/proxmox/server/_advanced.html.erb +0 -2
- data/app/views/compute_resources_vms/form/proxmox/server/_config.html.erb +16 -14
- data/app/views/compute_resources_vms/form/proxmox/server/_network.html.erb +2 -2
- data/app/views/compute_resources_vms/form/proxmox/server/_volume_cdrom.html.erb +34 -0
- data/app/views/compute_resources_vms/form/proxmox/server/_volume_cloud_init.html.erb +29 -0
- data/app/views/compute_resources_vms/form/proxmox/server/{_volume.html.erb → _volume_hard_disk.html.erb} +7 -3
- data/app/views/compute_resources_vms/show/_proxmox.html.erb +2 -0
- data/lib/foreman_fog_proxmox/engine.rb +9 -10
- data/lib/foreman_fog_proxmox/hash_collection.rb +69 -0
- data/lib/foreman_fog_proxmox/version.rb +1 -1
- data/lib/tasks/foreman_fog_proxmox_tasks.rake +0 -3
- data/test/factories/foreman_fog_proxmox/proxmox_container_mock_factory.rb +20 -8
- data/test/factories/foreman_fog_proxmox/proxmox_node_mock_factory.rb +5 -5
- data/test/factories/foreman_fog_proxmox/proxmox_server_mock_factory.rb +17 -7
- data/test/factories/proxmox_factory.rb +4 -4
- data/test/functional/compute_resources_controller_test.rb +4 -4
- data/test/unit/foreman_fog_proxmox/helpers/proxmox_container_helper_test.rb +49 -29
- data/test/unit/foreman_fog_proxmox/helpers/proxmox_server_helper_test.rb +53 -30
- data/test/unit/foreman_fog_proxmox/helpers/proxmox_vm_helper_test.rb +22 -20
- data/test/unit/foreman_fog_proxmox/helpers/proxmox_vm_volumes_helper_test.rb +50 -0
- data/test/unit/foreman_fog_proxmox/proxmox_compute_attributes_test.rb +12 -5
- data/test/unit/foreman_fog_proxmox/proxmox_interfaces_test.rb +38 -10
- data/test/unit/foreman_fog_proxmox/proxmox_version_test.rb +10 -10
- data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_container_test.rb +34 -24
- data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_create_test.rb +21 -7
- data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_cdrom_test.rb +181 -0
- data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_cloudinit_test.rb +131 -0
- data/test/unit/foreman_fog_proxmox/{proxmox_vm_commands_server_update_volumes_test.rb → proxmox_vm_commands_server_update_hard_disk_test.rb} +45 -19
- data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_test.rb +21 -21
- data/test/unit/foreman_fog_proxmox/proxmox_vm_new_test.rb +3 -3
- metadata +44 -27
- data/app/helpers/proxmox_container_helper.rb +0 -163
- data/app/helpers/proxmox_server_helper.rb +0 -155
@@ -44,9 +44,9 @@ module ForemanFogProxmox
|
|
44
44
|
vm.stubs(:container?).returns(false)
|
45
45
|
vm.stubs(:templated?).returns(false)
|
46
46
|
vm.stubs(:type).returns('qemu')
|
47
|
-
vm.stubs(:node_id).returns('
|
47
|
+
vm.stubs(:node_id).returns('proxmox')
|
48
48
|
@cr.stubs(:find_vm_by_uuid).returns(vm)
|
49
|
-
attr = { 'templated' => '0', 'node_id' => '
|
49
|
+
attr = { 'templated' => '0', 'node_id' => 'proxmox2' }
|
50
50
|
vm.expects(:migrate)
|
51
51
|
@cr.save_vm(uuid, attr)
|
52
52
|
end
|
@@ -60,10 +60,10 @@ module ForemanFogProxmox
|
|
60
60
|
vm.stubs(:container?).returns(false)
|
61
61
|
vm.stubs(:templated?).returns(false)
|
62
62
|
vm.stubs(:type).returns('qemu')
|
63
|
-
vm.stubs(:node_id).returns('
|
63
|
+
vm.stubs(:node_id).returns('proxmox')
|
64
64
|
@cr.stubs(:find_vm_by_uuid).returns(vm)
|
65
|
-
attr = { 'templated' => '0', 'node_id' => '
|
66
|
-
@cr.stubs(:
|
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')
|
67
67
|
expected_attr = { :cores => '1', :cpulimit => '1' }.with_indifferent_access
|
68
68
|
vm.expects(:update, expected_attr)
|
69
69
|
@cr.save_vm(uuid, attr)
|
@@ -97,11 +97,11 @@ module ForemanFogProxmox
|
|
97
97
|
vm.stubs(:config).returns(config)
|
98
98
|
vm.stubs(:container?).returns(false)
|
99
99
|
vm.stubs(:type).returns('qemu')
|
100
|
-
vm.stubs(:node_id).returns('
|
100
|
+
vm.stubs(:node_id).returns('proxmox')
|
101
101
|
@cr.stubs(:find_vm_by_uuid).returns(vm)
|
102
102
|
new_attributes = {
|
103
103
|
'templated' => '0',
|
104
|
-
'node_id' => '
|
104
|
+
'node_id' => 'proxmox',
|
105
105
|
'config_attributes' => {
|
106
106
|
'cores' => '1',
|
107
107
|
'cpulimit' => '1'
|
@@ -113,9 +113,9 @@ module ForemanFogProxmox
|
|
113
113
|
}
|
114
114
|
}
|
115
115
|
}.with_indifferent_access
|
116
|
-
@cr.stubs(:
|
116
|
+
@cr.stubs(:parse_typed_vm).returns(
|
117
117
|
'vmid' => '100',
|
118
|
-
'node_id' => '
|
118
|
+
'node_id' => 'proxmox',
|
119
119
|
'type' => 'qemu',
|
120
120
|
'cores' => '1',
|
121
121
|
'cpulimit' => '1',
|
@@ -136,7 +136,7 @@ module ForemanFogProxmox
|
|
136
136
|
vm.stubs(:config).returns(config)
|
137
137
|
vm.stubs(:container?).returns(false)
|
138
138
|
vm.stubs(:type).returns('qemu')
|
139
|
-
vm.stubs(:node_id).returns('
|
139
|
+
vm.stubs(:node_id).returns('proxmox')
|
140
140
|
vm.stubs(:vmid).returns(uuid)
|
141
141
|
@cr.stubs(:find_vm_by_uuid).returns(vm)
|
142
142
|
identity_client = mock('identity_client')
|
@@ -154,9 +154,9 @@ module ForemanFogProxmox
|
|
154
154
|
pools.expects(:get).with('pool2').returns(pool2)
|
155
155
|
identity_client.stubs(:pools).returns(pools)
|
156
156
|
@cr.stubs(:identity_client).returns(identity_client)
|
157
|
-
attr = { 'templated' => '0', 'node_id' => '
|
158
|
-
@cr.stubs(:
|
159
|
-
vm.expects(:update).with({ 'node_id' => '
|
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)
|
160
160
|
@cr.save_vm(uuid, attr)
|
161
161
|
end
|
162
162
|
|
@@ -169,7 +169,7 @@ module ForemanFogProxmox
|
|
169
169
|
vm.stubs(:config).returns(config)
|
170
170
|
vm.stubs(:container?).returns(false)
|
171
171
|
vm.stubs(:type).returns('qemu')
|
172
|
-
vm.stubs(:node_id).returns('
|
172
|
+
vm.stubs(:node_id).returns('proxmox')
|
173
173
|
vm.stubs(:vmid).returns(uuid)
|
174
174
|
@cr.stubs(:find_vm_by_uuid).returns(vm)
|
175
175
|
identity_client = mock('identity_client')
|
@@ -183,9 +183,9 @@ module ForemanFogProxmox
|
|
183
183
|
pools.expects(:get).with('').returns(nil)
|
184
184
|
identity_client.stubs(:pools).returns(pools)
|
185
185
|
@cr.stubs(:identity_client).returns(identity_client)
|
186
|
-
attr = { 'templated' => '0', 'node_id' => '
|
187
|
-
@cr.stubs(:
|
188
|
-
vm.expects(:update).with({ 'node_id' => '
|
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)
|
189
189
|
@cr.save_vm(uuid, attr)
|
190
190
|
end
|
191
191
|
|
@@ -198,7 +198,7 @@ module ForemanFogProxmox
|
|
198
198
|
vm.stubs(:config).returns(config)
|
199
199
|
vm.stubs(:container?).returns(false)
|
200
200
|
vm.stubs(:type).returns('qemu')
|
201
|
-
vm.stubs(:node_id).returns('
|
201
|
+
vm.stubs(:node_id).returns('proxmox')
|
202
202
|
vm.stubs(:vmid).returns(uuid)
|
203
203
|
@cr.stubs(:find_vm_by_uuid).returns(vm)
|
204
204
|
identity_client = mock('identity_client')
|
@@ -212,9 +212,9 @@ module ForemanFogProxmox
|
|
212
212
|
pools.expects(:get).with('').returns(nil)
|
213
213
|
identity_client.stubs(:pools).returns(pools)
|
214
214
|
@cr.stubs(:identity_client).returns(identity_client)
|
215
|
-
attr = { 'templated' => '0', 'node_id' => '
|
216
|
-
@cr.stubs(:
|
217
|
-
vm.expects(:update).with({ 'node_id' => '
|
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)
|
218
218
|
@cr.save_vm(uuid, attr)
|
219
219
|
end
|
220
220
|
end
|
@@ -43,7 +43,7 @@ module ForemanFogProxmox
|
|
43
43
|
config = mock('config')
|
44
44
|
config.stubs(:inspect).returns('config')
|
45
45
|
vm.stubs(:config).returns(config)
|
46
|
-
@cr.stubs(:
|
46
|
+
@cr.stubs(:new_typed_vm).with(attr, 'qemu').returns(vm)
|
47
47
|
assert_equal vm, @cr.new_vm(attr)
|
48
48
|
end
|
49
49
|
|
@@ -53,7 +53,7 @@ module ForemanFogProxmox
|
|
53
53
|
config = mock('config')
|
54
54
|
config.stubs(:inspect).returns('config')
|
55
55
|
vm.stubs(:config).returns(config)
|
56
|
-
@cr.stubs(:
|
56
|
+
@cr.stubs(:new_typed_vm).with(attr, 'qemu').returns(vm)
|
57
57
|
assert_equal vm, @cr.new_vm(attr)
|
58
58
|
end
|
59
59
|
|
@@ -63,7 +63,7 @@ module ForemanFogProxmox
|
|
63
63
|
config = mock('config')
|
64
64
|
config.stubs(:inspect).returns('config')
|
65
65
|
vm.stubs(:config).returns(config)
|
66
|
-
@cr.stubs(:
|
66
|
+
@cr.stubs(:new_typed_vm).with(attr, 'lxc').returns(vm)
|
67
67
|
assert_equal vm, @cr.new_vm(attr)
|
68
68
|
end
|
69
69
|
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.
|
4
|
+
version: 0.13.0
|
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:
|
12
|
+
date: 2021-02-23 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.
|
34
|
+
version: '0.14'
|
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.
|
41
|
+
version: '0.14'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: rdoc
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -97,20 +97,29 @@ files:
|
|
97
97
|
- app/assets/javascripts/foreman_fog_proxmox/proxmox_vm.js
|
98
98
|
- app/assets/javascripts/foreman_fog_proxmox/proxmox_vm_container.js
|
99
99
|
- app/assets/javascripts/foreman_fog_proxmox/proxmox_vm_server.js
|
100
|
+
- app/assets/javascripts/foreman_fog_proxmox/proxmox_volume.js
|
101
|
+
- app/assets/javascripts/foreman_fog_proxmox/proxmox_volume_cdrom.js
|
102
|
+
- app/assets/javascripts/foreman_fog_proxmox/proxmox_volume_cloudinit.js
|
100
103
|
- app/controllers/concerns/foreman_fog_proxmox/controller/parameters/compute_resource.rb
|
101
104
|
- app/controllers/foreman_fog_proxmox/compute_resources_controller.rb
|
102
105
|
- app/helpers/node_dashboard_helper.rb
|
106
|
+
- app/helpers/proxmox_compute_controllers_helper.rb
|
107
|
+
- app/helpers/proxmox_compute_resources_helper.rb
|
103
108
|
- app/helpers/proxmox_compute_selectors_helper.rb
|
104
|
-
- app/helpers/proxmox_container_helper.rb
|
105
109
|
- app/helpers/proxmox_form_helper.rb
|
106
|
-
- app/helpers/
|
110
|
+
- app/helpers/proxmox_storages_helper.rb
|
111
|
+
- app/helpers/proxmox_vm_cdrom_helper.rb
|
112
|
+
- app/helpers/proxmox_vm_cloudinit_helper.rb
|
113
|
+
- app/helpers/proxmox_vm_config_helper.rb
|
107
114
|
- app/helpers/proxmox_vm_helper.rb
|
115
|
+
- app/helpers/proxmox_vm_interfaces_helper.rb
|
116
|
+
- app/helpers/proxmox_vm_os_template_helper.rb
|
117
|
+
- app/helpers/proxmox_vm_volumes_helper.rb
|
108
118
|
- app/models/concerns/fog_extensions/proxmox/disk.rb
|
109
119
|
- app/models/concerns/fog_extensions/proxmox/interface.rb
|
110
120
|
- app/models/concerns/fog_extensions/proxmox/node.rb
|
111
121
|
- app/models/concerns/fog_extensions/proxmox/server.rb
|
112
122
|
- app/models/concerns/fog_extensions/proxmox/server_config.rb
|
113
|
-
- app/models/concerns/fog_extensions/proxmox/volume.rb
|
114
123
|
- app/models/concerns/host_ext/proxmox/interfaces.rb
|
115
124
|
- app/models/concerns/orchestration/proxmox/compute.rb
|
116
125
|
- app/models/foreman_fog_proxmox/options_select.rb
|
@@ -122,7 +131,6 @@ files:
|
|
122
131
|
- app/models/foreman_fog_proxmox/proxmox_interfaces.rb
|
123
132
|
- app/models/foreman_fog_proxmox/proxmox_operating_systems.rb
|
124
133
|
- app/models/foreman_fog_proxmox/proxmox_pools.rb
|
125
|
-
- app/models/foreman_fog_proxmox/proxmox_token_expiration.rb
|
126
134
|
- app/models/foreman_fog_proxmox/proxmox_version.rb
|
127
135
|
- app/models/foreman_fog_proxmox/proxmox_vm_commands.rb
|
128
136
|
- app/models/foreman_fog_proxmox/proxmox_vm_new.rb
|
@@ -162,7 +170,9 @@ files:
|
|
162
170
|
- app/views/compute_resources_vms/form/proxmox/server/_advanced.html.erb
|
163
171
|
- app/views/compute_resources_vms/form/proxmox/server/_config.html.erb
|
164
172
|
- app/views/compute_resources_vms/form/proxmox/server/_network.html.erb
|
165
|
-
- app/views/compute_resources_vms/form/proxmox/server/
|
173
|
+
- app/views/compute_resources_vms/form/proxmox/server/_volume_cdrom.html.erb
|
174
|
+
- app/views/compute_resources_vms/form/proxmox/server/_volume_cloud_init.html.erb
|
175
|
+
- app/views/compute_resources_vms/form/proxmox/server/_volume_hard_disk.html.erb
|
166
176
|
- app/views/compute_resources_vms/index/_proxmox.html.erb
|
167
177
|
- app/views/compute_resources_vms/show/_proxmox.html.erb
|
168
178
|
- app/views/dashboard/_foreman_fog_proxmox_widget.erb
|
@@ -170,6 +180,7 @@ files:
|
|
170
180
|
- config/routes.rb
|
171
181
|
- lib/foreman_fog_proxmox.rb
|
172
182
|
- lib/foreman_fog_proxmox/engine.rb
|
183
|
+
- lib/foreman_fog_proxmox/hash_collection.rb
|
173
184
|
- lib/foreman_fog_proxmox/semver.rb
|
174
185
|
- lib/foreman_fog_proxmox/value.rb
|
175
186
|
- lib/foreman_fog_proxmox/version.rb
|
@@ -188,6 +199,7 @@ files:
|
|
188
199
|
- test/unit/foreman_fog_proxmox/helpers/proxmox_container_helper_test.rb
|
189
200
|
- test/unit/foreman_fog_proxmox/helpers/proxmox_server_helper_test.rb
|
190
201
|
- test/unit/foreman_fog_proxmox/helpers/proxmox_vm_helper_test.rb
|
202
|
+
- test/unit/foreman_fog_proxmox/helpers/proxmox_vm_volumes_helper_test.rb
|
191
203
|
- test/unit/foreman_fog_proxmox/proxmox_compute_attributes_test.rb
|
192
204
|
- test/unit/foreman_fog_proxmox/proxmox_images_test.rb
|
193
205
|
- test/unit/foreman_fog_proxmox/proxmox_interfaces_test.rb
|
@@ -195,8 +207,10 @@ files:
|
|
195
207
|
- test/unit/foreman_fog_proxmox/proxmox_version_test.rb
|
196
208
|
- test/unit/foreman_fog_proxmox/proxmox_vm_commands_container_test.rb
|
197
209
|
- test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_create_test.rb
|
210
|
+
- test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_cdrom_test.rb
|
211
|
+
- test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_cloudinit_test.rb
|
212
|
+
- test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_hard_disk_test.rb
|
198
213
|
- test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_test.rb
|
199
|
-
- test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_volumes_test.rb
|
200
214
|
- test/unit/foreman_fog_proxmox/proxmox_vm_commands_test.rb
|
201
215
|
- test/unit/foreman_fog_proxmox/proxmox_vm_new_test.rb
|
202
216
|
- test/unit/foreman_fog_proxmox/proxmox_vm_queries_test.rb
|
@@ -220,30 +234,33 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
220
234
|
- !ruby/object:Gem::Version
|
221
235
|
version: '0'
|
222
236
|
requirements: []
|
223
|
-
rubygems_version: 3.
|
237
|
+
rubygems_version: 3.2.3
|
224
238
|
signing_key:
|
225
239
|
specification_version: 4
|
226
240
|
summary: Foreman plugin that adds Proxmox VE compute resource using fog-proxmox
|
227
241
|
test_files:
|
242
|
+
- test/factories/foreman_fog_proxmox/proxmox_container_mock_factory.rb
|
243
|
+
- test/factories/foreman_fog_proxmox/proxmox_node_mock_factory.rb
|
244
|
+
- test/factories/foreman_fog_proxmox/proxmox_server_mock_factory.rb
|
245
|
+
- test/factories/proxmox_factory.rb
|
228
246
|
- test/functional/compute_resources_controller_test.rb
|
229
|
-
- test/
|
230
|
-
- test/unit/foreman_fog_proxmox/proxmox_vm_new_test.rb
|
231
|
-
- test/unit/foreman_fog_proxmox/proxmox_version_test.rb
|
232
|
-
- test/unit/foreman_fog_proxmox/helpers/proxmox_vm_helper_test.rb
|
233
|
-
- test/unit/foreman_fog_proxmox/helpers/proxmox_server_helper_test.rb
|
247
|
+
- test/test_plugin_helper.rb
|
234
248
|
- test/unit/foreman_fog_proxmox/helpers/proxmox_container_helper_test.rb
|
249
|
+
- test/unit/foreman_fog_proxmox/helpers/proxmox_server_helper_test.rb
|
250
|
+
- test/unit/foreman_fog_proxmox/helpers/proxmox_vm_helper_test.rb
|
251
|
+
- test/unit/foreman_fog_proxmox/helpers/proxmox_vm_volumes_helper_test.rb
|
235
252
|
- test/unit/foreman_fog_proxmox/proxmox_compute_attributes_test.rb
|
236
|
-
- test/unit/foreman_fog_proxmox/
|
237
|
-
- test/unit/foreman_fog_proxmox/proxmox_vm_queries_test.rb
|
238
|
-
- test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_test.rb
|
253
|
+
- test/unit/foreman_fog_proxmox/proxmox_images_test.rb
|
239
254
|
- test/unit/foreman_fog_proxmox/proxmox_interfaces_test.rb
|
255
|
+
- test/unit/foreman_fog_proxmox/proxmox_test.rb
|
256
|
+
- test/unit/foreman_fog_proxmox/proxmox_version_test.rb
|
257
|
+
- test/unit/foreman_fog_proxmox/proxmox_vm_commands_container_test.rb
|
258
|
+
- test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_create_test.rb
|
259
|
+
- test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_cdrom_test.rb
|
260
|
+
- test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_cloudinit_test.rb
|
261
|
+
- test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_hard_disk_test.rb
|
262
|
+
- test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_test.rb
|
240
263
|
- test/unit/foreman_fog_proxmox/proxmox_vm_commands_test.rb
|
241
|
-
- test/unit/foreman_fog_proxmox/
|
264
|
+
- test/unit/foreman_fog_proxmox/proxmox_vm_new_test.rb
|
265
|
+
- test/unit/foreman_fog_proxmox/proxmox_vm_queries_test.rb
|
242
266
|
- test/unit/foreman_fog_proxmox/semver_test.rb
|
243
|
-
- test/unit/foreman_fog_proxmox/proxmox_vm_commands_container_test.rb
|
244
|
-
- test/unit/foreman_fog_proxmox/proxmox_test.rb
|
245
|
-
- test/factories/proxmox_factory.rb
|
246
|
-
- test/factories/foreman_fog_proxmox/proxmox_server_mock_factory.rb
|
247
|
-
- test/factories/foreman_fog_proxmox/proxmox_node_mock_factory.rb
|
248
|
-
- test/factories/foreman_fog_proxmox/proxmox_container_mock_factory.rb
|
249
|
-
- test/test_plugin_helper.rb
|
@@ -1,163 +0,0 @@
|
|
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 'fog/proxmox/helpers/disk_helper'
|
21
|
-
require 'fog/proxmox/helpers/nic_helper'
|
22
|
-
require 'foreman_fog_proxmox/value'
|
23
|
-
|
24
|
-
module ProxmoxContainerHelper
|
25
|
-
def config_keys
|
26
|
-
general_a = ['node_id', 'name', 'type', 'config_attributes', 'volumes_attributes', 'interfaces_attributes']
|
27
|
-
general_a += ['firmware_type', 'provision_method', 'container_volumes', 'server_volumes', 'start_after_create']
|
28
|
-
keys = { general: general_a }
|
29
|
-
keys.store(:main, ['name', 'type', 'node_id', 'vmid', 'interfaces', 'mount_points', 'disks'])
|
30
|
-
keys.store(:cpu, ['arch', 'cpulimit', 'cpuunits', 'cores'])
|
31
|
-
keys.store(:memory, ['memory', 'swap'])
|
32
|
-
keys
|
33
|
-
end
|
34
|
-
|
35
|
-
def ostemplate_keys
|
36
|
-
['ostemplate', 'ostemplate_storage', 'ostemplate_file']
|
37
|
-
end
|
38
|
-
|
39
|
-
def parse_ostemplate_without_keys(args)
|
40
|
-
parse_container_ostemplate(args.select { |key, _value| ostemplate_keys.include? key })
|
41
|
-
end
|
42
|
-
|
43
|
-
def config_general_or_ostemplate_key?(key)
|
44
|
-
config_keys[:general].include?(key) || ostemplate_keys.include?(key)
|
45
|
-
end
|
46
|
-
|
47
|
-
def parse_container_vm(args)
|
48
|
-
logger.debug("parse_container_vm args=#{args}")
|
49
|
-
args = ActiveSupport::HashWithIndifferentAccess.new(args)
|
50
|
-
return {} unless args
|
51
|
-
return {} if args.empty?
|
52
|
-
return {} unless args['type'] == 'lxc'
|
53
|
-
|
54
|
-
config = args['config_attributes']
|
55
|
-
config ||= args.reject { |key, _value| config_keys[:main].include? key }
|
56
|
-
ostemplate = parse_ostemplate_without_keys(args)
|
57
|
-
ostemplate = parse_ostemplate_without_keys(config) unless ostemplate[:ostemplate]
|
58
|
-
volumes = parse_container_volumes(args['volumes_attributes'])
|
59
|
-
cpu = parse_container_cpu(config.select { |key, _value| config_keys[:cpu].include? key })
|
60
|
-
memory = parse_container_memory(config.select { |key, _value| config_keys[:memory].include? key })
|
61
|
-
interfaces_attributes = args['interfaces_attributes']
|
62
|
-
interfaces_to_add, interfaces_to_delete = parse_container_interfaces(interfaces_attributes)
|
63
|
-
logger.debug("config_keys[:general]: #{config_keys[:general]}")
|
64
|
-
parsed_vm = args.reject { |key, value| config_general_or_ostemplate_key?(key) || ForemanFogProxmox::Value.empty?(value) }
|
65
|
-
parsed_config = config.reject { |key, value| config_keys.include?(key) || ForemanFogProxmox::Value.empty?(value) }
|
66
|
-
logger.debug("parse_container_config(): #{parsed_config}")
|
67
|
-
parsed_vm = parsed_vm.merge(parsed_config).merge(cpu).merge(memory).merge(ostemplate)
|
68
|
-
interfaces_to_add.each { |interface| parsed_vm = parsed_vm.merge(interface) }
|
69
|
-
parsed_vm = parsed_vm.merge(delete: interfaces_to_delete.join(',')) unless interfaces_to_delete.empty?
|
70
|
-
volumes.each { |volume| parsed_vm = parsed_vm.merge(volume) }
|
71
|
-
logger.debug("parse_container_vm(): #{parsed_vm}")
|
72
|
-
parsed_vm
|
73
|
-
end
|
74
|
-
|
75
|
-
def parse_container_memory(args)
|
76
|
-
memory = {}
|
77
|
-
args.delete_if { |_key, value| ForemanFogProxmox::Value.empty?(value) }
|
78
|
-
memory.store(:memory, args['memory'].to_i) if args['memory']
|
79
|
-
memory.store(:swap, args['swap'].to_i) if args['swap']
|
80
|
-
logger.debug("parse_container_memory(): #{memory}")
|
81
|
-
memory
|
82
|
-
end
|
83
|
-
|
84
|
-
def parse_container_cpu(args)
|
85
|
-
cpu = {}
|
86
|
-
args.delete_if { |_key, value| ForemanFogProxmox::Value.empty?(value) }
|
87
|
-
cpu.store(:arch, args['arch'].to_s) if args['arch']
|
88
|
-
cpu.store(:cpulimit, args['cpulimit'].to_i) if args['cpulimit']
|
89
|
-
cpu.store(:cpuunits, args['cpuunits'].to_i) if args['cpuunits']
|
90
|
-
cpu.store(:cores, args['cores'].to_i) if args['cores']
|
91
|
-
logger.debug("parse_container_cpu(): #{cpu}")
|
92
|
-
cpu
|
93
|
-
end
|
94
|
-
|
95
|
-
def parse_container_ostemplate(args)
|
96
|
-
ostemplate = args['ostemplate']
|
97
|
-
ostemplate_file = args['ostemplate_file']
|
98
|
-
ostemplate ||= ostemplate_file
|
99
|
-
ostemplate_storage = args['ostemplate_storage']
|
100
|
-
ostemplate_storage, ostemplate_file, _size = Fog::Proxmox::DiskHelper.extract_storage_volid_size(ostemplate) unless ForemanFogProxmox::Value.empty?(ostemplate)
|
101
|
-
parsed_ostemplate = { ostemplate: ostemplate, ostemplate_file: ostemplate_file, ostemplate_storage: ostemplate_storage }
|
102
|
-
logger.debug("parse_container_ostemplate(): #{parsed_ostemplate}")
|
103
|
-
parsed_ostemplate
|
104
|
-
end
|
105
|
-
|
106
|
-
def parse_container_volume(args)
|
107
|
-
disk = {}
|
108
|
-
id = args['id']
|
109
|
-
id = "mp#{args['device']}" if args.key?('device')
|
110
|
-
logger.debug("parse_container_volume() args=#{args}")
|
111
|
-
return args if ForemanFogProxmox::Value.empty?(id) || Fog::Proxmox::DiskHelper.server_disk?(id)
|
112
|
-
|
113
|
-
args.delete_if { |_key, value| ForemanFogProxmox::Value.empty?(value) }
|
114
|
-
disk.store(:id, id)
|
115
|
-
disk.store(:volid, args['volid'])
|
116
|
-
disk.store(:storage, args['storage'].to_s)
|
117
|
-
disk.store(:size, args['size'].to_i)
|
118
|
-
options = args.reject { |key, _value| ['id', 'volid', 'device', 'storage', 'size', '_delete'].include? key }
|
119
|
-
disk.store(:options, options)
|
120
|
-
logger.debug("parse_container_volume(): disk=#{disk}")
|
121
|
-
Fog::Proxmox::DiskHelper.flatten(disk)
|
122
|
-
end
|
123
|
-
|
124
|
-
def parse_container_volumes(args)
|
125
|
-
logger.debug("parse_container_volumes() args=#{args}")
|
126
|
-
volumes = []
|
127
|
-
args&.each_value { |value| volumes.push(parse_container_volume(value)) }
|
128
|
-
logger.debug("parse_container_volumes(): volumes=#{volumes}")
|
129
|
-
volumes
|
130
|
-
end
|
131
|
-
|
132
|
-
def parse_container_interfaces(interfaces_attributes)
|
133
|
-
interfaces_to_add = []
|
134
|
-
interfaces_to_delete = []
|
135
|
-
interfaces_attributes&.each_value { |value| add_container_interface(value, interfaces_to_delete, interfaces_to_add) }
|
136
|
-
logger.debug("parse_container_interfaces(): interfaces_to_add=#{interfaces_to_add}, interfaces_to_delete=#{interfaces_to_delete}")
|
137
|
-
[interfaces_to_add, interfaces_to_delete]
|
138
|
-
end
|
139
|
-
|
140
|
-
def add_container_interface(interface_attributes, interfaces_to_delete, interfaces_to_add)
|
141
|
-
interface_attributes.delete_if { |_key, value| ForemanFogProxmox::Value.empty?(value) }
|
142
|
-
nic = {}
|
143
|
-
id = interface_attributes['id']
|
144
|
-
logger.debug("parse_container_interface(): id=#{id}")
|
145
|
-
delete = interface_attributes['_delete'].to_i == 1
|
146
|
-
if delete
|
147
|
-
interfaces_to_delete.push(id.to_s)
|
148
|
-
else
|
149
|
-
nic.store(:id, id)
|
150
|
-
nic.store(:hwaddr, interface_attributes['macaddr']) if interface_attributes['macaddr']
|
151
|
-
nic.store(:name, interface_attributes['name'].to_s)
|
152
|
-
nic.store(:bridge, interface_attributes['bridge'].to_s) if interface_attributes['bridge']
|
153
|
-
nic.store(:ip, interface_attributes['ip'].to_s) if interface_attributes['ip']
|
154
|
-
nic.store(:ip6, interface_attributes['ip6'].to_s) if interface_attributes['ip6']
|
155
|
-
nic.store(:gw, interface_attributes['gw'].to_s) if interface_attributes['gw']
|
156
|
-
nic.store(:gw6, interface_attributes['gw6'].to_s) if interface_attributes['gw6']
|
157
|
-
nic.store(:rate, interface_attributes['rate'].to_i) if interface_attributes['rate']
|
158
|
-
nic.store(:tag, interface_attributes['tag'].to_i) if interface_attributes['tag']
|
159
|
-
logger.debug("parse_container_interface(): add nic=#{nic}")
|
160
|
-
interfaces_to_add.push(Fog::Proxmox::NicHelper.flatten(nic))
|
161
|
-
end
|
162
|
-
end
|
163
|
-
end
|