vagrant-openstack-provider 0.6.1 → 0.7.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 +12 -5
- data/CHANGELOG.md +18 -0
- data/Gemfile +3 -2
- data/{LICENSE.txt → LICENSE} +2 -1
- data/lib/vagrant-openstack-provider/action.rb +3 -2
- data/lib/vagrant-openstack-provider/action/provision.rb +60 -0
- data/lib/vagrant-openstack-provider/action/read_ssh_info.rb +4 -0
- data/lib/vagrant-openstack-provider/client/domain.rb +2 -2
- data/lib/vagrant-openstack-provider/client/keystone.rb +17 -6
- data/lib/vagrant-openstack-provider/client/nova.rb +14 -3
- data/lib/vagrant-openstack-provider/command/abstract_command.rb +1 -0
- data/lib/vagrant-openstack-provider/command/main.rb +1 -3
- data/lib/vagrant-openstack-provider/config.rb +3 -3
- data/lib/vagrant-openstack-provider/config_resolver.rb +46 -16
- data/lib/vagrant-openstack-provider/errors.rb +15 -0
- data/lib/vagrant-openstack-provider/plugin.rb +7 -1
- data/lib/vagrant-openstack-provider/version.rb +11 -1
- data/lib/vagrant-openstack-provider/version_checker.rb +76 -0
- data/locales/en.yml +21 -4
- data/spec/vagrant-openstack-provider/action/connect_openstack_spec.rb +17 -19
- data/spec/vagrant-openstack-provider/action/create_server_spec.rb +19 -18
- data/spec/vagrant-openstack-provider/action/create_stack_spec.rb +4 -6
- data/spec/vagrant-openstack-provider/action/delete_server_spec.rb +4 -6
- data/spec/vagrant-openstack-provider/action/delete_stack_spec.rb +1 -2
- data/spec/vagrant-openstack-provider/action/message_spec.rb +1 -2
- data/spec/vagrant-openstack-provider/action/provision_spec.rb +104 -0
- data/spec/vagrant-openstack-provider/action/read_ssh_info_spec.rb +1 -3
- data/spec/vagrant-openstack-provider/action/read_state_spec.rb +1 -2
- data/spec/vagrant-openstack-provider/action/resume_server_spec.rb +1 -2
- data/spec/vagrant-openstack-provider/action/start_server_spec.rb +1 -2
- data/spec/vagrant-openstack-provider/action/stop_server_spec.rb +1 -2
- data/spec/vagrant-openstack-provider/action/suspend_server_spec.rb +1 -2
- data/spec/vagrant-openstack-provider/action/sync_folders_spec.rb +1 -2
- data/spec/vagrant-openstack-provider/action/wait_accessible_spec.rb +1 -2
- data/spec/vagrant-openstack-provider/action/wait_active_spec.rb +3 -4
- data/spec/vagrant-openstack-provider/action/wait_stop_spec.rb +3 -4
- data/spec/vagrant-openstack-provider/action_spec.rb +0 -1
- data/spec/vagrant-openstack-provider/client/cinder_spec.rb +5 -8
- data/spec/vagrant-openstack-provider/client/glance_spec.rb +69 -70
- data/spec/vagrant-openstack-provider/client/heat_spec.rb +24 -28
- data/spec/vagrant-openstack-provider/client/keystone_spec.rb +34 -16
- data/spec/vagrant-openstack-provider/client/neutron_spec.rb +76 -80
- data/spec/vagrant-openstack-provider/client/nova_spec.rb +198 -168
- data/spec/vagrant-openstack-provider/client/utils_spec.rb +1 -3
- data/spec/vagrant-openstack-provider/command/flavor_list_spec.rb +1 -2
- data/spec/vagrant-openstack-provider/command/floatingip_list_spec.rb +1 -2
- data/spec/vagrant-openstack-provider/command/image_list_spec.rb +1 -6
- data/spec/vagrant-openstack-provider/command/network_list_spec.rb +1 -3
- data/spec/vagrant-openstack-provider/command/reset_spec.rb +1 -2
- data/spec/vagrant-openstack-provider/command/subnet_list_spec.rb +1 -2
- data/spec/vagrant-openstack-provider/command/volume_list_spec.rb +1 -2
- data/spec/vagrant-openstack-provider/config_resolver_spec.rb +100 -6
- data/spec/vagrant-openstack-provider/config_spec.rb +2 -6
- data/spec/vagrant-openstack-provider/e2e_spec.rb.save +27 -0
- data/spec/vagrant-openstack-provider/spec_helper.rb +1 -0
- data/spec/vagrant-openstack-provider/utils_spec.rb +1 -2
- data/spec/vagrant-openstack-provider/version_checker_spec.rb +39 -0
- data/vagrant-openstack-provider.gemspec +4 -2
- metadata +29 -9
- data/gemfiles/latest_stable.gemfile +0 -10
- data/gemfiles/minimal_release.gemfile +0 -10
- data/gemfiles/previous_release.gemfile +0 -10
@@ -4,6 +4,17 @@ module VagrantPlugins
|
|
4
4
|
module Openstack
|
5
5
|
module Errors
|
6
6
|
class VagrantOpenstackError < Vagrant::Errors::VagrantError
|
7
|
+
#
|
8
|
+
# Added for vagrant 1.4.x compatibility This attribute had been
|
9
|
+
# added in Vagrant::Errors::VagrantError form the version 1.5.0
|
10
|
+
#
|
11
|
+
attr_accessor :extra_data
|
12
|
+
|
13
|
+
def initialize(args = nil)
|
14
|
+
@extra_data = args
|
15
|
+
super(args)
|
16
|
+
end
|
17
|
+
|
7
18
|
error_namespace('vagrant_openstack.errors')
|
8
19
|
error_key(:default)
|
9
20
|
end
|
@@ -40,6 +51,10 @@ module VagrantPlugins
|
|
40
51
|
error_key(:no_matching_image)
|
41
52
|
end
|
42
53
|
|
54
|
+
class ConflictBootVolume < VagrantOpenstackError
|
55
|
+
error_key(:conflict_boot_volume)
|
56
|
+
end
|
57
|
+
|
43
58
|
class SyncMethodError < VagrantOpenstackError
|
44
59
|
error_key(:sync_method_error)
|
45
60
|
end
|
@@ -4,6 +4,8 @@ rescue LoadError
|
|
4
4
|
raise 'The Openstack Cloud provider must be run within Vagrant.'
|
5
5
|
end
|
6
6
|
|
7
|
+
require 'vagrant-openstack-provider/version_checker'
|
8
|
+
|
7
9
|
# This is a sanity check to make sure no one is attempting to install
|
8
10
|
# this into an early Vagrant version.
|
9
11
|
if Vagrant::VERSION < '1.4.0'
|
@@ -24,9 +26,9 @@ module VagrantPlugins
|
|
24
26
|
end
|
25
27
|
|
26
28
|
provider(:openstack, box_optional: true) do
|
27
|
-
# Setup some things
|
28
29
|
Openstack.init_i18n
|
29
30
|
Openstack.init_logging
|
31
|
+
VagrantPlugins::Openstack.check_version
|
30
32
|
|
31
33
|
# Load the actual provider
|
32
34
|
require_relative 'provider'
|
@@ -34,6 +36,10 @@ module VagrantPlugins
|
|
34
36
|
end
|
35
37
|
|
36
38
|
command('openstack') do
|
39
|
+
Openstack.init_i18n
|
40
|
+
Openstack.init_logging
|
41
|
+
VagrantPlugins::Openstack.check_version
|
42
|
+
|
37
43
|
require_relative 'command/main'
|
38
44
|
Command::Main
|
39
45
|
end
|
@@ -1,5 +1,15 @@
|
|
1
1
|
module VagrantPlugins
|
2
2
|
module Openstack
|
3
|
-
|
3
|
+
#
|
4
|
+
# Stable versions must respect the pattern given
|
5
|
+
# by VagrantPlugins::Openstack::VERSION_PATTERN
|
6
|
+
#
|
7
|
+
VERSION = '0.7.0'
|
8
|
+
|
9
|
+
#
|
10
|
+
# Stable version must respect the naming convention 'x.y.z'
|
11
|
+
# where x, y and z are integers inside the range [0, 999]
|
12
|
+
#
|
13
|
+
VERSION_PATTERN = /^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/
|
4
14
|
end
|
5
15
|
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'colorize'
|
2
|
+
require 'singleton'
|
3
|
+
require 'vagrant-openstack-provider/version'
|
4
|
+
|
5
|
+
module VagrantPlugins
|
6
|
+
module Openstack
|
7
|
+
class VersionChecker
|
8
|
+
include Singleton
|
9
|
+
|
10
|
+
#
|
11
|
+
# :latest, :outdated or :unstable
|
12
|
+
#
|
13
|
+
# A version is considered unstable if it does not
|
14
|
+
# respect the pattern or if it is greater than the
|
15
|
+
# latest from rubygem
|
16
|
+
#
|
17
|
+
attr_accessor :status
|
18
|
+
|
19
|
+
def initialize
|
20
|
+
@status = nil
|
21
|
+
end
|
22
|
+
|
23
|
+
#
|
24
|
+
# Check the latest version from rubygem and set the status
|
25
|
+
#
|
26
|
+
def check
|
27
|
+
return @status unless @status.nil?
|
28
|
+
latest = Gem.latest_spec_for('vagrant-openstack-provider').version.version
|
29
|
+
current = VagrantPlugins::Openstack::VERSION
|
30
|
+
|
31
|
+
unless current =~ VERSION_PATTERN
|
32
|
+
@status = :unstable
|
33
|
+
print I18n.t('vagrant_openstack.version_unstable')
|
34
|
+
return
|
35
|
+
end
|
36
|
+
|
37
|
+
if latest.eql? current
|
38
|
+
@status = :latest
|
39
|
+
return
|
40
|
+
end
|
41
|
+
|
42
|
+
v_latest = latest.split('.').map(&:to_i)
|
43
|
+
v_current = current.split('.').map(&:to_i)
|
44
|
+
|
45
|
+
i_latest = v_latest[2] + v_latest[1] * 1000 + v_latest[0] * 1_000_000
|
46
|
+
i_current = v_current[2] + v_current[1] * 1000 + v_current[0] * 1_000_000
|
47
|
+
|
48
|
+
if i_current > i_latest
|
49
|
+
@status = :unstable
|
50
|
+
print I18n.t('vagrant_openstack.version_unstable')
|
51
|
+
return
|
52
|
+
end
|
53
|
+
|
54
|
+
@status = :outdated
|
55
|
+
print I18n.t('vagrant_openstack.version_outdated', latest: latest, current: current)
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
def print(message)
|
61
|
+
puts message.yellow
|
62
|
+
puts ''
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# rubocop:disable Lint/HandleExceptions
|
67
|
+
def self.check_version
|
68
|
+
timeout(3, Errors::Timeout) do
|
69
|
+
VersionChecker.instance.check
|
70
|
+
end
|
71
|
+
rescue
|
72
|
+
# Do nothing whatever the failure cause
|
73
|
+
end
|
74
|
+
# rubocop:enable Lint/HandleExceptions
|
75
|
+
end
|
76
|
+
end
|
data/locales/en.yml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
en:
|
2
2
|
vagrant_openstack:
|
3
3
|
global_error: |-
|
4
|
-
An
|
4
|
+
An unknown error happened in Vagrant OpenStack provider
|
5
5
|
|
6
6
|
To easily debug what happened, we recommend to set the environment
|
7
7
|
variable VAGRANT_OPENSTACK_LOG to debug
|
@@ -15,6 +15,20 @@ en:
|
|
15
15
|
|
16
16
|
We are looking for feedback, so feel free to ask questions or
|
17
17
|
describe features you would like to see in this provider.
|
18
|
+
version_outdated: |-
|
19
|
+
You're not using the latest version of the 'vagrant-openstack-provider' plugin.
|
20
|
+
The latest version is %{latest}, yours is %{current}. You should update to the latest
|
21
|
+
version running the command :
|
22
|
+
|
23
|
+
$ vagrant plugin update vagrant-openstack-provider
|
24
|
+
version_unstable: |-
|
25
|
+
You're not running a stable version of the 'vagrant-openstack-provider' plugin.
|
26
|
+
Unless you are either developing on vagrant or have deliberatly installed a not
|
27
|
+
stable version, you should uninstall it an install the latest stable version
|
28
|
+
running commands :
|
29
|
+
|
30
|
+
$ vagrant plugin uninstall vagrant-openstack-provider
|
31
|
+
$ vagrant plugin install vagrant-openstack-provider
|
18
32
|
already_created: |-
|
19
33
|
The server is already created.
|
20
34
|
create_stack: |-
|
@@ -70,7 +84,7 @@ en:
|
|
70
84
|
waiting_for_stack_deleted: |-
|
71
85
|
Waiting for Heat Stack to be created...
|
72
86
|
warn_networks: |-
|
73
|
-
Warning! The
|
87
|
+
Warning! The OpenStack provider doesn't support any of the Vagrant
|
74
88
|
high-level network configurations (`config.vm.network`). They
|
75
89
|
will be silently ignored.
|
76
90
|
warn_network_identifier_is_assumed_to_be_an_id: |-
|
@@ -106,7 +120,7 @@ en:
|
|
106
120
|
Metadata must be a hash.
|
107
121
|
keypair_name_required: |-
|
108
122
|
Warning! You have specified ssh.private_key_path in your Vagrant configuration.
|
109
|
-
but nor keypair_name neither public_key_path are present. The
|
123
|
+
but nor keypair_name neither public_key_path are present. The OpenStack provider
|
110
124
|
will automatically generate a new keypair and your configuration option
|
111
125
|
ssh.private_key_path will be overriden
|
112
126
|
private_key_missing: |-
|
@@ -153,6 +167,9 @@ en:
|
|
153
167
|
no_matching_image: |-
|
154
168
|
No matching image was found! Please check your image setting to
|
155
169
|
make sure you have a valid image chosen.
|
170
|
+
conflict_boot_volume: |-
|
171
|
+
When booting from an existing volume it is not authorized to specify in your Vagrantfile either 'image' or 'size' or 'delete_on_destroy'.
|
172
|
+
When booting from a newly creating volume it is not authorized to specify in your Vagrantfile either 'id' or 'name'.
|
156
173
|
sync_method_error: |-
|
157
174
|
Value '%{sync_method_value}' is not allowed for 'sync_method' configuration parameter. Valid values are 'rsync' and 'none'
|
158
175
|
rsync_error: |-
|
@@ -355,7 +372,7 @@ en:
|
|
355
372
|
|
356
373
|
command:
|
357
374
|
main_synopsis: |-
|
358
|
-
|
375
|
+
OpenStack provider specific commands
|
359
376
|
main_usage : |-
|
360
377
|
Usage: vagrant openstack command
|
361
378
|
available_subcommands: |-
|
@@ -4,7 +4,6 @@ include VagrantPlugins::Openstack::Action
|
|
4
4
|
include VagrantPlugins::Openstack::HttpUtils
|
5
5
|
|
6
6
|
describe VagrantPlugins::Openstack::Action::ConnectOpenstack do
|
7
|
-
|
8
7
|
let(:app) do
|
9
8
|
double.tap do |app|
|
10
9
|
app.stub(:call)
|
@@ -160,7 +159,7 @@ describe VagrantPlugins::Openstack::Action::ConnectOpenstack do
|
|
160
159
|
end
|
161
160
|
|
162
161
|
let(:env) do
|
163
|
-
|
162
|
+
{}.tap do |env|
|
164
163
|
env[:ui] = double
|
165
164
|
env[:ui].stub(:info).with(anything)
|
166
165
|
env[:ui].stub(:warn).with(anything)
|
@@ -309,9 +308,9 @@ describe VagrantPlugins::Openstack::Action::ConnectOpenstack do
|
|
309
308
|
@action.call(env)
|
310
309
|
|
311
310
|
expect(env[:openstack_client].session.endpoints)
|
312
|
-
|
313
|
-
|
314
|
-
|
311
|
+
.to eq(compute: 'http://france.nova/v2/projectId',
|
312
|
+
network: 'http://france.neutron/v2.0',
|
313
|
+
image: 'http://france.glance/v2.0')
|
315
314
|
end
|
316
315
|
end
|
317
316
|
|
@@ -417,10 +416,10 @@ describe VagrantPlugins::Openstack::Action::ConnectOpenstack do
|
|
417
416
|
@action.call(env)
|
418
417
|
|
419
418
|
expect(env[:openstack_client].session.endpoints)
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
419
|
+
.to eq(compute: 'http://nova/v2/projectId/admin',
|
420
|
+
network: 'http://neutron/v2.0/admin',
|
421
|
+
volume: 'http://cinder/v2/projectId/admin',
|
422
|
+
image: 'http://glance/v2.0/admin')
|
424
423
|
end
|
425
424
|
end
|
426
425
|
end
|
@@ -464,8 +463,8 @@ describe VagrantPlugins::Openstack::Action::ConnectOpenstack do
|
|
464
463
|
@action.call(env)
|
465
464
|
|
466
465
|
expect(env[:openstack_client].session.endpoints)
|
467
|
-
|
468
|
-
|
466
|
+
.to eq(compute: 'http://nova/v2/projectId/internal',
|
467
|
+
volume: 'http://cinder/v2/projectId/internal')
|
469
468
|
end
|
470
469
|
end
|
471
470
|
end
|
@@ -531,10 +530,10 @@ describe VagrantPlugins::Openstack::Action::ConnectOpenstack do
|
|
531
530
|
@action.call(env)
|
532
531
|
|
533
532
|
expect(env[:openstack_client].session.endpoints)
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
533
|
+
.to eq(compute: 'http://nova/v2/projectId',
|
534
|
+
network: 'http://neutron/v2.0',
|
535
|
+
volume: 'http://cinder/v2/projectId',
|
536
|
+
image: 'http://glance/v2.0')
|
538
537
|
end
|
539
538
|
end
|
540
539
|
end
|
@@ -573,8 +572,8 @@ describe VagrantPlugins::Openstack::Action::ConnectOpenstack do
|
|
573
572
|
@action.call(env)
|
574
573
|
|
575
574
|
expect(env[:openstack_client].session.endpoints)
|
576
|
-
|
577
|
-
|
575
|
+
.to eq(compute: 'http://nova/v2/projectId',
|
576
|
+
image: 'http://glance/v1')
|
578
577
|
end
|
579
578
|
end
|
580
579
|
|
@@ -603,7 +602,6 @@ describe VagrantPlugins::Openstack::Action::ConnectOpenstack do
|
|
603
602
|
end
|
604
603
|
|
605
604
|
context 'with no matching versions for network service' do
|
606
|
-
|
607
605
|
let(:neutron) do
|
608
606
|
double.tap do |neutron|
|
609
607
|
neutron.stub(:get_api_version_list).with(anything, anything) do
|
@@ -690,7 +688,7 @@ describe VagrantPlugins::Openstack::Action::ConnectOpenstack do
|
|
690
688
|
@action.call(env)
|
691
689
|
|
692
690
|
expect(env[:openstack_client].session.endpoints)
|
693
|
-
|
691
|
+
.to eq(compute: 'http://nova/v2/projectId', identity: 'http://keystone/v2.0')
|
694
692
|
end
|
695
693
|
end
|
696
694
|
end
|
@@ -7,7 +7,6 @@ include VagrantPlugins::Openstack::HttpUtils
|
|
7
7
|
include VagrantPlugins::Openstack::Domain
|
8
8
|
|
9
9
|
describe VagrantPlugins::Openstack::Action::CreateServer do
|
10
|
-
|
11
10
|
let(:config) do
|
12
11
|
double('config').tap do |config|
|
13
12
|
config.stub(:tenant_name) { 'testTenant' }
|
@@ -41,7 +40,7 @@ describe VagrantPlugins::Openstack::Action::CreateServer do
|
|
41
40
|
end
|
42
41
|
|
43
42
|
let(:env) do
|
44
|
-
|
43
|
+
{}.tap do |env|
|
45
44
|
env[:ui] = double('ui')
|
46
45
|
env[:ui].stub(:info).with(anything)
|
47
46
|
env[:machine] = double('machine')
|
@@ -124,18 +123,19 @@ describe VagrantPlugins::Openstack::Action::CreateServer do
|
|
124
123
|
context 'with all options specified' do
|
125
124
|
it 'calls nova with all the options' do
|
126
125
|
nova.stub(:create_server).with(
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
126
|
+
env,
|
127
|
+
name: 'testName',
|
128
|
+
flavor_ref: flavor.id,
|
129
|
+
image_ref: image.id,
|
130
|
+
volume_boot: nil,
|
131
|
+
networks: [{ uuid: 'test-networks-1' }, { uuid: 'test-networks-2', fixed_ip: '1.2.3.4' }],
|
132
|
+
keypair: 'test-keypair',
|
133
|
+
availability_zone: 'test-az',
|
134
|
+
scheduler_hints: 'test-sched-hints',
|
135
|
+
security_groups: ['test-sec-groups'],
|
136
|
+
user_data: 'test-user_data',
|
137
|
+
metadata: 'test-metadata') do
|
138
|
+
'1234'
|
139
139
|
end
|
140
140
|
|
141
141
|
options = {
|
@@ -169,7 +169,8 @@ describe VagrantPlugins::Openstack::Action::CreateServer do
|
|
169
169
|
scheduler_hints: nil,
|
170
170
|
security_groups: [],
|
171
171
|
user_data: nil,
|
172
|
-
metadata: nil) do
|
172
|
+
metadata: nil) do
|
173
|
+
'1234'
|
173
174
|
end
|
174
175
|
|
175
176
|
options = {
|
@@ -193,19 +194,19 @@ describe VagrantPlugins::Openstack::Action::CreateServer do
|
|
193
194
|
describe 'waiting_for_server_to_be_built' do
|
194
195
|
context 'when server is not yet active' do
|
195
196
|
it 'become active after one retry' do
|
196
|
-
nova.stub(:get_server_details).and_return({ 'status' => 'BUILD' },
|
197
|
+
nova.stub(:get_server_details).and_return({ 'status' => 'BUILD' }, 'status' => 'ACTIVE')
|
197
198
|
nova.should_receive(:get_server_details).with(env, 'server-01').exactly(2).times
|
198
199
|
config.stub(:server_create_timeout) { 5 }
|
199
200
|
@action.waiting_for_server_to_be_built(env, 'server-01', 1)
|
200
201
|
end
|
201
202
|
it 'timeout before the server become active' do
|
202
|
-
nova.stub(:get_server_details).and_return({ 'status' => 'BUILD' },
|
203
|
+
nova.stub(:get_server_details).and_return({ 'status' => 'BUILD' }, 'status' => 'BUILD')
|
203
204
|
nova.should_receive(:get_server_details).with(env, 'server-01').at_least(2).times
|
204
205
|
config.stub(:server_create_timeout) { 3 }
|
205
206
|
expect { @action.waiting_for_server_to_be_built(env, 'server-01', 1) }.to raise_error Errors::Timeout
|
206
207
|
end
|
207
208
|
it 'raise an error after one retry' do
|
208
|
-
nova.stub(:get_server_details).and_return({ 'status' => 'BUILD' },
|
209
|
+
nova.stub(:get_server_details).and_return({ 'status' => 'BUILD' }, 'status' => 'ERROR')
|
209
210
|
nova.should_receive(:get_server_details).with(env, 'server-01').exactly(2).times
|
210
211
|
config.stub(:server_create_timeout) { 3 }
|
211
212
|
expect { @action.waiting_for_server_to_be_built(env, 'server-01', 1) }.to raise_error Errors::ServerStatusError
|
@@ -7,7 +7,6 @@ include VagrantPlugins::Openstack::HttpUtils
|
|
7
7
|
include VagrantPlugins::Openstack::Domain
|
8
8
|
|
9
9
|
describe VagrantPlugins::Openstack::Action::CreateStack do
|
10
|
-
|
11
10
|
let(:config) do
|
12
11
|
double('config').tap do |config|
|
13
12
|
config.stub(:stacks) do
|
@@ -31,7 +30,7 @@ describe VagrantPlugins::Openstack::Action::CreateStack do
|
|
31
30
|
end
|
32
31
|
|
33
32
|
let(:env) do
|
34
|
-
|
33
|
+
{}.tap do |env|
|
35
34
|
env[:ui] = double('ui')
|
36
35
|
env[:ui].stub(:info).with(anything)
|
37
36
|
env[:machine] = double('machine')
|
@@ -61,7 +60,6 @@ describe VagrantPlugins::Openstack::Action::CreateStack do
|
|
61
60
|
image: CoreOS
|
62
61
|
flavor: 1_vCPU_RAM_512M_HD_10G
|
63
62
|
'))
|
64
|
-
|
65
63
|
end
|
66
64
|
|
67
65
|
describe 'call' do
|
@@ -79,19 +77,19 @@ describe VagrantPlugins::Openstack::Action::CreateStack do
|
|
79
77
|
describe 'waiting_for_server_to_be_built' do
|
80
78
|
context 'when server is not yet active' do
|
81
79
|
it 'become active after one retry' do
|
82
|
-
heat.stub(:get_stack_details).and_return({ 'stack_status' => 'CREATE_IN_PROGRESS' },
|
80
|
+
heat.stub(:get_stack_details).and_return({ 'stack_status' => 'CREATE_IN_PROGRESS' }, 'stack_status' => 'CREATE_COMPLETE')
|
83
81
|
heat.should_receive(:get_stack_details).with(env, 'stack1', 'id-01').exactly(2).times
|
84
82
|
config.stub(:stack_create_timeout) { 5 }
|
85
83
|
@action.waiting_for_stack_to_be_created(env, 'stack1', 'id-01', 1)
|
86
84
|
end
|
87
85
|
it 'timeout before the server become active' do
|
88
|
-
heat.stub(:get_stack_details).and_return({ 'stack_status' => 'CREATE_IN_PROGRESS' },
|
86
|
+
heat.stub(:get_stack_details).and_return({ 'stack_status' => 'CREATE_IN_PROGRESS' }, 'stack_status' => 'CREATE_IN_PROGRESS')
|
89
87
|
heat.should_receive(:get_stack_details).with(env, 'stack1', 'id-01').at_least(2).times
|
90
88
|
config.stub(:stack_create_timeout) { 3 }
|
91
89
|
expect { @action.waiting_for_stack_to_be_created(env, 'stack1', 'id-01', 1) }.to raise_error Errors::Timeout
|
92
90
|
end
|
93
91
|
it 'raise an error after one retry' do
|
94
|
-
heat.stub(:get_stack_details).and_return({ 'stack_status' => 'CREATE_IN_PROGRESS' },
|
92
|
+
heat.stub(:get_stack_details).and_return({ 'stack_status' => 'CREATE_IN_PROGRESS' }, 'stack_status' => 'CREATE_FAILED')
|
95
93
|
heat.should_receive(:get_stack_details).with(env, 'stack1', 'id-01').exactly(2).times
|
96
94
|
config.stub(:stack_create_timeout) { 3 }
|
97
95
|
expect { @action.waiting_for_stack_to_be_created(env, 'stack1', 'id-01', 1) }.to raise_error Errors::StackStatusError
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'vagrant-openstack-provider/spec_helper'
|
2
2
|
|
3
3
|
describe VagrantPlugins::Openstack::Action::DeleteServer do
|
4
|
-
|
5
4
|
let(:nova) do
|
6
5
|
double('nova').tap do |app|
|
7
6
|
app.stub(:delete_server)
|
@@ -20,7 +19,7 @@ describe VagrantPlugins::Openstack::Action::DeleteServer do
|
|
20
19
|
end
|
21
20
|
|
22
21
|
let(:env) do
|
23
|
-
|
22
|
+
{}.tap do |env|
|
24
23
|
env[:ui] = double('ui')
|
25
24
|
env[:ui].stub(:info).with(anything)
|
26
25
|
env[:ui].stub(:error).with(anything)
|
@@ -68,24 +67,23 @@ describe VagrantPlugins::Openstack::Action::DeleteServer do
|
|
68
67
|
@action.waiting_for_instance_to_be_deleted(env, 'server-01', 1)
|
69
68
|
end
|
70
69
|
it 'become deleted after one retry' do
|
71
|
-
nova.stub(:get_server_details).and_return({ 'status' => 'ACTIVE' },
|
70
|
+
nova.stub(:get_server_details).and_return({ 'status' => 'ACTIVE' }, 'status' => 'DELETED')
|
72
71
|
nova.should_receive(:get_server_details).with(env, 'server-01').exactly(2).times
|
73
72
|
config.stub(:server_delete_timeout) { 5 }
|
74
73
|
@action.waiting_for_instance_to_be_deleted(env, 'server-01', 1)
|
75
74
|
end
|
76
75
|
it 'timeout before the server become active' do
|
77
|
-
nova.stub(:get_server_details).and_return({ 'status' => 'ACTIVE' },
|
76
|
+
nova.stub(:get_server_details).and_return({ 'status' => 'ACTIVE' }, 'status' => 'ACTIVE')
|
78
77
|
nova.should_receive(:get_server_details).with(env, 'server-01').at_least(2).times
|
79
78
|
config.stub(:server_delete_timeout) { 3 }
|
80
79
|
expect { @action.waiting_for_instance_to_be_deleted(env, 'server-01', 1) }.to raise_error Errors::Timeout
|
81
80
|
end
|
82
81
|
it 'raise an error after one retry' do
|
83
|
-
nova.stub(:get_server_details).and_return({ 'status' => 'ACTIVE' },
|
82
|
+
nova.stub(:get_server_details).and_return({ 'status' => 'ACTIVE' }, 'status' => 'ERROR')
|
84
83
|
nova.should_receive(:get_server_details).with(env, 'server-01').exactly(2).times
|
85
84
|
config.stub(:server_delete_timeout) { 3 }
|
86
85
|
expect { @action.waiting_for_instance_to_be_deleted(env, 'server-01', 1) }.to raise_error Errors::ServerStatusError
|
87
86
|
end
|
88
87
|
end
|
89
88
|
end
|
90
|
-
|
91
89
|
end
|