fog-proxmox 0.9.0 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/FUNDING.yml +12 -0
- data/.gitignore +1 -0
- data/.travis.yml +4 -9
- data/README.md +8 -7
- data/fog-proxmox.gemspec +2 -2
- data/lib/fog/compute/proxmox/models/interface.rb +2 -0
- data/lib/fog/proxmox/helpers/controller_helper.rb +1 -1
- data/lib/fog/proxmox/helpers/ip_helper.rb +100 -0
- data/lib/fog/proxmox/helpers/nic_helper.rb +16 -2
- data/lib/fog/proxmox/version.rb +1 -1
- data/spec/helpers/controller_helper_spec.rb +13 -2
- data/spec/helpers/ip_helper_spec.rb +160 -0
- data/spec/helpers/nic_helper_spec.rb +18 -4
- metadata +9 -6
- data/Gemfile.lock +0 -153
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b70163a7fccb9ed54779d18ca8dc37d6ea04fec9ab2c94c91d13282feb589c6
|
4
|
+
data.tar.gz: 65b66339365af13f176e4cd4410f58bd9fa46c10c45082852b36bb5beaa4332b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e85b1ec840dd0bb45da7eec64fb4b0a0727cf99fadc08a6a2f8a1b6a389a280b6ea36420bb611f645be77f19c351b00651f08d32e9448f904f1e4b1e0a91ee4
|
7
|
+
data.tar.gz: 7e4fcd61713c55989078272a458b98fddb6399eacf36e5dc0d2678925799a48179097cec35bcc0f2332569b432d1c275fd5b25c50ba5d2fe4f3697c6c8f7ec69
|
data/.github/FUNDING.yml
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# These are supported funding model platforms
|
2
|
+
|
3
|
+
github: [tristanrobert] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
4
|
+
patreon: # Replace with a single Patreon username
|
5
|
+
open_collective: # Replace with a single Open Collective username
|
6
|
+
ko_fi: # Replace with a single Ko-fi username
|
7
|
+
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
8
|
+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
9
|
+
liberapay: # Replace with a single Liberapay username
|
10
|
+
issuehunt: # Replace with a single IssueHunt username
|
11
|
+
otechie: # Replace with a single Otechie username
|
12
|
+
custom: ["https://paypal.me/TristanRobert"]# Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -5,17 +5,12 @@ language: ruby
|
|
5
5
|
sudo: false
|
6
6
|
cache: bundler
|
7
7
|
rvm:
|
8
|
-
- 2.
|
9
|
-
- 2.
|
10
|
-
- 2.
|
11
|
-
- 2.6.2
|
8
|
+
- 2.5.7
|
9
|
+
- 2.6.5
|
10
|
+
- 2.7.0
|
12
11
|
notifications:
|
13
|
-
email: false
|
14
|
-
slack:
|
15
|
-
secure: e79Y7mFzf+DwnQVg9kniuk9qwtWt1S+7iT8chNMPkugEdsgGt5vKsWvMd0fNmPGsmmHqTaVd4m8Xf4+CpR7nB4oG5pWADrKc4p/syPYWBl/MlC7U3W214oZG5U06hAyJIhpdsC3+ufGHcp3pWUS/SjCUTZgMlp5fNZSh/wzmZe2yWWheFObE2Zj/UAWw0g6WFCmO7ST44Yvy2jhECSIKT9l8ChWr1jXD3h9eDWDJmybySHzO7Tsf/l0gMy92TzqZpjcrPHZsDs+BfVRMucHuO2D72t3WgyJzoVUolYs2nboDUm2IbWzx7Ut/RuvdlG6wv98BJmImzt4ickIZPNzxus56bFHsJQMZ0wSsJR/rAfzwuXqyLd2gQBuSmS352q4w7h4WAVH+i9xhcR5VIazS9tLLGYHEQ7Df/K4fN9+qnOAg+ngDaUU26ChmfsgjXc1fW+9ipzlg7L6OlUOkpypuOGGWKxz0K/gercyJy3DsHS9i1SstgiAEZJ3rJIUUgA9kynuCOEQ8Lv3YodZ+ezqB6HOtk6tZVBpZKDPkvHuapDZikKycvTvyNxD/BugfpRgMub6ac9Ub6aXC2S3xWbD8BHjGWZzRI21LYK6jWBuSu6r5ce2rXWACTWFQbRrNa5iWPXGiTd3sSRoGMZK9yrMdpWJfkhBPHf+6R7RMgiJ499M=
|
16
12
|
before_install:
|
17
|
-
- gem update
|
18
|
-
- gem update bundler
|
13
|
+
- gem update bundler
|
19
14
|
before_script:
|
20
15
|
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
21
16
|
- chmod +x ./cc-test-reporter
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
[![Maintainability](https://api.codeclimate.com/v1/badges/33e619f2167cc9864b61/maintainability)](https://codeclimate.com/github/fog/fog-proxmox/maintainability)
|
7
7
|
[![Test Coverage](https://api.codeclimate.com/v1/badges/33e619f2167cc9864b61/test_coverage)](https://codeclimate.com/github/fog/fog-proxmox/test_coverage)
|
8
8
|
|
9
|
-
This is a [FOG](http://fog.io/) (>= 1
|
9
|
+
This is a [FOG](http://fog.io/) (>= 2.1) module gem to support [Proxmox VE](https://www.proxmox.com/en/proxmox-ve)
|
10
10
|
|
11
11
|
It is intended to satisfy this [feature](https://github.com/fog/fog/issues/3644), but Proxmox provider only, and above all this [Foreman](http://www.theforeman.org) [feature](https://projects.theforeman.org/issues/2186).
|
12
12
|
|
@@ -14,12 +14,13 @@ It is inspired by the great [fog-openstack](https://github.com/fog/fog-openstack
|
|
14
14
|
|
15
15
|
## Compatibility versions
|
16
16
|
|
17
|
-
|Fog-Proxmox|Proxmox VE|
|
18
|
-
|
19
|
-
|<0.6|<5.3|
|
20
|
-
|>=0.6|>=5.3|
|
21
|
-
|>=0.8|>=5.4|
|
22
|
-
|>=0.9|>=6.0|
|
17
|
+
|Fog-Proxmox|Proxmox VE|Fog-core|ruby|
|
18
|
+
|--|--|--|--|
|
19
|
+
|<0.6|<5.3|>=1.45|>=2.3|
|
20
|
+
|>=0.6|>=5.3|>=1.45|>=2.3|
|
21
|
+
|>=0.8|>=5.4|>=1.45|>=2.3|
|
22
|
+
|>=0.9|>=6.0|>=2.1|>=2.3|
|
23
|
+
|>=0.10|>=6.0|>=2.1|>=2.5|
|
23
24
|
|
24
25
|
## Installation
|
25
26
|
|
data/fog-proxmox.gemspec
CHANGED
@@ -36,10 +36,10 @@ Gem::Specification.new do |spec|
|
|
36
36
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
37
37
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
38
38
|
spec.require_paths = ['lib']
|
39
|
-
spec.required_ruby_version = '>= 2.
|
39
|
+
spec.required_ruby_version = '>= 2.5'
|
40
40
|
spec.rubygems_version = '~> 2.6'
|
41
41
|
|
42
|
-
spec.add_development_dependency 'bundler', '~> 2.
|
42
|
+
spec.add_development_dependency 'bundler', '~> 2.1'
|
43
43
|
spec.add_development_dependency 'debase', '~> 0.2.2'
|
44
44
|
spec.add_development_dependency 'debride', '~> 1.8'
|
45
45
|
spec.add_development_dependency 'fasterer', '~> 0.3'
|
@@ -24,7 +24,7 @@ module Fog
|
|
24
24
|
|
25
25
|
CONTROLLERS = %w[ide sata scsi virtio mp rootfs].freeze
|
26
26
|
def self.extract(name, controller_value)
|
27
|
-
matches = controller_value.match(/[,]{0,1}#{name}[=]{1}(?<name_value>[\w
|
27
|
+
matches = controller_value.match(/[,]{0,1}#{name}[=]{1}(?<name_value>[\w\/\.\:]+)/)
|
28
28
|
matches ? matches[:name_value] : matches
|
29
29
|
end
|
30
30
|
|
@@ -0,0 +1,100 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2018 Tristan Robert
|
4
|
+
|
5
|
+
# This file is part of Fog::Proxmox.
|
6
|
+
|
7
|
+
# Fog::Proxmox 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
|
+
# Fog::Proxmox 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 Fog::Proxmox. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
|
20
|
+
require 'resolv'
|
21
|
+
require 'fog/proxmox/hash'
|
22
|
+
|
23
|
+
module Fog
|
24
|
+
module Proxmox
|
25
|
+
# module IpHelper mixins
|
26
|
+
module IpHelper
|
27
|
+
|
28
|
+
CIDRv4_PREFIX = '([0-9]|[1-2][0-9]|3[0-2])'
|
29
|
+
CIDRv4_PREFIX_REGEXP = /^#{CIDRv4_PREFIX}$/
|
30
|
+
IPv4_SRC = "#{Resolv::IPv4::Regex.source.delete_suffix('\z').delete_prefix('\A')}"
|
31
|
+
CIDRv4_REGEXP = Regexp.new("\\A(#{IPv4_SRC})(\/#{CIDRv4_PREFIX})?\\z")
|
32
|
+
CIDRv6_PREFIX = '(\d+)'
|
33
|
+
CIDRv6_PREFIX_REGEXP = /^#{CIDRv6_PREFIX}$/xi
|
34
|
+
IPv6_SRC = "#{Resolv::IPv6::Regex_8Hex.source.delete_suffix('\z').delete_prefix('\A')}"
|
35
|
+
CIDRv6_REGEXP = Regexp.new("\\A(#{IPv6_SRC})(\/#{CIDRv6_PREFIX})?\\z", Regexp::EXTENDED | Regexp::IGNORECASE)
|
36
|
+
|
37
|
+
def self.cidr?(ip)
|
38
|
+
CIDRv4_REGEXP.match?(ip)
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.cidr6?(ip)
|
42
|
+
CIDRv6_REGEXP.match?(ip)
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.prefix(ip)
|
46
|
+
if cidr = CIDRv4_REGEXP.match(ip)
|
47
|
+
cidr[7]
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.prefix6(ip)
|
52
|
+
if cidr = CIDRv6_REGEXP.match(ip)
|
53
|
+
cidr[3]
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.ip?(ip)
|
58
|
+
Resolv::IPv4::Regex.match?(ip)
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.ip6?(ip)
|
62
|
+
Resolv::IPv6::Regex.match?(ip)
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.cidr_prefix?(prefix)
|
66
|
+
CIDRv4_PREFIX_REGEXP.match?(prefix)
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.cidr6_prefix?(prefix)
|
70
|
+
CIDRv6_PREFIX_REGEXP.match?(prefix) && prefix.to_i >= 0 && prefix.to_i <= 128
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.ip(ip)
|
74
|
+
if cidr = CIDRv4_REGEXP.match(ip)
|
75
|
+
cidr[1]
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def self.ip6(ip)
|
80
|
+
if cidr = CIDRv6_REGEXP.match(ip)
|
81
|
+
cidr[1]
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def self.to_cidr(ip,prefix = nil)
|
86
|
+
return nil unless self.ip?(ip) && (!prefix || self.cidr_prefix?(prefix))
|
87
|
+
cidr = "#{ip}"
|
88
|
+
cidr += "/#{prefix}" if self.cidr_prefix?(prefix)
|
89
|
+
cidr
|
90
|
+
end
|
91
|
+
|
92
|
+
def self.to_cidr6(ip,prefix = nil)
|
93
|
+
return nil unless self.ip6?(ip) && (!prefix || self.cidr6_prefix?(prefix))
|
94
|
+
cidr = "#{ip}"
|
95
|
+
cidr += "/#{prefix}" if self.cidr6_prefix?(prefix)
|
96
|
+
cidr
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
@@ -38,16 +38,24 @@ module Fog
|
|
38
38
|
/^name=(\w+)[,].+/
|
39
39
|
end
|
40
40
|
|
41
|
+
def self.ip_regexp
|
42
|
+
/^(.+)[,]{1}ip=([\d\.\/]+)[,]?(.+)?$/
|
43
|
+
end
|
44
|
+
|
41
45
|
def self.nic_update_regexp
|
42
46
|
/^(\w+)[=]{1}([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2}).+/
|
43
47
|
end
|
44
48
|
|
45
49
|
def self.has_model?(nic_value)
|
46
|
-
nic_value.match(self.model_regexp)
|
50
|
+
nic_value.match?(self.model_regexp)
|
47
51
|
end
|
48
52
|
|
49
53
|
def self.has_name?(nic_value)
|
50
|
-
nic_value.match(self.name_regexp)
|
54
|
+
nic_value.match?(self.name_regexp)
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.has_ip?(nic_value)
|
58
|
+
nic_value.match?(self.ip_regexp)
|
51
59
|
end
|
52
60
|
|
53
61
|
def self.extract_nic_id(nic_value)
|
@@ -96,6 +104,12 @@ module Fog
|
|
96
104
|
def self.nic?(id)
|
97
105
|
NICS_REGEXP.match(id) ? true : false
|
98
106
|
end
|
107
|
+
|
108
|
+
def self.extract_ip(nic_value)
|
109
|
+
if ip = self.ip_regexp.match(nic_value)
|
110
|
+
ip[2]
|
111
|
+
end
|
112
|
+
end
|
99
113
|
end
|
100
114
|
end
|
101
115
|
end
|
data/lib/fog/proxmox/version.rb
CHANGED
@@ -23,11 +23,14 @@ require 'fog/proxmox/helpers/controller_helper'
|
|
23
23
|
describe Fog::Proxmox::ControllerHelper do
|
24
24
|
|
25
25
|
let(:net) do
|
26
|
-
{ net0: 'virtio=66:89:C5:59:AA:96,bridge=vmbr0,firewall=1,link_down=1,queues=1,rate=1,tag=1
|
26
|
+
{ net0: 'virtio=66:89:C5:59:AA:96,bridge=vmbr0,firewall=1,link_down=1,queues=1,rate=1,tag=1' }
|
27
27
|
end
|
28
28
|
let(:net_no_options) do
|
29
29
|
{ net0: 'virtio=66:89:C5:59:AA:96' }
|
30
|
-
end
|
30
|
+
end
|
31
|
+
let(:net_lxc) do
|
32
|
+
{ net0: 'virtio=66:89:C5:59:AA:96,bridge=vmbr0,firewall=1,link_down=1,queues=1,rate=1,tag=1,ip=192.168.56.100/31,ip6=2001:0000:1234:0000:0000:C1C0:ABCD:0876/31' }
|
33
|
+
end
|
31
34
|
let(:scsi) do
|
32
35
|
{ scsi10: 'local-lvm:1,cache=none' }
|
33
36
|
end
|
@@ -62,6 +65,14 @@ require 'fog/proxmox/helpers/controller_helper'
|
|
62
65
|
path = Fog::Proxmox::ControllerHelper.extract('mp',mp[:mp0])
|
63
66
|
assert_equal '/opt/path', path
|
64
67
|
end
|
68
|
+
it "returns cidr ip" do
|
69
|
+
path = Fog::Proxmox::ControllerHelper.extract('ip',net_lxc[:net0])
|
70
|
+
assert_equal '192.168.56.100/31', path
|
71
|
+
end
|
72
|
+
it "returns cidr ip6" do
|
73
|
+
path = Fog::Proxmox::ControllerHelper.extract('ip6',net_lxc[:net0])
|
74
|
+
assert_equal '2001:0000:1234:0000:0000:C1C0:ABCD:0876/31', path
|
75
|
+
end
|
65
76
|
end
|
66
77
|
|
67
78
|
describe '#extract_index' do
|
@@ -0,0 +1,160 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2018 Tristan Robert
|
4
|
+
|
5
|
+
# This file is part of Fog::Proxmox.
|
6
|
+
|
7
|
+
# Fog::Proxmox 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
|
+
# Fog::Proxmox 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 Fog::Proxmox. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
|
20
|
+
require 'spec_helper'
|
21
|
+
require 'fog/proxmox/helpers/ip_helper'
|
22
|
+
|
23
|
+
describe Fog::Proxmox::IpHelper do
|
24
|
+
|
25
|
+
let(:ip) do
|
26
|
+
{ ip: '192.168.56.100/31' }
|
27
|
+
end
|
28
|
+
|
29
|
+
let(:invalid_ip) do
|
30
|
+
{ ip: '192.168.56.100/sfsdfsdfdsf' }
|
31
|
+
end
|
32
|
+
|
33
|
+
let(:ip6) do
|
34
|
+
{ ip: '2001:0000:1234:0000:0000:C1C0:ABCD:0876/31' }
|
35
|
+
end
|
36
|
+
|
37
|
+
let(:invalid_ip6) do
|
38
|
+
{ ip: '2001:0000:1234:0000:0000:C1C0:ABCD:0876/sfsdfsdfdsf' }
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '#cidr?' do
|
42
|
+
it "192.168.56.100/31 returns true" do
|
43
|
+
assert_equal true, Fog::Proxmox::IpHelper.cidr?(ip[:ip])
|
44
|
+
end
|
45
|
+
it "192.168.56.100/sfsdfsdfdsf returns false" do
|
46
|
+
assert_equal false, Fog::Proxmox::IpHelper.cidr?(invalid_ip[:ip])
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe '#cidr6?' do
|
51
|
+
it "2001:0000:1234:0000:0000:C1C0:ABCD:0876/31 returns true" do
|
52
|
+
assert_equal true, Fog::Proxmox::IpHelper.cidr6?(ip6[:ip])
|
53
|
+
end
|
54
|
+
it "2001:0000:1234:0000:0000:C1C0:ABCD:0876/sfsdfsdfdsf returns false" do
|
55
|
+
assert_equal false, Fog::Proxmox::IpHelper.cidr6?(invalid_ip6[:ip])
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe '#prefix' do
|
60
|
+
it "192.168.56.100/31 returns 31" do
|
61
|
+
assert_equal '31', Fog::Proxmox::IpHelper.prefix(ip[:ip])
|
62
|
+
end
|
63
|
+
it "192.168.56.100/sfsdfsdfdsf returns nil" do
|
64
|
+
assert_nil Fog::Proxmox::IpHelper.prefix(invalid_ip[:ip])
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe '#prefix6' do
|
69
|
+
it "2001:0000:1234:0000:0000:C1C0:ABCD:0876/31 returns 31" do
|
70
|
+
assert_equal '31', Fog::Proxmox::IpHelper.prefix6(ip6[:ip])
|
71
|
+
end
|
72
|
+
it "2001:0000:1234:0000:0000:C1C0:ABCD:0876/sfsdfsdfdsf returns nil" do
|
73
|
+
assert_nil Fog::Proxmox::IpHelper.prefix6(invalid_ip6[:ip])
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
describe '#ip' do
|
78
|
+
it "192.168.56.100/31 returns 192.168.56.100" do
|
79
|
+
assert_equal '192.168.56.100', Fog::Proxmox::IpHelper.ip(ip[:ip])
|
80
|
+
end
|
81
|
+
it "192.168.56.100/sfsdfsdfdsf returns nil" do
|
82
|
+
assert_nil Fog::Proxmox::IpHelper.ip(invalid_ip[:ip])
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe '#ip6' do
|
87
|
+
it "2001:0000:1234:0000:0000:C1C0:ABCD:0876/31 returns 2001:0000:1234:0000:0000:C1C0:ABCD:0876" do
|
88
|
+
assert_equal '2001:0000:1234:0000:0000:C1C0:ABCD:0876', Fog::Proxmox::IpHelper.ip6(ip6[:ip])
|
89
|
+
end
|
90
|
+
it "2001:0000:1234:0000:0000:C1C0:ABCD:0876/sfsdfsdfdsf returns nil" do
|
91
|
+
assert_nil Fog::Proxmox::IpHelper.ip6(invalid_ip6[:ip])
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
describe '#to_cidr' do
|
96
|
+
it "192.168.56.100 returns 192.168.56.100" do
|
97
|
+
assert_equal '192.168.56.100', Fog::Proxmox::IpHelper.to_cidr('192.168.56.100')
|
98
|
+
end
|
99
|
+
it "192.168.56.100,31 returns 192.168.56.100/31" do
|
100
|
+
assert_equal '192.168.56.100/31', Fog::Proxmox::IpHelper.to_cidr('192.168.56.100','31')
|
101
|
+
end
|
102
|
+
it "192,31 returns nil" do
|
103
|
+
assert_nil Fog::Proxmox::IpHelper.to_cidr('192','31')
|
104
|
+
end
|
105
|
+
it "192.168.56.100,56 returns nil" do
|
106
|
+
assert_nil Fog::Proxmox::IpHelper.to_cidr('192.168.56.100','56')
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
describe '#to_cidr6' do
|
111
|
+
it "2001:0000:1234:0000:0000:C1C0:ABCD:0876 returns 2001:0000:1234:0000:0000:C1C0:ABCD:0876" do
|
112
|
+
assert_equal '2001:0000:1234:0000:0000:C1C0:ABCD:0876', Fog::Proxmox::IpHelper.to_cidr6('2001:0000:1234:0000:0000:C1C0:ABCD:0876')
|
113
|
+
end
|
114
|
+
it "2001:0000:1234:0000:0000:C1C0:ABCD:0876,31 returns 2001:0000:1234:0000:0000:C1C0:ABCD:0876/31" do
|
115
|
+
assert_equal '2001:0000:1234:0000:0000:C1C0:ABCD:0876/31', Fog::Proxmox::IpHelper.to_cidr6('2001:0000:1234:0000:0000:C1C0:ABCD:0876','31')
|
116
|
+
end
|
117
|
+
it "2001:0000:1234:0000:0000:C1C0:ABCD:0876,158 returns nil" do
|
118
|
+
assert_nil Fog::Proxmox::IpHelper.to_cidr6('2001:0000:1234:0000:0000:C1C0:ABCD:0876','158')
|
119
|
+
end
|
120
|
+
it "192,31 returns nil" do
|
121
|
+
assert_nil Fog::Proxmox::IpHelper.to_cidr6('192','31')
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
describe '#ip?' do
|
126
|
+
it "192.168.56.100 returns true" do
|
127
|
+
assert_equal true, Fog::Proxmox::IpHelper.ip?('192.168.56.100')
|
128
|
+
end
|
129
|
+
it "541536 returns false" do
|
130
|
+
assert_equal false, Fog::Proxmox::IpHelper.ip?('541536')
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
describe '#ip6?' do
|
135
|
+
it "2001:0000:1234:0000:0000:C1C0:ABCD:0876 returns true" do
|
136
|
+
assert_equal true, Fog::Proxmox::IpHelper.ip6?('2001:0000:1234:0000:0000:C1C0:ABCD:0876')
|
137
|
+
end
|
138
|
+
it "541536 returns false" do
|
139
|
+
assert_equal false, Fog::Proxmox::IpHelper.ip6?('541536')
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
describe '#cidr_prefix?' do
|
144
|
+
it "31 returns true" do
|
145
|
+
assert_equal true, Fog::Proxmox::IpHelper.cidr_prefix?('31')
|
146
|
+
end
|
147
|
+
it "56 returns false" do
|
148
|
+
assert_equal false, Fog::Proxmox::IpHelper.cidr_prefix?('56')
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
describe '#cidr6_prefix?' do
|
153
|
+
it "100 returns true" do
|
154
|
+
assert_equal true, Fog::Proxmox::IpHelper.cidr6_prefix?('100')
|
155
|
+
end
|
156
|
+
it "158 returns false" do
|
157
|
+
assert_equal false, Fog::Proxmox::IpHelper.cidr6_prefix?('158')
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
@@ -31,15 +31,15 @@ require 'fog/proxmox/helpers/nic_helper'
|
|
31
31
|
end
|
32
32
|
|
33
33
|
let(:net_lxc) do
|
34
|
-
{ net0: 'eth0=66:89:C5:59:AA:96,bridge=vmbr0,firewall=1,link_down=1,queues=1,rate=1,tag=1' }
|
34
|
+
{ net0: 'eth0=66:89:C5:59:AA:96,bridge=vmbr0,firewall=1,link_down=1,queues=1,rate=1,tag=1,ip=192.168.56.100/31' }
|
35
35
|
end
|
36
36
|
|
37
37
|
let(:net_lxc_create) do
|
38
|
-
{ net0: 'name=eth0,bridge=vmbr0,firewall=1,link_down=1,queues=1,rate=1,tag=1' }
|
38
|
+
{ net0: 'name=eth0,bridge=vmbr0,firewall=1,link_down=1,queues=1,rate=1,tag=1,ip=192.168.56.100/31' }
|
39
39
|
end
|
40
40
|
|
41
41
|
let(:lxc_nic) do
|
42
|
-
{ id: 'net0', name: 'eth0', macaddr: '66:89:C5:59:AA:96', bridge: 'vmbr0', firewall: 1, link_down: 1, queues: 1, rate: 1, tag: 1 }
|
42
|
+
{ id: 'net0', name: 'eth0', macaddr: '66:89:C5:59:AA:96', bridge: 'vmbr0', firewall: 1, link_down: 1, queues: 1, rate: 1, tag: 1, ip: '192.168.56.100/31' }
|
43
43
|
end
|
44
44
|
|
45
45
|
let(:qemu_nic) do
|
@@ -115,8 +115,22 @@ require 'fog/proxmox/helpers/nic_helper'
|
|
115
115
|
assert_equal flat_qemu ,Fog::Proxmox::NicHelper.flatten(qemu_nic_create)
|
116
116
|
end
|
117
117
|
it "returns lxc nic string" do
|
118
|
-
flat_lxc = { net0: 'eth0=66:89:C5:59:AA:96,bridge=vmbr0,firewall=1,link_down=1,queues=1,rate=1,tag=1' }
|
118
|
+
flat_lxc = { net0: 'eth0=66:89:C5:59:AA:96,bridge=vmbr0,firewall=1,link_down=1,queues=1,rate=1,tag=1,ip=192.168.56.100/31' }
|
119
119
|
assert_equal flat_lxc ,Fog::Proxmox::NicHelper.flatten(lxc_nic)
|
120
120
|
end
|
121
121
|
end
|
122
|
+
|
123
|
+
describe '#has_ip?' do
|
124
|
+
it "returns true" do
|
125
|
+
ip = Fog::Proxmox::NicHelper.has_ip?(net_lxc[:net0])
|
126
|
+
assert_equal true, ip
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
describe '#extract_ip' do
|
131
|
+
it "returns lxc ip cidr" do
|
132
|
+
ip = Fog::Proxmox::NicHelper.extract_ip(net_lxc[:net0])
|
133
|
+
assert_equal '192.168.56.100/31', ip
|
134
|
+
end
|
135
|
+
end
|
122
136
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fog-proxmox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tristan Robert
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '2.
|
19
|
+
version: '2.1'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '2.
|
26
|
+
version: '2.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: debase
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -304,6 +304,7 @@ files:
|
|
304
304
|
- ".github/CODE_OF_CONDUCT.md"
|
305
305
|
- ".github/CONTRIBUTING.md"
|
306
306
|
- ".github/CONTRIBUTORS.md"
|
307
|
+
- ".github/FUNDING.yml"
|
307
308
|
- ".github/ISSUE_TEMPLATE.md"
|
308
309
|
- ".github/ISSUE_TEMPLATE/bug_report.md"
|
309
310
|
- ".github/ISSUE_TEMPLATE/feature_request.md"
|
@@ -319,7 +320,6 @@ files:
|
|
319
320
|
- ".vscode/settings.json"
|
320
321
|
- ".vscode/tasks.json"
|
321
322
|
- Gemfile
|
322
|
-
- Gemfile.lock
|
323
323
|
- LICENSE
|
324
324
|
- README.md
|
325
325
|
- Rakefile
|
@@ -453,6 +453,7 @@ files:
|
|
453
453
|
- lib/fog/proxmox/helpers/controller_helper.rb
|
454
454
|
- lib/fog/proxmox/helpers/cpu_helper.rb
|
455
455
|
- lib/fog/proxmox/helpers/disk_helper.rb
|
456
|
+
- lib/fog/proxmox/helpers/ip_helper.rb
|
456
457
|
- lib/fog/proxmox/helpers/nic_helper.rb
|
457
458
|
- lib/fog/proxmox/json.rb
|
458
459
|
- lib/fog/proxmox/string.rb
|
@@ -484,6 +485,7 @@ files:
|
|
484
485
|
- spec/helpers/controller_helper_spec.rb
|
485
486
|
- spec/helpers/cpu_helper_spec.rb
|
486
487
|
- spec/helpers/disk_helper_spec.rb
|
488
|
+
- spec/helpers/ip_helper_spec.rb
|
487
489
|
- spec/helpers/nic_helper_spec.rb
|
488
490
|
- spec/identity_spec.rb
|
489
491
|
- spec/network_spec.rb
|
@@ -501,7 +503,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
501
503
|
requirements:
|
502
504
|
- - ">="
|
503
505
|
- !ruby/object:Gem::Version
|
504
|
-
version: '2.
|
506
|
+
version: '2.5'
|
505
507
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
506
508
|
requirements:
|
507
509
|
- - ">="
|
@@ -538,6 +540,7 @@ test_files:
|
|
538
540
|
- spec/helpers/controller_helper_spec.rb
|
539
541
|
- spec/helpers/cpu_helper_spec.rb
|
540
542
|
- spec/helpers/disk_helper_spec.rb
|
543
|
+
- spec/helpers/ip_helper_spec.rb
|
541
544
|
- spec/helpers/nic_helper_spec.rb
|
542
545
|
- spec/identity_spec.rb
|
543
546
|
- spec/network_spec.rb
|
data/Gemfile.lock
DELETED
@@ -1,153 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
fog-proxmox (0.9.0)
|
5
|
-
fog-core (~> 2.1)
|
6
|
-
fog-json (~> 1.2)
|
7
|
-
ipaddress (~> 0.8)
|
8
|
-
|
9
|
-
GEM
|
10
|
-
remote: https://rubygems.org/
|
11
|
-
specs:
|
12
|
-
addressable (2.7.0)
|
13
|
-
public_suffix (>= 2.0.2, < 5.0)
|
14
|
-
ast (2.4.0)
|
15
|
-
axiom-types (0.1.1)
|
16
|
-
descendants_tracker (~> 0.0.4)
|
17
|
-
ice_nine (~> 0.11.0)
|
18
|
-
thread_safe (~> 0.3, >= 0.3.1)
|
19
|
-
builder (3.2.3)
|
20
|
-
bundler-audit (0.6.1)
|
21
|
-
bundler (>= 1.2.0, < 3)
|
22
|
-
thor (~> 0.18)
|
23
|
-
codeclimate-engine-rb (0.4.1)
|
24
|
-
virtus (~> 1.0)
|
25
|
-
coderay (1.1.2)
|
26
|
-
coercible (1.0.0)
|
27
|
-
descendants_tracker (~> 0.0.1)
|
28
|
-
colorize (0.8.1)
|
29
|
-
crack (0.4.3)
|
30
|
-
safe_yaml (~> 1.0.0)
|
31
|
-
debase (0.2.4.1)
|
32
|
-
debase-ruby_core_source (>= 0.10.2)
|
33
|
-
debase-ruby_core_source (0.10.6)
|
34
|
-
debride (1.8.2)
|
35
|
-
path_expander (~> 1.0)
|
36
|
-
ruby_parser (~> 3.6)
|
37
|
-
sexp_processor (~> 4.5)
|
38
|
-
descendants_tracker (0.0.4)
|
39
|
-
thread_safe (~> 0.3, >= 0.3.1)
|
40
|
-
diff-lcs (1.3)
|
41
|
-
docile (1.3.2)
|
42
|
-
equalizer (0.0.11)
|
43
|
-
excon (0.68.0)
|
44
|
-
fasterer (0.7.1)
|
45
|
-
colorize (~> 0.7)
|
46
|
-
ruby_parser (>= 3.13.0)
|
47
|
-
fastri (0.3.1.1)
|
48
|
-
fog-core (2.1.2)
|
49
|
-
builder
|
50
|
-
excon (~> 0.58)
|
51
|
-
formatador (~> 0.2)
|
52
|
-
mime-types
|
53
|
-
fog-json (1.2.0)
|
54
|
-
fog-core
|
55
|
-
multi_json (~> 1.10)
|
56
|
-
formatador (0.2.5)
|
57
|
-
hashdiff (1.0.0)
|
58
|
-
ice_nine (0.11.2)
|
59
|
-
ipaddress (0.8.3)
|
60
|
-
jaro_winkler (1.5.3)
|
61
|
-
json (2.2.0)
|
62
|
-
method_source (0.9.2)
|
63
|
-
mime-types (3.3)
|
64
|
-
mime-types-data (~> 3.2015)
|
65
|
-
mime-types-data (3.2019.1009)
|
66
|
-
minitest (5.12.2)
|
67
|
-
multi_json (1.14.1)
|
68
|
-
parallel (1.18.0)
|
69
|
-
parser (2.5.3.0)
|
70
|
-
ast (~> 2.4.0)
|
71
|
-
path_expander (1.1.0)
|
72
|
-
pry (0.12.2)
|
73
|
-
coderay (~> 1.1.0)
|
74
|
-
method_source (~> 0.9.0)
|
75
|
-
public_suffix (4.0.1)
|
76
|
-
rainbow (3.0.0)
|
77
|
-
rake (12.3.3)
|
78
|
-
rcodetools (0.8.5.0)
|
79
|
-
reek (4.8.2)
|
80
|
-
codeclimate-engine-rb (~> 0.4.0)
|
81
|
-
parser (>= 2.5.0.0, < 2.6)
|
82
|
-
rainbow (>= 2.0, < 4.0)
|
83
|
-
rspec (3.9.0)
|
84
|
-
rspec-core (~> 3.9.0)
|
85
|
-
rspec-expectations (~> 3.9.0)
|
86
|
-
rspec-mocks (~> 3.9.0)
|
87
|
-
rspec-core (3.9.0)
|
88
|
-
rspec-support (~> 3.9.0)
|
89
|
-
rspec-expectations (3.9.0)
|
90
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
91
|
-
rspec-support (~> 3.9.0)
|
92
|
-
rspec-mocks (3.9.0)
|
93
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
94
|
-
rspec-support (~> 3.9.0)
|
95
|
-
rspec-support (3.9.0)
|
96
|
-
rubocop (0.68.1)
|
97
|
-
jaro_winkler (~> 1.5.1)
|
98
|
-
parallel (~> 1.10)
|
99
|
-
parser (>= 2.5, != 2.5.1.1)
|
100
|
-
rainbow (>= 2.2.2, < 4.0)
|
101
|
-
ruby-progressbar (~> 1.7)
|
102
|
-
unicode-display_width (>= 1.4.0, < 1.6)
|
103
|
-
ruby-debug-ide (0.7.0)
|
104
|
-
rake (>= 0.8.1)
|
105
|
-
ruby-progressbar (1.10.1)
|
106
|
-
ruby_parser (3.14.0)
|
107
|
-
sexp_processor (~> 4.9)
|
108
|
-
safe_yaml (1.0.5)
|
109
|
-
sexp_processor (4.13.0)
|
110
|
-
simplecov (0.17.1)
|
111
|
-
docile (~> 1.1)
|
112
|
-
json (>= 1.8, < 3)
|
113
|
-
simplecov-html (~> 0.10.0)
|
114
|
-
simplecov-html (0.10.2)
|
115
|
-
thor (0.20.3)
|
116
|
-
thread_safe (0.3.6)
|
117
|
-
unicode-display_width (1.5.0)
|
118
|
-
vcr (4.0.0)
|
119
|
-
virtus (1.0.5)
|
120
|
-
axiom-types (~> 0.1)
|
121
|
-
coercible (~> 1.0)
|
122
|
-
descendants_tracker (~> 0.0, >= 0.0.3)
|
123
|
-
equalizer (~> 0.0, >= 0.0.9)
|
124
|
-
webmock (3.7.6)
|
125
|
-
addressable (>= 2.3.6)
|
126
|
-
crack (>= 0.3.2)
|
127
|
-
hashdiff (>= 0.4.0, < 2.0.0)
|
128
|
-
|
129
|
-
PLATFORMS
|
130
|
-
ruby
|
131
|
-
|
132
|
-
DEPENDENCIES
|
133
|
-
bundler (~> 2.0)
|
134
|
-
bundler-audit (~> 0.6)
|
135
|
-
debase (~> 0.2.2)
|
136
|
-
debride (~> 1.8)
|
137
|
-
fasterer (~> 0.3)
|
138
|
-
fastri (~> 0.3)
|
139
|
-
fog-proxmox!
|
140
|
-
minitest (~> 5.11)
|
141
|
-
pry (~> 0.11)
|
142
|
-
rake (~> 12.3)
|
143
|
-
rcodetools (~> 0.3)
|
144
|
-
reek (~> 4.7)
|
145
|
-
rspec (~> 3.7)
|
146
|
-
rubocop (~> 0.55)
|
147
|
-
ruby-debug-ide (~> 0.6)
|
148
|
-
simplecov
|
149
|
-
vcr (~> 4.0)
|
150
|
-
webmock (~> 3.5)
|
151
|
-
|
152
|
-
BUNDLED WITH
|
153
|
-
2.0.2
|