foreman_fog_proxmox 0.11.1 → 0.12.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.

Potentially problematic release.


This version of foreman_fog_proxmox might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e6bb8fe5df4bb574ffc4870265793222d2704c7d43412e087493306b7b599cc3
4
- data.tar.gz: 48a5e82861e06306ad0ab8614c86fdab34ddbf73eb97ca08705c7cc788974822
3
+ metadata.gz: ce063ca3e1f223b49897b86d1a310bad8c15e1c25baa9eabb2304520e1904001
4
+ data.tar.gz: a44facfbc190a729c68d2ef82ae37de9d8b91fcd0f49e7808f85bd05911bcd44
5
5
  SHA512:
6
- metadata.gz: e0b68b69c292fbc33284c18bd81e975d226eb82047ea7880a9ce97cf04ccbdddc9125c195ad75f60db923604f4c8ca480c45d5840c0eb41c9c5c9e1c1d60e985
7
- data.tar.gz: aed1ca445f09e2fa6237641be539958d83e3537f9508169c23a0320e0f7365e587cc279fa231cb5a01d59ceeb7357bfa2f35678b144fed9b820a4c6d00b2b0c7
6
+ metadata.gz: 3b2c86fade0bcf232ca6c29e162a5baba2d02083d078b401f0d3d3e9c23ecd7ffcb41ba8b07e2980ce09186956d19537ee51b26bed3a126d908ee56ef05187d1
7
+ data.tar.gz: 757d04ed4a596e1d0ea80424ef4d405b258b3d6b9c0bbcc1cc4081e945f087cfbe910043290a341b2cd821dfbdb73f9423683606ae2ee35c93e0928740c4a9e1
data/README.md CHANGED
@@ -141,6 +141,8 @@ gem 'simplecov' # test
141
141
  * In foreman directory, install dependencies:
142
142
 
143
143
  ```shell
144
+ gem install bundler
145
+ # prerequisites postgresql-client library on OS
144
146
  bundle config set without 'libvirt ovirt mysql2'
145
147
  bundle install
146
148
  ```
@@ -155,6 +157,12 @@ npm install
155
157
  cp config/settings.yaml.test config/settings.yaml
156
158
  ```
157
159
 
160
+ add these lines to config/settings.yml:
161
+
162
+ ```yaml
163
+ :webpack_dev_server: true
164
+ ```
165
+
158
166
  * SQLite is no more default rails dev or test database, instead add:
159
167
 
160
168
  ```shell
@@ -176,4 +176,9 @@ module ProxmoxComputeSelectorsHelper
176
176
  OpenStruct.new(id: 'rtl8139', name: 'Realtek RTL8139'),
177
177
  OpenStruct.new(id: 'vmxnet3', name: 'VMware vmxnet3')]
178
178
  end
179
+
180
+ def proxmox_bios_map
181
+ [OpenStruct.new(id: 'seabios', name: '(Default) Seabios'),
182
+ OpenStruct.new(id: 'ovmf', name: 'OVMF (UEFI)')]
183
+ end
179
184
  end
@@ -85,12 +85,4 @@ module ProxmoxVmHelper
85
85
  memory = (config_hash[key].to_i / MEGA).to_s == '0' ? config_hash[key] : (config_hash[key].to_i / MEGA).to_s
86
86
  config_hash.store(key, memory)
87
87
  end
88
-
89
- def vm_type(host)
90
- host.compute_object.type
91
- end
92
-
93
- def node_id(host)
94
- host.compute_object.node_id
95
- end
96
88
  end
@@ -38,12 +38,25 @@ module ForemanFogProxmox
38
38
  [:disks, :interfaces, :vmid, :node_id, :node, :type].include?(key) || !vm.config.respond_to?(key)
39
39
  end
40
40
 
41
+ def interface_compute_attributes(interface_attributes)
42
+ vm_attrs = {}
43
+ vm_attrs.store(:mac, interface_attributes[:macaddr])
44
+ vm_attrs.store(:id, interface_attributes[:id])
45
+ vm_attrs.store(:identifier, interface_attributes[:id])
46
+ vm_attrs.store(:ip, interface_attributes[:ip])
47
+ vm_attrs.store(:ip6, interface_attributes[:ip6])
48
+ vm_attrs[:compute_attributes] = interface_attributes.reject { |k, _v| [:macaddr, :id].include?(k) }
49
+ vm_attrs
50
+ end
51
+
41
52
  def vm_compute_attributes(vm)
42
53
  vm_attrs = {}
43
54
  if vm.respond_to?(:config)
44
55
  vm_attrs = vm_attrs.merge(vmid: vm.identity, node_id: vm.node_id, type: vm.type)
45
56
  vm_attrs[:volumes_attributes] = Hash[vm.config.disks.each_with_index.map { |disk, idx| [idx.to_s, disk.attributes] }] if vm.config.respond_to?(:disks)
46
- vm_attrs[:interfaces_attributes] = Hash[vm.config.interfaces.each_with_index.map { |interface, idx| [idx.to_s, interface.attributes] }] if vm.config.respond_to?(:interfaces)
57
+ if vm.config.respond_to?(:interfaces)
58
+ vm_attrs[:interfaces_attributes] = Hash[vm.config.interfaces.each_with_index.map { |interface, idx| [idx.to_s, interface_compute_attributes(interface.attributes)] }]
59
+ end
47
60
  vm_attrs[:config_attributes] = vm.config.attributes.reject do |key, value|
48
61
  not_config_key?(vm, key) || ForemanFogProxmox::Value.empty?(value.to_s) || Fog::Proxmox::DiskHelper.disk?(key.to_s) || Fog::Proxmox::NicHelper.nic?(key.to_s)
49
62
  end
@@ -39,7 +39,7 @@ module ForemanFogProxmox
39
39
  end
40
40
 
41
41
  def os_linux_types_mapping(host)
42
- ['Debian', 'Redhat', 'Suse', 'Altlinux', 'Archlinux', 'CoreOs', 'Gentoo'].include?(host.operatingsystem.type) ? available_linux_operating_systems : []
42
+ ['Debian', 'Redhat', 'Suse', 'Altlinux', 'Archlinux', 'Coreos', 'Gentoo'].include?(host.operatingsystem.type) ? available_linux_operating_systems : []
43
43
  end
44
44
 
45
45
  def os_windows_types_mapping(host)
@@ -32,6 +32,7 @@ module ForemanFogProxmox
32
32
  vmid = args[:vmid].to_i
33
33
  type = args[:type]
34
34
  node = client.nodes.get(args[:node_id])
35
+ vmid = node.servers.next_id.to_i if vmid < 1
35
36
  raise ::Foreman::Exception, format(N_('invalid vmid=%<vmid>s'), vmid: vmid) unless node.servers.id_valid?(vmid)
36
37
 
37
38
  image_id = args[:image_id]
@@ -16,8 +16,8 @@ You should have received a copy of the GNU General Public License
16
16
  along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>. %>
17
17
  <% if @host.compute_resource.class == ForemanFogProxmox::Proxmox %>
18
18
  <% compute_attributes = f.object.compute_attributes %>
19
- <% vm_type = vm_type(@host) %>
20
- <% node_id = node_id(@host) %>
19
+ <% vm_type = f.object.respond_to?('type') ? f.object.type : nil %>
20
+ <% node_id = f.object.respond_to?('node_id') ? f.object.node_id : nil %>
21
21
 
22
22
  <%= f.fields_for 'compute_attributes', OpenStruct.new(f.object.compute_attributes) do |f| %>
23
23
  <%= render provider_partial(@host.compute_resource, 'network'), :f => f, :vm_type => vm_type, :node_id => node_id, :disabled => f.object.persisted?, :compute_resource => @host.compute_resource, :new_host => new_vm, :new_vm => new_vm %>
@@ -28,6 +28,7 @@ along with ForemanFogProxmox. If not, see . %>
28
28
  <%= select_f f, :keyboard, proxmox_keyboards_map, :id, :name, { }, :label => _('Keyboard'), :label_size => "col-md-2" %>
29
29
  <%= select_f f, :vga, proxmox_vgas_map, :id, :name, { :include_blank => true }, :label => _('VGA'), :label_size => "col-md-2" %>
30
30
  <%= select_f f, :scsihw, proxmox_scsi_controllers_map, :id, :name, { }, :label => _('SCSI Controller'), :label_size => "col-md-2" %>
31
+ <%= select_f f, :bios, proxmox_bios_map, :id, :name, { }, :label => _('BIOS'), :label_size => "col-md-2" %>
31
32
  <% end %>
32
33
  <%= field_set_tag _("CPU"), :id => "server_config_cpu", :class => 'hide', :disabled => !server do %>
33
34
  <%= select_f f, :cpu_type, proxmox_cpus_map, :id, :name, { }, :label => _('Type'), :label_size => "col-md-2" %>
@@ -18,5 +18,5 @@
18
18
  # along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>.
19
19
 
20
20
  module ForemanFogProxmox
21
- VERSION = '0.11.1'
21
+ VERSION = '0.12.0'
22
22
  end
@@ -96,7 +96,11 @@ module ForemanFogProxmox
96
96
  assert_equal volume_attributes, vm_attrs[:volumes_attributes]['0']
97
97
  assert_not vm_attrs[:config_attributes].key?(:interfaces)
98
98
  assert vm_attrs.key?(:interfaces_attributes)
99
- assert_equal interface_attributes, vm_attrs[:interfaces_attributes]['0']
99
+ assert_equal interface_attributes[:id], vm_attrs[:interfaces_attributes]['0'][:id]
100
+ assert_equal interface_attributes[:id], vm_attrs[:interfaces_attributes]['0'][:identifier]
101
+ assert_equal interface_attributes[:macaddr], vm_attrs[:interfaces_attributes]['0'][:mac]
102
+ assert_equal interface_attributes[:model], vm_attrs[:interfaces_attributes]['0'][:compute_attributes][:model]
103
+ assert_equal interface_attributes[:bridge], vm_attrs[:interfaces_attributes]['0'][:compute_attributes][:bridge]
100
104
  end
101
105
 
102
106
  it 'converts a container to hash' do
@@ -109,7 +113,11 @@ module ForemanFogProxmox
109
113
  assert vm_attrs.key?(:volumes_attributes)
110
114
  assert_equal volume_attributes, vm_attrs[:volumes_attributes]['0']
111
115
  assert vm_attrs.key?(:interfaces_attributes)
112
- assert_equal interface_attributes, vm_attrs[:interfaces_attributes]['0']
116
+ assert_equal interface_attributes[:id], vm_attrs[:interfaces_attributes]['0'][:id]
117
+ assert_equal interface_attributes[:id], vm_attrs[:interfaces_attributes]['0'][:identifier]
118
+ assert_equal interface_attributes[:name], vm_attrs[:interfaces_attributes]['0'][:compute_attributes][:name]
119
+ assert_equal interface_attributes[:mac], vm_attrs[:interfaces_attributes]['0'][:compute_attributes][:mac]
120
+ assert_equal interface_attributes[:bridge], vm_attrs[:interfaces_attributes]['0'][:compute_attributes][:bridge]
113
121
  end
114
122
  end
115
123
  end
@@ -31,7 +31,7 @@ module ForemanFogProxmox
31
31
  include ProxmoxVmHelper
32
32
 
33
33
  describe 'create_vm' do
34
- it 'raises Foreman::Exception when vmid is invalid' do
34
+ it 'raises Foreman::Exception when vmid <= 100 and vmid > 0' do
35
35
  args = { vmid: '100' }
36
36
  servers = mock('servers')
37
37
  servers.stubs(:id_valid?).returns(false)
@@ -42,6 +42,20 @@ module ForemanFogProxmox
42
42
  assert err.message.end_with?('invalid vmid=100')
43
43
  end
44
44
 
45
+ it 'computes next vmid when vmid == 0 and creates server' do
46
+ args = { vmid: '0', type: 'qemu', node_id: 'pve', start_after_create: '0' }
47
+ servers = mock('servers')
48
+ servers.stubs(:id_valid?).returns(true)
49
+ servers.stubs(:next_id).returns('101')
50
+ cr = mock_node_servers(ForemanFogProxmox::Proxmox.new, servers)
51
+ cr.stubs(:convert_sizes).with(args)
52
+ cr.stubs(:parse_server_vm).with(args).returns(args)
53
+ servers.stubs(:create).with(args)
54
+ vm = mock('vm')
55
+ cr.stubs(:find_vm_by_uuid).with((args[:vmid]).to_s).returns(vm)
56
+ cr.create_vm(args)
57
+ end
58
+
45
59
  it 'creates server without bootstart' do
46
60
  args = { vmid: '100', type: 'qemu', node_id: 'pve', start_after_create: '0' }
47
61
  servers = mock('servers')
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.11.1
4
+ version: 0.12.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: 2020-05-15 00:00:00.000000000 Z
12
+ date: 2020-07-22 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.12'
34
+ version: '0.13'
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.12'
41
+ version: '0.13'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: rdoc
44
44
  requirement: !ruby/object:Gem::Requirement
@@ -225,25 +225,25 @@ signing_key:
225
225
  specification_version: 4
226
226
  summary: Foreman plugin that adds Proxmox VE compute resource using fog-proxmox
227
227
  test_files:
228
- - test/functional/compute_resources_controller_test.rb
229
- - test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_create_test.rb
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
234
- - test/unit/foreman_fog_proxmox/helpers/proxmox_container_helper_test.rb
235
- - test/unit/foreman_fog_proxmox/proxmox_compute_attributes_test.rb
228
+ - test/test_plugin_helper.rb
229
+ - test/factories/proxmox_factory.rb
230
+ - test/factories/foreman_fog_proxmox/proxmox_node_mock_factory.rb
231
+ - test/factories/foreman_fog_proxmox/proxmox_server_mock_factory.rb
232
+ - test/factories/foreman_fog_proxmox/proxmox_container_mock_factory.rb
233
+ - test/unit/foreman_fog_proxmox/proxmox_interfaces_test.rb
236
234
  - test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_volumes_test.rb
235
+ - test/unit/foreman_fog_proxmox/proxmox_images_test.rb
236
+ - test/unit/foreman_fog_proxmox/proxmox_test.rb
237
+ - test/unit/foreman_fog_proxmox/proxmox_compute_attributes_test.rb
238
+ - test/unit/foreman_fog_proxmox/proxmox_vm_commands_container_test.rb
239
+ - test/unit/foreman_fog_proxmox/semver_test.rb
240
+ - test/unit/foreman_fog_proxmox/proxmox_version_test.rb
241
+ - test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_create_test.rb
237
242
  - test/unit/foreman_fog_proxmox/proxmox_vm_queries_test.rb
243
+ - test/unit/foreman_fog_proxmox/proxmox_vm_new_test.rb
238
244
  - test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_test.rb
239
- - test/unit/foreman_fog_proxmox/proxmox_interfaces_test.rb
240
245
  - test/unit/foreman_fog_proxmox/proxmox_vm_commands_test.rb
241
- - test/unit/foreman_fog_proxmox/proxmox_images_test.rb
242
- - 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
246
+ - test/unit/foreman_fog_proxmox/helpers/proxmox_server_helper_test.rb
247
+ - test/unit/foreman_fog_proxmox/helpers/proxmox_container_helper_test.rb
248
+ - test/unit/foreman_fog_proxmox/helpers/proxmox_vm_helper_test.rb
249
+ - test/functional/compute_resources_controller_test.rb