foreman_fog_proxmox 0.9.3 → 0.9.4
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 +4 -4
- data/README.md +8 -1
- data/app/helpers/proxmox_container_helper.rb +2 -0
- data/app/models/concerns/fog_extensions/proxmox/interface.rb +11 -0
- data/app/models/concerns/host_ext/proxmox/interfaces.rb +7 -0
- data/app/models/foreman_fog_proxmox/proxmox_interfaces.rb +45 -2
- data/app/views/compute_resources_vms/form/proxmox/_add_vm_type_to_nic_provider_specific_form.html.erb +1 -1
- data/app/views/compute_resources_vms/form/proxmox/container/_network.html.erb +6 -0
- data/lib/foreman_fog_proxmox/version.rb +1 -1
- data/test/unit/foreman_fog_proxmox/helpers/proxmox_container_helper_test.rb +11 -11
- data/test/unit/foreman_fog_proxmox/proxmox_compute_attributes_test.rb +1 -1
- data/test/unit/foreman_fog_proxmox/proxmox_interfaces_test.rb +48 -2
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4c422b2ba09e7b1cd71a0dec7ec72398c71f4653a0b8386d4949ea15932df346
|
4
|
+
data.tar.gz: e870f6684243b1a7f7ee061648d0ad6efd1a1e51a466861f2c1e60f13bc6bc10
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eede4a7f2e4a098e90737ba71c389d979254720fbd876d5a5c73e792302fc6b59a69e37ec8736fa4fd31da982384b6bde8bd9651131ec71035338460c6bb4c26
|
7
|
+
data.tar.gz: 315fc305b50d96704ac6637d9a8689af9cc7d43ec93afe0c2804755b2b14a35183754a212be2f33cec25c1b37c0b124e9c20f0e0ed12a397560749115c88907c
|
data/README.md
CHANGED
@@ -28,6 +28,7 @@ You can support the plugin development via the following methods:
|
|
28
28
|
|<=0.8 |<6.0|>=0.7|>=1.22|>=2.3|
|
29
29
|
|<0.9 |<6.0|=0.9|>=1.22|>=2.3|
|
30
30
|
|>=0.9 |>=5.4|>=0.9.1|>=1.22|>=2.3|
|
31
|
+
|>=0.10 |>=5.4|>=0.9.4|>=1.22|>=2.5|
|
31
32
|
|
32
33
|
## Installation
|
33
34
|
|
@@ -110,7 +111,7 @@ Redhat, CentOS or Fedora users should also [setup Selinux](https://projects.thef
|
|
110
111
|
### Prerequisites
|
111
112
|
|
112
113
|
* You need a Proxmox VE 5.4+ server running.
|
113
|
-
* You need ruby >= 2.
|
114
|
+
* You need ruby >= 2.5. You can install it with [rbenv](https://github.com/rbenv/rbenv).
|
114
115
|
* You also need nodejs in your dev machine to run webpack-dev-server. You can install it with [nvm](https://github.com/creationix/nvm).
|
115
116
|
|
116
117
|
### Platform
|
@@ -182,6 +183,12 @@ export DISABLE_SPRING=true
|
|
182
183
|
bundle exec bin/rake test TEST=test/functional/compute_resources_controller_test.rb
|
183
184
|
```
|
184
185
|
|
186
|
+
* Check code syntax with rubocop and foreman rules:
|
187
|
+
|
188
|
+
```shell
|
189
|
+
bundle exec bin/rake foreman_fog_proxmox:rubocop
|
190
|
+
```
|
191
|
+
|
185
192
|
* See deface overrides result:
|
186
193
|
|
187
194
|
```shell
|
@@ -150,6 +150,8 @@ module ProxmoxContainerHelper
|
|
150
150
|
nic.store(:bridge, interface_attributes['bridge'].to_s) if interface_attributes['bridge']
|
151
151
|
nic.store(:ip, interface_attributes['ip'].to_s) if interface_attributes['ip']
|
152
152
|
nic.store(:ip6, interface_attributes['ip6'].to_s) if interface_attributes['ip6']
|
153
|
+
nic.store(:gw, interface_attributes['gw'].to_s) if interface_attributes['gw']
|
154
|
+
nic.store(:gw6, interface_attributes['gw6'].to_s) if interface_attributes['gw6']
|
153
155
|
nic.store(:rate, interface_attributes['rate'].to_i) if interface_attributes['rate']
|
154
156
|
nic.store(:tag, interface_attributes['tag'].to_i) if interface_attributes['tag']
|
155
157
|
logger.debug("parse_container_interface(): add nic=#{nic}")
|
@@ -17,13 +17,24 @@
|
|
17
17
|
# You should have received a copy of the GNU General Public License
|
18
18
|
# along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>.
|
19
19
|
|
20
|
+
require 'fog/proxmox/helpers/ip_helper'
|
21
|
+
|
20
22
|
module FogExtensions
|
21
23
|
module Proxmox
|
22
24
|
module Interface
|
23
25
|
extend ActiveSupport::Concern
|
26
|
+
attr_accessor :dhcpv4, :dhcpv6, :gwv4, :gwv6
|
24
27
|
def mac
|
25
28
|
macaddr
|
26
29
|
end
|
30
|
+
|
31
|
+
def cidrv4_prefix
|
32
|
+
Fog::Proxmox::IpHelper.prefix(ip) if ip
|
33
|
+
end
|
34
|
+
|
35
|
+
def cidrv6_prefix
|
36
|
+
Fog::Proxmox::IpHelper.prefix6(ip) if ip
|
37
|
+
end
|
27
38
|
end
|
28
39
|
end
|
29
40
|
end
|
@@ -17,6 +17,8 @@
|
|
17
17
|
# You should have received a copy of the GNU General Public License
|
18
18
|
# along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>.
|
19
19
|
|
20
|
+
require 'fog/proxmox/helpers/ip_helper'
|
21
|
+
|
20
22
|
module HostExt
|
21
23
|
module Proxmox
|
22
24
|
module Interfaces
|
@@ -33,11 +35,16 @@ module HostExt
|
|
33
35
|
end
|
34
36
|
end
|
35
37
|
|
38
|
+
def cidr_ip(interface_attributes)
|
39
|
+
Fog::Proxmox::IpHelper.to_cidr(interface_attributes['ip'], interface_attributes['compute_attributes']['cidr_suffix'])
|
40
|
+
end
|
41
|
+
|
36
42
|
def add_interface_to_compute_attributes(index, interface_attributes, compute_attributes)
|
37
43
|
compute_attributes[index] = {}
|
38
44
|
compute_attributes[index].store('id', interface_attributes['identifier'])
|
39
45
|
compute_attributes[index].store('_delete', interface_attributes['_destroy'])
|
40
46
|
compute_attributes[index].store('macaddr', interface_attributes['mac'])
|
47
|
+
compute_attributes[index].store('ip', cidr_ip(interface_attributes))
|
41
48
|
compute_attributes[index].merge!(interface_attributes['compute_attributes'].reject { |k, _v| k == 'id' })
|
42
49
|
end
|
43
50
|
end
|
@@ -17,6 +17,8 @@
|
|
17
17
|
# You should have received a copy of the GNU General Public License
|
18
18
|
# along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>.
|
19
19
|
|
20
|
+
require 'fog/proxmox/helpers/ip_helper'
|
21
|
+
|
20
22
|
module ForemanFogProxmox
|
21
23
|
module ProxmoxInterfaces
|
22
24
|
def editable_network_interfaces?
|
@@ -41,6 +43,45 @@ module ForemanFogProxmox
|
|
41
43
|
raise ::Foreman::Exception, _(format('Invalid name interface[%<index>s]. Must be eth[n] with n integer >= 0', index: index)) unless container_nic_name_valid?(nic)
|
42
44
|
end
|
43
45
|
|
46
|
+
def cidr_prefix(nic_compute_attributes, v6 = false)
|
47
|
+
attr_name = 'cidrv'
|
48
|
+
attr_name += v6 ? '6' : '4'
|
49
|
+
attr_name += '_prefix'
|
50
|
+
nic_compute_attributes[attr_name] if nic_compute_attributes[attr_name].presence
|
51
|
+
end
|
52
|
+
|
53
|
+
def set_ip(host, nic, nic_compute_attributes, v6 = false)
|
54
|
+
return 'dhcp' if dhcp?(nic_compute_attributes, v6)
|
55
|
+
|
56
|
+
ip = v6 ? nic.ip6 : nic.ip
|
57
|
+
return ip unless container?(host) || cidr_prefix(nic_compute_attributes, v6)
|
58
|
+
|
59
|
+
valid = v6 ? Fog::Proxmox::IpHelper.cidr6_prefix?(cidr_prefix(nic_compute_attributes, v6)) : Fog::Proxmox::IpHelper.cidr_prefix?(cidr_prefix(nic_compute_attributes, v6))
|
60
|
+
ipv = v6 ? 'IPv6' : 'IPv4'
|
61
|
+
max = v6 ? 128 : 32
|
62
|
+
unless valid
|
63
|
+
raise ::Foreman::Exception, _(format('Invalid Interface Proxmox CIDR %<ip>s. If %<ip>s is not empty, Proxmox CIDR prefix must be an integer between 0 and %<max>i.', ip: ipv, max: max))
|
64
|
+
end
|
65
|
+
|
66
|
+
v6 ? Fog::Proxmox::IpHelper.to_cidr6(nic.ip6, cidr_prefix(nic_compute_attributes, v6)) : Fog::Proxmox::IpHelper.to_cidr(nic.ip, cidr_prefix(nic_compute_attributes, v6))
|
67
|
+
end
|
68
|
+
|
69
|
+
def set_gw(nic_compute_attributes, v6 = false)
|
70
|
+
attr_name = 'gwv'
|
71
|
+
attr_name += v6 ? '6' : '4'
|
72
|
+
nic_compute_attributes[attr_name] if nic_compute_attributes[attr_name].presence
|
73
|
+
end
|
74
|
+
|
75
|
+
def to_boolean(value)
|
76
|
+
[1, true, '1', 'true'].include?(value)
|
77
|
+
end
|
78
|
+
|
79
|
+
def dhcp?(nic_compute_attributes, v6 = false)
|
80
|
+
attr_name = 'dhcpv'
|
81
|
+
attr_name += v6 ? '6' : '4'
|
82
|
+
to_boolean(nic_compute_attributes[attr_name]) if nic_compute_attributes[attr_name].present?
|
83
|
+
end
|
84
|
+
|
44
85
|
def host_interfaces_attrs(host)
|
45
86
|
host.interfaces.select(&:physical?).each.with_index.reduce({}) do |hash, (nic, index)|
|
46
87
|
set_nic_identifier(nic, index)
|
@@ -51,8 +92,10 @@ module ForemanFogProxmox
|
|
51
92
|
nic_compute_attributes.store(:macaddr, mac) if mac.present?
|
52
93
|
interface_compute_attributes = host.compute_attributes['interfaces_attributes'] ? host.compute_attributes['interfaces_attributes'].select { |_k, v| v['id'] == nic.identifier } : {}
|
53
94
|
nic_compute_attributes.store(:_delete, interface_compute_attributes[interface_compute_attributes.keys[0]]['_delete']) unless interface_compute_attributes.empty?
|
54
|
-
nic_compute_attributes.store(:ip, nic
|
55
|
-
nic_compute_attributes.store(:
|
95
|
+
nic_compute_attributes.store(:ip, set_ip(host, nic, nic_compute_attributes))
|
96
|
+
nic_compute_attributes.store(:gw, set_gw(nic_compute_attributes))
|
97
|
+
nic_compute_attributes.store(:ip6, set_ip(host, nic, nic_compute_attributes, true))
|
98
|
+
nic_compute_attributes.store(:gw6, set_gw(nic_compute_attributes, true))
|
56
99
|
hash.merge(index.to_s => nic_compute_attributes)
|
57
100
|
end
|
58
101
|
end
|
@@ -15,7 +15,7 @@ GNU General Public License for more details.
|
|
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
|
<% if @host.compute_resource.class == ForemanFogProxmox::Proxmox %>
|
18
|
-
<% compute_attributes = f.
|
18
|
+
<% compute_attributes = f.object.compute_attributes %>
|
19
19
|
<% vm_type = compute_attributes ? compute_attributes['type'] : f.object.type %>
|
20
20
|
|
21
21
|
<%= f.fields_for 'compute_attributes', OpenStruct.new(f.object.compute_attributes) do |f| %>
|
@@ -20,6 +20,12 @@ along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>. %>
|
|
20
20
|
<%= field_set_tag _("Nic"), :id => "container_network_#{f.index}", :style => ('display: none;' unless container), :disabled => !container do %>
|
21
21
|
<%= f.hidden_field :id if !new_vm %>
|
22
22
|
<%= text_f f, :name, :label => _('Name'), :label_size => "col-md-2" %>
|
23
|
+
<%= checkbox_f f, :dhcpv4, :label => _('DHCP IPv4') %>
|
24
|
+
<%= text_f f, :cidrv4_prefix, :label => _('CIDR IPv4 prefix'), :label_size => "col-md-2" %>
|
25
|
+
<%= text_f f, :gwv4, :label => _('Gateway IPv4'), :label_size => "col-md-2" %>
|
26
|
+
<%= checkbox_f f, :dhcpv6, :label => _('DHCP IPv6') %>
|
27
|
+
<%= text_f f, :cidrv6_prefix, :label => _('CIDR IPv6 prefix'), :label_size => "col-md-2" %>
|
28
|
+
<%= text_f f, :gwv6, :label => _('Gateway IPv6'), :label_size => "col-md-2" %>
|
23
29
|
<%= counter_f f, :tag, :class => "input-mini", :label => _('VLAN tag'), :label_size => "col-md-2" %>
|
24
30
|
<%= counter_f f, :rate, :class => "input-mini", :label => _('Rate limit'), :label_size => "col-md-2" %>
|
25
31
|
<%= select_f f, :bridge, compute_resource.bridges, :iface, :iface, { }, :label => _('Bridge'), :label_size => "col-md-2" %>
|
@@ -56,8 +56,8 @@ module ForemanFogProxmox
|
|
56
56
|
'1' => { 'id' => 'mp0', 'storage' => 'local-lvm', 'size' => '1073741824', 'mp' => '/opt/path' }
|
57
57
|
},
|
58
58
|
'interfaces_attributes' => {
|
59
|
-
'0' => { 'id' => 'net0', 'name' => 'eth0', 'bridge' => 'vmbr0', 'ip' => 'dhcp', 'ip6' => 'dhcp', 'rate' => '' },
|
60
|
-
'1' => { 'id' => 'net1', 'name' => 'eth1', 'bridge' => 'vmbr0', 'ip' => 'dhcp', 'ip6' => 'dhcp' }
|
59
|
+
'0' => { 'id' => 'net0', 'name' => 'eth0', 'bridge' => 'vmbr0', 'ip' => 'dhcp', 'ip6' => 'dhcp', 'rate' => '', 'gw' => '192.168.56.100', 'gw6' => '2001:0:1234::c1c0:abcd:876' },
|
60
|
+
'1' => { 'id' => 'net1', 'name' => 'eth1', 'bridge' => 'vmbr0', 'ip' => 'dhcp', 'ip6' => 'dhcp', 'gw' => '192.168.56.100', 'gw6' => '2001:0:1234::c1c0:abcd:876' }
|
61
61
|
} }
|
62
62
|
end
|
63
63
|
|
@@ -82,8 +82,8 @@ module ForemanFogProxmox
|
|
82
82
|
'password' => 'proxmox01',
|
83
83
|
:rootfs => 'local-lvm:1073741824',
|
84
84
|
:mp0 => 'local-lvm:1073741824,mp=/opt/path',
|
85
|
-
'net0' => 'name=eth0,bridge=vmbr0,ip=dhcp,ip6=dhcp',
|
86
|
-
'net1' => 'model=eth1,bridge=vmbr0,ip=dhcp,ip6=dhcp' }
|
85
|
+
'net0' => 'name=eth0,bridge=vmbr0,ip=dhcp,ip6=dhcp,gw=192.168.56.100,gw6=2001:0:1234::c1c0:abcd:876',
|
86
|
+
'net1' => 'model=eth1,bridge=vmbr0,ip=dhcp,ip6=dhcp,gw=192.168.56.100,gw6=2001:0:1234::c1c0:abcd:876' }
|
87
87
|
end
|
88
88
|
|
89
89
|
let(:host_delete) do
|
@@ -125,7 +125,7 @@ module ForemanFogProxmox
|
|
125
125
|
vm = parse_container_vm(host)
|
126
126
|
assert_equal 536_870_912, vm[:memory]
|
127
127
|
assert_equal 'local-lvm:1073741824', vm[:rootfs]
|
128
|
-
assert_equal 'name=eth0,bridge=vmbr0,ip=dhcp,ip6=dhcp', vm[:net0]
|
128
|
+
assert_equal 'name=eth0,bridge=vmbr0,ip=dhcp,ip6=dhcp,gw=192.168.56.100,gw6=2001:0:1234::c1c0:abcd:876', vm[:net0]
|
129
129
|
assert_not vm.key?(:config)
|
130
130
|
assert_not vm.key?(:node)
|
131
131
|
assert_not vm.key?(:type)
|
@@ -145,8 +145,8 @@ module ForemanFogProxmox
|
|
145
145
|
:ostemplate => 'local:vztmpl/alpine-3.7-default_20171211_amd64.tar.xz',
|
146
146
|
:ostemplate_file => 'local:vztmpl/alpine-3.7-default_20171211_amd64.tar.xz',
|
147
147
|
:ostemplate_storage => 'local',
|
148
|
-
:net0 => 'name=eth0,bridge=vmbr0,ip=dhcp,ip6=dhcp',
|
149
|
-
:net1 => 'name=eth1,bridge=vmbr0,ip=dhcp,ip6=dhcp',
|
148
|
+
:net0 => 'name=eth0,bridge=vmbr0,ip=dhcp,ip6=dhcp,gw=192.168.56.100,gw6=2001:0:1234::c1c0:abcd:876',
|
149
|
+
:net1 => 'name=eth1,bridge=vmbr0,ip=dhcp,ip6=dhcp,gw=192.168.56.100,gw6=2001:0:1234::c1c0:abcd:876',
|
150
150
|
:rootfs => 'local-lvm:1073741824',
|
151
151
|
:mp0 => 'local-lvm:1073741824,mp=/opt/path'
|
152
152
|
)
|
@@ -171,7 +171,7 @@ module ForemanFogProxmox
|
|
171
171
|
add_container_interface(host['interfaces_attributes']['0'], deletes, nics)
|
172
172
|
assert 1, nics.length
|
173
173
|
assert nics[0].key?(:net0)
|
174
|
-
assert_equal 'name=eth0,bridge=vmbr0,ip=dhcp,ip6=dhcp', nics[0][:net0]
|
174
|
+
assert_equal 'name=eth0,bridge=vmbr0,ip=dhcp,ip6=dhcp,gw=192.168.56.100,gw6=2001:0:1234::c1c0:abcd:876', nics[0][:net0]
|
175
175
|
end
|
176
176
|
|
177
177
|
test '#interface with name eth1 and bridge' do
|
@@ -180,7 +180,7 @@ module ForemanFogProxmox
|
|
180
180
|
add_container_interface(host['interfaces_attributes']['1'], deletes, nics)
|
181
181
|
assert 1, nics.length
|
182
182
|
assert nics[0].key?(:net1)
|
183
|
-
assert_equal 'name=eth1,bridge=vmbr0,ip=dhcp,ip6=dhcp', nics[0][:net1]
|
183
|
+
assert_equal 'name=eth1,bridge=vmbr0,ip=dhcp,ip6=dhcp,gw=192.168.56.100,gw6=2001:0:1234::c1c0:abcd:876', nics[0][:net1]
|
184
184
|
end
|
185
185
|
|
186
186
|
test '#interface delete net0' do
|
@@ -196,8 +196,8 @@ module ForemanFogProxmox
|
|
196
196
|
interfaces_to_add, interfaces_to_delete = parse_container_interfaces(host['interfaces_attributes'])
|
197
197
|
assert interfaces_to_delete.empty?
|
198
198
|
assert_equal 2, interfaces_to_add.length
|
199
|
-
assert interfaces_to_add.include?(net0: 'name=eth0,bridge=vmbr0,ip=dhcp,ip6=dhcp')
|
200
|
-
assert interfaces_to_add.include?(net1: 'name=eth1,bridge=vmbr0,ip=dhcp,ip6=dhcp')
|
199
|
+
assert interfaces_to_add.include?(net0: 'name=eth0,bridge=vmbr0,ip=dhcp,ip6=dhcp,gw=192.168.56.100,gw6=2001:0:1234::c1c0:abcd:876')
|
200
|
+
assert interfaces_to_add.include?(net1: 'name=eth1,bridge=vmbr0,ip=dhcp,ip6=dhcp,gw=192.168.56.100,gw6=2001:0:1234::c1c0:abcd:876')
|
201
201
|
end
|
202
202
|
end
|
203
203
|
end
|
@@ -61,7 +61,7 @@ module ForemanFogProxmox
|
|
61
61
|
end
|
62
62
|
|
63
63
|
it 'sets container hostname with host name' do
|
64
|
-
physical_nic = FactoryBot.build(:nic_base_empty, :identifier => 'net0', :primary => true)
|
64
|
+
physical_nic = FactoryBot.build(:nic_base_empty, :identifier => 'net0', :primary => true, :compute_attributes => { 'dhcpv4' => '1', 'dhcpv6' => '1' })
|
65
65
|
host = FactoryBot.build(
|
66
66
|
:host_empty,
|
67
67
|
:interfaces => [physical_nic],
|
@@ -46,8 +46,8 @@ module ForemanFogProxmox
|
|
46
46
|
assert err.message.end_with?('Invalid identifier interface[0]. Must be net[n] with n integer >= 0')
|
47
47
|
end
|
48
48
|
|
49
|
-
it 'sets compute id with identifier, ip and ip6' do
|
50
|
-
ip =
|
49
|
+
it 'sets server compute id with identifier, ip and ip6' do
|
50
|
+
ip = '192.168.56.100'
|
51
51
|
ip6 = Array.new(4) { format('%<x>s', x: rand(16**4)) }.join(':') + '::1'
|
52
52
|
physical_nic = FactoryBot.build(:nic_base_empty, :identifier => 'net0', :ip => ip, :ip6 => ip6)
|
53
53
|
host = FactoryBot.build(
|
@@ -66,6 +66,52 @@ module ForemanFogProxmox
|
|
66
66
|
assert_equal ip, nic_attr[:ip]
|
67
67
|
assert_equal ip6, nic_attr[:ip6]
|
68
68
|
end
|
69
|
+
|
70
|
+
it 'sets container compute id with identifier, ip/CIDR, gw and ip6' do
|
71
|
+
ip = '192.168.56.100'
|
72
|
+
cidr_suffix = '31'
|
73
|
+
ip6 = Array.new(4) { format('%<x>s', x: rand(16**4)) }.join(':') + '::1'
|
74
|
+
physical_nic = FactoryBot.build(:nic_base_empty, :identifier => 'net0', :ip => ip, :ip6 => ip6, :compute_attributes => { 'cidrv4_prefix' => cidr_suffix, 'gwv4' => ip, 'dhcpv6' => '1' })
|
75
|
+
host = FactoryBot.build(
|
76
|
+
:host_empty,
|
77
|
+
:interfaces => [physical_nic],
|
78
|
+
:compute_attributes => {
|
79
|
+
'type' => 'lxc',
|
80
|
+
'interfaces_attributes' => {
|
81
|
+
'0' => physical_nic
|
82
|
+
}
|
83
|
+
}
|
84
|
+
)
|
85
|
+
nic_attributes = @cr.host_interfaces_attrs(host).values.select(&:present?)
|
86
|
+
nic_attr = nic_attributes.first
|
87
|
+
assert_equal 'net0', nic_attr[:id]
|
88
|
+
assert_equal Fog::Proxmox::IpHelper.to_cidr(ip, cidr_suffix), nic_attr[:ip]
|
89
|
+
assert_equal ip, nic_attr[:gw]
|
90
|
+
assert_equal 'dhcp', nic_attr[:ip6]
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'sets container compute id with identifier, ip DHCP, gw6 and ip6' do
|
94
|
+
ip = '192.168.56.100'
|
95
|
+
cidr6_suffix = '100'
|
96
|
+
ip6 = '2001:0:1234::c1c0:abcd:876'
|
97
|
+
physical_nic = FactoryBot.build(:nic_base_empty, :identifier => 'net0', :ip => ip, :ip6 => ip6, :compute_attributes => { 'cidrv6_prefix' => cidr6_suffix, 'dhcpv4' => '1', 'gwv6' => ip6 })
|
98
|
+
host = FactoryBot.build(
|
99
|
+
:host_empty,
|
100
|
+
:interfaces => [physical_nic],
|
101
|
+
:compute_attributes => {
|
102
|
+
'type' => 'lxc',
|
103
|
+
'interfaces_attributes' => {
|
104
|
+
'0' => physical_nic
|
105
|
+
}
|
106
|
+
}
|
107
|
+
)
|
108
|
+
nic_attributes = @cr.host_interfaces_attrs(host).values.select(&:present?)
|
109
|
+
nic_attr = nic_attributes.first
|
110
|
+
assert_equal 'net0', nic_attr[:id]
|
111
|
+
assert_equal 'dhcp', nic_attr[:ip]
|
112
|
+
assert_equal Fog::Proxmox::IpHelper.to_cidr6(ip6, cidr6_suffix), nic_attr[:ip6]
|
113
|
+
assert_equal ip6, nic_attr[:gw6]
|
114
|
+
end
|
69
115
|
end
|
70
116
|
end
|
71
117
|
end
|
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.9.
|
4
|
+
version: 0.9.4
|
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:
|
12
|
+
date: 2020-01-30 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.
|
34
|
+
version: '0.10'
|
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.
|
41
|
+
version: '0.10'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: rdoc
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|