vagrant-openstack-provider 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +2 -2
  3. data/CHANGELOG.md +22 -0
  4. data/Gemfile +8 -15
  5. data/Vagrantfile +12 -10
  6. data/gemfiles/latest_stable.gemfile +6 -16
  7. data/gemfiles/minimal_release.gemfile +10 -0
  8. data/gemfiles/previous_release.gemfile +6 -16
  9. data/lib/vagrant-openstack-provider/action/connect_openstack.rb +2 -1
  10. data/lib/vagrant-openstack-provider/action/create_server.rb +40 -248
  11. data/lib/vagrant-openstack-provider/action/read_ssh_info.rb +30 -29
  12. data/lib/vagrant-openstack-provider/action/sync_folders.rb +19 -9
  13. data/lib/vagrant-openstack-provider/action/wait_accessible.rb +58 -0
  14. data/lib/vagrant-openstack-provider/action/wait_active.rb +5 -3
  15. data/lib/vagrant-openstack-provider/action/wait_stop.rb +5 -3
  16. data/lib/vagrant-openstack-provider/action.rb +19 -11
  17. data/lib/vagrant-openstack-provider/client/http_utils.rb +3 -2
  18. data/lib/vagrant-openstack-provider/client/neutron.rb +11 -1
  19. data/lib/vagrant-openstack-provider/client/nova.rb +49 -30
  20. data/lib/vagrant-openstack-provider/command/abstract_command.rb +10 -1
  21. data/lib/vagrant-openstack-provider/command/flavor_list.rb +1 -1
  22. data/lib/vagrant-openstack-provider/command/floatingip_list.rb +1 -1
  23. data/lib/vagrant-openstack-provider/command/image_list.rb +1 -1
  24. data/lib/vagrant-openstack-provider/command/main.rb +2 -1
  25. data/lib/vagrant-openstack-provider/command/network_list.rb +8 -2
  26. data/lib/vagrant-openstack-provider/command/reset.rb +21 -0
  27. data/lib/vagrant-openstack-provider/command/utils.rb +1 -1
  28. data/lib/vagrant-openstack-provider/command/volume_list.rb +1 -1
  29. data/lib/vagrant-openstack-provider/config.rb +16 -1
  30. data/lib/vagrant-openstack-provider/config_resolver.rb +262 -0
  31. data/lib/vagrant-openstack-provider/errors.rb +40 -0
  32. data/lib/vagrant-openstack-provider/plugin.rb +3 -3
  33. data/lib/vagrant-openstack-provider/utils.rb +21 -0
  34. data/lib/vagrant-openstack-provider/version.rb +1 -1
  35. data/locales/en.yml +35 -1
  36. data/spec/vagrant-openstack-provider/action/create_server_spec.rb +121 -368
  37. data/spec/vagrant-openstack-provider/action/delete_server_spec.rb +54 -0
  38. data/spec/vagrant-openstack-provider/action/message_spec.rb +34 -0
  39. data/spec/vagrant-openstack-provider/action/read_ssh_info_spec.rb +34 -17
  40. data/spec/vagrant-openstack-provider/action/read_state_spec.rb +70 -0
  41. data/spec/vagrant-openstack-provider/action/resume_server_spec.rb +50 -0
  42. data/spec/vagrant-openstack-provider/action/start_server_spec.rb +50 -0
  43. data/spec/vagrant-openstack-provider/action/stop_server_spec.rb +50 -0
  44. data/spec/vagrant-openstack-provider/action/suspend_server_spec.rb +50 -0
  45. data/spec/vagrant-openstack-provider/action/sync_folders_spec.rb +155 -0
  46. data/spec/vagrant-openstack-provider/action/wait_accessible_spec.rb +68 -0
  47. data/spec/vagrant-openstack-provider/action/wait_active_spec.rb +47 -0
  48. data/spec/vagrant-openstack-provider/action/wait_stop_spec.rb +47 -0
  49. data/spec/vagrant-openstack-provider/action_spec.rb +121 -0
  50. data/spec/vagrant-openstack-provider/client/cinder_spec.rb +1 -1
  51. data/spec/vagrant-openstack-provider/client/keystone_spec.rb +1 -1
  52. data/spec/vagrant-openstack-provider/client/neutron_spec.rb +37 -1
  53. data/spec/vagrant-openstack-provider/client/nova_spec.rb +60 -7
  54. data/spec/vagrant-openstack-provider/client/utils_spec.rb +1 -1
  55. data/spec/vagrant-openstack-provider/command/flavor_list_spec.rb +44 -0
  56. data/spec/vagrant-openstack-provider/command/floatingip_list_spec.rb +19 -2
  57. data/spec/vagrant-openstack-provider/command/image_list_spec.rb +48 -0
  58. data/spec/vagrant-openstack-provider/command/network_list_spec.rb +67 -0
  59. data/spec/vagrant-openstack-provider/command/reset_spec.rb +25 -0
  60. data/spec/vagrant-openstack-provider/command/volume_list_spec.rb +10 -2
  61. data/spec/vagrant-openstack-provider/config_resolver_spec.rb +680 -0
  62. data/spec/vagrant-openstack-provider/config_spec.rb +15 -1
  63. data/spec/vagrant-openstack-provider/spec_helper.rb +3 -0
  64. data/spec/vagrant-openstack-provider/utils_spec.rb +103 -0
  65. data/vagrant-openstack-provider.gemspec +4 -2
  66. metadata +78 -11
  67. data/Appraisals +0 -13
  68. data/gemfiles/oldest_current.gemfile +0 -20
@@ -22,7 +22,7 @@ describe VagrantPlugins::Openstack::Config do
22
22
  its(:public_key_path) { should be_nil }
23
23
  its(:availability_zone) { should be_nil }
24
24
  its(:ssh_username) { should be_nil }
25
- its(:floating_ip_pool_always_allocate) { should be_false }
25
+ its(:floating_ip_pool_always_allocate) { should eq(false) }
26
26
  its(:scheduler_hints) { should be_nil }
27
27
  its(:security_groups) { should be_nil }
28
28
  its(:user_data) { should be_nil }
@@ -139,6 +139,20 @@ describe VagrantPlugins::Openstack::Config do
139
139
  end
140
140
  end
141
141
 
142
+ context 'the ssh_timeout' do
143
+ it 'should error if do not represent an integer' do
144
+ subject.ssh_timeout = 'timeout'
145
+ I18n.should_receive(:t).with('vagrant_openstack.config.invalid_value_for_parameter',
146
+ parameter: 'ssh_timeout', value: 'timeout').and_return error_message
147
+ validation_errors.first.should == error_message
148
+ end
149
+ it 'should be parsed as integer if is a string that represent an integer' do
150
+ subject.ssh_timeout = '100'
151
+ validation_errors.size.should eq(0)
152
+ expect(subject.ssh_timeout).to eq(100)
153
+ end
154
+ end
155
+
142
156
  [:openstack_compute_url, :openstack_auth_url].each do |url|
143
157
  context "the #{url}" do
144
158
  it 'should not validate if the URL is invalid' do
@@ -13,12 +13,15 @@ end
13
13
 
14
14
  Dir[
15
15
  'lib/vagrant-openstack-provider/config.rb',
16
+ 'lib/vagrant-openstack-provider/config_resolver.rb',
17
+ 'lib/vagrant-openstack-provider/utils.rb',
16
18
  'lib/vagrant-openstack-provider/errors.rb',
17
19
  'lib/vagrant-openstack-provider/provider.rb',
18
20
  'lib/vagrant-openstack-provider/client/*.rb',
19
21
  'lib/vagrant-openstack-provider/command/*.rb',
20
22
  'lib/vagrant-openstack-provider/action/*.rb'].each { |file| require file[4, file.length - 1] }
21
23
 
24
+ require 'rspec/its'
22
25
  require 'webmock/rspec'
23
26
  require 'fakefs/safe'
24
27
  require 'fakefs/spec_helpers'
@@ -0,0 +1,103 @@
1
+ require 'vagrant-openstack-provider/spec_helper'
2
+
3
+ describe VagrantPlugins::Openstack::Utils do
4
+
5
+ let(:config) do
6
+ double('config').tap do |config|
7
+ config.stub(:tenant_name) { 'testTenant' }
8
+ config.stub(:server_name) { 'testName' }
9
+ config.stub(:floating_ip) { nil }
10
+ end
11
+ end
12
+
13
+ let(:nova) do
14
+ double('nova').tap do |nova|
15
+ nova.stub(:get_all_floating_ips).with(anything) do
16
+ [FloatingIP.new('80.81.82.83', 'pool-1', nil), FloatingIP.new('30.31.32.33', 'pool-2', '1234')]
17
+ end
18
+ end
19
+ end
20
+
21
+ let(:env) do
22
+ Hash.new.tap do |env|
23
+ env[:machine] = double('machine')
24
+ env[:machine].stub(:provider_config) { config }
25
+ env[:machine].stub(:id) { '1234id' }
26
+ env[:openstack_client] = double('openstack_client')
27
+ env[:openstack_client].stub(:nova) { nova }
28
+ end
29
+ end
30
+
31
+ before :each do
32
+ Utils.send(:public, *Utils.private_instance_methods)
33
+ @action = Utils.new
34
+ end
35
+
36
+ describe 'get_ip_address' do
37
+ context 'without config.floating_ip' do
38
+ context 'with floating ip in nova details' do
39
+ it 'returns floating_ip from nova details' do
40
+ config.stub(:floating_ip) { nil }
41
+ nova.stub(:get_server_details).with(env, '1234id') do
42
+ {
43
+ 'addresses' => {
44
+ 'toto' => [{
45
+ 'addr' => '13.13.13.13'
46
+ }, {
47
+ 'addr' => '12.12.12.12',
48
+ 'OS-EXT-IPS:type' => 'floating'
49
+ }]
50
+ }
51
+ }
52
+ end
53
+ @action.get_ip_address(env).should eq('12.12.12.12')
54
+ end
55
+ end
56
+
57
+ context 'without floating ip in nova details' do
58
+ context 'with on single ip in nova details' do
59
+ it 'returns the single ip' do
60
+ config.stub(:floating_ip) { nil }
61
+ nova.stub(:get_server_details).with(env, '1234id') do
62
+ {
63
+ 'addresses' => {
64
+ 'toto' => [{
65
+ 'addr' => '13.13.13.13',
66
+ 'OS-EXT-IPS:type' => 'fixed'
67
+ }]
68
+ }
69
+ }
70
+ end
71
+ expect(@action.get_ip_address(env)).to eq('13.13.13.13')
72
+ end
73
+ end
74
+
75
+ context 'with multiple ips in nova details' do
76
+ it 'fails' do
77
+ config.stub(:floating_ip) { nil }
78
+ nova.stub(:get_server_details).with(env, '1234id') do
79
+ {
80
+ 'addresses' => {
81
+ 'toto' => [{
82
+ 'addr' => '13.13.13.13'
83
+ }, {
84
+ 'addr' => '12.12.12.12',
85
+ 'OS-EXT-IPS:type' => 'private'
86
+ }]
87
+ }
88
+ }
89
+ end
90
+ expect { @action.get_ip_address(env) }.to raise_error(Errors::UnableToResolveIP)
91
+ end
92
+ end
93
+ end
94
+ end
95
+
96
+ context 'with config.floating_ip' do
97
+ it 'returns floating_ip' do
98
+ config.stub(:floating_ip) { '1.2.3.4' }
99
+ @action.get_ip_address(env).should eq('1.2.3.4')
100
+ end
101
+ end
102
+ end
103
+ end
@@ -18,8 +18,10 @@ Gem::Specification.new do |gem|
18
18
  gem.add_dependency 'colorize', '0.7.3'
19
19
 
20
20
  gem.add_development_dependency 'rake'
21
- gem.add_development_dependency 'rspec', '~> 2.13.0'
22
- gem.add_development_dependency 'aruba'
21
+ gem.add_development_dependency 'rspec', '~> 3.1.0'
22
+ gem.add_development_dependency 'rspec-its', '~> 1.0.1'
23
+ gem.add_development_dependency 'webmock', '~> 1.18.0'
24
+ gem.add_development_dependency 'fakefs', '~> 0.5.2'
23
25
 
24
26
  gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
25
27
  gem.executables = gem.files.grep(/^bin\//).map { |f| File.basename(f) }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-openstack-provider
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guillaume Giamarchi
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-10-03 00:00:00.000000000 Z
12
+ date: 2014-11-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
@@ -101,28 +101,56 @@ dependencies:
101
101
  requirements:
102
102
  - - ~>
103
103
  - !ruby/object:Gem::Version
104
- version: 2.13.0
104
+ version: 3.1.0
105
105
  type: :development
106
106
  prerelease: false
107
107
  version_requirements: !ruby/object:Gem::Requirement
108
108
  requirements:
109
109
  - - ~>
110
110
  - !ruby/object:Gem::Version
111
- version: 2.13.0
111
+ version: 3.1.0
112
112
  - !ruby/object:Gem::Dependency
113
- name: aruba
113
+ name: rspec-its
114
114
  requirement: !ruby/object:Gem::Requirement
115
115
  requirements:
116
- - - '>='
116
+ - - ~>
117
117
  - !ruby/object:Gem::Version
118
- version: '0'
118
+ version: 1.0.1
119
119
  type: :development
120
120
  prerelease: false
121
121
  version_requirements: !ruby/object:Gem::Requirement
122
122
  requirements:
123
- - - '>='
123
+ - - ~>
124
124
  - !ruby/object:Gem::Version
125
- version: '0'
125
+ version: 1.0.1
126
+ - !ruby/object:Gem::Dependency
127
+ name: webmock
128
+ requirement: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ~>
131
+ - !ruby/object:Gem::Version
132
+ version: 1.18.0
133
+ type: :development
134
+ prerelease: false
135
+ version_requirements: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ~>
138
+ - !ruby/object:Gem::Version
139
+ version: 1.18.0
140
+ - !ruby/object:Gem::Dependency
141
+ name: fakefs
142
+ requirement: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - ~>
145
+ - !ruby/object:Gem::Version
146
+ version: 0.5.2
147
+ type: :development
148
+ prerelease: false
149
+ version_requirements: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - ~>
152
+ - !ruby/object:Gem::Version
153
+ version: 0.5.2
126
154
  description: Enables Vagrant to manage machines in Openstack Cloud.
127
155
  email:
128
156
  - guillaume.giamarchi@gmail.com
@@ -133,7 +161,6 @@ extra_rdoc_files: []
133
161
  files:
134
162
  - .gitignore
135
163
  - .rubocop.yml
136
- - Appraisals
137
164
  - CHANGELOG.md
138
165
  - Gemfile
139
166
  - LICENSE.txt
@@ -148,7 +175,7 @@ files:
148
175
  - functional_tests/keys/vagrant-openstack.pub
149
176
  - functional_tests/run_tests.sh
150
177
  - gemfiles/latest_stable.gemfile
151
- - gemfiles/oldest_current.gemfile
178
+ - gemfiles/minimal_release.gemfile
152
179
  - gemfiles/previous_release.gemfile
153
180
  - lib/vagrant-openstack-provider.rb
154
181
  - lib/vagrant-openstack-provider/action.rb
@@ -163,6 +190,7 @@ files:
163
190
  - lib/vagrant-openstack-provider/action/stop_server.rb
164
191
  - lib/vagrant-openstack-provider/action/suspend.rb
165
192
  - lib/vagrant-openstack-provider/action/sync_folders.rb
193
+ - lib/vagrant-openstack-provider/action/wait_accessible.rb
166
194
  - lib/vagrant-openstack-provider/action/wait_active.rb
167
195
  - lib/vagrant-openstack-provider/action/wait_stop.rb
168
196
  - lib/vagrant-openstack-provider/client/cinder.rb
@@ -179,27 +207,48 @@ files:
179
207
  - lib/vagrant-openstack-provider/command/image_list.rb
180
208
  - lib/vagrant-openstack-provider/command/main.rb
181
209
  - lib/vagrant-openstack-provider/command/network_list.rb
210
+ - lib/vagrant-openstack-provider/command/reset.rb
182
211
  - lib/vagrant-openstack-provider/command/utils.rb
183
212
  - lib/vagrant-openstack-provider/command/volume_list.rb
184
213
  - lib/vagrant-openstack-provider/config.rb
214
+ - lib/vagrant-openstack-provider/config_resolver.rb
185
215
  - lib/vagrant-openstack-provider/errors.rb
186
216
  - lib/vagrant-openstack-provider/plugin.rb
187
217
  - lib/vagrant-openstack-provider/provider.rb
218
+ - lib/vagrant-openstack-provider/utils.rb
188
219
  - lib/vagrant-openstack-provider/version.rb
189
220
  - locales/en.yml
190
221
  - spec/vagrant-openstack-provider/action/connect_openstack_spec.rb
191
222
  - spec/vagrant-openstack-provider/action/create_server_spec.rb
223
+ - spec/vagrant-openstack-provider/action/delete_server_spec.rb
224
+ - spec/vagrant-openstack-provider/action/message_spec.rb
192
225
  - spec/vagrant-openstack-provider/action/read_ssh_info_spec.rb
226
+ - spec/vagrant-openstack-provider/action/read_state_spec.rb
227
+ - spec/vagrant-openstack-provider/action/resume_server_spec.rb
228
+ - spec/vagrant-openstack-provider/action/start_server_spec.rb
229
+ - spec/vagrant-openstack-provider/action/stop_server_spec.rb
230
+ - spec/vagrant-openstack-provider/action/suspend_server_spec.rb
231
+ - spec/vagrant-openstack-provider/action/sync_folders_spec.rb
232
+ - spec/vagrant-openstack-provider/action/wait_accessible_spec.rb
233
+ - spec/vagrant-openstack-provider/action/wait_active_spec.rb
234
+ - spec/vagrant-openstack-provider/action/wait_stop_spec.rb
235
+ - spec/vagrant-openstack-provider/action_spec.rb
193
236
  - spec/vagrant-openstack-provider/client/cinder_spec.rb
194
237
  - spec/vagrant-openstack-provider/client/keystone_spec.rb
195
238
  - spec/vagrant-openstack-provider/client/neutron_spec.rb
196
239
  - spec/vagrant-openstack-provider/client/nova_spec.rb
197
240
  - spec/vagrant-openstack-provider/client/utils_spec.rb
241
+ - spec/vagrant-openstack-provider/command/flavor_list_spec.rb
198
242
  - spec/vagrant-openstack-provider/command/floatingip_list_spec.rb
243
+ - spec/vagrant-openstack-provider/command/image_list_spec.rb
244
+ - spec/vagrant-openstack-provider/command/network_list_spec.rb
245
+ - spec/vagrant-openstack-provider/command/reset_spec.rb
199
246
  - spec/vagrant-openstack-provider/command/volume_list_spec.rb
247
+ - spec/vagrant-openstack-provider/config_resolver_spec.rb
200
248
  - spec/vagrant-openstack-provider/config_spec.rb
201
249
  - spec/vagrant-openstack-provider/provider_spec.rb
202
250
  - spec/vagrant-openstack-provider/spec_helper.rb
251
+ - spec/vagrant-openstack-provider/utils_spec.rb
203
252
  - stackrc
204
253
  - vagrant-openstack-provider.gemspec
205
254
  homepage: https://github.com/ggiamarchi/vagrant-openstack-provider
@@ -228,14 +277,32 @@ summary: Enables Vagrant to manage machines in Openstack Cloud.
228
277
  test_files:
229
278
  - spec/vagrant-openstack-provider/action/connect_openstack_spec.rb
230
279
  - spec/vagrant-openstack-provider/action/create_server_spec.rb
280
+ - spec/vagrant-openstack-provider/action/delete_server_spec.rb
281
+ - spec/vagrant-openstack-provider/action/message_spec.rb
231
282
  - spec/vagrant-openstack-provider/action/read_ssh_info_spec.rb
283
+ - spec/vagrant-openstack-provider/action/read_state_spec.rb
284
+ - spec/vagrant-openstack-provider/action/resume_server_spec.rb
285
+ - spec/vagrant-openstack-provider/action/start_server_spec.rb
286
+ - spec/vagrant-openstack-provider/action/stop_server_spec.rb
287
+ - spec/vagrant-openstack-provider/action/suspend_server_spec.rb
288
+ - spec/vagrant-openstack-provider/action/sync_folders_spec.rb
289
+ - spec/vagrant-openstack-provider/action/wait_accessible_spec.rb
290
+ - spec/vagrant-openstack-provider/action/wait_active_spec.rb
291
+ - spec/vagrant-openstack-provider/action/wait_stop_spec.rb
292
+ - spec/vagrant-openstack-provider/action_spec.rb
232
293
  - spec/vagrant-openstack-provider/client/cinder_spec.rb
233
294
  - spec/vagrant-openstack-provider/client/keystone_spec.rb
234
295
  - spec/vagrant-openstack-provider/client/neutron_spec.rb
235
296
  - spec/vagrant-openstack-provider/client/nova_spec.rb
236
297
  - spec/vagrant-openstack-provider/client/utils_spec.rb
298
+ - spec/vagrant-openstack-provider/command/flavor_list_spec.rb
237
299
  - spec/vagrant-openstack-provider/command/floatingip_list_spec.rb
300
+ - spec/vagrant-openstack-provider/command/image_list_spec.rb
301
+ - spec/vagrant-openstack-provider/command/network_list_spec.rb
302
+ - spec/vagrant-openstack-provider/command/reset_spec.rb
238
303
  - spec/vagrant-openstack-provider/command/volume_list_spec.rb
304
+ - spec/vagrant-openstack-provider/config_resolver_spec.rb
239
305
  - spec/vagrant-openstack-provider/config_spec.rb
240
306
  - spec/vagrant-openstack-provider/provider_spec.rb
241
307
  - spec/vagrant-openstack-provider/spec_helper.rb
308
+ - spec/vagrant-openstack-provider/utils_spec.rb
data/Appraisals DELETED
@@ -1,13 +0,0 @@
1
- appraise 'latest-stable' do
2
- gem 'vagrant', git: 'git://github.com/mitchellh/vagrant.git', tag: 'v1.6.3'
3
- end
4
-
5
- # Oldest (current release)
6
- appraise 'oldest-current' do
7
- gem 'vagrant', git: 'git://github.com/mitchellh/vagrant.git', tag: 'v1.5.4'
8
- end
9
-
10
- # Latest patch (previous release)
11
- appraise 'previous-release' do
12
- gem 'vagrant', git: 'git://github.com/mitchellh/vagrant.git', tag: 'v1.4.3'
13
- end
@@ -1,20 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "appraisal", "1.0.0"
6
- gem "restclient", "0.10.0"
7
- gem "terminal-table", "1.4.5"
8
- gem "webmock", "~> 1.18.0", :group => [:test]
9
- gem "rubocop", "0.23.0", :require => false
10
- gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git", :tag => "v1.4.3"
11
- gem "fakefs", "~> 0.5.2", :group => [:test]
12
- gem "sshkey", "~> 1.6.1"
13
- gem "colorize", "~> 0.7.3"
14
-
15
- group :development do
16
- gem "coveralls", :require => false
17
- gem "debugger"
18
- end
19
-
20
- gemspec :path => "../"