vagrant-openstack-provider 0.6.0 → 0.6.1
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/CHANGELOG.md +15 -0
- data/lib/vagrant-openstack-provider/action/connect_openstack.rb +0 -1
- data/lib/vagrant-openstack-provider/action/create_server.rb +3 -2
- data/lib/vagrant-openstack-provider/action/create_stack.rb +3 -2
- data/lib/vagrant-openstack-provider/action/delete_server.rb +3 -2
- data/lib/vagrant-openstack-provider/action/delete_stack.rb +3 -2
- data/lib/vagrant-openstack-provider/action/wait_active.rb +3 -3
- data/lib/vagrant-openstack-provider/action/wait_stop.rb +3 -3
- data/lib/vagrant-openstack-provider/catalog/openstack_catalog.rb +6 -5
- data/lib/vagrant-openstack-provider/client/cinder.rb +0 -1
- data/lib/vagrant-openstack-provider/client/domain.rb +0 -1
- data/lib/vagrant-openstack-provider/client/glance.rb +5 -3
- data/lib/vagrant-openstack-provider/client/heat.rb +0 -1
- data/lib/vagrant-openstack-provider/client/http_utils.rb +7 -6
- data/lib/vagrant-openstack-provider/client/keystone.rb +5 -4
- data/lib/vagrant-openstack-provider/client/neutron.rb +0 -1
- data/lib/vagrant-openstack-provider/client/nova.rb +0 -1
- data/lib/vagrant-openstack-provider/client/openstack.rb +0 -1
- data/lib/vagrant-openstack-provider/client/request_logger.rb +0 -1
- data/lib/vagrant-openstack-provider/client/rest_utils.rb +25 -0
- data/lib/vagrant-openstack-provider/command/abstract_command.rb +4 -1
- data/lib/vagrant-openstack-provider/command/flavor_list.rb +3 -5
- data/lib/vagrant-openstack-provider/command/floatingip_list.rb +3 -5
- data/lib/vagrant-openstack-provider/command/image_list.rb +3 -5
- data/lib/vagrant-openstack-provider/command/network_list.rb +3 -5
- data/lib/vagrant-openstack-provider/command/openstack_command.rb +16 -0
- data/lib/vagrant-openstack-provider/command/reset.rb +1 -2
- data/lib/vagrant-openstack-provider/command/subnet_list.rb +2 -5
- data/lib/vagrant-openstack-provider/command/volume_list.rb +3 -5
- data/lib/vagrant-openstack-provider/config.rb +59 -2
- data/lib/vagrant-openstack-provider/config/http.rb +39 -0
- data/lib/vagrant-openstack-provider/config_resolver.rb +13 -9
- data/lib/vagrant-openstack-provider/utils.rb +11 -6
- data/lib/vagrant-openstack-provider/version.rb +1 -1
- data/locales/en.yml +4 -0
- data/spec/vagrant-openstack-provider/action/connect_openstack_spec.rb +226 -4
- data/spec/vagrant-openstack-provider/action/create_server_spec.rb +6 -3
- data/spec/vagrant-openstack-provider/action/create_stack_spec.rb +7 -3
- data/spec/vagrant-openstack-provider/action/delete_server_spec.rb +13 -4
- data/spec/vagrant-openstack-provider/action/read_ssh_info_spec.rb +24 -3
- data/spec/vagrant-openstack-provider/action/wait_active_spec.rb +9 -2
- data/spec/vagrant-openstack-provider/action/wait_stop_spec.rb +9 -2
- data/spec/vagrant-openstack-provider/client/cinder_spec.rb +17 -1
- data/spec/vagrant-openstack-provider/client/glance_spec.rb +18 -2
- data/spec/vagrant-openstack-provider/client/heat_spec.rb +8 -0
- data/spec/vagrant-openstack-provider/client/keystone_spec.rb +8 -0
- data/spec/vagrant-openstack-provider/client/neutron_spec.rb +18 -2
- data/spec/vagrant-openstack-provider/client/nova_spec.rb +8 -0
- data/spec/vagrant-openstack-provider/config_resolver_spec.rb +10 -0
- data/spec/vagrant-openstack-provider/config_spec.rb +39 -4
- data/spec/vagrant-openstack-provider/utils_spec.rb +17 -17
- metadata +5 -2
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'vagrant-openstack-provider/command/utils'
|
2
|
+
require 'vagrant-openstack-provider/command/abstract_command'
|
3
|
+
|
4
|
+
module VagrantPlugins
|
5
|
+
module Openstack
|
6
|
+
module Command
|
7
|
+
class OpenstackCommand < AbstractCommand
|
8
|
+
include VagrantPlugins::Openstack::Command::Utils
|
9
|
+
|
10
|
+
def before_cmd(_name, _argv, env)
|
11
|
+
VagrantPlugins::Openstack::Action::ConnectOpenstack.new(nil, env).call(env)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -5,11 +5,10 @@ module VagrantPlugins
|
|
5
5
|
module Openstack
|
6
6
|
module Command
|
7
7
|
class Reset < AbstractCommand
|
8
|
-
include VagrantPlugins::Openstack::Command::Utils
|
9
|
-
|
10
8
|
def self.synopsis
|
11
9
|
I18n.t('vagrant_openstack.command.reset')
|
12
10
|
end
|
11
|
+
|
13
12
|
def cmd(name, argv, env)
|
14
13
|
fail Errors::NoArgRequiredForCommand, cmd: name unless argv.size == 0
|
15
14
|
FileUtils.remove_dir("#{env[:machine].data_dir}")
|
@@ -1,12 +1,9 @@
|
|
1
|
-
require 'vagrant-openstack-provider/command/
|
2
|
-
require 'vagrant-openstack-provider/command/abstract_command'
|
1
|
+
require 'vagrant-openstack-provider/command/openstack_command'
|
3
2
|
|
4
3
|
module VagrantPlugins
|
5
4
|
module Openstack
|
6
5
|
module Command
|
7
|
-
class SubnetList <
|
8
|
-
include VagrantPlugins::Openstack::Command::Utils
|
9
|
-
|
6
|
+
class SubnetList < OpenstackCommand
|
10
7
|
def self.synopsis
|
11
8
|
I18n.t('vagrant_openstack.command.subnet_list_synopsis')
|
12
9
|
end
|
@@ -1,15 +1,13 @@
|
|
1
|
-
require 'vagrant-openstack-provider/command/
|
2
|
-
require 'vagrant-openstack-provider/command/abstract_command'
|
1
|
+
require 'vagrant-openstack-provider/command/openstack_command'
|
3
2
|
|
4
3
|
module VagrantPlugins
|
5
4
|
module Openstack
|
6
5
|
module Command
|
7
|
-
class VolumeList <
|
8
|
-
include VagrantPlugins::Openstack::Command::Utils
|
9
|
-
|
6
|
+
class VolumeList < OpenstackCommand
|
10
7
|
def self.synopsis
|
11
8
|
I18n.t('vagrant_openstack.command.volume_list_synopsis')
|
12
9
|
end
|
10
|
+
|
13
11
|
def cmd(name, argv, env)
|
14
12
|
fail Errors::NoArgRequiredForCommand, cmd: name unless argv.size == 0
|
15
13
|
volumes = env[:openstack_client].cinder.get_all_volumes(env)
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'vagrant'
|
2
2
|
require 'colorize'
|
3
|
+
require 'vagrant-openstack-provider/config/http'
|
3
4
|
|
4
5
|
module VagrantPlugins
|
5
6
|
module Openstack
|
@@ -160,6 +161,39 @@ module VagrantPlugins
|
|
160
161
|
# @return [Boolean]
|
161
162
|
attr_accessor :ssh_disabled
|
162
163
|
|
164
|
+
# Specify the endpoint_type to use : publicURL, adminURL, or internalURL (default is publicURL)
|
165
|
+
#
|
166
|
+
# @return [String]
|
167
|
+
attr_accessor :endpoint_type
|
168
|
+
|
169
|
+
#
|
170
|
+
# @return [Integer]
|
171
|
+
attr_accessor :server_create_timeout
|
172
|
+
|
173
|
+
#
|
174
|
+
# @return [Integer]
|
175
|
+
attr_accessor :server_active_timeout
|
176
|
+
|
177
|
+
#
|
178
|
+
# @return [Integer]
|
179
|
+
attr_accessor :server_stop_timeout
|
180
|
+
|
181
|
+
#
|
182
|
+
# @return [Integer]
|
183
|
+
attr_accessor :server_delete_timeout
|
184
|
+
|
185
|
+
#
|
186
|
+
# @return [Integer]
|
187
|
+
attr_accessor :stack_create_timeout
|
188
|
+
|
189
|
+
#
|
190
|
+
# @return [Integer]
|
191
|
+
attr_accessor :stack_delete_timeout
|
192
|
+
|
193
|
+
#
|
194
|
+
# @return [HttpConfig]
|
195
|
+
attr_accessor :http
|
196
|
+
|
163
197
|
def initialize
|
164
198
|
@password = UNSET_VALUE
|
165
199
|
@openstack_compute_url = UNSET_VALUE
|
@@ -168,6 +202,7 @@ module VagrantPlugins
|
|
168
202
|
@openstack_orchestration_url = UNSET_VALUE
|
169
203
|
@openstack_image_url = UNSET_VALUE
|
170
204
|
@openstack_auth_url = UNSET_VALUE
|
205
|
+
@endpoint_type = UNSET_VALUE
|
171
206
|
@region = UNSET_VALUE
|
172
207
|
@flavor = UNSET_VALUE
|
173
208
|
@image = UNSET_VALUE
|
@@ -194,6 +229,13 @@ module VagrantPlugins
|
|
194
229
|
@user_data = UNSET_VALUE
|
195
230
|
@metadata = UNSET_VALUE
|
196
231
|
@ssh_disabled = UNSET_VALUE
|
232
|
+
@server_create_timeout = UNSET_VALUE
|
233
|
+
@server_active_timeout = UNSET_VALUE
|
234
|
+
@server_stop_timeout = UNSET_VALUE
|
235
|
+
@server_delete_timeout = UNSET_VALUE
|
236
|
+
@stack_create_timeout = UNSET_VALUE
|
237
|
+
@stack_delete_timeout = UNSET_VALUE
|
238
|
+
@http = HttpConfig.new
|
197
239
|
end
|
198
240
|
|
199
241
|
def merge(other)
|
@@ -210,11 +252,16 @@ module VagrantPlugins
|
|
210
252
|
# Let user inputs a string or an array for floating ip pool attribute
|
211
253
|
obj.floating_ip_pool = [obj.floating_ip_pool].flatten if key.eql?(:@floating_ip_pool) && !obj.floating_ip_pool.nil?
|
212
254
|
|
255
|
+
# Let user inputs a string or an array for networks attribute
|
256
|
+
obj.networks = [obj.networks].flatten if key.eql?(:@networks) && !obj.networks.nil?
|
257
|
+
|
213
258
|
# Don't set the value if it is the unset value, either.
|
214
259
|
value = obj.instance_variable_get(key)
|
215
260
|
|
216
261
|
if [:@networks, :@volumes, :@rsync_includes, :@ignore_files, :@floating_ip_pool, :@stacks].include? key
|
217
262
|
result.instance_variable_set(key, value) unless value.empty?
|
263
|
+
elsif [:@http].include? key
|
264
|
+
result.instance_variable_set(key, instance_variable_get(key).merge(other.instance_variable_get(key))) if value != UNSET_VALUE
|
218
265
|
else
|
219
266
|
result.instance_variable_set(key, value) if value != UNSET_VALUE
|
220
267
|
end
|
@@ -238,6 +285,7 @@ module VagrantPlugins
|
|
238
285
|
@openstack_volume_url = nil if @openstack_volume_url == UNSET_VALUE
|
239
286
|
@openstack_image_url = nil if @openstack_image_url == UNSET_VALUE
|
240
287
|
@openstack_auth_url = nil if @openstack_auth_url == UNSET_VALUE
|
288
|
+
@endpoint_type = 'publicURL' if @endpoint_type == UNSET_VALUE
|
241
289
|
@region = nil if @region == UNSET_VALUE
|
242
290
|
@flavor = nil if @flavor == UNSET_VALUE
|
243
291
|
@image = nil if @image == UNSET_VALUE
|
@@ -264,9 +312,16 @@ module VagrantPlugins
|
|
264
312
|
# `config.ssh` values are used.
|
265
313
|
@ssh_username = nil if @ssh_username == UNSET_VALUE
|
266
314
|
@ssh_timeout = 180 if @ssh_timeout == UNSET_VALUE
|
315
|
+
@server_create_timeout = 200 if @server_create_timeout == UNSET_VALUE
|
316
|
+
@server_active_timeout = 200 if @server_active_timeout == UNSET_VALUE
|
317
|
+
@server_stop_timeout = 200 if @server_stop_timeout == UNSET_VALUE
|
318
|
+
@server_delete_timeout = 200 if @server_delete_timeout == UNSET_VALUE
|
319
|
+
@stack_create_timeout = 200 if @stack_create_timeout == UNSET_VALUE
|
320
|
+
@stack_delete_timeout = 200 if @stack_delete_timeout == UNSET_VALUE
|
267
321
|
@networks = nil if @networks.empty?
|
268
322
|
@volumes = nil if @volumes.empty?
|
269
323
|
@stacks = nil if @stacks.empty?
|
324
|
+
@http.finalize!
|
270
325
|
end
|
271
326
|
# rubocop:enable Style/CyclomaticComplexity
|
272
327
|
|
@@ -277,8 +332,10 @@ module VagrantPlugins
|
|
277
332
|
def validate(machine)
|
278
333
|
errors = _detected_errors
|
279
334
|
|
280
|
-
errors << I18n.t('vagrant_openstack.config.password_required')
|
281
|
-
errors << I18n.t('vagrant_openstack.config.username_required')
|
335
|
+
errors << I18n.t('vagrant_openstack.config.password_required') if @password.nil? || @password.empty?
|
336
|
+
errors << I18n.t('vagrant_openstack.config.username_required') if @username.nil? || @username.empty?
|
337
|
+
errors << I18n.t('vagrant_openstack.config.tenant_name_required') if @tenant_name.nil? || @tenant_name.empty?
|
338
|
+
errors << I18n.t('vagrant_openstack.config.invalid_endpoint_type') unless %w(publicURL adminURL internalURL).include?(@endpoint_type)
|
282
339
|
|
283
340
|
validate_ssh_username(machine, errors)
|
284
341
|
validate_stack_config(errors)
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module Openstack
|
3
|
+
class HttpConfig
|
4
|
+
UNSET_VALUE = Vagrant.plugin('2', :config).const_get(:UNSET_VALUE)
|
5
|
+
|
6
|
+
#
|
7
|
+
# @return [Integer]
|
8
|
+
attr_accessor :open_timeout
|
9
|
+
|
10
|
+
#
|
11
|
+
# @return [Integer]
|
12
|
+
attr_accessor :read_timeout
|
13
|
+
|
14
|
+
def initialize
|
15
|
+
@open_timeout = UNSET_VALUE
|
16
|
+
@read_timeout = UNSET_VALUE
|
17
|
+
end
|
18
|
+
|
19
|
+
def finalize!
|
20
|
+
@open_timeout = 60 if @open_timeout == UNSET_VALUE
|
21
|
+
@read_timeout = 30 if @read_timeout == UNSET_VALUE
|
22
|
+
end
|
23
|
+
|
24
|
+
def merge(other)
|
25
|
+
result = self.class.new
|
26
|
+
|
27
|
+
[self, other].each do |obj|
|
28
|
+
obj.instance_variables.each do |key|
|
29
|
+
next if key.to_s.start_with?('@__')
|
30
|
+
|
31
|
+
value = obj.instance_variable_get(key)
|
32
|
+
result.instance_variable_set(key, value) if value != UNSET_VALUE
|
33
|
+
end
|
34
|
+
end
|
35
|
+
result
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -275,17 +275,21 @@ module VagrantPlugins
|
|
275
275
|
{ id: volume_id, device: device }
|
276
276
|
end
|
277
277
|
|
278
|
-
# This method finds
|
279
|
-
#
|
280
|
-
#
|
278
|
+
# This method finds any matching _thing_ from a list of names
|
279
|
+
# in a collection of _things_. The first to match is the returned
|
280
|
+
# one. Names in list can be a regexp, a partial match is chosen
|
281
281
|
# as well.
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
282
|
+
|
283
|
+
def find_matching(collection, name_or_names)
|
284
|
+
name_or_names = [name_or_names] if name_or_names.class != Array
|
285
|
+
name_or_names.each do |name|
|
286
|
+
collection.each do |single|
|
287
|
+
return single if single.id == name
|
288
|
+
return single if single.name == name
|
289
|
+
return single if name.is_a?(Regexp) && name =~ single.name
|
290
|
+
end
|
287
291
|
end
|
288
|
-
@logger.error "
|
292
|
+
@logger.error "No element of '#{name_or_names}' found in collection #{collection}"
|
289
293
|
nil
|
290
294
|
end
|
291
295
|
end
|
@@ -6,15 +6,20 @@ module VagrantPlugins
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def get_ip_address(env)
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
network[1].each do |network_detail|
|
9
|
+
addresses = env[:openstack_client].nova.get_server_details(env, env[:machine].id)['addresses']
|
10
|
+
addresses.each do |_, network|
|
11
|
+
network.each do |network_detail|
|
13
12
|
return network_detail['addr'] if network_detail['OS-EXT-IPS:type'] == 'floating'
|
14
13
|
end
|
15
14
|
end
|
16
|
-
|
17
|
-
|
15
|
+
fail Errors::UnableToResolveIP if addresses.size == 0
|
16
|
+
if addresses.size == 1
|
17
|
+
net_addresses = addresses.first[1]
|
18
|
+
else
|
19
|
+
net_addresses = addresses[env[:machine].provider_config.networks[0]]
|
20
|
+
end
|
21
|
+
fail Errors::UnableToResolveIP if net_addresses.size == 0
|
22
|
+
net_addresses[0]['addr']
|
18
23
|
end
|
19
24
|
end
|
20
25
|
end
|
data/locales/en.yml
CHANGED
@@ -89,6 +89,8 @@ en:
|
|
89
89
|
A password is required.
|
90
90
|
username_required: |-
|
91
91
|
A username is required.
|
92
|
+
tenant_name_required: |-
|
93
|
+
A tenant name is required.
|
92
94
|
invalid_uri: |-
|
93
95
|
The value for %{key} is not a valid URI: %{uri}
|
94
96
|
invalid_stack: |-
|
@@ -98,6 +100,8 @@ en:
|
|
98
100
|
name: 'mystack',
|
99
101
|
template: '/path/to/heat_template.yml',
|
100
102
|
}]
|
103
|
+
invalid_endpoint_type: |-
|
104
|
+
endpoint_type must be publicURL, adminURL or internalURL (if not provided, default is publicURL)
|
101
105
|
metadata_must_be_hash: |-
|
102
106
|
Metadata must be a hash.
|
103
107
|
keypair_name_required: |-
|
@@ -22,12 +22,13 @@ describe VagrantPlugins::Openstack::Action::ConnectOpenstack do
|
|
22
22
|
config.stub(:username) { 'username' }
|
23
23
|
config.stub(:password) { 'password' }
|
24
24
|
config.stub(:region) { nil }
|
25
|
+
config.stub(:endpoint_type) { 'publicURL' }
|
25
26
|
end
|
26
27
|
end
|
27
28
|
|
28
29
|
let(:neutron) do
|
29
30
|
double.tap do |neutron|
|
30
|
-
neutron.stub(:get_api_version_list).with(anything) do
|
31
|
+
neutron.stub(:get_api_version_list).with(anything, anything) do
|
31
32
|
[
|
32
33
|
{
|
33
34
|
'status' => 'CURRENT',
|
@@ -44,9 +45,28 @@ describe VagrantPlugins::Openstack::Action::ConnectOpenstack do
|
|
44
45
|
end
|
45
46
|
end
|
46
47
|
|
48
|
+
let(:neutron_admin_url) do
|
49
|
+
double.tap do |neutron|
|
50
|
+
neutron.stub(:get_api_version_list).with(anything, anything) do
|
51
|
+
[
|
52
|
+
{
|
53
|
+
'status' => 'CURRENT',
|
54
|
+
'id' => 'v2.0',
|
55
|
+
'links' => [
|
56
|
+
{
|
57
|
+
'href' => 'http://neutron/v2.0/admin',
|
58
|
+
'rel' => 'self'
|
59
|
+
}
|
60
|
+
]
|
61
|
+
}
|
62
|
+
]
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
47
67
|
let(:neutron_france) do
|
48
68
|
double.tap do |neutron|
|
49
|
-
neutron.stub(:get_api_version_list).with(anything) do
|
69
|
+
neutron.stub(:get_api_version_list).with(anything, anything) do
|
50
70
|
[
|
51
71
|
{
|
52
72
|
'status' => 'CURRENT',
|
@@ -82,6 +102,25 @@ describe VagrantPlugins::Openstack::Action::ConnectOpenstack do
|
|
82
102
|
end
|
83
103
|
end
|
84
104
|
|
105
|
+
let(:glance_admin_url) do
|
106
|
+
double.tap do |glance|
|
107
|
+
glance.stub(:get_api_version_list).with(anything) do
|
108
|
+
[
|
109
|
+
{
|
110
|
+
'status' => 'CURRENT',
|
111
|
+
'id' => 'v2.1',
|
112
|
+
'links' => [
|
113
|
+
{
|
114
|
+
'href' => 'http://glance/v2.0/admin',
|
115
|
+
'rel' => 'self'
|
116
|
+
}
|
117
|
+
]
|
118
|
+
}
|
119
|
+
]
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
85
124
|
let(:glance_v1) do
|
86
125
|
double.tap do |glance|
|
87
126
|
glance.stub(:get_api_version_list).with(anything) do
|
@@ -317,8 +356,191 @@ describe VagrantPlugins::Openstack::Action::ConnectOpenstack do
|
|
317
356
|
end
|
318
357
|
end
|
319
358
|
|
359
|
+
describe 'endpoint_type' do
|
360
|
+
context 'with adminURL specified' do
|
361
|
+
it 'read service catalog and stores endpoints URL in session' do
|
362
|
+
catalog = [
|
363
|
+
{
|
364
|
+
'endpoints' => [
|
365
|
+
{
|
366
|
+
'publicURL' => 'http://nova/v2/projectId',
|
367
|
+
'adminURL' => 'http://nova/v2/projectId/admin',
|
368
|
+
'id' => '1'
|
369
|
+
}
|
370
|
+
],
|
371
|
+
'type' => 'compute',
|
372
|
+
'name' => 'nova'
|
373
|
+
},
|
374
|
+
{
|
375
|
+
'endpoints' => [
|
376
|
+
{
|
377
|
+
'publicURL' => 'http://neutron',
|
378
|
+
'adminURL' => 'http://neutron/admin',
|
379
|
+
'id' => '2'
|
380
|
+
}
|
381
|
+
],
|
382
|
+
'type' => 'network',
|
383
|
+
'name' => 'neutron'
|
384
|
+
},
|
385
|
+
{
|
386
|
+
'endpoints' => [
|
387
|
+
{
|
388
|
+
'publicURL' => 'http://cinder/v2/projectId',
|
389
|
+
'adminURL' => 'http://cinder/v2/projectId/admin',
|
390
|
+
'id' => '2'
|
391
|
+
}
|
392
|
+
],
|
393
|
+
'type' => 'volume',
|
394
|
+
'name' => 'cinder'
|
395
|
+
},
|
396
|
+
{
|
397
|
+
'endpoints' => [
|
398
|
+
{
|
399
|
+
'publicURL' => 'http://glance',
|
400
|
+
'adminURL' => 'http://glance/admin',
|
401
|
+
'id' => '2'
|
402
|
+
}
|
403
|
+
],
|
404
|
+
'type' => 'image',
|
405
|
+
'name' => 'glance'
|
406
|
+
}
|
407
|
+
]
|
408
|
+
|
409
|
+
double.tap do |keystone|
|
410
|
+
keystone.stub(:authenticate).with(anything) { catalog }
|
411
|
+
env[:openstack_client].stub(:keystone) { keystone }
|
412
|
+
end
|
413
|
+
env[:openstack_client].stub(:neutron) { neutron_admin_url }
|
414
|
+
env[:openstack_client].stub(:glance) { glance_admin_url }
|
415
|
+
config.stub(:endpoint_type) { 'adminURL' }
|
416
|
+
|
417
|
+
@action.call(env)
|
418
|
+
|
419
|
+
expect(env[:openstack_client].session.endpoints)
|
420
|
+
.to eq(compute: 'http://nova/v2/projectId/admin',
|
421
|
+
network: 'http://neutron/v2.0/admin',
|
422
|
+
volume: 'http://cinder/v2/projectId/admin',
|
423
|
+
image: 'http://glance/v2.0/admin')
|
424
|
+
end
|
425
|
+
end
|
426
|
+
end
|
427
|
+
|
428
|
+
describe 'endpoint_type' do
|
429
|
+
context 'with internalURL specified' do
|
430
|
+
it 'read service catalog and stores endpoints URL in session' do
|
431
|
+
catalog = [
|
432
|
+
{
|
433
|
+
'endpoints' => [
|
434
|
+
{
|
435
|
+
'publicURL' => 'http://nova/v2/projectId',
|
436
|
+
'adminURL' => 'http://nova/v2/projectId/admin',
|
437
|
+
'internalURL' => 'http://nova/v2/projectId/internal',
|
438
|
+
'id' => '1'
|
439
|
+
}
|
440
|
+
],
|
441
|
+
'type' => 'compute',
|
442
|
+
'name' => 'nova'
|
443
|
+
},
|
444
|
+
{
|
445
|
+
'endpoints' => [
|
446
|
+
{
|
447
|
+
'publicURL' => 'http://cinder/v2/projectId',
|
448
|
+
'adminURL' => 'http://cinder/v2/projectId/admin',
|
449
|
+
'internalURL' => 'http://cinder/v2/projectId/internal',
|
450
|
+
'id' => '2'
|
451
|
+
}
|
452
|
+
],
|
453
|
+
'type' => 'volume',
|
454
|
+
'name' => 'cinder'
|
455
|
+
}
|
456
|
+
]
|
457
|
+
|
458
|
+
double.tap do |keystone|
|
459
|
+
keystone.stub(:authenticate).with(anything) { catalog }
|
460
|
+
env[:openstack_client].stub(:keystone) { keystone }
|
461
|
+
end
|
462
|
+
config.stub(:endpoint_type) { 'internalURL' }
|
463
|
+
|
464
|
+
@action.call(env)
|
465
|
+
|
466
|
+
expect(env[:openstack_client].session.endpoints)
|
467
|
+
.to eq(compute: 'http://nova/v2/projectId/internal',
|
468
|
+
volume: 'http://cinder/v2/projectId/internal')
|
469
|
+
end
|
470
|
+
end
|
471
|
+
end
|
472
|
+
|
473
|
+
describe 'endpoint_type' do
|
474
|
+
context 'with publicURL specified' do
|
475
|
+
it 'read service catalog and stores endpoints URL in session' do
|
476
|
+
catalog = [
|
477
|
+
{
|
478
|
+
'endpoints' => [
|
479
|
+
{
|
480
|
+
'publicURL' => 'http://nova/v2/projectId',
|
481
|
+
'adminURL' => 'http://nova/v2/projectId/admin',
|
482
|
+
'id' => '1'
|
483
|
+
}
|
484
|
+
],
|
485
|
+
'type' => 'compute',
|
486
|
+
'name' => 'nova'
|
487
|
+
},
|
488
|
+
{
|
489
|
+
'endpoints' => [
|
490
|
+
{
|
491
|
+
'publicURL' => 'http://neutron',
|
492
|
+
'adminURL' => 'http://neutron/admin',
|
493
|
+
'id' => '2'
|
494
|
+
}
|
495
|
+
],
|
496
|
+
'type' => 'network',
|
497
|
+
'name' => 'neutron'
|
498
|
+
},
|
499
|
+
{
|
500
|
+
'endpoints' => [
|
501
|
+
{
|
502
|
+
'publicURL' => 'http://cinder/v2/projectId',
|
503
|
+
'adminURL' => 'http://cinder/v2/projectId/admin',
|
504
|
+
'id' => '2'
|
505
|
+
}
|
506
|
+
],
|
507
|
+
'type' => 'volume',
|
508
|
+
'name' => 'cinder'
|
509
|
+
},
|
510
|
+
{
|
511
|
+
'endpoints' => [
|
512
|
+
{
|
513
|
+
'publicURL' => 'http://glance',
|
514
|
+
'adminURL' => 'http://glance/admin',
|
515
|
+
'id' => '2'
|
516
|
+
}
|
517
|
+
],
|
518
|
+
'type' => 'image',
|
519
|
+
'name' => 'glance'
|
520
|
+
}
|
521
|
+
]
|
522
|
+
|
523
|
+
double.tap do |keystone|
|
524
|
+
keystone.stub(:authenticate).with(anything) { catalog }
|
525
|
+
env[:openstack_client].stub(:keystone) { keystone }
|
526
|
+
end
|
527
|
+
env[:openstack_client].stub(:neutron) { neutron }
|
528
|
+
env[:openstack_client].stub(:glance) { glance }
|
529
|
+
config.stub(:endpoint_type) { 'publicURL' }
|
530
|
+
|
531
|
+
@action.call(env)
|
532
|
+
|
533
|
+
expect(env[:openstack_client].session.endpoints)
|
534
|
+
.to eq(compute: 'http://nova/v2/projectId',
|
535
|
+
network: 'http://neutron/v2.0',
|
536
|
+
volume: 'http://cinder/v2/projectId',
|
537
|
+
image: 'http://glance/v2.0')
|
538
|
+
end
|
539
|
+
end
|
540
|
+
end
|
541
|
+
|
320
542
|
context 'with glance v1 only' do
|
321
|
-
it 'read service catalog and stores endpoints URL in session'
|
543
|
+
it 'read service catalog and stores endpoints URL in session' do
|
322
544
|
catalog = [
|
323
545
|
{
|
324
546
|
'endpoints' => [
|
@@ -384,7 +606,7 @@ describe VagrantPlugins::Openstack::Action::ConnectOpenstack do
|
|
384
606
|
|
385
607
|
let(:neutron) do
|
386
608
|
double.tap do |neutron|
|
387
|
-
neutron.stub(:get_api_version_list).with(anything) do
|
609
|
+
neutron.stub(:get_api_version_list).with(anything, anything) do
|
388
610
|
[
|
389
611
|
{
|
390
612
|
'status' => 'CURRENT',
|