kitchen-openstack 1.5.3 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -0
- data/.travis.yml +0 -1
- data/CHANGELOG.md +18 -0
- data/kitchen-openstack.gemspec +2 -0
- data/lib/kitchen/driver/openstack.rb +36 -29
- data/lib/kitchen/driver/openstack_version.rb +1 -1
- data/spec/kitchen/driver/openstack_spec.rb +41 -26
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aaa67866b7346e3d53a47909387604044676368d
|
4
|
+
data.tar.gz: 8a63780cf40fd676075a000ec5430ebba442e0ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 768a16ad10875cd5117bd4bc963b5040a48c6e03ae9cf36f2fc3a3dc53ca3b06968abce37fda1f064663a20da56c4983a681a46055a4f8c384ef92361d50197e
|
7
|
+
data.tar.gz: 7960728018b0817c36fb6fe09b2237ed31235ca5c6210eacc74759419e3f3b7f2a71eee218d53c8fe4384b026368fb1dc99b4ee03d39006f15c15c46d3e8e2e6
|
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
# 1.6.0 / 2014-09.04
|
2
|
+
|
3
|
+
### Improvements
|
4
|
+
|
5
|
+
* PR [#56][] - Fall back to the first valid IP if no public or private nets can
|
6
|
+
be found; via [@jer][]
|
7
|
+
* PR [#55][] - Give a floating IP priority over an IP pool if both are present;
|
8
|
+
via [@StaymanHou][]
|
9
|
+
|
10
|
+
### Bug Fixes
|
11
|
+
|
12
|
+
* PR [#58][] - Prevent errors when run without a login shell
|
13
|
+
|
1
14
|
# 1.5.3 / 2014-08-01
|
2
15
|
|
3
16
|
* PR [#53][] - Rework how server names are generated, disallowing possibly
|
@@ -106,6 +119,9 @@ certain specified NICs; via [@monsterzz][]
|
|
106
119
|
|
107
120
|
* Initial release! Woo!
|
108
121
|
|
122
|
+
[#58]: https://github.com/test-kitchen/kitchen-openstack/pull/58
|
123
|
+
[#56]: https://github.com/test-kitchen/kitchen-openstack/pull/56
|
124
|
+
[#55]: https://github.com/test-kitchen/kitchen-openstack/pull/55
|
109
125
|
[#53]: https://github.com/test-kitchen/kitchen-openstack/pull/53
|
110
126
|
[#50]: https://github.com/test-kitchen/kitchen-openstack/pull/50
|
111
127
|
[#49]: https://github.com/test-kitchen/kitchen-openstack/pull/49
|
@@ -130,6 +146,8 @@ certain specified NICs; via [@monsterzz][]
|
|
130
146
|
[#7]: https://github.com/test-kitchen/kitchen-openstack/pull/7
|
131
147
|
[#2]: https://github.com/test-kitchen/kitchen-openstack/pull/2
|
132
148
|
|
149
|
+
[@StaymanHou]: https://github.com/StaymanHou
|
150
|
+
[@jer]: https://github.com/jer
|
133
151
|
[@dschlenk]: https://github.com/dschlenk
|
134
152
|
[@wilreichert]: https://github.com/wilreichert
|
135
153
|
[@tenforward]: https://github.com/tenforward
|
data/kitchen-openstack.gemspec
CHANGED
@@ -19,6 +19,8 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.test_files = spec.files.grep(/^(test|spec|features)\//)
|
20
20
|
spec.require_paths = ['lib']
|
21
21
|
|
22
|
+
spec.required_ruby_version = '>= 1.9.3'
|
23
|
+
|
22
24
|
spec.add_dependency 'test-kitchen', '~> 1.1'
|
23
25
|
spec.add_dependency 'fog', '~> 1.18'
|
24
26
|
# Newer Fogs throw a warning if unf isn't there :(
|
@@ -56,7 +56,7 @@ module Kitchen
|
|
56
56
|
default_config :network_ref, nil
|
57
57
|
|
58
58
|
def create(state)
|
59
|
-
config[:server_name] ||=
|
59
|
+
config[:server_name] ||= default_name
|
60
60
|
config[:disable_ssl_validation] && disable_ssl_validation
|
61
61
|
server = create_server
|
62
62
|
state[:server_id] = server.id
|
@@ -66,22 +66,14 @@ module Kitchen
|
|
66
66
|
ready?
|
67
67
|
end
|
68
68
|
info "\n(server ready)"
|
69
|
-
if config[:
|
70
|
-
attach_ip_from_pool(server, config[:floating_ip_pool])
|
71
|
-
elsif config[:floating_ip]
|
69
|
+
if config[:floating_ip]
|
72
70
|
attach_ip(server, config[:floating_ip])
|
71
|
+
elsif config[:floating_ip_pool]
|
72
|
+
attach_ip_from_pool(server, config[:floating_ip_pool])
|
73
73
|
end
|
74
74
|
state[:hostname] = get_ip(server)
|
75
|
-
state
|
76
|
-
wait_for_sshd(state[:hostname], config[:username], port: config[:port])
|
77
|
-
info '(ssh ready)'
|
78
|
-
if config[:key_name]
|
79
|
-
info "Using OpenStack keypair <#{config[:key_name]}>"
|
80
|
-
end
|
81
|
-
info "Using public SSH key <#{config[:public_key_path]}>"
|
82
|
-
info "Using private SSH key <#{config[:private_key_path]}>"
|
75
|
+
setup_ssh(server, state)
|
83
76
|
add_ohai_hint(state)
|
84
|
-
do_ssh_setup(state, config, server) unless config[:key_name]
|
85
77
|
rescue Fog::Errors::Error, Excon::Errors::Error => ex
|
86
78
|
raise ActionFailed, ex.message
|
87
79
|
end
|
@@ -197,16 +189,13 @@ module Kitchen
|
|
197
189
|
# Separators: 3
|
198
190
|
# ================
|
199
191
|
# Total: 63
|
200
|
-
def
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
Etc.getlogin.gsub(/\W/, '')[0..14],
|
192
|
+
def default_name
|
193
|
+
[
|
194
|
+
instance.name.gsub(/\W/, '')[0..14],
|
195
|
+
(Etc.getlogin || 'nologin').gsub(/\W/, '')[0..14],
|
205
196
|
Socket.gethostname.gsub(/\W/, '')[0..22],
|
206
197
|
Array.new(7) { rand(36).to_s(36) }.join
|
207
|
-
]
|
208
|
-
puts "Name: #{pieces.join(sep)}"
|
209
|
-
pieces.join(sep)
|
198
|
+
].join('-')
|
210
199
|
end
|
211
200
|
|
212
201
|
def attach_ip_from_pool(server, pool)
|
@@ -229,6 +218,18 @@ module Kitchen
|
|
229
218
|
(server.addresses['public'] ||= []) << { 'version' => 4, 'addr' => ip }
|
230
219
|
end
|
231
220
|
|
221
|
+
def get_public_private_ips(server)
|
222
|
+
begin
|
223
|
+
pub, priv = server.public_ip_addresses, server.private_ip_addresses
|
224
|
+
rescue Fog::Compute::OpenStack::NotFound, Excon::Errors::Forbidden
|
225
|
+
# See Fog issue: https://github.com/fog/fog/issues/2160
|
226
|
+
addrs = server.addresses
|
227
|
+
addrs['public'] && pub = addrs['public'].map { |i| i['addr'] }
|
228
|
+
addrs['private'] && priv = addrs['private'].map { |i| i['addr'] }
|
229
|
+
end
|
230
|
+
[pub, priv]
|
231
|
+
end
|
232
|
+
|
232
233
|
def get_ip(server)
|
233
234
|
unless config[:floating_ip].nil?
|
234
235
|
debug "Using floating ip: #{config[:floating_ip]}"
|
@@ -238,14 +239,8 @@ module Kitchen
|
|
238
239
|
debug "Using configured net: #{config[:openstack_network_name]}"
|
239
240
|
return server.addresses[config[:openstack_network_name]].first['addr']
|
240
241
|
end
|
241
|
-
|
242
|
-
|
243
|
-
rescue Fog::Compute::OpenStack::NotFound
|
244
|
-
# See Fog issue: https://github.com/fog/fog/issues/2160
|
245
|
-
addrs = server.addresses
|
246
|
-
addrs['public'] && pub = addrs['public'].map { |i| i['addr'] }
|
247
|
-
addrs['private'] && priv = addrs['private'].map { |i| i['addr'] }
|
248
|
-
end
|
242
|
+
pub, priv = get_public_private_ips(server)
|
243
|
+
priv ||= server.ip_addresses unless pub
|
249
244
|
pub, priv = parse_ips(pub, priv)
|
250
245
|
pub.first || priv.first || fail(ActionFailed, 'Could not find an IP')
|
251
246
|
end
|
@@ -269,6 +264,18 @@ module Kitchen
|
|
269
264
|
])
|
270
265
|
end
|
271
266
|
|
267
|
+
def setup_ssh(server, state)
|
268
|
+
wait_for_sshd(state[:hostname], config[:username], port: config[:port])
|
269
|
+
info '(ssh ready)'
|
270
|
+
if config[:key_name]
|
271
|
+
info "Using OpenStack keypair <#{config[:key_name]}>"
|
272
|
+
end
|
273
|
+
info "Using public SSH key <#{config[:public_key_path]}>"
|
274
|
+
info "Using private SSH key <#{config[:private_key_path]}>"
|
275
|
+
state[:ssh_key] = config[:private_key_path]
|
276
|
+
do_ssh_setup(state, config, server) unless config[:key_name]
|
277
|
+
end
|
278
|
+
|
272
279
|
def do_ssh_setup(state, config, server)
|
273
280
|
info "Setting up SSH access for key <#{config[:public_key_path]}>"
|
274
281
|
ssh = Fog::SSH.new(state[:hostname],
|
@@ -31,10 +31,11 @@ describe Kitchen::Driver::Openstack do
|
|
31
31
|
let(:state) { Hash.new }
|
32
32
|
let(:dsa) { File.expand_path('~/.ssh/id_dsa') }
|
33
33
|
let(:rsa) { File.expand_path('~/.ssh/id_rsa') }
|
34
|
+
let(:instance_name) { 'potatoes' }
|
34
35
|
|
35
36
|
let(:instance) do
|
36
37
|
double(
|
37
|
-
name:
|
38
|
+
name: instance_name, logger: logger, to_str: 'instance'
|
38
39
|
)
|
39
40
|
end
|
40
41
|
|
@@ -148,8 +149,7 @@ describe Kitchen::Driver::Openstack do
|
|
148
149
|
let(:driver) do
|
149
150
|
d = Kitchen::Driver::Openstack.new(config)
|
150
151
|
d.instance = instance
|
151
|
-
allow(d).to receive(:
|
152
|
-
.and_return('a_monkey!')
|
152
|
+
allow(d).to receive(:default_name).and_return('a_monkey!')
|
153
153
|
allow(d).to receive(:create_server).and_return(server)
|
154
154
|
allow(d).to receive(:wait_for_sshd).with('1.2.3.4', 'root', port: '22')
|
155
155
|
.and_return(true)
|
@@ -625,52 +625,56 @@ describe Kitchen::Driver::Openstack do
|
|
625
625
|
end
|
626
626
|
end
|
627
627
|
|
628
|
-
describe '#
|
628
|
+
describe '#default_name' do
|
629
|
+
let(:login) { 'user' }
|
630
|
+
let(:hostname) { 'host' }
|
631
|
+
|
629
632
|
before(:each) do
|
630
|
-
allow(Etc).to receive(:getlogin).and_return(
|
631
|
-
allow(Socket).to receive(:gethostname).and_return(
|
633
|
+
allow(Etc).to receive(:getlogin).and_return(login)
|
634
|
+
allow(Socket).to receive(:gethostname).and_return(hostname)
|
632
635
|
end
|
633
636
|
|
634
637
|
it 'generates a name' do
|
635
|
-
expect(driver.send(:
|
636
|
-
/^monkey-user-host-/)
|
638
|
+
expect(driver.send(:default_name)).to match(/^potatoes-user-host-(\S*)/)
|
637
639
|
end
|
638
640
|
|
639
641
|
context 'local node with a long hostname' do
|
640
|
-
|
641
|
-
allow(Socket).to receive(:gethostname).and_return('ab.c' * 20)
|
642
|
-
end
|
642
|
+
let(:hostname) { 'ab.c' * 20 }
|
643
643
|
|
644
644
|
it 'limits the generated name to 63 characters' do
|
645
|
-
expect(driver.send(:
|
645
|
+
expect(driver.send(:default_name).length).to be <= (63)
|
646
646
|
end
|
647
647
|
end
|
648
648
|
|
649
649
|
context 'node with a long hostname, username, and base name' do
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
end
|
650
|
+
let(:login) { 'abcd' * 20 }
|
651
|
+
let(:hostname) { 'efgh' * 20 }
|
652
|
+
let(:instance_name) { 'ijkl' * 20 }
|
654
653
|
|
655
654
|
it 'limits the generated name to 63 characters' do
|
656
|
-
expect(driver.send(:
|
655
|
+
expect(driver.send(:default_name).length).to eq(63)
|
657
656
|
end
|
658
657
|
end
|
659
658
|
|
660
659
|
context 'a login and hostname with punctuation in them' do
|
661
|
-
let(:
|
662
|
-
|
663
|
-
|
664
|
-
allow(Etc).to receive(:getlogin).and_return('some.u-se-r' * 20)
|
665
|
-
allow(Socket).to receive(:gethostname).and_return('a.host-name' * 20)
|
666
|
-
end
|
660
|
+
let(:login) { 'some.u-se-r' }
|
661
|
+
let(:hostname) { 'a.host-name' }
|
662
|
+
let(:instance_name) { 'a.instance-name' }
|
667
663
|
|
668
664
|
it 'strips out the dots to prevent bad server names' do
|
669
|
-
expect(driver.send(:
|
665
|
+
expect(driver.send(:default_name)).to_not include('.')
|
670
666
|
end
|
671
667
|
|
672
668
|
it 'strips out all but the three hyphen separators' do
|
673
|
-
expect(driver.send(:
|
669
|
+
expect(driver.send(:default_name).count('-')).to eq(3)
|
670
|
+
end
|
671
|
+
end
|
672
|
+
|
673
|
+
context 'a non-login shell' do
|
674
|
+
let(:login) { nil }
|
675
|
+
|
676
|
+
it 'subs in a placeholder login string' do
|
677
|
+
expect(driver.send(:default_name)).to match(/^potatoes-nologin-/)
|
674
678
|
end
|
675
679
|
end
|
676
680
|
end
|
@@ -726,6 +730,7 @@ describe Kitchen::Driver::Openstack do
|
|
726
730
|
let(:addresses) { nil }
|
727
731
|
let(:public_ip_addresses) { nil }
|
728
732
|
let(:private_ip_addresses) { nil }
|
733
|
+
let(:ip_addresses) { nil }
|
729
734
|
let(:parsed_ips) { [[], []] }
|
730
735
|
let(:driver) do
|
731
736
|
d = Kitchen::Driver::Openstack.new(config)
|
@@ -736,7 +741,8 @@ describe Kitchen::Driver::Openstack do
|
|
736
741
|
let(:server) do
|
737
742
|
double(addresses: addresses,
|
738
743
|
public_ip_addresses: public_ip_addresses,
|
739
|
-
private_ip_addresses: private_ip_addresses
|
744
|
+
private_ip_addresses: private_ip_addresses,
|
745
|
+
ip_addresses: ip_addresses)
|
740
746
|
end
|
741
747
|
|
742
748
|
context 'both public and private IPs' do
|
@@ -767,6 +773,15 @@ describe Kitchen::Driver::Openstack do
|
|
767
773
|
end
|
768
774
|
end
|
769
775
|
|
776
|
+
context 'no predictable network name' do
|
777
|
+
let(:ip_addresses) { %w(3::1 5.5.5.5) }
|
778
|
+
let(:parsed_ips) { [[], %w(5.5.5.5)] }
|
779
|
+
|
780
|
+
it 'returns the first IP that matches the IP version' do
|
781
|
+
expect(driver.send(:get_ip, server)).to eq('5.5.5.5')
|
782
|
+
end
|
783
|
+
end
|
784
|
+
|
770
785
|
context 'IPs in user-defined network group' do
|
771
786
|
let(:config) { { openstack_network_name: 'mynetwork' } }
|
772
787
|
let(:addresses) do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kitchen-openstack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Hartman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: test-kitchen
|
@@ -224,7 +224,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
224
224
|
requirements:
|
225
225
|
- - ">="
|
226
226
|
- !ruby/object:Gem::Version
|
227
|
-
version:
|
227
|
+
version: 1.9.3
|
228
228
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
229
229
|
requirements:
|
230
230
|
- - ">="
|
@@ -232,7 +232,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
232
232
|
version: '0'
|
233
233
|
requirements: []
|
234
234
|
rubyforge_project:
|
235
|
-
rubygems_version: 2.
|
235
|
+
rubygems_version: 2.4.1
|
236
236
|
signing_key:
|
237
237
|
specification_version: 4
|
238
238
|
summary: A Test Kitchen OpenStack Nova driver
|