foreman_fog_proxmox 0.9.4 → 0.10.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/app/assets/javascripts/foreman_fog_proxmox/proxmox_vm.js +89 -0
- data/app/assets/javascripts/foreman_fog_proxmox/proxmox_vm_container.js +5 -41
- data/app/assets/javascripts/foreman_fog_proxmox/proxmox_vm_server.js +2 -21
- data/app/controllers/concerns/foreman_fog_proxmox/controller/parameters/compute_resource.rb +1 -1
- data/app/controllers/foreman_fog_proxmox/compute_resources_controller.rb +46 -6
- data/app/helpers/proxmox_container_helper.rb +3 -1
- data/app/helpers/proxmox_server_helper.rb +2 -1
- data/app/helpers/proxmox_vm_helper.rb +19 -0
- data/app/models/concerns/fog_extensions/proxmox/node.rb +0 -5
- data/app/models/concerns/fog_extensions/proxmox/server.rb +1 -1
- data/app/models/foreman_fog_proxmox/proxmox.rb +9 -13
- data/app/models/foreman_fog_proxmox/proxmox_images.rb +10 -5
- data/app/models/foreman_fog_proxmox/proxmox_vm_commands.rb +6 -2
- data/app/models/foreman_fog_proxmox/proxmox_vm_new.rb +22 -6
- data/app/models/foreman_fog_proxmox/proxmox_vm_queries.rb +9 -7
- data/app/models/foreman_fog_proxmox/vms.rb +37 -0
- data/app/overrides/compute_resources_vms/form/add_vm_type_node_to_new_form.rb +25 -0
- data/app/views/compute_resources/form/_proxmox.html.erb +0 -2
- data/app/views/compute_resources/show/_proxmox.html.erb +4 -0
- data/app/views/compute_resources_vms/form/proxmox/_add_vm_type_node_to_new_form.html.erb +24 -0
- data/app/views/compute_resources_vms/form/proxmox/_add_vm_type_to_networks_form.html.erb +2 -1
- data/app/views/compute_resources_vms/form/proxmox/_add_vm_type_to_networks_new_childs_form.html.erb +2 -1
- data/app/views/compute_resources_vms/form/proxmox/_add_vm_type_to_nic_provider_specific_form.html.erb +3 -2
- data/app/views/compute_resources_vms/form/proxmox/_add_vm_type_to_volumes_edit.html.erb +6 -5
- data/app/views/compute_resources_vms/form/proxmox/_base.html.erb +3 -3
- data/app/views/compute_resources_vms/form/proxmox/_general.html.erb +2 -1
- data/app/views/compute_resources_vms/form/proxmox/_network.html.erb +2 -2
- data/app/views/compute_resources_vms/form/proxmox/container/_extended.html.erb +3 -2
- data/app/views/compute_resources_vms/form/proxmox/container/_network.html.erb +4 -3
- data/app/views/compute_resources_vms/form/proxmox/container/_volume_mp.html.erb +1 -1
- data/app/views/compute_resources_vms/form/proxmox/container/_volume_rootfs.html.erb +1 -1
- data/app/views/compute_resources_vms/form/proxmox/server/_config.html.erb +1 -1
- data/app/views/compute_resources_vms/form/proxmox/server/_network.html.erb +4 -3
- data/app/views/compute_resources_vms/form/proxmox/server/_volume.html.erb +1 -1
- data/app/views/compute_resources_vms/index/_proxmox.html.erb +4 -2
- data/config/routes.rb +7 -2
- data/lib/foreman_fog_proxmox/engine.rb +4 -0
- data/lib/foreman_fog_proxmox/version.rb +1 -1
- data/locale/en/foreman_fog_proxmox.edit.po +508 -0
- data/locale/en/foreman_fog_proxmox.po +34 -7
- data/locale/en/foreman_fog_proxmox.po.time_stamp +0 -0
- data/locale/foreman_fog_proxmox.pot +112 -70
- data/locale/fr/foreman_fog_proxmox.edit.po +508 -0
- data/locale/fr/foreman_fog_proxmox.po +39 -12
- data/locale/fr/foreman_fog_proxmox.po.time_stamp +0 -0
- data/test/factories/foreman_fog_proxmox/proxmox_node_mock_factory.rb +28 -8
- data/test/factories/proxmox_factory.rb +0 -1
- data/test/functional/compute_resources_controller_test.rb +16 -4
- data/test/unit/foreman_fog_proxmox/helpers/proxmox_server_helper_test.rb +1 -0
- data/test/unit/foreman_fog_proxmox/proxmox_test.rb +0 -1
- data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_container_test.rb +33 -8
- data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_create_test.rb +2 -2
- data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_test.rb +22 -2
- data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_volumes_test.rb +18 -6
- metadata +9 -2
@@ -17,8 +17,8 @@ msgstr ""
|
|
17
17
|
"Plural-Forms: nplurals=2; plural=n>1;\n"
|
18
18
|
"\n"
|
19
19
|
|
20
|
-
msgid "
|
21
|
-
msgstr "
|
20
|
+
msgid "%<s>s console is not supported at this time"
|
21
|
+
msgstr ""
|
22
22
|
|
23
23
|
msgid "Add Volume"
|
24
24
|
msgstr "Ajouter un volume"
|
@@ -47,6 +47,12 @@ msgstr ""
|
|
47
47
|
msgid "CDROM"
|
48
48
|
msgstr ""
|
49
49
|
|
50
|
+
msgid "CIDR IPv4 prefix"
|
51
|
+
msgstr ""
|
52
|
+
|
53
|
+
msgid "CIDR IPv6 prefix"
|
54
|
+
msgstr ""
|
55
|
+
|
50
56
|
msgid "CPU"
|
51
57
|
msgstr ""
|
52
58
|
|
@@ -62,15 +68,15 @@ msgstr ""
|
|
62
68
|
msgid "Cache"
|
63
69
|
msgstr ""
|
64
70
|
|
65
|
-
msgid "Caps lock ON"
|
66
|
-
msgstr "Touches verrouillées"
|
67
|
-
|
68
71
|
msgid "Card"
|
69
72
|
msgstr "Carte"
|
70
73
|
|
71
74
|
msgid "Change the password"
|
72
75
|
msgstr "Changer le mot de passe"
|
73
76
|
|
77
|
+
msgid "Cluster nodes"
|
78
|
+
msgstr "Noeuds de la ferme"
|
79
|
+
|
74
80
|
msgid "Controller"
|
75
81
|
msgstr "Contrôleur"
|
76
82
|
|
@@ -80,6 +86,12 @@ msgstr "Coeurs"
|
|
80
86
|
msgid "Create image?"
|
81
87
|
msgstr "Créer image?"
|
82
88
|
|
89
|
+
msgid "DHCP IPv4"
|
90
|
+
msgstr ""
|
91
|
+
|
92
|
+
msgid "DHCP IPv6"
|
93
|
+
msgstr ""
|
94
|
+
|
83
95
|
msgid "DNS"
|
84
96
|
msgstr ""
|
85
97
|
|
@@ -110,6 +122,15 @@ msgstr "Activer/désactiver la virtualisation matérielle de KVM"
|
|
110
122
|
msgid "Extended"
|
111
123
|
msgstr "Etendu"
|
112
124
|
|
125
|
+
msgid "Failed retrieving proxmox compute client caused by %<e>s"
|
126
|
+
msgstr ""
|
127
|
+
|
128
|
+
msgid "Failed retrieving proxmox identity client caused by %<e>s"
|
129
|
+
msgstr ""
|
130
|
+
|
131
|
+
msgid "Failed retrieving proxmox network client caused by %<e>s"
|
132
|
+
msgstr ""
|
133
|
+
|
113
134
|
msgid "Failed retrieving proxmox server vm by vmid=%<vmid>s"
|
114
135
|
msgstr ""
|
115
136
|
|
@@ -131,6 +152,12 @@ msgstr ""
|
|
131
152
|
msgid "ForemanFogProxmox plugin adds Proxmox VE compute resource to Foreman using fog-proxmox gem."
|
132
153
|
msgstr "Le plugin ForemanFogProxmox ajoute la ressource de calcul Proxmox VE à foreman en utilisant le gem fog-proxmox"
|
133
154
|
|
155
|
+
msgid "Gateway IPv4"
|
156
|
+
msgstr ""
|
157
|
+
|
158
|
+
msgid "Gateway IPv6"
|
159
|
+
msgstr ""
|
160
|
+
|
134
161
|
msgid "General"
|
135
162
|
msgstr "Général"
|
136
163
|
|
@@ -206,7 +233,7 @@ msgid "Password to authenticate with - used for SSH finish step."
|
|
206
233
|
msgstr "Mot de passe d'authentification - utilisé dans la dernière phase avec SSH."
|
207
234
|
|
208
235
|
msgid "Path"
|
209
|
-
msgstr ""
|
236
|
+
msgstr "Chemin"
|
210
237
|
|
211
238
|
msgid "Physical"
|
212
239
|
msgstr "Physique"
|
@@ -230,7 +257,7 @@ msgid "Rate limit"
|
|
230
257
|
msgstr "Taux limite"
|
231
258
|
|
232
259
|
msgid "Renew expired token ?"
|
233
|
-
msgstr ""
|
260
|
+
msgstr "Renouveler jeton expiré?"
|
234
261
|
|
235
262
|
msgid "Root password"
|
236
263
|
msgstr "Mot de passe root"
|
@@ -256,6 +283,9 @@ msgstr ""
|
|
256
283
|
msgid "Spectre-CTRL"
|
257
284
|
msgstr ""
|
258
285
|
|
286
|
+
msgid "Start after creation?"
|
287
|
+
msgstr "Démarrer après création?"
|
288
|
+
|
259
289
|
msgid "Start at boot"
|
260
290
|
msgstr "Démarrer au boot"
|
261
291
|
|
@@ -278,13 +308,10 @@ msgid "Time"
|
|
278
308
|
msgstr "Temps"
|
279
309
|
|
280
310
|
msgid "Token expires on"
|
281
|
-
msgstr ""
|
282
|
-
|
283
|
-
msgid "Token expires on #{token_deadline}"
|
284
|
-
msgstr ""
|
311
|
+
msgstr "Jeton expire le "
|
285
312
|
|
286
313
|
msgid "Token has expired?"
|
287
|
-
msgstr ""
|
314
|
+
msgstr "Jeton expiré?"
|
288
315
|
|
289
316
|
msgid "Type"
|
290
317
|
msgstr ""
|
File without changes
|
@@ -21,26 +21,41 @@ module ForemanFogProxmox
|
|
21
21
|
module ProxmoxNodeMockFactory
|
22
22
|
def mock_node_servers(cr, servers)
|
23
23
|
node = mock('node')
|
24
|
+
nodes = mock('nodes')
|
25
|
+
node.stubs(:node).returns('pve')
|
24
26
|
node.stubs(:servers).returns(servers)
|
25
|
-
|
26
|
-
|
27
|
+
nodes.stubs(:get).returns(node)
|
28
|
+
nodes.stubs(:all).returns([node])
|
29
|
+
client = mock('client')
|
30
|
+
client.stubs(:nodes).returns(nodes)
|
31
|
+
cr.stubs(:client).returns(client)
|
27
32
|
cr
|
28
33
|
end
|
29
34
|
|
30
35
|
def mock_node_containers(cr, containers)
|
31
36
|
node = mock('node')
|
37
|
+
nodes = mock('nodes')
|
38
|
+
node.stubs(:node).returns('pve')
|
32
39
|
node.stubs(:containers).returns(containers)
|
33
|
-
|
34
|
-
|
40
|
+
nodes.stubs(:get).returns(node)
|
41
|
+
nodes.stubs(:all).returns([node])
|
42
|
+
client = mock('client')
|
43
|
+
client.stubs(:nodes).returns(nodes)
|
44
|
+
cr.stubs(:client).returns(client)
|
35
45
|
cr
|
36
46
|
end
|
37
47
|
|
38
48
|
def mock_node_servers_containers(cr, servers, containers)
|
39
49
|
node = mock('node')
|
50
|
+
node.stubs(:node).returns('pve')
|
40
51
|
node.stubs(:containers).returns(containers)
|
41
52
|
node.stubs(:servers).returns(servers)
|
42
|
-
|
43
|
-
|
53
|
+
nodes = mock('nodes')
|
54
|
+
nodes.stubs(:get).returns(node)
|
55
|
+
nodes.stubs(:all).returns([node])
|
56
|
+
client = mock('client')
|
57
|
+
client.stubs(:nodes).returns(nodes)
|
58
|
+
cr.stubs(:client).returns(client)
|
44
59
|
cr
|
45
60
|
end
|
46
61
|
|
@@ -53,8 +68,13 @@ module ForemanFogProxmox
|
|
53
68
|
node2.stubs(:node).returns('node2')
|
54
69
|
node2.stubs(:servers).returns(n2s)
|
55
70
|
node2.stubs(:containers).returns(n2c)
|
56
|
-
|
57
|
-
|
71
|
+
nodes = mock('nodes')
|
72
|
+
nodes.stubs(:get).with('pve').returns(node1)
|
73
|
+
nodes.stubs(:get).with('pve2').returns(node2)
|
74
|
+
nodes.stubs(:all).returns([node1, node2])
|
75
|
+
client = mock('client')
|
76
|
+
client.stubs(:nodes).returns(nodes)
|
77
|
+
cr.stubs(:client).returns(client)
|
58
78
|
cr
|
59
79
|
end
|
60
80
|
end
|
@@ -20,14 +20,26 @@ require 'test_plugin_helper'
|
|
20
20
|
|
21
21
|
module ForemanFogProxmox
|
22
22
|
class ComputeResourcesControllerTest < ActionController::TestCase
|
23
|
-
test 'should get isos' do
|
24
|
-
get :
|
23
|
+
test 'should get isos by node and storage' do
|
24
|
+
get :isos_by_node_and_storage, params: { :node_id => 'pve', :storage => 'local' }
|
25
25
|
assert_response :found
|
26
26
|
show_response = @response.body
|
27
27
|
assert_not show_response.empty?
|
28
28
|
end
|
29
|
-
test 'should get ostemplates' do
|
30
|
-
get :
|
29
|
+
test 'should get ostemplates by node and storage' do
|
30
|
+
get :ostemplates_by_node_and_storage, params: { :node_id => 'pve', :storage => 'local' }
|
31
|
+
assert_response :found
|
32
|
+
show_response = @response.body
|
33
|
+
assert_not show_response.empty?
|
34
|
+
end
|
35
|
+
test 'should get isos by node' do
|
36
|
+
get :isos_by_node, params: { :node_id => 'pve' }
|
37
|
+
assert_response :found
|
38
|
+
show_response = @response.body
|
39
|
+
assert_not show_response.empty?
|
40
|
+
end
|
41
|
+
test 'should get ostemplates by node' do
|
42
|
+
get :ostemplates_by_node, params: { :node_id => 'pve' }
|
31
43
|
assert_response :found
|
32
44
|
show_response = @response.body
|
33
45
|
assert_not show_response.empty?
|
@@ -35,7 +35,6 @@ module ForemanFogProxmox
|
|
35
35
|
should validate_presence_of(:url)
|
36
36
|
should validate_presence_of(:user)
|
37
37
|
should validate_presence_of(:password)
|
38
|
-
should validate_presence_of(:node_id)
|
39
38
|
should allow_value('root@pam').for(:user)
|
40
39
|
should_not allow_value('root').for(:user)
|
41
40
|
should_not allow_value('a').for(:url)
|
@@ -35,6 +35,23 @@ module ForemanFogProxmox
|
|
35
35
|
@cr = FactoryBot.build_stubbed(:proxmox_cr)
|
36
36
|
end
|
37
37
|
|
38
|
+
it 'migrates container from one node to another in the cluster' do
|
39
|
+
uuid = '100'
|
40
|
+
config = mock('config')
|
41
|
+
config.stubs(:attributes).returns(:cores => '')
|
42
|
+
vm = mock('vm')
|
43
|
+
vm.stubs(:config).returns(config)
|
44
|
+
vm.stubs(:container?).returns(true)
|
45
|
+
vm.stubs(:type).returns('lxc')
|
46
|
+
vm.stubs(:node_id).returns('pve')
|
47
|
+
@cr.stubs(:find_vm_by_uuid).returns(vm)
|
48
|
+
attr = { 'templated' => '0', 'node_id' => 'pve', 'config_attributes' => { 'cores' => '1', 'cpulimit' => '1', 'onboot' => '0' } }.with_indifferent_access
|
49
|
+
@cr.stubs(:parse_container_vm).returns('vmid' => '100', 'node_id' => 'pve2', 'type' => 'lxc', 'cores' => '1', 'cpulimit' => '1')
|
50
|
+
expected_attr = { :cores => '1', :cpulimit => '1' }
|
51
|
+
vm.expects(:update, expected_attr)
|
52
|
+
@cr.save_vm(uuid, attr)
|
53
|
+
end
|
54
|
+
|
38
55
|
it 'saves modified container config' do
|
39
56
|
uuid = '100'
|
40
57
|
config = mock('config')
|
@@ -43,9 +60,10 @@ module ForemanFogProxmox
|
|
43
60
|
vm.stubs(:config).returns(config)
|
44
61
|
vm.stubs(:container?).returns(true)
|
45
62
|
vm.stubs(:type).returns('lxc')
|
63
|
+
vm.stubs(:node_id).returns('pve')
|
46
64
|
@cr.stubs(:find_vm_by_uuid).returns(vm)
|
47
|
-
attr = { 'templated' => '0', 'config_attributes' => { 'cores' => '1', 'cpulimit' => '1', 'onboot' => '0' } }.with_indifferent_access
|
48
|
-
@cr.stubs(:parse_container_vm).returns('vmid' => '100', 'type' => 'lxc', 'cores' => '1', 'cpulimit' => '1')
|
65
|
+
attr = { 'templated' => '0', 'node_id' => 'pve', 'config_attributes' => { 'cores' => '1', 'cpulimit' => '1', 'onboot' => '0' } }.with_indifferent_access
|
66
|
+
@cr.stubs(:parse_container_vm).returns('vmid' => '100', 'node_id' => 'pve', 'type' => 'lxc', 'cores' => '1', 'cpulimit' => '1')
|
49
67
|
expected_attr = { :cores => '1', :cpulimit => '1' }
|
50
68
|
vm.expects(:update, expected_attr)
|
51
69
|
@cr.save_vm(uuid, attr)
|
@@ -66,9 +84,11 @@ module ForemanFogProxmox
|
|
66
84
|
vm.stubs(:config).returns(config)
|
67
85
|
vm.stubs(:container?).returns(true)
|
68
86
|
vm.stubs(:type).returns('lxc')
|
87
|
+
vm.stubs(:node_id).returns('pve')
|
69
88
|
@cr.stubs(:find_vm_by_uuid).returns(vm)
|
70
89
|
new_attributes = {
|
71
90
|
'templated' => '0',
|
91
|
+
'node_id' => 'pve',
|
72
92
|
'config_attributes' => {
|
73
93
|
'cores' => '1',
|
74
94
|
'cpulimit' => '1'
|
@@ -85,7 +105,7 @@ module ForemanFogProxmox
|
|
85
105
|
}
|
86
106
|
}
|
87
107
|
}.with_indifferent_access
|
88
|
-
@cr.stubs(:parse_container_vm).returns('vmid' => '100', 'type' => 'lxc', 'cores' => '1', 'cpulimit' => '1')
|
108
|
+
@cr.stubs(:parse_container_vm).returns('vmid' => '100', 'node_id' => 'pve', 'type' => 'lxc', 'cores' => '1', 'cpulimit' => '1')
|
89
109
|
expected_config_attr = { :cores => '1', :cpulimit => '1' }
|
90
110
|
expected_volume_attr =
|
91
111
|
[
|
@@ -118,10 +138,12 @@ module ForemanFogProxmox
|
|
118
138
|
vm.stubs(:config).returns(config)
|
119
139
|
vm.stubs(:container?).returns(true)
|
120
140
|
vm.stubs(:type).returns('lxc')
|
141
|
+
vm.stubs(:node_id).returns('pve')
|
121
142
|
@cr.stubs(:find_vm_by_uuid).returns(vm)
|
122
143
|
new_attributes =
|
123
144
|
{
|
124
145
|
'templated' => '0',
|
146
|
+
'node_id' => 'pve',
|
125
147
|
'config_attributes' => {
|
126
148
|
'cores' => '1',
|
127
149
|
'cpulimit' => '1',
|
@@ -141,6 +163,7 @@ module ForemanFogProxmox
|
|
141
163
|
}.with_indifferent_access
|
142
164
|
@cr.stubs(:parse_container_vm).returns(
|
143
165
|
'vmid' => '100',
|
166
|
+
'node_id' => 'pve',
|
144
167
|
'type' => 'lxc',
|
145
168
|
'cores' => '1',
|
146
169
|
'cpulimit' => '1'
|
@@ -169,9 +192,11 @@ module ForemanFogProxmox
|
|
169
192
|
vm.stubs(:config).returns(config)
|
170
193
|
vm.stubs(:container?).returns(true)
|
171
194
|
vm.stubs(:type).returns('lxc')
|
195
|
+
vm.stubs(:node_id).returns('pve')
|
172
196
|
@cr.stubs(:find_vm_by_uuid).returns(vm)
|
173
197
|
new_attributes = {
|
174
198
|
'templated' => '0',
|
199
|
+
'node_id' => 'pve',
|
175
200
|
'config_attributes' => {
|
176
201
|
'cores' => '1',
|
177
202
|
'cpulimit' => '1'
|
@@ -189,7 +214,7 @@ module ForemanFogProxmox
|
|
189
214
|
}
|
190
215
|
}
|
191
216
|
}.with_indifferent_access
|
192
|
-
@cr.stubs(:parse_server_vm).returns('vmid' => '100', 'type' => 'qemu', 'cores' => '1', 'cpulimit' => '1')
|
217
|
+
@cr.stubs(:parse_server_vm).returns('vmid' => '100', 'node_id' => 'pve', 'type' => 'qemu', 'cores' => '1', 'cpulimit' => '1')
|
193
218
|
expected_config_attr = { :cores => '1', :cpulimit => '1' }
|
194
219
|
expected_volume_attr = { :id => 'mp0', :volid => 'local-lvm:vm-100-disk-0', :size => 1_073_741_824 }, { :mp => '/opt/toto' }
|
195
220
|
vm.expects(:attach, expected_volume_attr)
|
@@ -200,11 +225,11 @@ module ForemanFogProxmox
|
|
200
225
|
|
201
226
|
describe 'create_vm' do
|
202
227
|
it 'creates container without bootstart' do
|
203
|
-
args = { vmid: '100', type: 'lxc',
|
228
|
+
args = { vmid: '100', type: 'lxc', node_id: 'pve', start_after_create: '0' }
|
204
229
|
servers = mock('servers')
|
205
230
|
servers.stubs(:id_valid?).returns(true)
|
206
231
|
containers = mock('containers')
|
207
|
-
containers.stubs(:create).with(vmid: 100, type: 'lxc',
|
232
|
+
containers.stubs(:create).with(vmid: 100, type: 'lxc', node_id: 'pve', start_after_create: '0')
|
208
233
|
cr = mock_node_servers_containers(ForemanFogProxmox::Proxmox.new, servers, containers)
|
209
234
|
cr.stubs(:convert_sizes).with(args)
|
210
235
|
cr.stubs(:parse_container_vm).with(args).returns(args)
|
@@ -214,12 +239,12 @@ module ForemanFogProxmox
|
|
214
239
|
end
|
215
240
|
|
216
241
|
it 'creates container with bootstart' do
|
217
|
-
args = { vmid: '100', type: 'lxc',
|
242
|
+
args = { vmid: '100', type: 'lxc', node_id: 'pve', start_after_create: '1' }
|
218
243
|
servers = mock('servers')
|
219
244
|
servers.stubs(:id_valid?).returns(true)
|
220
245
|
containers = mock('containers')
|
221
246
|
vm = mock('vm')
|
222
|
-
containers.stubs(:create).with(vmid: 100, type: 'lxc',
|
247
|
+
containers.stubs(:create).with(vmid: 100, type: 'lxc', node_id: 'pve', start_after_create: '1').returns(vm)
|
223
248
|
cr = mock_node_servers_containers(ForemanFogProxmox::Proxmox.new, servers, containers)
|
224
249
|
cr.stubs(:convert_sizes).with(args)
|
225
250
|
cr.stubs(:parse_container_vm).with(args).returns(args)
|
@@ -43,7 +43,7 @@ module ForemanFogProxmox
|
|
43
43
|
end
|
44
44
|
|
45
45
|
it 'creates server without bootstart' do
|
46
|
-
args = { vmid: '100', type: 'qemu',
|
46
|
+
args = { vmid: '100', type: 'qemu', node_id: 'pve', start_after_create: '0' }
|
47
47
|
servers = mock('servers')
|
48
48
|
servers.stubs(:id_valid?).returns(true)
|
49
49
|
cr = mock_node_servers(ForemanFogProxmox::Proxmox.new, servers)
|
@@ -56,7 +56,7 @@ module ForemanFogProxmox
|
|
56
56
|
end
|
57
57
|
|
58
58
|
it 'creates server with bootstart' do
|
59
|
-
args = { vmid: '100', type: 'qemu',
|
59
|
+
args = { vmid: '100', type: 'qemu', node_id: 'pve', start_after_create: '1' }
|
60
60
|
servers = mock('servers')
|
61
61
|
servers.stubs(:id_valid?).returns(true)
|
62
62
|
cr = mock_node_servers(ForemanFogProxmox::Proxmox.new, servers)
|
@@ -35,6 +35,22 @@ module ForemanFogProxmox
|
|
35
35
|
@cr = FactoryBot.build_stubbed(:proxmox_cr)
|
36
36
|
end
|
37
37
|
|
38
|
+
it 'migrates server from node to another one in the cluster' do
|
39
|
+
uuid = '100'
|
40
|
+
config = mock('config')
|
41
|
+
config.stubs(:attributes).returns(:cores => '')
|
42
|
+
vm = mock('vm')
|
43
|
+
vm.stubs(:config).returns(config)
|
44
|
+
vm.stubs(:container?).returns(false)
|
45
|
+
vm.stubs(:templated?).returns(false)
|
46
|
+
vm.stubs(:type).returns('qemu')
|
47
|
+
vm.stubs(:node_id).returns('pve')
|
48
|
+
@cr.stubs(:find_vm_by_uuid).returns(vm)
|
49
|
+
attr = { 'templated' => '0', 'node_id' => 'pve2' }
|
50
|
+
vm.expects(:migrate)
|
51
|
+
@cr.save_vm(uuid, attr)
|
52
|
+
end
|
53
|
+
|
38
54
|
it 'saves modified server config with same volumes' do
|
39
55
|
uuid = '100'
|
40
56
|
config = mock('config')
|
@@ -44,9 +60,10 @@ module ForemanFogProxmox
|
|
44
60
|
vm.stubs(:container?).returns(false)
|
45
61
|
vm.stubs(:templated?).returns(false)
|
46
62
|
vm.stubs(:type).returns('qemu')
|
63
|
+
vm.stubs(:node_id).returns('pve')
|
47
64
|
@cr.stubs(:find_vm_by_uuid).returns(vm)
|
48
|
-
attr = { 'templated' => '0', 'config_attributes' => { 'cores' => '1', 'cpulimit' => '1', 'onboot' => '0' } }.with_indifferent_access
|
49
|
-
@cr.stubs(:parse_server_vm).returns('vmid' => '100', 'type' => 'qemu', 'cores' => '1', 'cpulimit' => '1', 'onboot' => '0')
|
65
|
+
attr = { 'templated' => '0', 'node_id' => 'pve', 'config_attributes' => { 'cores' => '1', 'cpulimit' => '1', 'onboot' => '0' } }.with_indifferent_access
|
66
|
+
@cr.stubs(:parse_server_vm).returns('vmid' => '100', 'node_id' => 'pve', 'type' => 'qemu', 'cores' => '1', 'cpulimit' => '1', 'onboot' => '0')
|
50
67
|
expected_attr = { :cores => '1', :cpulimit => '1' }.with_indifferent_access
|
51
68
|
vm.expects(:update, expected_attr)
|
52
69
|
@cr.save_vm(uuid, attr)
|
@@ -80,9 +97,11 @@ module ForemanFogProxmox
|
|
80
97
|
vm.stubs(:config).returns(config)
|
81
98
|
vm.stubs(:container?).returns(false)
|
82
99
|
vm.stubs(:type).returns('qemu')
|
100
|
+
vm.stubs(:node_id).returns('pve')
|
83
101
|
@cr.stubs(:find_vm_by_uuid).returns(vm)
|
84
102
|
new_attributes = {
|
85
103
|
'templated' => '0',
|
104
|
+
'node_id' => 'pve',
|
86
105
|
'config_attributes' => {
|
87
106
|
'cores' => '1',
|
88
107
|
'cpulimit' => '1'
|
@@ -96,6 +115,7 @@ module ForemanFogProxmox
|
|
96
115
|
}.with_indifferent_access
|
97
116
|
@cr.stubs(:parse_server_vm).returns(
|
98
117
|
'vmid' => '100',
|
118
|
+
'node_id' => 'pve',
|
99
119
|
'type' => 'qemu',
|
100
120
|
'cores' => '1',
|
101
121
|
'cpulimit' => '1',
|
@@ -50,9 +50,11 @@ module ForemanFogProxmox
|
|
50
50
|
vm.stubs(:config).returns(config)
|
51
51
|
vm.stubs(:container?).returns(false)
|
52
52
|
vm.stubs(:type).returns('qemu')
|
53
|
+
vm.stubs(:node_id).returns('pve')
|
53
54
|
@cr.stubs(:find_vm_by_uuid).returns(vm)
|
54
55
|
new_attributes = {
|
55
56
|
'templated' => '0',
|
57
|
+
'node_id' => 'pve',
|
56
58
|
'config_attributes' => {
|
57
59
|
'cores' => '1',
|
58
60
|
'cpulimit' => '1'
|
@@ -69,7 +71,7 @@ module ForemanFogProxmox
|
|
69
71
|
}
|
70
72
|
}
|
71
73
|
}.with_indifferent_access
|
72
|
-
@cr.stubs(:parse_server_vm).returns('vmid' => '100', 'type' => 'qemu', 'cores' => '1', 'cpulimit' => '1', 'onboot' => '0')
|
74
|
+
@cr.stubs(:parse_server_vm).returns('vmid' => '100', 'node_id' => 'pve', 'type' => 'qemu', 'cores' => '1', 'cpulimit' => '1', 'onboot' => '0')
|
73
75
|
expected_config_attr = { :cores => '1', :cpulimit => '1' }
|
74
76
|
expected_volume_attr = { id: 'scsi0', storage: 'local:lvm', size: (2_147_483_648 / GIGA).to_s }
|
75
77
|
vm.expects(:attach, expected_volume_attr)
|
@@ -93,9 +95,11 @@ module ForemanFogProxmox
|
|
93
95
|
vm.stubs(:container?).returns(false)
|
94
96
|
vm.stubs(:templated?).returns(false)
|
95
97
|
vm.stubs(:type).returns('qemu')
|
98
|
+
vm.stubs(:node_id).returns('pve')
|
96
99
|
@cr.stubs(:find_vm_by_uuid).returns(vm)
|
97
100
|
new_attributes = {
|
98
101
|
'templated' => '0',
|
102
|
+
'node_id' => 'pve',
|
99
103
|
'config_attributes' => {
|
100
104
|
'cores' => '1',
|
101
105
|
'cpulimit' => '1'
|
@@ -113,7 +117,7 @@ module ForemanFogProxmox
|
|
113
117
|
}
|
114
118
|
}
|
115
119
|
}.with_indifferent_access
|
116
|
-
@cr.stubs(:parse_server_vm).returns('vmid' => '100', 'type' => 'qemu', 'cores' => '1', 'cpulimit' => '1', 'config_attributes' => { 'onboot' => '0' })
|
120
|
+
@cr.stubs(:parse_server_vm).returns('vmid' => '100', 'node_id' => 'pve', 'type' => 'qemu', 'cores' => '1', 'cpulimit' => '1', 'config_attributes' => { 'onboot' => '0' })
|
117
121
|
expected_config_attr = { :cores => '1', :cpulimit => '1' }
|
118
122
|
expected_volume_attr = 'scsi0'
|
119
123
|
vm.expects(:detach, expected_volume_attr)
|
@@ -137,9 +141,11 @@ module ForemanFogProxmox
|
|
137
141
|
vm.stubs(:container?).returns(false)
|
138
142
|
vm.stubs(:templated?).returns(false)
|
139
143
|
vm.stubs(:type).returns('qemu')
|
144
|
+
vm.stubs(:node_id).returns('pve')
|
140
145
|
@cr.stubs(:find_vm_by_uuid).returns(vm)
|
141
146
|
new_attributes = {
|
142
147
|
'templated' => '0',
|
148
|
+
'node_id' => 'pve',
|
143
149
|
'config_attributes' => {
|
144
150
|
'cores' => '1',
|
145
151
|
'cpulimit' => '1'
|
@@ -157,7 +163,7 @@ module ForemanFogProxmox
|
|
157
163
|
}
|
158
164
|
}
|
159
165
|
}.with_indifferent_access
|
160
|
-
@cr.stubs(:parse_server_vm).returns('vmid' => '100', 'type' => 'qemu', 'cores' => '1', 'cpulimit' => '1')
|
166
|
+
@cr.stubs(:parse_server_vm).returns('vmid' => '100', 'node_id' => 'pve', 'type' => 'qemu', 'cores' => '1', 'cpulimit' => '1')
|
161
167
|
expected_config_attr = { :cores => '1', :cpulimit => '1' }
|
162
168
|
expected_volume_attr = ['scsi0', '+1G']
|
163
169
|
vm.expects(:extend, expected_volume_attr)
|
@@ -179,9 +185,11 @@ module ForemanFogProxmox
|
|
179
185
|
vm.stubs(:config).returns(config)
|
180
186
|
vm.stubs(:container?).returns(false)
|
181
187
|
vm.stubs(:type).returns('qemu')
|
188
|
+
vm.stubs(:node_id).returns('pve')
|
182
189
|
@cr.stubs(:find_vm_by_uuid).returns(vm)
|
183
190
|
new_attributes = {
|
184
191
|
'templated' => '0',
|
192
|
+
'node_id' => 'pve',
|
185
193
|
'config_attributes' => {
|
186
194
|
'cores' => '1',
|
187
195
|
'cpulimit' => '1'
|
@@ -199,7 +207,7 @@ module ForemanFogProxmox
|
|
199
207
|
}
|
200
208
|
}
|
201
209
|
}.with_indifferent_access
|
202
|
-
@cr.stubs(:parse_server_vm).returns('vmid' => '100', 'type' => 'qemu', 'cores' => '1', 'cpulimit' => '1')
|
210
|
+
@cr.stubs(:parse_server_vm).returns('vmid' => '100', 'node_id' => 'pve', 'type' => 'qemu', 'cores' => '1', 'cpulimit' => '1')
|
203
211
|
err = assert_raises Foreman::Exception do
|
204
212
|
@cr.save_vm(uuid, new_attributes)
|
205
213
|
end
|
@@ -220,9 +228,11 @@ module ForemanFogProxmox
|
|
220
228
|
vm.stubs(:config).returns(config)
|
221
229
|
vm.stubs(:container?).returns(false)
|
222
230
|
vm.stubs(:type).returns('qemu')
|
231
|
+
vm.stubs(:node_id).returns('pve')
|
223
232
|
@cr.stubs(:find_vm_by_uuid).returns(vm)
|
224
233
|
new_attributes = {
|
225
234
|
'templated' => '0',
|
235
|
+
'node_id' => 'pve',
|
226
236
|
'config_attributes' => {
|
227
237
|
'cores' => '1',
|
228
238
|
'cpulimit' => '1'
|
@@ -240,7 +250,7 @@ module ForemanFogProxmox
|
|
240
250
|
}
|
241
251
|
}
|
242
252
|
}.with_indifferent_access
|
243
|
-
@cr.stubs(:parse_server_vm).returns('vmid' => '100', 'type' => 'qemu', 'cores' => '1', 'cpulimit' => '1')
|
253
|
+
@cr.stubs(:parse_server_vm).returns('vmid' => '100', 'node_id' => 'pve', 'type' => 'qemu', 'cores' => '1', 'cpulimit' => '1')
|
244
254
|
expected_config_attr = { :cores => '1', :cpulimit => '1' }
|
245
255
|
expected_volume_attr = ['scsi0', 'local-lvm2']
|
246
256
|
vm.expects(:move, expected_volume_attr)
|
@@ -264,9 +274,11 @@ module ForemanFogProxmox
|
|
264
274
|
vm.stubs(:config).returns(config)
|
265
275
|
vm.stubs(:container?).returns(false)
|
266
276
|
vm.stubs(:type).returns('qemu')
|
277
|
+
vm.stubs(:node_id).returns('pve')
|
267
278
|
@cr.stubs(:find_vm_by_uuid).returns(vm)
|
268
279
|
new_attributes = {
|
269
280
|
'templated' => '0',
|
281
|
+
'node_id' => 'pve',
|
270
282
|
'config_attributes' => {
|
271
283
|
'cores' => '1',
|
272
284
|
'cpulimit' => '1'
|
@@ -284,7 +296,7 @@ module ForemanFogProxmox
|
|
284
296
|
}
|
285
297
|
}
|
286
298
|
}.with_indifferent_access
|
287
|
-
@cr.stubs(:parse_server_vm).returns('vmid' => '100', 'type' => 'qemu', 'cores' => '1', 'cpulimit' => '1')
|
299
|
+
@cr.stubs(:parse_server_vm).returns('vmid' => '100', 'node_id' => 'pve', 'type' => 'qemu', 'cores' => '1', 'cpulimit' => '1')
|
288
300
|
expected_config_attr = { :cores => '1', :cpulimit => '1' }
|
289
301
|
expected_volume_attr = { :id => 'scsi0', :volid => 'local-lvm:vm-100-disk-0', :size => 1_073_741_824 }, { :cache => 'directsync' }
|
290
302
|
vm.expects(:attach, expected_volume_attr)
|