foreman_fog_proxmox 0.13.1 → 0.14.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.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +27 -14
  3. data/app/assets/javascripts/foreman_fog_proxmox/proxmox_compute_resource.js +6 -8
  4. data/app/assets/javascripts/foreman_fog_proxmox/proxmox_vm.js +59 -60
  5. data/app/assets/javascripts/foreman_fog_proxmox/proxmox_vm_server.js +2 -4
  6. data/app/assets/javascripts/foreman_fog_proxmox/proxmox_volume.js +10 -10
  7. data/app/assets/javascripts/foreman_fog_proxmox/proxmox_volume_cloudinit.js +0 -1
  8. data/app/controllers/concerns/foreman_fog_proxmox/compute_resources_vms_controller.rb +80 -0
  9. data/app/controllers/concerns/foreman_fog_proxmox/hosts_controller.rb +53 -0
  10. data/app/helpers/proxmox_compute_resources_vms_helper.rb +99 -0
  11. data/app/helpers/proxmox_form_helper.rb +1 -1
  12. data/app/models/concerns/fog_extensions/proxmox/server.rb +3 -3
  13. data/app/models/concerns/host_ext/proxmox/associator.rb +46 -0
  14. data/app/models/concerns/host_ext/proxmox/for_vm.rb +33 -0
  15. data/app/models/concerns/orchestration/proxmox/compute.rb +18 -8
  16. data/app/models/foreman_fog_proxmox/proxmox.rb +4 -0
  17. data/app/models/foreman_fog_proxmox/proxmox_compute_attributes.rb +2 -6
  18. data/app/models/foreman_fog_proxmox/proxmox_images.rb +13 -4
  19. data/app/models/foreman_fog_proxmox/proxmox_interfaces.rb +14 -12
  20. data/app/models/foreman_fog_proxmox/proxmox_vm_commands.rb +4 -2
  21. data/app/models/foreman_fog_proxmox/proxmox_vm_new.rb +2 -4
  22. data/app/models/foreman_fog_proxmox/proxmox_vm_queries.rb +6 -1
  23. data/app/models/foreman_fog_proxmox/vms.rb +1 -1
  24. data/app/overrides/compute_resources_vms/form/add_clone_to_new_vm_compute_detail.rb +1 -1
  25. data/app/services/concerns/foreman_fog_proxmox/compute_resource_host_associator.rb +34 -0
  26. data/app/views/compute_resources_vms/form/proxmox/_add_from_profile_to_compute_form.html.erb +2 -2
  27. data/app/views/compute_resources_vms/form/proxmox/_add_from_profile_to_hosts_compute_detail_form.html.erb +4 -2
  28. data/app/views/compute_resources_vms/form/proxmox/_base.html.erb +0 -1
  29. data/app/views/compute_resources_vms/form/proxmox/container/_network.html.erb +1 -1
  30. data/app/views/compute_resources_vms/form/proxmox/server/_network.html.erb +2 -2
  31. data/app/views/compute_resources_vms/index/_proxmox.html.erb +2 -2
  32. data/lib/foreman_fog_proxmox/engine.rb +7 -1
  33. data/lib/foreman_fog_proxmox/version.rb +1 -1
  34. data/test/unit/foreman_fog_proxmox/proxmox_images_test.rb +3 -3
  35. data/test/unit/foreman_fog_proxmox/proxmox_interfaces_test.rb +40 -38
  36. metadata +9 -3
@@ -166,9 +166,7 @@ module ForemanFogProxmox
166
166
  def convert_config_attributes(new_attr)
167
167
  config_attributes = new_attr[:config_attributes]
168
168
  config_attributes[:volumes_attributes] = Hash[config_attributes[:disks].each_with_index.map { |disk, idx| [idx.to_s, disk.attributes] }] if config_attributes.key?(:disks)
169
- if config_attributes.key?(:interfaces)
170
- config_attributes[:interfaces_attributes] = Hash[config_attributes[:interfaces].each_with_index.map { |interface, idx| [idx.to_s, interface_compute_attributes(interface.attributes)] }]
171
- end
169
+ config_attributes[:interfaces_attributes] = Hash[config_attributes[:interfaces].each_with_index.map { |interface, idx| [idx.to_s, interface_compute_attributes(interface.attributes)] }] if config_attributes.key?(:interfaces)
172
170
  config_attributes.delete_if { |key, _value| ['disks', 'interfaces'].include?(key) }
173
171
  end
174
172
 
@@ -181,7 +179,7 @@ module ForemanFogProxmox
181
179
  new_attr_type ||= type
182
180
  logger.debug(format(_('new_typed_vm(%<type>s): new_attr_type=%<new_attr_type>s'), type: type, new_attr_type: new_attr_type))
183
181
  logger.debug(format(_('new_typed_vm(%<type>s): new_attr=%<new_attr>s'), type: type, new_attr: new_attr))
184
- options = !new_attr.key?('vmid') || ForemanFogProxmox::Value.empty?(new_attr['vmid']) ? new_attr.merge(vm_typed_instance_defaults(type)).merge(type: type) : new_attr
182
+ options = !new_attr.key?('vmid') || ForemanFogProxmox::Value.empty?(new_attr['vmid']) ? vm_typed_instance_defaults(type).merge(new_attr).merge(type: type) : new_attr
185
183
  logger.debug(format(_('new_typed_vm(%<type>s): options=%<options>s'), type: type, options: options))
186
184
  vm_h = parse_typed_vm(options, type).deep_symbolize_keys
187
185
  logger.debug(format(_('new_typed_vm(%<type>s): vm_h=%<vm_h>s'), type: type, vm_h: vm_h))
@@ -43,9 +43,14 @@ module ForemanFogProxmox
43
43
  end
44
44
 
45
45
  # TODO: Pagination with filters
46
- def vms(_opts = {})
46
+ def vms(opts = {})
47
47
  vms = []
48
48
  nodes.each { |node| vms += node.servers.all + node.containers.all }
49
+ if opts.key?(:eager_loading) && opts[:eager_loading]
50
+ vms_eager = []
51
+ vms.each { |vm| vms_eager << vm.collection.get(vm.identity) }
52
+ vms = vms_eager
53
+ end
49
54
  ForemanFogProxmox::Vms.new(vms)
50
55
  end
51
56
 
@@ -22,7 +22,7 @@ module ForemanFogProxmox
22
22
  attr_reader :items
23
23
 
24
24
  def each
25
- @items.each
25
+ @items.each { |item| yield item }
26
26
  end
27
27
 
28
28
  # TODO: Pagination with filters
@@ -20,6 +20,6 @@ Deface::Override.new(
20
20
  :name => 'add_from_profile_to_compute_detail',
21
21
  :replace => "erb[loud]:contains('provider_partial')",
22
22
  :partial => 'compute_resources_vms/form/proxmox/add_from_profile_to_hosts_compute_detail_form',
23
- :original => '448e3b265e4dc1789f0efbbc6076e32216ac3a24',
23
+ :original => '8902a49136f750d781dcaa44e7ffa8a29c1a94df',
24
24
  :namespaced => true
25
25
  )
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2021 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
+ module ForemanFogProxmox
21
+ module ComputeResourceHostAssociator
22
+ extend ActiveSupport::Concern
23
+ included do
24
+ prepend Overrides
25
+ end
26
+ module Overrides
27
+ def associate_hosts
28
+ compute_resource.vms(:eager_loading => true).each do |vm|
29
+ associate_vm(vm) if Host.for_vm_uuid(compute_resource, vm).empty?
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -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 compute_resource.class == ForemanFogProxmox::Proxmox %>
18
18
  <%= render :partial => provider_partial(compute_resource, 'base'),
19
- :locals => { :f => f, :compute_resource => compute_resource, :new_host => true, :new_vm => true, :hide_image => true, :from_profile => from_profile }.merge(args_for_compute_resource_partial(@host)) %>
19
+ :locals => { :f => f, :host => nil, :compute_resource => compute_resource, :new_host => true, :new_vm => true, :from_profile => from_profile } %>
20
20
  <% else %>
21
21
  <%= render :partial => provider_partial(compute_resource, 'base'),
22
- :locals => { :f => f, :compute_resource => compute_resource, :new_host => true, :new_vm => true, :hide_image => true }.merge(args_for_compute_resource_partial(@host)) %>
22
+ :locals => { :f => f, :host => nil, :compute_resource => compute_resource, :new_host => true, :new_vm => true } %>
23
23
  <% end %>
@@ -17,8 +17,10 @@ along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>. %>
17
17
 
18
18
  <% if compute_resource.class == ForemanFogProxmox::Proxmox %>
19
19
  <%= render :partial => provider_partial(compute_resource, 'base'),
20
- :locals => { :f => f, :compute_resource => compute_resource, :new_host => new_vm, :new_vm => new_vm, :from_profile => false }.merge(args_for_compute_resource_partial(@host)) %>
20
+ locals: { f: f, host: host, compute_resource: compute_resource, new_host: host.new_record?, new_vm: new_vm,
21
+ arch: host.architecture_id, os: host.operatingsystem_id, from_profile: false } %>
21
22
  <% else %>
22
23
  <%= render :partial => provider_partial(compute_resource, 'base'),
23
- :locals => { :f => f, :compute_resource => compute_resource, :new_host => new_vm, :new_vm => new_vm }.merge(args_for_compute_resource_partial(@host)) %>
24
+ locals: { f: f, host: host, compute_resource: compute_resource, new_host: host.new_record?, new_vm: new_vm,
25
+ arch: host.architecture_id, os: host.operatingsystem_id } %>
24
26
  <% end %>
@@ -16,7 +16,6 @@ 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
 
18
18
  <%= javascript_include_tag 'foreman_fog_proxmox/proxmox_vm', "data-turbolinks-track" => true %>
19
- <%= javascript_tag("$(document).on('ContentLoad', tfm.numFields.initAll)"); %>
20
19
 
21
20
  <%= select_f f, :type, proxmox_types_map, :id, :name, { }, :label => _('Type'), :label_size => "col-md-2", :required => true, :onchange => "vmTypeSelected()", :disabled => !new_vm %>
22
21
 
@@ -19,7 +19,7 @@ along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>. %>
19
19
  <% index = f.index ? f.index.present? : 0 %>
20
20
 
21
21
  <%= field_set_tag _("Nic"), :id => "container_network_#{index}", :style => ('display: none;' unless container), :disabled => !container do %>
22
- <%= f.hidden_field :id if !new_vm %>
22
+ <%= text_f f, :id, :label => _('Identifier'), :label_size => "col-md-2", :required => true, :label_help => _("net[n] with n integer >= 0, e.g. net0") %>
23
23
  <%= text_f f, :name, :label => _('Name'), :label_size => "col-md-2", :required => true, :label_help => _("eth[n] with n integer >= 0, e.g. eth0") %>
24
24
  <%= checkbox_f f, :dhcp, :label => _('DHCP IPv4') %>
25
25
  <%= text_f f, :cidr, :label => _('CIDR IPv4'), :label_size => "col-md-2", :label_help => _("integer within [0..32]") %>
@@ -18,8 +18,8 @@ along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>. %>
18
18
  <% server = vm_type == 'qemu' %>
19
19
  <% index = f.index ? f.index.present? : 0 %>
20
20
 
21
- <%= field_set_tag _("Nic"), :id => "server_network_#{index}", :style => ('display: none;' unless server), :disabled => !server do %>
22
- <%= f.hidden_field :id if !new_vm %>
21
+ <%= field_set_tag _("Nic"), :id => "server_network_#{index}", :style => ('display: none;' unless server), :disabled => !server do %>
22
+ <%= text_f f, :id, :label => _('Identifier'), :label_size => "col-md-2", :required => true, :label_help => _("net[n] with n integer >= 0, e.g. net0") %>
23
23
  <%= select_f f, :model, proxmox_networkcards_map, :id, :name, { }, :label => _('Card'), :label_size => "col-md-2" %>
24
24
  <%= select_f f, :bridge, compute_resource.bridges(node_id), :iface, :iface, { }, :label => _('Bridge'), :label_size => "col-md-2" %>
25
25
  <%= counter_f f, :tag, :class => "input-mini", :label => _('VLAN tag'), :label_size => "col-md-2" %>
@@ -31,7 +31,7 @@ along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>. %>
31
31
  <tbody>
32
32
  <% @vms.each do |vm| -%>
33
33
  <tr>
34
- <td><%= link_to_if_authorized vm.name, hash_for_compute_resource_vm_path(:compute_resource_id => @compute_resource, :id => vm.identity) %></td>
34
+ <td><%= link_to_if_authorized vm.name, hash_for_compute_resource_vm_path(:compute_resource_id => @compute_resource, :id => vm.unique_cluster_identity(@compute_resource)) %></td>
35
35
  <td><%= vm.node_id %></td>
36
36
  <td><%= vm.type %></td>
37
37
  <td><%= vm.cpus %></td>
@@ -41,7 +41,7 @@ along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>. %>
41
41
  <td>
42
42
  <%= action_buttons(
43
43
  vm_power_action(vm, authorizer),
44
- display_delete_if_authorized(hash_for_compute_resource_vm_path(:compute_resource_id => @compute_resource, :id => vm.identity).merge(:auth_object => @compute_resource, :authorizer => authorizer))) %>
44
+ display_delete_if_authorized(hash_for_compute_resource_vm_path(:compute_resource_id => @compute_resource, :id => vm.unique_cluster_identity(@compute_resource)).merge(:auth_object => @compute_resource, :authorizer => authorizer))) %>
45
45
  </td>
46
46
  </tr>
47
47
  <% end -%>
@@ -26,6 +26,7 @@ module ForemanFogProxmox
26
26
  config.autoload_paths += Dir["#{config.root}/app/controllers/concerns"]
27
27
  config.autoload_paths += Dir["#{config.root}/app/helpers/concerns"]
28
28
  config.autoload_paths += Dir["#{config.root}/app/models/concerns"]
29
+ config.autoload_paths += Dir["#{config.root}/app/services/concerns"]
29
30
  config.autoload_paths += Dir["#{config.root}/app/overrides"]
30
31
  config.autoload_paths += Dir["#{config.root}/app/services"]
31
32
 
@@ -101,10 +102,15 @@ module ForemanFogProxmox
101
102
  Fog::Proxmox::Compute::ServerConfig.include FogExtensions::Proxmox::ServerConfig
102
103
  Fog::Proxmox::Compute::Interface.include FogExtensions::Proxmox::Interface
103
104
  Fog::Proxmox::Compute::Disk.include FogExtensions::Proxmox::Disk
104
- ::ComputeResourcesController.include ForemanFogProxmox::Controller::Parameters::ComputeResource
105
105
  Fog::Proxmox::Compute::Node.include FogExtensions::Proxmox::Node
106
+ ::ComputeResourcesController.include ForemanFogProxmox::Controller::Parameters::ComputeResource
107
+ ::ComputeResourcesVmsController.include ForemanFogProxmox::ComputeResourcesVmsController
108
+ ::HostsController.include ForemanFogProxmox::HostsController
106
109
  ::Host::Managed.include Orchestration::Proxmox::Compute
107
110
  ::Host::Managed.include HostExt::Proxmox::Interfaces
111
+ ::Host::Managed.include HostExt::Proxmox::Associator
112
+ ::Host::Base.include HostExt::Proxmox::ForVm
113
+ ::ComputeResourceHostAssociator.include ForemanFogProxmox::ComputeResourceHostAssociator
108
114
  end
109
115
  end
110
116
  end
@@ -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.13.1'
21
+ VERSION = '0.14.0'
22
22
  end
@@ -28,7 +28,7 @@ module ForemanFogProxmox
28
28
  before do
29
29
  @cr = FactoryBot.build_stubbed(:proxmox_cr)
30
30
  @args = { :name => 'name' }
31
- @image_id = 100
31
+ @image_id = @cr.id.to_s + '_' + 100.to_s
32
32
  @vmid = 101
33
33
  @image = mock('vm')
34
34
  @image.expects(:clone)
@@ -38,13 +38,13 @@ module ForemanFogProxmox
38
38
  it 'clones server from image' do
39
39
  @clone.expects(:update).with(:name => 'name')
40
40
  @clone.stubs(:container?).returns(false)
41
- @cr.stubs(:find_vm_by_uuid).with(@vmid).returns(@clone)
41
+ @cr.stubs(:find_vm_by_uuid).with(@cr.id.to_s + '_' + @vmid.to_s).returns(@clone)
42
42
  @cr.clone_from_image(@image_id, @args, @vmid)
43
43
  end
44
44
  it 'clones container from image' do
45
45
  @clone.stubs(:container?).returns(true)
46
46
  @clone.expects(:update).with(:hostname => 'name')
47
- @cr.stubs(:find_vm_by_uuid).with(@vmid).returns(@clone)
47
+ @cr.stubs(:find_vm_by_uuid).with(@cr.id.to_s + '_' + @vmid.to_s).returns(@clone)
48
48
  @cr.clone_from_image(@image_id, @args, @vmid)
49
49
  end
50
50
  end
@@ -37,29 +37,30 @@ module ForemanFogProxmox
37
37
  @cr = FactoryBot.build_stubbed(:proxmox_cr)
38
38
  end
39
39
 
40
- it 'raises Foreman::Exception when physical identifier does not match net[k] with k integer' do
41
- physical_nic = FactoryBot.build(:nic_base_empty, :identifier => 'eth0')
42
- host = FactoryBot.build(:host_empty, :interfaces => [physical_nic])
40
+ it 'raises Foreman::Exception when server proxmox NIC id does not match net[k] with k integer' do
41
+ compute_attributes = ActiveSupport::HashWithIndifferentAccess.new({ 'id' => 'dsfqsfqzef' })
42
+ physical_nic = FactoryBot.build(:nic_base_empty, :identifier => 'eth0', :compute_attributes => compute_attributes)
43
+ host = FactoryBot.build(
44
+ :host_empty,
45
+ :interfaces => [physical_nic],
46
+ :compute_attributes => ActiveSupport::HashWithIndifferentAccess.new({ type: 'qemu' })
47
+ )
43
48
  err = assert_raises Foreman::Exception do
44
49
  @cr.host_interfaces_attrs(host)
45
50
  end
46
- assert err.message.end_with?('Invalid identifier interface[0]. Must be net[n] with n integer >= 0')
51
+ assert err.message.end_with?('Invalid proxmox NIC id on interface[0]. Must be net[n] with n integer >= 0')
47
52
  end
48
53
 
49
- it 'sets server compute id with identifier, ip and ip6 and mac adress' do
54
+ it 'sets interface identifier with server compute id, ip and ip6 and mac adress' do
50
55
  ip = '192.168.56.100'
51
- mac_address = '36:25:8C:53:0C:50'
56
+ mac_address = '36:25:8c:53:0c:50'
52
57
  ip6 = Array.new(4) { format('%<x>s', x: rand(16**4)) }.join(':') + '::1'
53
- physical_nic = FactoryBot.build(:nic_base_empty, :identifier => 'net0', :ip => ip, :ip6 => ip6, :mac => mac_address)
58
+ compute_attributes = ActiveSupport::HashWithIndifferentAccess.new({ 'id' => 'net0' })
59
+ physical_nic = FactoryBot.build(:nic_base_empty, :identifier => 'net0', :ip => ip, :ip6 => ip6, :mac => mac_address, :compute_attributes => compute_attributes)
54
60
  host = FactoryBot.build(
55
61
  :host_empty,
56
62
  :interfaces => [physical_nic],
57
- :compute_attributes => {
58
- 'type' => 'qemu',
59
- 'interfaces_attributes' => {
60
- '0' => physical_nic
61
- }
62
- }
63
+ :compute_attributes => ActiveSupport::HashWithIndifferentAccess.new({ type: 'qemu' })
63
64
  )
64
65
  nic_attributes = @cr.host_interfaces_attrs(host).values.select(&:present?)
65
66
  nic_attr = nic_attributes.first
@@ -69,20 +70,30 @@ module ForemanFogProxmox
69
70
  assert_equal mac_address, nic_attr[:macaddr]
70
71
  end
71
72
 
72
- it 'sets container compute id with identifier, ip/CIDR, gw and ip6' do
73
+ it 'raises Foreman::Exception when container proxmox NIC id does not match net[k] with k integer' do
74
+ compute_attributes = ActiveSupport::HashWithIndifferentAccess.new({ 'id' => 'dsfqsfqzef' })
75
+ physical_nic = FactoryBot.build(:nic_base_empty, :identifier => 'eth0', :compute_attributes => compute_attributes)
76
+ host = FactoryBot.build(
77
+ :host_empty,
78
+ :interfaces => [physical_nic],
79
+ :compute_attributes => ActiveSupport::HashWithIndifferentAccess.new({ type: 'lxc' })
80
+ )
81
+ err = assert_raises Foreman::Exception do
82
+ @cr.host_interfaces_attrs(host)
83
+ end
84
+ assert err.message.end_with?('Invalid proxmox NIC id on interface[0]. Must be net[n] with n integer >= 0')
85
+ end
86
+
87
+ it 'sets container compute ip/CIDR, gw and ip6' do
73
88
  ip = '192.168.56.100'
74
89
  cidr = '31'
75
90
  ip6 = Array.new(4) { format('%<x>s', x: rand(16**4)) }.join(':') + '::1'
76
- physical_nic = FactoryBot.build(:nic_base_empty, :identifier => 'net0', :ip => ip, :ip6 => ip6, :compute_attributes => { 'cidr' => cidr, 'gw' => ip, 'ip' => ip, 'dhcp6' => '1' })
91
+ compute_attributes = ActiveSupport::HashWithIndifferentAccess.new({ 'id' => 'net0', 'cidr' => cidr, 'gw' => ip, 'ip' => ip, 'dhcp6' => '1' })
92
+ physical_nic = FactoryBot.build(:nic_base_empty, :identifier => 'net0', :ip => ip, :ip6 => ip6, :compute_attributes => compute_attributes)
77
93
  host = FactoryBot.build(
78
94
  :host_empty,
79
95
  :interfaces => [physical_nic],
80
- :compute_attributes => {
81
- 'type' => 'lxc',
82
- 'interfaces_attributes' => {
83
- '0' => physical_nic
84
- }
85
- }
96
+ :compute_attributes => ActiveSupport::HashWithIndifferentAccess.new({ type: 'lxc' })
86
97
  )
87
98
  nic_attributes = @cr.host_interfaces_attrs(host).values.select(&:present?)
88
99
  nic_attr = nic_attributes.first
@@ -92,20 +103,16 @@ module ForemanFogProxmox
92
103
  assert_equal 'dhcp', nic_attr[:ip6]
93
104
  end
94
105
 
95
- it 'sets container compute id with identifier, ip DHCP, gw6 and ip6' do
106
+ it 'sets container compute ip DHCP, gw6 and ip6' do
96
107
  ip = '192.168.56.100'
97
108
  cidr6 = '100'
98
109
  ip6 = '2001:0:1234::c1c0:abcd:876'
99
- physical_nic = FactoryBot.build(:nic_base_empty, :identifier => 'net0', :ip => ip, :ip6 => ip6, :compute_attributes => { 'cidr6' => cidr6, 'dhcp' => '1', 'gw6' => ip6 })
110
+ compute_attributes = ActiveSupport::HashWithIndifferentAccess.new({ 'id' => 'net0', 'cidr6' => cidr6, 'dhcp' => '1', 'gw6' => ip6 })
111
+ physical_nic = FactoryBot.build(:nic_base_empty, :identifier => 'net0', :ip => ip, :ip6 => ip6, :compute_attributes => compute_attributes)
100
112
  host = FactoryBot.build(
101
113
  :host_empty,
102
114
  :interfaces => [physical_nic],
103
- :compute_attributes => {
104
- 'type' => 'lxc',
105
- 'interfaces_attributes' => {
106
- '0' => physical_nic
107
- }
108
- }
115
+ :compute_attributes => ActiveSupport::HashWithIndifferentAccess.new({ type: 'lxc' })
109
116
  )
110
117
  nic_attributes = @cr.host_interfaces_attrs(host).values.select(&:present?)
111
118
  nic_attr = nic_attributes.first
@@ -115,22 +122,17 @@ module ForemanFogProxmox
115
122
  assert_equal ip6, nic_attr['gw6']
116
123
  end
117
124
 
118
- it 'sets container compute id with identifier, ip DHCP, mac adress and firewall' do
125
+ it 'sets container compute ip DHCP, mac adress and firewall' do
119
126
  ip = '192.168.56.100'
120
- mac_address = '36:25:8C:53:0C:50'
127
+ mac_address = '36:25:8c:53:0c:50'
121
128
  ip6 = '2001:0:1234::c1c0:abcd:876'
122
129
  firewall = '1'
123
- compute_attributes = { 'dhcp' => '1', 'ip6' => ip6, 'firewall' => firewall }
130
+ compute_attributes = ActiveSupport::HashWithIndifferentAccess.new({ 'id' => 'net0', 'dhcp' => '1', 'ip6' => ip6, 'firewall' => firewall })
124
131
  physical_nic = FactoryBot.build(:nic_base_empty, :identifier => 'net0', :ip => ip, :ip6 => ip6, :mac => mac_address, :compute_attributes => compute_attributes)
125
132
  host = FactoryBot.build(
126
133
  :host_empty,
127
134
  :interfaces => [physical_nic],
128
- :compute_attributes => {
129
- 'type' => 'lxc',
130
- 'interfaces_attributes' => {
131
- '0' => physical_nic
132
- }
133
- }
135
+ :compute_attributes => ActiveSupport::HashWithIndifferentAccess.new({ type: 'lxc' })
134
136
  )
135
137
  nic_attributes = @cr.host_interfaces_attrs(host).values.select(&:present?)
136
138
  nic_attr = nic_attributes.first
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_fog_proxmox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.1
4
+ version: 0.14.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: 2021-03-17 00:00:00.000000000 Z
12
+ date: 2021-07-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: deface
@@ -100,11 +100,14 @@ files:
100
100
  - app/assets/javascripts/foreman_fog_proxmox/proxmox_volume.js
101
101
  - app/assets/javascripts/foreman_fog_proxmox/proxmox_volume_cdrom.js
102
102
  - app/assets/javascripts/foreman_fog_proxmox/proxmox_volume_cloudinit.js
103
+ - app/controllers/concerns/foreman_fog_proxmox/compute_resources_vms_controller.rb
103
104
  - app/controllers/concerns/foreman_fog_proxmox/controller/parameters/compute_resource.rb
105
+ - app/controllers/concerns/foreman_fog_proxmox/hosts_controller.rb
104
106
  - app/controllers/foreman_fog_proxmox/compute_resources_controller.rb
105
107
  - app/helpers/node_dashboard_helper.rb
106
108
  - app/helpers/proxmox_compute_controllers_helper.rb
107
109
  - app/helpers/proxmox_compute_resources_helper.rb
110
+ - app/helpers/proxmox_compute_resources_vms_helper.rb
108
111
  - app/helpers/proxmox_compute_selectors_helper.rb
109
112
  - app/helpers/proxmox_form_helper.rb
110
113
  - app/helpers/proxmox_storages_helper.rb
@@ -121,6 +124,8 @@ files:
121
124
  - app/models/concerns/fog_extensions/proxmox/node.rb
122
125
  - app/models/concerns/fog_extensions/proxmox/server.rb
123
126
  - app/models/concerns/fog_extensions/proxmox/server_config.rb
127
+ - app/models/concerns/host_ext/proxmox/associator.rb
128
+ - app/models/concerns/host_ext/proxmox/for_vm.rb
124
129
  - app/models/concerns/host_ext/proxmox/interfaces.rb
125
130
  - app/models/concerns/orchestration/proxmox/compute.rb
126
131
  - app/models/foreman_fog_proxmox/options_select.rb
@@ -146,6 +151,7 @@ files:
146
151
  - app/overrides/compute_resources_vms/form/add_vm_type_to_volumes_edit.rb
147
152
  - app/overrides/compute_resources_vms/form/add_vm_type_to_volumes_new_volume.rb
148
153
  - app/overrides/compute_resources_vms/form/remove_new_vm_from_removable_layout.rb
154
+ - app/services/concerns/foreman_fog_proxmox/compute_resource_host_associator.rb
149
155
  - app/services/foreman_fog_proxmox/node_dashboard/data.rb
150
156
  - app/views/api/v2/compute_resources/proxmox.json.rabl
151
157
  - app/views/compute_resources/form/_proxmox.html.erb
@@ -237,7 +243,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
237
243
  - !ruby/object:Gem::Version
238
244
  version: '0'
239
245
  requirements: []
240
- rubygems_version: 3.2.3
246
+ rubygems_version: 3.2.22
241
247
  signing_key:
242
248
  specification_version: 4
243
249
  summary: Foreman plugin that adds Proxmox VE compute resource using fog-proxmox