foreman_fog_proxmox 0.8.2 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +14 -4
- data/app/models/foreman_fog_proxmox/proxmox_images.rb +6 -3
- data/app/models/foreman_fog_proxmox/proxmox_version.rb +1 -1
- data/app/models/foreman_fog_proxmox/proxmox_volumes.rb +13 -4
- data/app/views/compute_resources_vms/form/proxmox/server/_volume.html.erb +1 -1
- data/lib/foreman_fog_proxmox/semver.rb +12 -12
- data/lib/foreman_fog_proxmox/version.rb +1 -1
- data/test/unit/foreman_fog_proxmox/proxmox_images_test.rb +52 -0
- data/test/unit/foreman_fog_proxmox/proxmox_version_test.rb +10 -4
- data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_container_test.rb +47 -13
- data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_create_test.rb +1 -11
- data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_test.rb +44 -0
- data/test/unit/foreman_fog_proxmox/semver_test.rb +22 -2
- metadata +15 -17
- data/locale/en/foreman_fog_proxmox.edit.po +0 -472
- data/locale/en/foreman_fog_proxmox.po.time_stamp +0 -0
- data/locale/fr/foreman_fog_proxmox.edit.po +0 -472
- data/locale/fr/foreman_fog_proxmox.po.time_stamp +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 88c0db5bfdca9f434f07d13fd1d18b55b4cb041d093a75e30698182f8f16d533
|
|
4
|
+
data.tar.gz: 3e9cf561af0f98223a17edbe1a7bf0489379a26eada8152d62990476bce30091
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f505da06a2573c212f4438d82fa0da3c565ca23747c03d6716ae1dafa82f4dd9aae20ddfa31994fea759ba068a1490cd0f8f38426c9de3906da7854902452eeb
|
|
7
|
+
data.tar.gz: 3c5c3d8d77c936b8368ce68c1b5ede56c9933bcded2b225976cd75b0cbf85f049a63d5015933de7261a544bcd300f628a142fe859b14faae87118fbfe4131824
|
data/README.md
CHANGED
|
@@ -10,7 +10,14 @@
|
|
|
10
10
|
|
|
11
11
|
It is intended to satisfy this [feature](http://projects.theforeman.org/issues/2186).
|
|
12
12
|
|
|
13
|
-
If you like it and need more features you can [support](.github/SUPPORT.md) it
|
|
13
|
+
If you like it and need more features you can [contribute](.github/CONTRIBUTING.md) or simply [support](.github/SUPPORT.md) it:
|
|
14
|
+
|
|
15
|
+
## Support
|
|
16
|
+
|
|
17
|
+
You can support the plugin development via the following methods:
|
|
18
|
+
|
|
19
|
+
* [Donate by PayPal](https://paypal.me/TristanRobert)
|
|
20
|
+
* [Sponsor by Github](https://github.com/sponsors/tristanrobert)
|
|
14
21
|
|
|
15
22
|
## Compatibility versions
|
|
16
23
|
|
|
@@ -18,7 +25,8 @@ If you like it and need more features you can [support](.github/SUPPORT.md) it.
|
|
|
18
25
|
|--|--|--|--|--|
|
|
19
26
|
|<0.6|<5.3|<0.6|<=1.20|>=2.3|
|
|
20
27
|
|=0.6|=5.3|=0.6|=1.21|>=2.3|
|
|
21
|
-
|<=
|
|
28
|
+
|<=0.8 |=5.4|>=0.7|>=1.22|>=2.3|
|
|
29
|
+
|>=0.9 |>=5.4|>=0.9|>=1.22|>=2.3|
|
|
22
30
|
|
|
23
31
|
## Installation
|
|
24
32
|
|
|
@@ -100,7 +108,7 @@ Redhat, CentOS or Fedora users should also [setup Selinux](https://projects.thef
|
|
|
100
108
|
|
|
101
109
|
### Prerequisites
|
|
102
110
|
|
|
103
|
-
* You need a Proxmox VE 5.4 server running.
|
|
111
|
+
* You need a Proxmox VE 5.4+ server running.
|
|
104
112
|
* You need ruby >= 2.3. You can install it with [rbenv](https://github.com/rbenv/rbenv).
|
|
105
113
|
* You also need nodejs in your dev machine to run webpack-dev-server. You can install it with [nvm](https://github.com/creationix/nvm).
|
|
106
114
|
|
|
@@ -108,7 +116,7 @@ Redhat, CentOS or Fedora users should also [setup Selinux](https://projects.thef
|
|
|
108
116
|
|
|
109
117
|
* Fork this github repo.
|
|
110
118
|
* Clone it on your local machine
|
|
111
|
-
* Install foreman v1.22 on your machine:
|
|
119
|
+
* Install foreman v1.22+ on your machine:
|
|
112
120
|
|
|
113
121
|
```shell
|
|
114
122
|
git clone https://github.com/theforeman/foreman -b develop
|
|
@@ -213,6 +221,8 @@ See details in [foreman plugin development](https://projects.theforeman.org/proj
|
|
|
213
221
|
|
|
214
222
|
## Contributing
|
|
215
223
|
|
|
224
|
+
If you like it and still want to improve it, [sponsor me](https://github.com/sponsors/tristanrobert)!
|
|
225
|
+
|
|
216
226
|
You can reach the [contributors](.github/CONTRIBUTORS.md).
|
|
217
227
|
Bug reports and pull requests are welcome on GitHub at [ForemanFogProxmox](https://github.com/theforeman/foreman_fog_proxmox).
|
|
218
228
|
|
|
@@ -44,10 +44,13 @@ module ForemanFogProxmox
|
|
|
44
44
|
|
|
45
45
|
def clone_from_image(image_id, args, vmid)
|
|
46
46
|
logger.debug(format(_('create_vm(): clone %<image_id>s in %<vmid>s'), image_id: image_id, vmid: vmid))
|
|
47
|
-
image =
|
|
47
|
+
image = find_vm_by_uuid(image_id)
|
|
48
48
|
image.clone(vmid)
|
|
49
|
-
clone =
|
|
50
|
-
|
|
49
|
+
clone = find_vm_by_uuid(vmid)
|
|
50
|
+
options = {}
|
|
51
|
+
options.store(:name, args[:name]) unless clone.container?
|
|
52
|
+
options.store(:hostname, args[:name]) if clone.container?
|
|
53
|
+
clone.update(options)
|
|
51
54
|
end
|
|
52
55
|
end
|
|
53
56
|
end
|
|
@@ -25,7 +25,7 @@ module ForemanFogProxmox
|
|
|
25
25
|
logger.debug(format(_('Proxmox compute resource version is %<version>s'), version: version))
|
|
26
26
|
raise ::Foreman::Exception, format(_('Proxmox version %<version>s is not semver suitable'), version: version) unless ForemanFogProxmox::Semver.semver?(version)
|
|
27
27
|
|
|
28
|
-
ForemanFogProxmox::Semver.to_semver(version) >= ForemanFogProxmox::Semver.to_semver('5.3.0') && ForemanFogProxmox::Semver.to_semver(version) < ForemanFogProxmox::Semver.to_semver('
|
|
28
|
+
ForemanFogProxmox::Semver.to_semver(version) >= ForemanFogProxmox::Semver.to_semver('5.3.0') && ForemanFogProxmox::Semver.to_semver(version) < ForemanFogProxmox::Semver.to_semver('6.1.0')
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
def version
|
|
@@ -29,7 +29,14 @@ module ForemanFogProxmox
|
|
|
29
29
|
vm.detach('unused' + device.to_s)
|
|
30
30
|
end
|
|
31
31
|
|
|
32
|
-
def
|
|
32
|
+
def volume_options(vm, id, volume_attributes)
|
|
33
|
+
options = {}
|
|
34
|
+
options.store(:mp, volume_attributes['mp']) if vm.container? && id != 'rootfs'
|
|
35
|
+
options.store(:cache, volume_attributes['cache']) unless vm.container?
|
|
36
|
+
options
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def update_volume(vm, id, volume_attributes)
|
|
33
40
|
disk = vm.config.disks.get(id)
|
|
34
41
|
diff_size = volume_attributes['size'].to_i - disk.size
|
|
35
42
|
raise ::Foreman::Exception, format(_('Unable to shrink %<id>s size. Proxmox allows only increasing size.'), id: id) unless diff_size >= 0
|
|
@@ -39,6 +46,9 @@ module ForemanFogProxmox
|
|
|
39
46
|
vm.extend(id, extension)
|
|
40
47
|
elsif disk.storage != volume_attributes['storage']
|
|
41
48
|
vm.move(id, volume_attributes['storage'])
|
|
49
|
+
else
|
|
50
|
+
options = volume_options(vm, id, volume_attributes)
|
|
51
|
+
vm.attach({:id => disk.id, :volid => disk.volid, :size => disk.size}, options)
|
|
42
52
|
end
|
|
43
53
|
end
|
|
44
54
|
|
|
@@ -63,8 +73,7 @@ module ForemanFogProxmox
|
|
|
63
73
|
end
|
|
64
74
|
|
|
65
75
|
def add_volume(vm, id, volume_attributes)
|
|
66
|
-
options =
|
|
67
|
-
options.store(:mp, volume_attributes['mp']) if vm.container?
|
|
76
|
+
options = volume_options(vm, id, volume_attributes)
|
|
68
77
|
disk_attributes = { id: id, storage: volume_attributes['storage'], size: (volume_attributes['size'].to_i / GIGA).to_s }
|
|
69
78
|
vm.attach(disk_attributes, options)
|
|
70
79
|
end
|
|
@@ -75,7 +84,7 @@ module ForemanFogProxmox
|
|
|
75
84
|
if volume_to_delete?(volume_attributes)
|
|
76
85
|
delete_volume(vm, id)
|
|
77
86
|
else
|
|
78
|
-
|
|
87
|
+
update_volume(vm, id, volume_attributes)
|
|
79
88
|
end
|
|
80
89
|
else
|
|
81
90
|
add_volume(vm, id, volume_attributes)
|
|
@@ -23,6 +23,6 @@ along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>. %>
|
|
|
23
23
|
<%= select_f f, :storage, compute_resource.storages, :storage, :storage, { }, :label => _('Storage'), :label_size => "col-md-2" %>
|
|
24
24
|
<%= select_f f, :controller, proxmox_controllers_map, :id, :name, { }, :label => _('Controller'), :label_size => "col-md-2", :disabled => !new_volume, :onchange => 'controllerSelected(this)' %>
|
|
25
25
|
<%= text_f f, :device, :label => _('Device'), :label_size => "col-md-2", :disabled => !new_volume, :'data-min' => 0, :'data-soft-max' => proxmox_max_device(f.object.controller), :onchange => 'deviceSelected(this)' %>
|
|
26
|
-
<%= select_f f, :cache, proxmox_caches_map, :id, :name, { }, :label => _('Cache'), :label_size => "col-md-2" %>
|
|
26
|
+
<%= select_f f, :cache, proxmox_caches_map, :id, :name, { include_blank: true }, :label => _('Cache'), :label_size => "col-md-2" %>
|
|
27
27
|
<%= byte_size_f f, :size, :class => "input-mini", :label => _("Size"), :label_size => "col-md-2" %>
|
|
28
28
|
<% end %>
|
|
@@ -42,36 +42,36 @@ module ForemanFogProxmox
|
|
|
42
42
|
def <=(other)
|
|
43
43
|
raise TypeError unless other.is_a?(SemverClass)
|
|
44
44
|
|
|
45
|
-
result = @
|
|
46
|
-
result = @
|
|
47
|
-
result = @minor
|
|
45
|
+
result = @major <= other.major
|
|
46
|
+
result = @minor <= other.minor if @major == other.major
|
|
47
|
+
result = @patch <= other.patch if @minor == other.minor && @major == other.major
|
|
48
48
|
result
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
def <(other)
|
|
52
52
|
raise TypeError unless other.is_a?(SemverClass)
|
|
53
53
|
|
|
54
|
-
result = @
|
|
55
|
-
result = @
|
|
56
|
-
result = @
|
|
54
|
+
result = @major < other.major
|
|
55
|
+
result = @minor < other.minor if @major == other.major
|
|
56
|
+
result = @patch < other.patch if @minor == other.minor && @major == other.major
|
|
57
57
|
result
|
|
58
58
|
end
|
|
59
59
|
|
|
60
60
|
def >(other)
|
|
61
61
|
raise TypeError unless other.is_a?(SemverClass)
|
|
62
62
|
|
|
63
|
-
result = @
|
|
64
|
-
result = @
|
|
65
|
-
result = @
|
|
63
|
+
result = @major > other.major
|
|
64
|
+
result = @minor > other.minor if @major == other.major
|
|
65
|
+
result = @patch > other.patch if @minor == other.minor && @major == other.major
|
|
66
66
|
result
|
|
67
67
|
end
|
|
68
68
|
|
|
69
69
|
def >=(other)
|
|
70
70
|
raise TypeError unless other.is_a?(SemverClass)
|
|
71
71
|
|
|
72
|
-
result = @
|
|
73
|
-
result = @
|
|
74
|
-
result = @
|
|
72
|
+
result = @major >= other.major
|
|
73
|
+
result = @minor >= other.minor if @major == other.major
|
|
74
|
+
result = @patch >= other.patch if @minor == other.minor && @major == other.major
|
|
75
75
|
result
|
|
76
76
|
end
|
|
77
77
|
|
|
@@ -0,0 +1,52 @@
|
|
|
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
|
+
require 'active_support/core_ext/hash/indifferent_access'
|
|
22
|
+
|
|
23
|
+
module ForemanFogProxmox
|
|
24
|
+
class ProxmoxVmCommandsServerTest < ActiveSupport::TestCase
|
|
25
|
+
include ComputeResourceTestHelpers
|
|
26
|
+
|
|
27
|
+
describe 'clone_from_image' do
|
|
28
|
+
before do
|
|
29
|
+
@cr = FactoryBot.build_stubbed(:proxmox_cr)
|
|
30
|
+
@args = {:name => 'name'}
|
|
31
|
+
@image_id = 100
|
|
32
|
+
@vmid = 101
|
|
33
|
+
@image = mock('vm')
|
|
34
|
+
@image.expects(:clone)
|
|
35
|
+
@cr.stubs(:find_vm_by_uuid).with(@image_id).returns(@image)
|
|
36
|
+
@clone = mock('vm')
|
|
37
|
+
end
|
|
38
|
+
it 'clones server from image' do
|
|
39
|
+
@clone.expects(:update).with({:name => 'name'})
|
|
40
|
+
@clone.stubs(:container?).returns(false)
|
|
41
|
+
@cr.stubs(:find_vm_by_uuid).with(@vmid).returns(@clone)
|
|
42
|
+
@cr.clone_from_image(@image_id, @args, @vmid)
|
|
43
|
+
end
|
|
44
|
+
it 'clones container from image' do
|
|
45
|
+
@clone.stubs(:container?).returns(true)
|
|
46
|
+
@clone.expects(:update).with({:hostname => 'name'})
|
|
47
|
+
@cr.stubs(:find_vm_by_uuid).with(@vmid).returns(@clone)
|
|
48
|
+
@cr.clone_from_image(@image_id, @args, @vmid)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -28,7 +28,8 @@ module ForemanFogProxmox
|
|
|
28
28
|
|
|
29
29
|
wrong_version = { version: '5.a', release: '1' }.with_indifferent_access
|
|
30
30
|
supported_version = { version: '5.4', release: '3' }.with_indifferent_access
|
|
31
|
-
|
|
31
|
+
supported_6_version = { version: '6.0', release: '1' }.with_indifferent_access
|
|
32
|
+
unsupported_version = { version: '6.2', release: '2' }.with_indifferent_access
|
|
32
33
|
|
|
33
34
|
describe 'version' do
|
|
34
35
|
before do
|
|
@@ -47,9 +48,9 @@ module ForemanFogProxmox
|
|
|
47
48
|
assert_equal '5.4.3', @cr.version
|
|
48
49
|
end
|
|
49
50
|
|
|
50
|
-
it 'returns 6.
|
|
51
|
+
it 'returns 6.2.2 with 6.2-2' do
|
|
51
52
|
@identity_client.stubs(:read_version).returns(unsupported_version)
|
|
52
|
-
assert_equal '6.
|
|
53
|
+
assert_equal '6.2.2', @cr.version
|
|
53
54
|
end
|
|
54
55
|
end
|
|
55
56
|
|
|
@@ -73,7 +74,12 @@ module ForemanFogProxmox
|
|
|
73
74
|
assert_equal true, @cr.version_suitable?
|
|
74
75
|
end
|
|
75
76
|
|
|
76
|
-
it 'is
|
|
77
|
+
it 'is true with 6.0-1' do
|
|
78
|
+
@identity_client.stubs(:read_version).returns(supported_6_version)
|
|
79
|
+
assert_equal true, @cr.version_suitable?
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
it 'is false with 6.2-2' do
|
|
77
83
|
@identity_client.stubs(:read_version).returns(unsupported_version)
|
|
78
84
|
assert_equal false, @cr.version_suitable?
|
|
79
85
|
end
|
|
@@ -151,6 +151,51 @@ module ForemanFogProxmox
|
|
|
151
151
|
vm.expects(:update, expected_config_attr)
|
|
152
152
|
@cr.save_vm(uuid, new_attributes)
|
|
153
153
|
end
|
|
154
|
+
|
|
155
|
+
it 'saves modified container config with modified volumes options' do
|
|
156
|
+
uuid = '100'
|
|
157
|
+
config = mock('config')
|
|
158
|
+
disks = mock('disks')
|
|
159
|
+
disk = mock('disk')
|
|
160
|
+
disk.stubs(:rootfs?).returns(false)
|
|
161
|
+
disk.stubs(:volid).returns('local-lvm:vm-100-disk-0')
|
|
162
|
+
disk.stubs(:id).returns('mp0')
|
|
163
|
+
disk.stubs(:size).returns(1_073_741_824)
|
|
164
|
+
disk.stubs(:storage).returns('local-lvm')
|
|
165
|
+
disks.stubs(:get).returns(disk)
|
|
166
|
+
config.stubs(:disks).returns(disks)
|
|
167
|
+
config.stubs(:attributes).returns(:cores => '')
|
|
168
|
+
vm = mock('vm')
|
|
169
|
+
vm.stubs(:config).returns(config)
|
|
170
|
+
vm.stubs(:container?).returns(true)
|
|
171
|
+
vm.stubs(:type).returns('lxc')
|
|
172
|
+
@cr.stubs(:find_vm_by_uuid).returns(vm)
|
|
173
|
+
new_attributes = {
|
|
174
|
+
'templated' => '0',
|
|
175
|
+
'config_attributes' => {
|
|
176
|
+
'cores' => '1',
|
|
177
|
+
'cpulimit' => '1'
|
|
178
|
+
},
|
|
179
|
+
'volumes_attributes' => {
|
|
180
|
+
'0' => {
|
|
181
|
+
'id' => 'mp0',
|
|
182
|
+
'_delete' => '',
|
|
183
|
+
'volid' => 'local-lvm:vm-100-disk-0',
|
|
184
|
+
'device' => '0',
|
|
185
|
+
'controller' => 'mp',
|
|
186
|
+
'storage' => 'local-lvm',
|
|
187
|
+
'size' => '1073741824',
|
|
188
|
+
'mp' => '/opt/toto'
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}.with_indifferent_access
|
|
192
|
+
@cr.stubs(:parse_server_vm).returns('vmid' => '100', 'type' => 'qemu', 'cores' => '1', 'cpulimit' => '1')
|
|
193
|
+
expected_config_attr = { :cores => '1', :cpulimit => '1' }
|
|
194
|
+
expected_volume_attr = {:id => 'mp0', :volid => 'local-lvm:vm-100-disk-0', :size => 1_073_741_824}, {:mp => '/opt/toto'}
|
|
195
|
+
vm.expects(:attach, expected_volume_attr)
|
|
196
|
+
vm.expects(:update, expected_config_attr)
|
|
197
|
+
@cr.save_vm(uuid, new_attributes)
|
|
198
|
+
end
|
|
154
199
|
end
|
|
155
200
|
|
|
156
201
|
describe 'create_vm' do
|
|
@@ -187,19 +232,8 @@ module ForemanFogProxmox
|
|
|
187
232
|
args = { vmid: '100', type: 'lxc', image_id: '999', name: 'name' }
|
|
188
233
|
servers = mock('servers')
|
|
189
234
|
servers.stubs(:id_valid?).returns(true)
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
image = mock('image')
|
|
193
|
-
clone = mock('clone')
|
|
194
|
-
image.stubs(:clone).with(100)
|
|
195
|
-
servers.stubs(:get).with(100).returns(clone)
|
|
196
|
-
servers.stubs(:get).with('999').returns(image)
|
|
197
|
-
clone.stubs(:update).with(name: 'name')
|
|
198
|
-
cr = mock_node_servers_containers(ForemanFogProxmox::Proxmox.new, servers, containers)
|
|
199
|
-
cr.stubs(:convert_sizes).with(args)
|
|
200
|
-
cr.stubs(:parse_container_vm).with(args).returns(args)
|
|
201
|
-
vm = mock('vm')
|
|
202
|
-
cr.stubs(:find_vm_by_uuid).with((args[:vmid]).to_s).returns(vm)
|
|
235
|
+
cr = mock_node_servers(ForemanFogProxmox::Proxmox.new, servers)
|
|
236
|
+
cr.expects(:clone_from_image).with('999', args, 100)
|
|
203
237
|
cr.create_vm(args)
|
|
204
238
|
end
|
|
205
239
|
end
|
|
@@ -74,17 +74,7 @@ module ForemanFogProxmox
|
|
|
74
74
|
servers = mock('servers')
|
|
75
75
|
servers.stubs(:id_valid?).returns(true)
|
|
76
76
|
cr = mock_node_servers(ForemanFogProxmox::Proxmox.new, servers)
|
|
77
|
-
cr.
|
|
78
|
-
cr.stubs(:parse_server_vm).with(args).returns(args)
|
|
79
|
-
servers.stubs(:create).with(args)
|
|
80
|
-
image = mock('image')
|
|
81
|
-
clone = mock('clone')
|
|
82
|
-
image.stubs(:clone).with(100)
|
|
83
|
-
servers.stubs(:get).with(100).returns(clone)
|
|
84
|
-
servers.stubs(:get).with('999').returns(image)
|
|
85
|
-
clone.stubs(:update).with(name: 'name')
|
|
86
|
-
vm = mock('vm')
|
|
87
|
-
cr.stubs(:find_vm_by_uuid).with((args[:vmid]).to_s).returns(vm)
|
|
77
|
+
cr.expects(:clone_from_image).with('999', args, 100)
|
|
88
78
|
cr.create_vm(args)
|
|
89
79
|
end
|
|
90
80
|
end
|
|
@@ -319,6 +319,50 @@ module ForemanFogProxmox
|
|
|
319
319
|
vm.expects(:update, expected_config_attr)
|
|
320
320
|
@cr.save_vm(uuid, new_attributes)
|
|
321
321
|
end
|
|
322
|
+
|
|
323
|
+
it 'saves modified server config with modified volumes options' do
|
|
324
|
+
uuid = '100'
|
|
325
|
+
config = mock('config')
|
|
326
|
+
disks = mock('disks')
|
|
327
|
+
disk = mock('disk')
|
|
328
|
+
disk.stubs(:size).returns(1_073_741_824)
|
|
329
|
+
disk.stubs(:storage).returns('local-lvm')
|
|
330
|
+
disk.stubs(:volid).returns('local-lvm:vm-100-disk-0')
|
|
331
|
+
disk.stubs(:id).returns('scsi0')
|
|
332
|
+
disks.stubs(:get).returns(disk)
|
|
333
|
+
config.stubs(:disks).returns(disks)
|
|
334
|
+
config.stubs(:attributes).returns(:cores => '')
|
|
335
|
+
vm = mock('vm')
|
|
336
|
+
vm.stubs(:config).returns(config)
|
|
337
|
+
vm.stubs(:container?).returns(false)
|
|
338
|
+
vm.stubs(:type).returns('qemu')
|
|
339
|
+
@cr.stubs(:find_vm_by_uuid).returns(vm)
|
|
340
|
+
new_attributes = {
|
|
341
|
+
'templated' => '0',
|
|
342
|
+
'config_attributes' => {
|
|
343
|
+
'cores' => '1',
|
|
344
|
+
'cpulimit' => '1'
|
|
345
|
+
},
|
|
346
|
+
'volumes_attributes' => {
|
|
347
|
+
'0' => {
|
|
348
|
+
'id' => 'scsi0',
|
|
349
|
+
'_delete' => '',
|
|
350
|
+
'volid' => 'local-lvm:vm-100-disk-0',
|
|
351
|
+
'device' => '0',
|
|
352
|
+
'controller' => 'scsi',
|
|
353
|
+
'storage' => 'local-lvm',
|
|
354
|
+
'size' => '1073741824',
|
|
355
|
+
'cache' => 'directsync'
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}.with_indifferent_access
|
|
359
|
+
@cr.stubs(:parse_server_vm).returns('vmid' => '100', 'type' => 'qemu', 'cores' => '1', 'cpulimit' => '1')
|
|
360
|
+
expected_config_attr = { :cores => '1', :cpulimit => '1' }
|
|
361
|
+
expected_volume_attr = {:id => 'scsi0', :volid => 'local-lvm:vm-100-disk-0', :size => 1_073_741_824}, {:cache => 'directsync'}
|
|
362
|
+
vm.expects(:attach, expected_volume_attr)
|
|
363
|
+
vm.expects(:update, expected_config_attr)
|
|
364
|
+
@cr.save_vm(uuid, new_attributes)
|
|
365
|
+
end
|
|
322
366
|
end
|
|
323
367
|
end
|
|
324
368
|
end
|
|
@@ -59,8 +59,17 @@ module ForemanFogProxmox
|
|
|
59
59
|
end
|
|
60
60
|
# rubocop:disable Lint/UselessComparison
|
|
61
61
|
describe 'semverclass comparators' do
|
|
62
|
-
it '#5.3.0 <= 5.4.
|
|
63
|
-
assert ForemanFogProxmox::Semver.to_semver('5.3.0') <= ForemanFogProxmox::Semver.to_semver('5.4.
|
|
62
|
+
it '#5.3.0 <= 5.4.3 returns true' do
|
|
63
|
+
assert ForemanFogProxmox::Semver.to_semver('5.3.0') <= ForemanFogProxmox::Semver.to_semver('5.4.3')
|
|
64
|
+
end
|
|
65
|
+
it '#5.3.0 <= 6.0.1 returns true' do
|
|
66
|
+
assert ForemanFogProxmox::Semver.to_semver('5.3.0') <= ForemanFogProxmox::Semver.to_semver('6.0.1')
|
|
67
|
+
end
|
|
68
|
+
it '#5.4.3 < 6.1.0 returns true' do
|
|
69
|
+
assert ForemanFogProxmox::Semver.to_semver('5.4.3') < ForemanFogProxmox::Semver.to_semver('6.1.0')
|
|
70
|
+
end
|
|
71
|
+
it '#6.0.1 < 6.1.0 returns true' do
|
|
72
|
+
assert ForemanFogProxmox::Semver.to_semver('6.0.1') < ForemanFogProxmox::Semver.to_semver('6.1.0')
|
|
64
73
|
end
|
|
65
74
|
it '#2.4.0 >= 1.3.0 returns true' do
|
|
66
75
|
assert ForemanFogProxmox::Semver.to_semver('2.4.0') >= ForemanFogProxmox::Semver.to_semver('1.3.0')
|
|
@@ -85,6 +94,17 @@ module ForemanFogProxmox
|
|
|
85
94
|
assert ForemanFogProxmox::Semver.to_semver('1.10.2') < ForemanFogProxmox::Semver.to_semver('1.20.0')
|
|
86
95
|
end
|
|
87
96
|
it '#0.10.2 < 1.20.0 returns true' do
|
|
97
|
+
assert_equal 0, ForemanFogProxmox::Semver.to_semver('0.10.2').major
|
|
98
|
+
assert_equal 10, ForemanFogProxmox::Semver.to_semver('0.10.2').minor
|
|
99
|
+
assert_equal 2, ForemanFogProxmox::Semver.to_semver('0.10.2').patch
|
|
100
|
+
assert_equal 1, ForemanFogProxmox::Semver.to_semver('1.20.0').major
|
|
101
|
+
assert_equal 20, ForemanFogProxmox::Semver.to_semver('1.20.0').minor
|
|
102
|
+
assert_equal 0, ForemanFogProxmox::Semver.to_semver('1.20.0').patch
|
|
103
|
+
assert ForemanFogProxmox::Semver.to_semver('0.10.2').major < ForemanFogProxmox::Semver.to_semver('1.20.0').major
|
|
104
|
+
assert_equal false, ForemanFogProxmox::Semver.to_semver('0.10.2').major == ForemanFogProxmox::Semver.to_semver('1.20.0').major
|
|
105
|
+
assert_equal false, ForemanFogProxmox::Semver.to_semver('0.10.2').minor == ForemanFogProxmox::Semver.to_semver('1.20.0').minor
|
|
106
|
+
assert ForemanFogProxmox::Semver.to_semver('0.10.2').minor < ForemanFogProxmox::Semver.to_semver('1.20.0').minor
|
|
107
|
+
assert ForemanFogProxmox::Semver.to_semver('0.10.2').patch > ForemanFogProxmox::Semver.to_semver('1.20.0').patch
|
|
88
108
|
assert ForemanFogProxmox::Semver.to_semver('0.10.2') < ForemanFogProxmox::Semver.to_semver('1.20.0')
|
|
89
109
|
end
|
|
90
110
|
end
|