kitchen-nodes 0.3.2 → 0.3.3
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.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -0
- data/lib/kitchen/provisioner/ip_finder/ssh.rb +6 -10
- data/lib/kitchen/provisioner/nodes.rb +3 -1
- data/lib/kitchen/provisioner/nodes_version.rb +1 -1
- data/spec/unit/nodes_spec.rb +24 -0
- data/spec/unit/stubs/ifconfig.txt +9 -0
- data/spec/unit/stubs/ip.txt +5 -0
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 32559c20845947bc1b2c40d2fd7393841da83db5
|
|
4
|
+
data.tar.gz: df3c3bd467f8adabab15aaf89d4a94997d679e32
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c0c555909d3ac750086b938136841209d03a3915f63b70a61fcd11004defcf2efa9b977e11abbfce19f23a48a09cf0e2c94138e658e58136f4ebb10713f74b12
|
|
7
|
+
data.tar.gz: 5ca523f6854c4a6c913d2b7e98dcd985e2b8c5b556f0c8adbe3816056623c677d4ec7048e97c4f869876583f827e5035deed6453c1452ca9589ce6dbc20df785
|
data/.rubocop.yml
ADDED
|
@@ -51,6 +51,7 @@ module Kitchen
|
|
|
51
51
|
module IpFinder
|
|
52
52
|
# SSH implementation for returning active non-localhost IPs
|
|
53
53
|
class Ssh
|
|
54
|
+
IP4REGEX = /(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/
|
|
54
55
|
def initialize(connection)
|
|
55
56
|
@connection = connection
|
|
56
57
|
end
|
|
@@ -66,6 +67,7 @@ module Kitchen
|
|
|
66
67
|
return ips unless ips.empty?
|
|
67
68
|
sleep 0.5
|
|
68
69
|
end
|
|
70
|
+
ips
|
|
69
71
|
end
|
|
70
72
|
|
|
71
73
|
def run_ifconfig
|
|
@@ -73,7 +75,7 @@ module Kitchen
|
|
|
73
75
|
ips = []
|
|
74
76
|
response.split(/^\S+/).each do |device|
|
|
75
77
|
next if !device.include?('RUNNING') || device.include?('LOOPBACK')
|
|
76
|
-
ips <<
|
|
78
|
+
ips << IP4REGEX.match(device)[1]
|
|
77
79
|
end
|
|
78
80
|
ips.compact
|
|
79
81
|
end
|
|
@@ -81,19 +83,13 @@ module Kitchen
|
|
|
81
83
|
def run_ip_addr
|
|
82
84
|
response = @connection.node_execute('/sbin/ip -4 addr show')
|
|
83
85
|
ips = []
|
|
84
|
-
response.split(
|
|
86
|
+
response.split(/^[0-9]+: /).each do |device|
|
|
85
87
|
next if device.include?('LOOPBACK') || device.include?('NO-CARRIER')
|
|
86
|
-
|
|
88
|
+
next if device == ''
|
|
89
|
+
ips << IP4REGEX.match(device)[1]
|
|
87
90
|
end
|
|
88
91
|
ips.compact
|
|
89
92
|
end
|
|
90
|
-
|
|
91
|
-
def parse_ip(device, start_token, delimiter)
|
|
92
|
-
start_idx = device.index(start_token)
|
|
93
|
-
start_idx += start_token.length unless start_idx.nil?
|
|
94
|
-
end_idx = device.index(delimiter, start_idx) unless start_idx.nil?
|
|
95
|
-
device[start_idx, end_idx - start_idx] unless end_idx.nil?
|
|
96
|
-
end
|
|
97
93
|
end
|
|
98
94
|
end
|
|
99
95
|
end
|
|
@@ -84,7 +84,9 @@ module Kitchen
|
|
|
84
84
|
[:username, :password].each do |prop|
|
|
85
85
|
state[prop] = instance.driver[prop] if instance.driver[prop]
|
|
86
86
|
end
|
|
87
|
-
IpFinder.for_transport(transport, state).find_ips
|
|
87
|
+
ips = IpFinder.for_transport(transport, state).find_ips
|
|
88
|
+
fail 'Unable to retrieve IPs' if ips.empty?
|
|
89
|
+
ips
|
|
88
90
|
end
|
|
89
91
|
end
|
|
90
92
|
end
|
data/spec/unit/nodes_spec.rb
CHANGED
|
@@ -85,6 +85,28 @@ describe Kitchen::Provisioner::Nodes do
|
|
|
85
85
|
allow(transport).to receive(:connection)
|
|
86
86
|
.and_return(Kitchen::Transport::Base::Connection.new)
|
|
87
87
|
end
|
|
88
|
+
|
|
89
|
+
context 'cannot find an ip' do
|
|
90
|
+
let(:ifconfig_response) do
|
|
91
|
+
FakeFS.deactivate!
|
|
92
|
+
template = File.read('spec/unit/stubs/ifconfig.txt')
|
|
93
|
+
FakeFS.activate!
|
|
94
|
+
template.gsub!('', machine_ips[0])
|
|
95
|
+
template.gsub!('', machine_ips[1])
|
|
96
|
+
template.gsub!('', machine_ips[2])
|
|
97
|
+
end
|
|
98
|
+
let(:transport) { Kitchen::Transport::Ssh.new }
|
|
99
|
+
|
|
100
|
+
before do
|
|
101
|
+
allow_any_instance_of(Kitchen::Transport::Base::Connection)
|
|
102
|
+
.to receive(:node_execute).and_return(ifconfig_response)
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
it 'fails' do
|
|
106
|
+
expect { subject.create_node }.to raise_error('Unable to retrieve IPs')
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
88
110
|
context 'platform is windows' do
|
|
89
111
|
let(:transport) { Kitchen::Transport::Winrm.new }
|
|
90
112
|
|
|
@@ -125,6 +147,7 @@ describe Kitchen::Provisioner::Nodes do
|
|
|
125
147
|
FakeFS.activate!
|
|
126
148
|
template.gsub!('1.1.1.1', machine_ips[0])
|
|
127
149
|
template.gsub!('2.2.2.2', machine_ips[1])
|
|
150
|
+
template.gsub!('3.3.3.3', machine_ips[2])
|
|
128
151
|
end
|
|
129
152
|
let(:transport) { Kitchen::Transport::Ssh.new }
|
|
130
153
|
|
|
@@ -146,6 +169,7 @@ describe Kitchen::Provisioner::Nodes do
|
|
|
146
169
|
FakeFS.activate!
|
|
147
170
|
template.gsub!('1.1.1.1', machine_ips[0])
|
|
148
171
|
template.gsub!('2.2.2.2', machine_ips[1])
|
|
172
|
+
template.gsub!('3.3.3.3', machine_ips[2])
|
|
149
173
|
end
|
|
150
174
|
|
|
151
175
|
before do
|
|
@@ -24,3 +24,12 @@ lo Link encap:Local Loopback
|
|
|
24
24
|
collisions:0 txqueuelen:0
|
|
25
25
|
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
|
|
26
26
|
|
|
27
|
+
# The following represents the format of ifconfig from CentOS 7.1
|
|
28
|
+
enp0s8: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
|
|
29
|
+
inet 3.3.3.3 netmask 255.255.255.0 broadcast 3.3.3.0
|
|
30
|
+
inet6 fe80::a00:27ff:fe5e:e9b0 prefixlen 64 scopeid 0x20<link>
|
|
31
|
+
ether 08:00:27:5e:e9:b0 txqueuelen 1000 (Ethernet)
|
|
32
|
+
RX packets 7961 bytes 823710 (804.4 KiB)
|
|
33
|
+
RX errors 0 dropped 0 overruns 0 frame 0
|
|
34
|
+
TX packets 263 bytes 50868 (49.6 KiB)
|
|
35
|
+
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
|
data/spec/unit/stubs/ip.txt
CHANGED
|
@@ -7,3 +7,8 @@
|
|
|
7
7
|
5: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
|
|
8
8
|
inet 2.2.2.2/16 scope global docker0
|
|
9
9
|
valid_lft forever preferred_lft forever
|
|
10
|
+
# The following represents the format of ipaddr from CentOS 7.1 (which is the same in this case, but
|
|
11
|
+
# adding for completeness)
|
|
12
|
+
6: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
|
|
13
|
+
inet 3.3.3.3/24 brd 3.3.3.255 scope global dynamic enp0s8
|
|
14
|
+
valid_lft 966sec preferred_lft 966sec
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: kitchen-nodes
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Matt Wrock
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-
|
|
11
|
+
date: 2015-07-30 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: net-ping
|
|
@@ -130,6 +130,7 @@ extensions: []
|
|
|
130
130
|
extra_rdoc_files: []
|
|
131
131
|
files:
|
|
132
132
|
- ".gitignore"
|
|
133
|
+
- ".rubocop.yml"
|
|
133
134
|
- ".travis.yml"
|
|
134
135
|
- CHANGELOG.md
|
|
135
136
|
- Gemfile
|