foreman_fog_proxmox 0.13.4 → 0.14.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e42832dc77d338bb20585f27678bc2207c23a610f7c7b478f24f3791ca65a414
4
- data.tar.gz: 1385bea7eed802496ae7ab85ca013e75dc0343a8a433a347d8811b59fd620cd0
3
+ metadata.gz: 19b7f2f30af319dbc8881900c660bf9ddc5026eb8762ace34dcd6b4ac7fa85f8
4
+ data.tar.gz: 5430f62a1d7db829fddb142c468d5c3741a0090131f0a3d26746bec75f6b943e
5
5
  SHA512:
6
- metadata.gz: 91a262ffeb2b720fae01136cdcd158cd8c577702fafbea36d550eae859c6734f7a7ec1c390b39077852100d4507d9b3502bb7f3f1cb5c7d22c02cd7b012c51cf
7
- data.tar.gz: 25512a916934966d9b5e66494f1b294c5b13d69ba326ed61170e330bff616111103984701a6311b150fb444dab3f0a48920c8debe193b7698a2ec43a0110cdd1
6
+ metadata.gz: ceac1a672eb780a7c7e8e05d8024f70d74d129a3ff48ad5d65f9947c78d60778a3697c7a70e030eff53346f3f56587a726fa71b5a719bb448bbea573d7970e47
7
+ data.tar.gz: cd477463a37e43ce80db0986f08d8203b225cfc5abae4f31b5c165cfc149197c99be2b2d8687b6e217246609c77d781658d93c119b37c41bfebc6049be852b4a
data/README.md CHANGED
@@ -38,9 +38,27 @@ You can support the plugin development via the following methods:
38
38
 
39
39
  ## Installation
40
40
 
41
- ### Prerequisites
41
+ ### From OS packages
42
42
 
43
- You need [nodejs](https://nodejs.org/en/download/package-manager/) installed in order to use foreman-assets package.
43
+ Please see the Foreman manual for complete instructions:
44
+
45
+ * [Foreman: How to Install a Plugin from package](https://theforeman.org/plugins/#2.Installation)
46
+
47
+ [Install from package](https://theforeman.org/plugins/#2.2Packageinstallation) is the easiest way to install the plugin. Choose the latest release plugins repository. If you don't find it in the same foreman release repository, get it from the `nightly` repository.
48
+
49
+ Then you can install it with the package manager, in Debian/Ubuntu:
50
+
51
+ ```shell
52
+ sudo apt-get install ruby-foreman-fog-proxmox
53
+ ```
54
+
55
+ and in Fedora/Redhat Linux:
56
+
57
+ ```shell
58
+ sudo dnf install rubygem-foreman_fog_proxmox
59
+ ```
60
+
61
+ Redhat, CentOS or Fedora users should also [setup Selinux](https://projects.theforeman.org/projects/foreman/wiki/SELinux) to allow foreman and all its plugins to work.
44
62
 
45
63
  ### From gem
46
64
 
@@ -69,6 +87,8 @@ sudo -u foreman /usr/bin/foreman-ruby /usr/bin/bundle install
69
87
 
70
88
  * Precompile plugin assets:
71
89
 
90
+ You need [nodejs](https://nodejs.org/en/download/package-manager/) installed in order to use foreman-assets package.
91
+
72
92
  ```shell
73
93
  /usr/bin/foreman-ruby /usr/bin/bundle exec bin/rake plugin:assets:precompile[foreman_fog_proxmox]
74
94
  ```
@@ -99,28 +119,6 @@ Then you can check plugin installation after login into your new foreman server
99
119
  ![About resources](.github/images/about_resources.png)
100
120
  ![About greffon](.github/images/about_greffon.png)
101
121
 
102
- ### From OS packages
103
-
104
- Please see the Foreman manual for complete instructions:
105
-
106
- * [Foreman: How to Install a Plugin from package](https://theforeman.org/plugins/#2.Installation)
107
-
108
- [Install from package](https://theforeman.org/plugins/#2.2Packageinstallation) is the easiest way to install the plugin. Choose the latest release plugins repository. If you don't find it in the same foreman release repository, get it from the `nightly` repository.
109
-
110
- Then you can install it with the package manager, in Debian/Ubuntu:
111
-
112
- ```shell
113
- sudo apt-get install ruby-foreman-fog-proxmox
114
- ```
115
-
116
- and in Fedora/Redhat Linux:
117
-
118
- ```shell
119
- sudo dnf install rubygem-foreman_fog_proxmox
120
- ```
121
-
122
- Redhat, CentOS or Fedora users should also [setup Selinux](https://projects.theforeman.org/projects/foreman/wiki/SELinux) to allow foreman and all its plugins to work.
123
-
124
122
  ## Usage
125
123
 
126
124
  * [Compute resource](.github/compute_resource.md)
@@ -15,8 +15,6 @@
15
15
  // 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
- $(document).on('ContentLoad', tfm.numFields.initAll);
19
-
20
18
  $(document).ready(function () {
21
19
  sslVerifyPeerSelected();
22
20
  authMethodSelected();
@@ -15,7 +15,6 @@
15
15
  // 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
- $(document).on('ContentLoad', tfm.numFields.initAll);
19
18
  $(document).ready(vmTypeSelected);
20
19
 
21
20
  function vmTypeSelected() {
@@ -46,7 +46,6 @@ function controllerSelected(item) {
46
46
  var device = $(device_selector).limitedSpinner('value');
47
47
  var id = controller + device;
48
48
  $(id_selector).val(id);
49
- tfm.numFields.initAll();
50
49
  }
51
50
 
52
51
  function deviceSelected(item) {
@@ -58,7 +57,6 @@ function deviceSelected(item) {
58
57
  var controller = $(controller_selector).val();
59
58
  var id = controller + device;
60
59
  $(id_selector).val(id);
61
- tfm.numFields.initAll();
62
60
  }
63
61
 
64
62
  function computeControllerMaxDevice(controller) {
@@ -21,5 +21,4 @@ function cloudinitControllerSelected(item) {
21
21
  var max = computeControllerMaxDevice(controller);
22
22
  var device_selector = 'host_compute_attributes_volumes_attributes_' + index + 'device';
23
23
  $(device_selector).attr('data-soft-max', max);
24
- tfm.numFields.initAll();
25
24
  }
@@ -0,0 +1,53 @@
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 HostsController
22
+ extend ActiveSupport::Concern
23
+ included do
24
+ prepend Overrides
25
+ end
26
+ module Overrides
27
+ include ForemanFogProxmox::ProxmoxVmNew
28
+ # Clone the host
29
+ def clone
30
+ super
31
+ return true unless @host.compute_resource.class == ForemanFogProxmox::Proxmox
32
+
33
+ @host.compute_attributes[:vmid] = next_vmid
34
+ @host.compute_attributes[:interfaces_attributes].each { |index, interface_attributes| @host.compute_attributes[:interfaces_attributes][index] = interface_attributes.merge(macaddr: nil).merge(hwaddr: nil).merge(ip: nil).merge(ip6: nil) }
35
+ @host.compute_attributes[:volumes_attributes].each { |index, volume_attributes| @host.compute_attributes[:volumes_attributes][index] = volume_attributes.merge(volid: nil) }
36
+ end
37
+
38
+ private
39
+
40
+ def bridges
41
+ @host.compute_resource.bridges
42
+ end
43
+
44
+ def nodes
45
+ @host.compute_resource.nodes
46
+ end
47
+
48
+ def storages
49
+ @host.compute_resource.storages
50
+ end
51
+ end
52
+ end
53
+ end
@@ -66,7 +66,7 @@ module ProxmoxFormHelper
66
66
  opts[:"data-association"] = (type + '_' + association.to_s).to_sym
67
67
  hide = ''
68
68
  hide += '$("[data-association=' + type + '_volumes]").hide();' unless ['hard_disk', 'mp'].include?(type)
69
- link_to_function(name.to_s, 'add_child_node(this);tfm.numFields.initAll();' + hide, opts)
69
+ link_to_function(name.to_s, 'add_child_node(this);' + hide, opts)
70
70
  end
71
71
 
72
72
  def remove_child_link_typed(name, f, type, opts = {})
@@ -63,7 +63,7 @@ module FogExtensions
63
63
  end
64
64
 
65
65
  def select_nic(fog_nics, nic)
66
- fog_nics.find { |fog_nic| fog_nic.identity.to_s == nic.identifier }
66
+ fog_nics.find { |fog_nic| fog_nic.identity.to_s == nic.compute_attributes[:id] }
67
67
  end
68
68
 
69
69
  delegate :interfaces, to: :config
@@ -27,8 +27,10 @@ module ForemanFogProxmox
27
27
  end
28
28
 
29
29
  def set_nic_identifier(nic, index)
30
- nic.identifier = format('net%<index>s', index: index) if nic.identifier.empty?
31
- raise ::Foreman::Exception, _(format('Invalid identifier interface[%<index>s]. Must be net[n] with n integer >= 0', index: index)) unless Fog::Proxmox::NicHelper.nic?(nic.identifier)
30
+ nic.compute_attributes[:id] = format('net%<index>s', index: index) if nic.compute_attributes[:id].empty?
31
+ raise ::Foreman::Exception, _(format('Invalid proxmox NIC id on interface[%<index>s]. Must be net[n] with n integer >= 0', index: index)) unless Fog::Proxmox::NicHelper.nic?(nic.compute_attributes[:id])
32
+
33
+ nic.identifier = nic.compute_attributes['id'] if nic.identifier.empty?
32
34
  end
33
35
 
34
36
  def vm_type(host)
@@ -112,17 +114,16 @@ module ForemanFogProxmox
112
114
  host.interfaces.select(&:physical?).each.with_index.reduce({}) do |hash, (nic, index)|
113
115
  set_nic_identifier(nic, index)
114
116
  set_container_interface_name(host, nic, index) if container?(host)
115
- nic_compute_attributes = nic.compute_attributes.merge(id: nic.identifier)
116
- ForemanFogProxmox::HashCollection.remove_empty_values(nic_compute_attributes)
117
+ ForemanFogProxmox::HashCollection.remove_empty_values(nic.compute_attributes)
117
118
  mac = nic.mac
118
119
  mac ||= nic.attributes['mac']
119
- set_mac(nic_compute_attributes, mac, vm_type(host)) if mac.present?
120
- interface_compute_attributes = host.compute_attributes['interfaces_attributes'] ? host.compute_attributes['interfaces_attributes'].select { |_k, v| v['id'] == nic.identifier } : {}
121
- nic_compute_attributes.store(:_delete, interface_compute_attributes[interface_compute_attributes.keys[0]]['_delete']) unless interface_compute_attributes.empty?
122
- set_ip(host, nic, nic_compute_attributes)
123
- set_ip(host, nic, nic_compute_attributes, true)
124
- ForemanFogProxmox::HashCollection.remove_keys(nic_compute_attributes, ['dhcp', 'dhcp6', 'cidr', 'cidr6'])
125
- hash.merge(index.to_s => nic_compute_attributes)
120
+ set_mac(nic.compute_attributes, mac, vm_type(host)) if mac.present?
121
+ interface_compute_attributes = host.compute_attributes['interfaces_attributes'] ? host.compute_attributes['interfaces_attributes'].select { |_k, v| v['id'] == nic.compute_attributes[:id] } : {}
122
+ nic.compute_attributes.store(:_delete, interface_compute_attributes[interface_compute_attributes.keys[0]]['_delete']) unless interface_compute_attributes.empty?
123
+ set_ip(host, nic, nic.compute_attributes)
124
+ set_ip(host, nic, nic.compute_attributes, true)
125
+ ForemanFogProxmox::HashCollection.remove_keys(nic.compute_attributes, ['dhcp', 'dhcp6', 'cidr', 'cidr6'])
126
+ hash.merge(index.to_s => nic.compute_attributes)
126
127
  end
127
128
  end
128
129
  end
@@ -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
  )
@@ -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" %>
@@ -105,6 +105,7 @@ module ForemanFogProxmox
105
105
  Fog::Proxmox::Compute::Node.include FogExtensions::Proxmox::Node
106
106
  ::ComputeResourcesController.include ForemanFogProxmox::Controller::Parameters::ComputeResource
107
107
  ::ComputeResourcesVmsController.include ForemanFogProxmox::ComputeResourcesVmsController
108
+ ::HostsController.include ForemanFogProxmox::HostsController
108
109
  ::Host::Managed.include Orchestration::Proxmox::Compute
109
110
  ::Host::Managed.include HostExt::Proxmox::Interfaces
110
111
  ::Host::Managed.include HostExt::Proxmox::Associator
@@ -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.4'
21
+ VERSION = '0.14.0'
22
22
  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
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
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.4
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-07-21 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
@@ -102,6 +102,7 @@ files:
102
102
  - app/assets/javascripts/foreman_fog_proxmox/proxmox_volume_cloudinit.js
103
103
  - app/controllers/concerns/foreman_fog_proxmox/compute_resources_vms_controller.rb
104
104
  - app/controllers/concerns/foreman_fog_proxmox/controller/parameters/compute_resource.rb
105
+ - app/controllers/concerns/foreman_fog_proxmox/hosts_controller.rb
105
106
  - app/controllers/foreman_fog_proxmox/compute_resources_controller.rb
106
107
  - app/helpers/node_dashboard_helper.rb
107
108
  - app/helpers/proxmox_compute_controllers_helper.rb